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

47 lines
1.4 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';
2023-06-23 18:56:05 +02:00
import { environment } from 'src/environments/environment';
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
) {
2023-06-24 12:11:50 +02:00
/*
2023-06-23 18:56:05 +02:00
console.log('Start versionUpdates subscribe', this._swUpdate.isEnabled, environment.production);
2023-06-23 16:23:18 +02:00
this._swUpdate.versionUpdates.subscribe((evt) => {
console.log('Version update', evt);
if (evt.type === 'VERSION_READY') {
2023-06-24 11:17:04 +02:00
console.log('tt');
2023-06-23 16:23:18 +02:00
this._swUpdate.activateUpdate().then(() => {
2023-06-24 11:17:04 +02:00
console.log('Update!');
2023-06-23 16:23:18 +02:00
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"
});
}
})
});
}
})
2023-06-24 12:11:50 +02:00
*/
2023-06-23 16:23:18 +02:00
}
}