Files
DiunaBI/Frontend/src/app/app.component.ts

41 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-11-29 18:25:52 +01:00
import { Component } from '@angular/core';
2023-06-23 15:32:59 +02:00
import { RouterOutlet } from '@angular/router';
2023-06-23 16:23:18 +02:00
import { SwUpdate } from '@angular/service-worker';
import { NotificationsService } from './services/notifications.service';
2022-11-29 18:25:52 +01:00
@Component({
2023-06-23 15:32:59 +02:00
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [RouterOutlet]
2022-11-29 18:25:52 +01:00
})
export class AppComponent {
2023-06-23 16:23:18 +02:00
constructor(
private readonly _swUpdate: SwUpdate,
private _notifications: NotificationsService
) {
this._swUpdate.versionUpdates.subscribe((evt) => {
console.log('Version update', evt);
if (evt.type === 'VERSION_READY') {
this._swUpdate.activateUpdate().then(() => {
this._notifications.add({
text: "New version available. DiunaBI will restart in 10 seconds.",
duration: 10000,
dismiss: () => {
window.location.reload()
},
btn: 'Cancel',
action: () => {
this._notifications.add({
text: "Restart canceled.",
btn: "Hide"
});
}
})
});
}
})
}
}