2021-07-08 10:43:40 +01:00
|
|
|
import { Component, Inject } from '@angular/core';
|
2020-08-05 15:39:16 +01:00
|
|
|
|
|
|
|
|
import { Platform } from '@ionic/angular';
|
2021-02-25 11:50:32 +01:00
|
|
|
/* import { SplashScreen } from '@ionic-native/splash-screen/ngx'; */
|
2020-08-05 15:39:16 +01:00
|
|
|
import { StatusBar } from '@ionic-native/status-bar/ngx';
|
2021-06-24 11:08:17 +01:00
|
|
|
import * as _moment from 'moment';
|
|
|
|
|
import * as _rollupMoment from 'moment';
|
|
|
|
|
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
|
|
|
|
|
const moment = _rollupMoment || _moment;
|
|
|
|
|
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
|
2021-10-30 16:51:29 +01:00
|
|
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
2021-11-22 15:26:04 +01:00
|
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
2021-10-28 09:30:28 +01:00
|
|
|
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
|
2021-11-23 13:55:43 +01:00
|
|
|
import { StorageService } from 'src/app/services/storage.service';
|
2022-06-10 14:52:05 +01:00
|
|
|
import { MessageModel } from './models/beast-orm';
|
|
|
|
|
import { InativityService } from "src/app/services/inativity.service";
|
2022-07-05 14:37:06 +01:00
|
|
|
import { ThemeService } from 'src/app/services/theme.service';
|
2021-06-24 11:08:17 +01:00
|
|
|
|
|
|
|
|
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
|
|
|
|
|
parse: {
|
|
|
|
|
dateInput: "YYYY-MMMM-DD HH:mm"
|
|
|
|
|
},
|
|
|
|
|
display: {
|
|
|
|
|
dateInput: "DD MMM YYYY H:mm",
|
|
|
|
|
monthYearLabel: "MMM YYYY",
|
|
|
|
|
dateA11yLabel: "LL",
|
|
|
|
|
monthYearA11yLabel: "MMMM YYYY"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-25 11:50:32 +01:00
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
|
|
|
|
templateUrl: 'app.component.html',
|
2021-06-24 11:08:17 +01:00
|
|
|
styleUrls: ['app.component.scss'],
|
|
|
|
|
providers: [
|
|
|
|
|
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
|
|
|
|
|
]
|
2020-08-05 15:39:16 +01:00
|
|
|
})
|
|
|
|
|
export class AppComponent {
|
|
|
|
|
constructor(
|
|
|
|
|
private platform: Platform,
|
2021-02-25 11:50:32 +01:00
|
|
|
/* private splashScreen: SplashScreen, */
|
2021-10-28 09:30:28 +01:00
|
|
|
private statusBar: StatusBar,
|
2021-10-30 16:51:29 +01:00
|
|
|
private screenOrientation: ScreenOrientation,
|
2021-11-22 15:26:04 +01:00
|
|
|
private sqliteservice: SqliteService,
|
2021-11-29 15:48:35 +01:00
|
|
|
private backgroundservice: BackgroundService,
|
2022-06-10 14:52:05 +01:00
|
|
|
private storageservice: StorageService,
|
2022-07-05 14:37:06 +01:00
|
|
|
private InativityService: InativityService,
|
|
|
|
|
public ThemeService: ThemeService,
|
2020-08-05 15:39:16 +01:00
|
|
|
) {
|
2021-11-30 10:23:46 +01:00
|
|
|
// this.createCacheFolder()
|
2020-08-05 15:39:16 +01:00
|
|
|
this.initializeApp();
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-30 10:23:46 +01:00
|
|
|
// async createCacheFolder(){
|
|
|
|
|
// await Filesystem.mkdir({
|
|
|
|
|
// directory: Directory.Cache,
|
|
|
|
|
// path: `CACHED-IMG`
|
|
|
|
|
// })
|
|
|
|
|
// }
|
2021-11-29 15:48:35 +01:00
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
initializeApp() {
|
|
|
|
|
this.platform.ready().then(() => {
|
2021-02-25 11:50:32 +01:00
|
|
|
this.statusBar.styleDefault();
|
|
|
|
|
/* this.splashScreen.hide(); */
|
2021-10-28 09:30:28 +01:00
|
|
|
|
|
|
|
|
if (this.platform.is("tablet")) {
|
2021-11-21 19:11:35 +01:00
|
|
|
window.screen.orientation.unlock();
|
2021-10-28 09:30:28 +01:00
|
|
|
} else if( this.platform.is("mobile")) {
|
2021-11-21 19:11:35 +01:00
|
|
|
window.screen.orientation.lock('portrait');
|
2022-06-29 15:51:28 +01:00
|
|
|
// console.log('Orientation locked')
|
2021-10-28 09:30:28 +01:00
|
|
|
}
|
2021-10-30 16:51:29 +01:00
|
|
|
|
|
|
|
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
this.sqliteservice.databaseConn();
|
|
|
|
|
} catch (error) {
|
2022-06-29 15:51:28 +01:00
|
|
|
// console.log("Error creating local database: ", error)
|
2021-10-30 16:51:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-22 15:26:04 +01:00
|
|
|
|
2021-11-23 13:55:43 +01:00
|
|
|
this.storageservice.get('networkCheckStore').then((network) => {
|
|
|
|
|
if(network === 'online') {
|
2022-06-29 15:51:28 +01:00
|
|
|
// console.log('Network app componente check', network)
|
2021-11-23 13:55:43 +01:00
|
|
|
this.backgroundservice.online()
|
2021-11-22 15:26:04 +01:00
|
|
|
} else {
|
2022-06-29 15:51:28 +01:00
|
|
|
// console.log('Network app componente check', network)
|
2021-11-23 13:55:43 +01:00
|
|
|
this.backgroundservice.offline();
|
2021-11-22 15:26:04 +01:00
|
|
|
}
|
2021-11-23 13:55:43 +01:00
|
|
|
})
|
2022-07-05 14:37:06 +01:00
|
|
|
|
|
|
|
|
this.storageservice.get('theme').then((theme) =>{
|
|
|
|
|
console.log('THEME: ', theme)
|
|
|
|
|
this.ThemeService.setTheme(theme)
|
|
|
|
|
})
|
2021-10-30 16:51:29 +01:00
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|