Files
doneit-web/src/app/app.component.ts
T

91 lines
2.7 KiB
TypeScript
Raw Normal View History

2023-01-02 15:42:15 +01:00
import { Component } from '@angular/core';
2020-08-05 15:39:16 +01:00
import { Platform } from '@ionic/angular';
import { StatusBar } from '@ionic-native/status-bar/ngx';
2021-06-24 11:08:17 +01:00
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
2023-06-22 12:53:35 +01:00
import { ChatSystemService } from 'src/app/services/chat/chat-system.service';
import { InativityService } from "src/app/services/inativity.service";
2022-07-05 14:37:06 +01:00
import { ThemeService } from 'src/app/services/theme.service';
2022-12-19 15:49:04 +01:00
import { environment } from 'src/environments/environment';
2022-12-22 15:24:48 +01:00
import { Storage } from '@ionic/storage';
2023-06-22 12:53:35 +01:00
import { ChatController } from './controller/chat';
2023-11-29 12:17:52 +01:00
import { register } from 'swiper/element/bundle';
2024-02-09 10:57:41 +01:00
import { DomSanitizer } from '@angular/platform-browser';
2024-03-11 11:18:32 +01:00
import {ScreenOrientation} from "@ionic-native/screen-orientation/ngx";
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"
}
}
2023-11-29 12:17:52 +01:00
register();
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-10-28 09:30:28 +01:00
private statusBar: StatusBar,
2022-07-05 14:37:06 +01:00
public ThemeService: ThemeService,
2023-06-22 12:53:35 +01:00
private storage: Storage,
2024-02-09 10:57:41 +01:00
private ChatSystemService: ChatSystemService,
2024-03-11 11:18:32 +01:00
private sanitizer: DomSanitizer,
private screenOrientation: ScreenOrientation
2020-08-05 15:39:16 +01:00
) {
2023-07-11 17:54:08 +01:00
2024-02-09 10:57:41 +01:00
window["sanitizer"] = this.sanitizer
2020-08-05 15:39:16 +01:00
this.initializeApp();
2022-12-22 15:24:48 +01:00
this.storage.set('version', environment.version).then(() => {})
2023-06-22 12:53:35 +01:00
ChatController.ChatSystemService = this.ChatSystemService
2024-02-22 11:40:06 +01:00
2020-08-05 15:39:16 +01:00
}
2023-06-26 11:12:57 +01:00
/* requestPermission() {
this.afMessaging.requestToken.subscribe(
(token) => {
// Save the token to your server for sending notifications
console.log('Permission granted! Token:', token);
},
(error) => {
console.error('Permission denied:', error);
}
);
}
receiveMessages() {
this.afMessaging.messages.subscribe((message) => {
console.log('Received message:', message);
// Handle the received message, e.g., show a notification
});
} */
2020-08-05 15:39:16 +01:00
initializeApp() {
this.platform.ready().then(() => {
2021-02-25 11:50:32 +01:00
this.statusBar.styleDefault();
2024-02-22 11:40:06 +01:00
2021-10-28 09:30:28 +01:00
if (this.platform.is("tablet")) {
window.screen.orientation.unlock();
2021-10-28 09:30:28 +01:00
} else if( this.platform.is("mobile")) {
2024-03-11 11:18:32 +01:00
if(this.platform.is('ios')){
this.screenOrientation.lock('portrait')
} else {
window.screen.orientation.lock('portrait');
}
2021-10-28 09:30:28 +01:00
}
2020-08-05 15:39:16 +01:00
});
}
}