-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajustar regra do SW para baixar os assets e tornar o Portugol mais am…
…igável offline
- Loading branch information
Showing
10 changed files
with
131 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/ide/src/app/new-version-available/new-version-available.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<strong>Uma nova versão do Portugol Webstudio está disponível</strong> | ||
|
||
<p>Lembre-se de salvar os seus arquivos antes de atualizar.</p> | ||
<p>Quando estiver pronto, basta atualizar a página ou clicar no botão abaixo.</p> | ||
|
||
<div class="buttons"> | ||
<button mat-raised-button color="primary" (click)="onReload()" type="button">Atualizar</button> | ||
<button mat-button color="primary" (click)="onIgnore()" type="button">Ignorar</button> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
packages/ide/src/app/new-version-available/new-version-available.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.buttons { | ||
display: flex; | ||
align-items: center; | ||
gap: 1rem; | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/ide/src/app/new-version-available/new-version-available.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, Inject, Optional } from "@angular/core"; | ||
import { MatButtonModule } from "@angular/material/button"; | ||
import { HotToastRef } from "@ngxpert/hot-toast"; | ||
|
||
@Component({ | ||
selector: "app-new-version-available", | ||
templateUrl: "./new-version-available.component.html", | ||
styleUrls: ["./new-version-available.component.scss"], | ||
standalone: true, | ||
imports: [MatButtonModule], | ||
}) | ||
export class NewVersionAvailableComponent { | ||
constructor(@Optional() @Inject(HotToastRef) public toastRef?: HotToastRef<any>) {} | ||
|
||
onReload() { | ||
if ( | ||
confirm( | ||
'Lembre-se de salvar seu código antes de recarregar a página!\n\nAperte "OK" para recarregar a página, ou "Cancelar" para abortar.', | ||
) | ||
) { | ||
window.location.reload(); | ||
} | ||
} | ||
|
||
onIgnore() { | ||
this.toastRef?.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { SwUpdate } from "@angular/service-worker"; | ||
import { CreateHotToastRef, HotToastService } from "@ngxpert/hot-toast"; | ||
import { NewVersionAvailableComponent } from "./new-version-available/new-version-available.component"; | ||
|
||
@Injectable({ providedIn: "root" }) | ||
export class PwaService { | ||
loadingToast?: CreateHotToastRef<unknown>; | ||
|
||
constructor( | ||
private swUpdate: SwUpdate, | ||
private toast: HotToastService, | ||
) { | ||
if (!this.swUpdate.isEnabled) { | ||
return; | ||
} | ||
|
||
this.swUpdate.versionUpdates.subscribe(event => { | ||
switch (event.type) { | ||
case "VERSION_DETECTED": { | ||
this.loadingToast = this.toast.loading("Baixando atualizações…", { | ||
autoClose: true, | ||
duration: 5000, | ||
}); | ||
|
||
break; | ||
} | ||
|
||
case "VERSION_READY": { | ||
this.loadingToast?.close(); | ||
this.toast.success(NewVersionAvailableComponent, { | ||
autoClose: false, | ||
dismissible: true, | ||
}); | ||
|
||
break; | ||
} | ||
|
||
default: { | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters