|
|
|
@ -1,6 +1,13 @@
|
|
|
|
|
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild, HostListener, Host} from '@angular/core';
|
|
|
|
|
|
|
|
|
|
import {AlertController, ModalController, Platform, PopoverController, LoadingController} from '@ionic/angular';
|
|
|
|
|
import {
|
|
|
|
|
AlertController,
|
|
|
|
|
ModalController,
|
|
|
|
|
Platform,
|
|
|
|
|
PopoverController,
|
|
|
|
|
LoadingController,
|
|
|
|
|
ToastController
|
|
|
|
|
} from '@ionic/angular';
|
|
|
|
|
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
|
|
|
|
|
import { StatusBar } from '@ionic-native/status-bar/ngx';
|
|
|
|
|
import { ApiService } from './service/api.service';
|
|
|
|
@ -70,7 +77,8 @@ export class AppComponent implements OnInit {
|
|
|
|
|
public darkMode = false;
|
|
|
|
|
protected loader?: any;
|
|
|
|
|
protected hasSearchOpen = false;
|
|
|
|
|
|
|
|
|
|
protected versionInterval?: any;
|
|
|
|
|
protected showedNewVersionAlert = false;
|
|
|
|
|
protected initialized$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
@ -85,6 +93,7 @@ export class AppComponent implements OnInit {
|
|
|
|
|
protected session: SessionService,
|
|
|
|
|
protected loading: LoadingController,
|
|
|
|
|
protected navService: NavigationService,
|
|
|
|
|
protected toasts: ToastController,
|
|
|
|
|
) {
|
|
|
|
|
this.initializeApp();
|
|
|
|
|
}
|
|
|
|
@ -96,9 +105,37 @@ export class AppComponent implements OnInit {
|
|
|
|
|
this.loader.dismiss();
|
|
|
|
|
this.menuTree.treeModel.expandAll();
|
|
|
|
|
}, 10);
|
|
|
|
|
|
|
|
|
|
if ( !this.versionInterval ) {
|
|
|
|
|
this.versionInterval = setInterval(() => {
|
|
|
|
|
this.checkNewVersion();
|
|
|
|
|
}, 1000 * 60 * 5); // Check for new version every 5 mins
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async checkNewVersion() {
|
|
|
|
|
if ( !this.showedNewVersionAlert && await this.session.newVersionAvailable() ) {
|
|
|
|
|
const toast = await this.toasts.create({
|
|
|
|
|
cssClass: 'compat-toast-container',
|
|
|
|
|
header: 'Update Available',
|
|
|
|
|
message: `A new version of ${this.appName} is available. Please refresh to update.`,
|
|
|
|
|
buttons: [
|
|
|
|
|
{
|
|
|
|
|
side: 'end',
|
|
|
|
|
text: 'Refresh',
|
|
|
|
|
handler: () => {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.showedNewVersionAlert = true;
|
|
|
|
|
await toast.present();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
if ( !this.initialized$.getValue() ) {
|
|
|
|
|
this.navService.sidebarRefresh$.subscribe(([_, quiet]) => {
|
|
|
|
@ -376,7 +413,6 @@ export class AppComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async initializeApp() {
|
|
|
|
|
console.log('session', this);
|
|
|
|
|
this.loader = await this.loading.create({
|
|
|
|
|
message: 'Starting up...',
|
|
|
|
|
cssClass: 'noded-loading-mask',
|
|
|
|
|