small improvements, pwa update
This commit is contained in:
parent
4a4917e4ed
commit
ce615f1475
@ -2,7 +2,7 @@
|
|||||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||||
"index": "/index.html",
|
"index": "/index.html",
|
||||||
"appData": {
|
"appData": {
|
||||||
"version": "1.5.2"
|
"version": "1.5.3"
|
||||||
},
|
},
|
||||||
"assetGroups": [
|
"assetGroups": [
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bstlboard",
|
"name": "bstlboard",
|
||||||
"version": "1.5.2",
|
"version": "1.5.3",
|
||||||
"license": "AGPL3",
|
"license": "AGPL3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
|
@ -2,15 +2,19 @@ mat-list mat-list-item {
|
|||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
mat-form-field {
|
|
||||||
margin-right: 15px;
|
|
||||||
flex-basis: 0;
|
|
||||||
flex-grow: 1;
|
|
||||||
min-width: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
|
||||||
|
mat-form-field {
|
||||||
|
margin-right: 15px;
|
||||||
|
flex-basis: 0;
|
||||||
|
flex-grow: 1;
|
||||||
|
min-width: 50px;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
min-width: 300px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mat-form-field .mat-form-field-wrapper {
|
mat-form-field .mat-form-field-wrapper {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
|
|
||||||
<div class="mat-mdc-paginator flex">
|
<div class="mat-mdc-paginator flex">
|
||||||
<div *ngIf="filter" class="filter-container">
|
<div *ngIf="filter" class="mat-mdc-paginator filter-container">
|
||||||
<a mat-icon-button (click)="filterOpen=!filterOpen" title="{{'entries.filter' | i18n}}"
|
<a mat-icon-button (click)="filterOpen=!filterOpen" title="{{'entries.filter' | i18n}}"
|
||||||
[color]="filterOpen ? 'accent' : 'primary'">
|
[color]="filterOpen ? 'accent' : 'primary'">
|
||||||
<mat-icon>filter_alt</mat-icon>
|
<mat-icon>filter_alt</mat-icon>
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
style="font-size: 0.7em;">
|
style="font-size: 0.7em;">
|
||||||
{{'page.privacy-policy' | i18n}}
|
{{'page.privacy-policy' | i18n}}
|
||||||
</a>
|
</a>
|
||||||
<span style="font-size: 0.7em; margin-right: 1em; float: right;">v{{version}}</span>
|
<span style="font-size: 0.7em; margin-right: 1em; float: right;">v{{version}} <span *ngIf="hasUpdate" (click)="updateSw()">{{'updateSw' | i18n}}</span></span>
|
||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
</mat-sidenav>
|
</mat-sidenav>
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import { I18nService } from '../../services/i18n.service';
|
|||||||
import { SettingsService } from '../../services/settings.service';
|
import { SettingsService } from '../../services/settings.service';
|
||||||
|
|
||||||
import packageJson from '../../../../package.json';
|
import packageJson from '../../../../package.json';
|
||||||
|
import { SwUpdate } from '@angular/service-worker';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ui-main',
|
selector: 'ui-main',
|
||||||
@ -28,6 +29,7 @@ export class UiMain {
|
|||||||
authenticated: boolean = false;
|
authenticated: boolean = false;
|
||||||
moderator: boolean = false;
|
moderator: boolean = false;
|
||||||
searchFocus: boolean = false;
|
searchFocus: boolean = false;
|
||||||
|
hasUpdate: boolean = false;
|
||||||
|
|
||||||
touchThresh: number = 150;
|
touchThresh: number = 150;
|
||||||
touchStartX: number;
|
touchStartX: number;
|
||||||
@ -43,8 +45,23 @@ export class UiMain {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private iconRegistry: MatIconRegistry,
|
private iconRegistry: MatIconRegistry,
|
||||||
private sanitizer: DomSanitizer,
|
private sanitizer: DomSanitizer,
|
||||||
private _adapter: DateAdapter<any>) {
|
private _adapter: DateAdapter<any>, private swUpdate: SwUpdate) {
|
||||||
iconRegistry.addSvgIcon('logo', sanitizer.bypassSecurityTrustResourceUrl('assets/icons/logo.svg'));
|
iconRegistry.addSvgIcon('logo', sanitizer.bypassSecurityTrustResourceUrl('assets/icons/logo.svg'));
|
||||||
|
|
||||||
|
this.swUpdate.versionUpdates.subscribe(evt => {
|
||||||
|
if (evt.type == 'VERSION_READY') {
|
||||||
|
this.hasUpdate = true;
|
||||||
|
} else if (evt.type == 'VERSION_INSTALLATION_FAILED') {
|
||||||
|
console.error(`Failed to install version '${evt.version.hash}': ${evt.error}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (this.swUpdate.isEnabled) {
|
||||||
|
// check for PWA update every 30s
|
||||||
|
setInterval(() => {
|
||||||
|
this.swUpdate.checkForUpdate();
|
||||||
|
}, 30000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@ -98,6 +115,7 @@ export class UiMain {
|
|||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
|
this.searchFocus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
preventClose(event) {
|
preventClose(event) {
|
||||||
@ -193,5 +211,28 @@ export class UiMain {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSw(force: boolean = false): void {
|
||||||
|
if (this.hasUpdate || force) {
|
||||||
|
if (this.swUpdate.isEnabled) {
|
||||||
|
this.swUpdate.activateUpdate().then(() => {
|
||||||
|
this.clearAndRefresh();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.clearAndRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAndRefresh() {
|
||||||
|
if ('caches' in window) {
|
||||||
|
caches.keys()
|
||||||
|
.then(function (keyList) {
|
||||||
|
return Promise.all(keyList.map(function (key) {
|
||||||
|
return caches.delete(key);
|
||||||
|
}));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,7 @@
|
|||||||
"error": "Url erforderlich"
|
"error": "Url erforderlich"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"updateSw": "Update?",
|
||||||
"user": {
|
"user": {
|
||||||
".": "User",
|
".": "User",
|
||||||
"about": "Über",
|
"about": "Über",
|
||||||
|
@ -152,6 +152,7 @@
|
|||||||
"error": "url required"
|
"error": "url required"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"updateSw": "Update?",
|
||||||
"user": {
|
"user": {
|
||||||
".": "user",
|
".": "user",
|
||||||
"about": "about",
|
"about": "about",
|
||||||
|
Loading…
Reference in New Issue
Block a user