2021-07-08 14:07:33 +01:00
|
|
|
/* eslint-disable */
|
2021-07-08 14:45:38 +01:00
|
|
|
/* tslint:disable */
|
2021-11-23 17:11:23 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2020-09-08 11:17:07 +01:00
|
|
|
import { Event } from '../models/event.model';
|
2021-04-12 08:34:17 +01:00
|
|
|
import { NotificationsService } from '../services/notifications.service';
|
2021-08-30 10:24:46 +01:00
|
|
|
import { AlertController, Platform } from '@ionic/angular';
|
2022-04-26 16:53:10 +01:00
|
|
|
import { Router } from '@angular/router';
|
2021-07-21 22:44:24 +01:00
|
|
|
import { ToDayEventStorage } from '../store/to-day-event-storage.service';
|
2021-08-25 10:40:17 +01:00
|
|
|
import { TotalDocumentStore } from '../store/total-document.service';
|
2021-08-26 13:48:29 +01:00
|
|
|
import { ExpedienteGdStore } from '../store/expedientegd-store.service';
|
2021-08-27 17:11:05 +01:00
|
|
|
import { SessionStore } from '../store/session.service';
|
2022-03-28 15:46:07 +01:00
|
|
|
import { PermissionService } from '../services/permission.service';
|
2021-10-07 16:22:31 +01:00
|
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
2021-10-18 07:44:24 +01:00
|
|
|
import { Storage } from '@ionic/storage';
|
2021-10-20 11:06:00 +01:00
|
|
|
import { EventsService } from 'src/app/services/events.service';
|
2021-11-16 13:12:25 +01:00
|
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
|
|
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
2021-11-25 15:50:41 +01:00
|
|
|
import { Device } from '@capacitor/device';
|
2022-01-06 14:47:22 +01:00
|
|
|
import { RouteService } from 'src/app/services/route.service';
|
2022-01-26 17:28:55 +01:00
|
|
|
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
2022-03-28 13:34:01 +01:00
|
|
|
import { UserSession } from '../models/user.model';
|
2022-03-30 15:08:23 +01:00
|
|
|
import { PermissionList } from '../models/permission/permissionList';
|
2022-04-07 17:47:45 +01:00
|
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
|
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
|
|
2021-10-07 16:22:31 +01:00
|
|
|
|
2022-04-08 13:52:00 +01:00
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-home',
|
|
|
|
|
templateUrl: './home.page.html',
|
|
|
|
|
styleUrls: ['./home.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class HomePage implements OnInit {
|
2020-09-08 11:17:07 +01:00
|
|
|
eventsList: Event[];
|
2020-11-20 13:36:35 +01:00
|
|
|
prEventList: Event[];
|
|
|
|
|
mdEventList: Event[];
|
|
|
|
|
|
2021-01-26 17:00:41 +01:00
|
|
|
totalEvent = 0;
|
|
|
|
|
totalExpediente = 0;
|
|
|
|
|
profile: string;
|
2020-08-05 15:39:16 +01:00
|
|
|
|
2021-07-21 22:44:24 +01:00
|
|
|
toDayEventStorage = ToDayEventStorage
|
2021-08-18 18:31:35 +01:00
|
|
|
totalDocumentStore = TotalDocumentStore
|
2021-08-26 13:48:29 +01:00
|
|
|
expedienteGdStore = ExpedienteGdStore
|
2021-07-21 22:44:24 +01:00
|
|
|
|
2021-04-08 22:54:15 +01:00
|
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
|
mobileComponent = {
|
|
|
|
|
showAddNewEvent: false,
|
|
|
|
|
showEditEvent: false,
|
|
|
|
|
showEventDetails: false,
|
|
|
|
|
showEventList: false,
|
|
|
|
|
transparentEventList: false,
|
|
|
|
|
transparentEventToApprove: false,
|
|
|
|
|
showEventToApprove: false,
|
|
|
|
|
showAttendees: false,
|
|
|
|
|
showAttendeeModal: false
|
|
|
|
|
}
|
2022-01-04 15:34:03 +01:00
|
|
|
tabButton = {
|
|
|
|
|
home: false,
|
|
|
|
|
agenda: false,
|
|
|
|
|
gabinete: false,
|
|
|
|
|
actions: false,
|
|
|
|
|
chat: false,
|
|
|
|
|
}
|
2021-04-08 22:54:15 +01:00
|
|
|
eventToaprove: any = {
|
|
|
|
|
back: false,
|
|
|
|
|
serialNumber: "",
|
|
|
|
|
saveData: {}
|
|
|
|
|
}
|
|
|
|
|
selectedEvent: Event;
|
|
|
|
|
postEvent: any;
|
|
|
|
|
folderId: string;
|
|
|
|
|
|
2021-10-07 16:22:31 +01:00
|
|
|
status: string = "";
|
|
|
|
|
audioName: string = "";
|
2022-03-28 13:34:01 +01:00
|
|
|
public user: UserSession;
|
2022-03-28 15:46:07 +01:00
|
|
|
permissionList = new PermissionList();
|
2022-04-07 17:47:45 +01:00
|
|
|
loggeduser: LoginUserRespose;
|
2022-04-08 12:31:23 +01:00
|
|
|
|
2022-01-07 15:48:35 +01:00
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
constructor(
|
2021-07-20 19:22:56 +01:00
|
|
|
private router: Router,
|
2021-06-16 08:37:31 +01:00
|
|
|
public modalCtrl: AlertController,
|
2021-08-25 11:51:02 +01:00
|
|
|
private notificationsService: NotificationsService,
|
2022-04-08 12:31:23 +01:00
|
|
|
public platform: Platform,
|
2021-08-25 08:51:52 +01:00
|
|
|
public p: PermissionService,
|
2021-10-18 07:44:24 +01:00
|
|
|
private backgroundservice: BackgroundService,
|
|
|
|
|
private storage: Storage,
|
2021-10-28 09:30:28 +01:00
|
|
|
private eventservice: EventsService,
|
2021-11-16 13:12:25 +01:00
|
|
|
private processservice: ProcessesService,
|
2022-02-16 15:52:59 +01:00
|
|
|
public RouteService: RouteService,
|
2022-04-07 17:47:45 +01:00
|
|
|
private authService: AuthService,
|
2022-04-26 16:53:10 +01:00
|
|
|
private NativeNotificationService: NativeNotificationService,
|
|
|
|
|
private sqliteservice: SqliteService,
|
2022-03-28 15:46:07 +01:00
|
|
|
) {
|
2022-04-07 17:47:45 +01:00
|
|
|
this.loggeduser = authService.ValidatedUser;
|
2022-03-28 13:34:01 +01:00
|
|
|
if (SessionStore.exist) {
|
|
|
|
|
this.user = SessionStore.user;
|
|
|
|
|
}
|
2022-01-07 16:39:46 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
this.NativeNotificationService.askForPermission()
|
2021-04-08 22:54:15 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
this.router.events.subscribe((val) => {
|
|
|
|
|
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
|
|
|
|
|
document.querySelectorAll('popover-viewport').forEach((e: any) => e.remove())
|
|
|
|
|
});
|
2022-03-28 13:34:01 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
window['platform'] = platform
|
2021-04-08 22:54:15 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
window['inactivity/function'] = () => {
|
2021-11-29 14:50:57 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
if (window.location.pathname != '/inactivity') {
|
2021-08-30 11:41:21 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
|
|
|
|
|
document.querySelectorAll('.popover-viewport').forEach((e: any) => e.remove())
|
2021-08-27 17:11:05 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
const pathname = window.location.pathname
|
|
|
|
|
SessionStore.setUrlBeforeInactivity(pathname)
|
|
|
|
|
|
|
|
|
|
if (this.platform.is('mobileweb')) {
|
|
|
|
|
this.router.navigate(['/inactivity']);
|
|
|
|
|
}else{
|
|
|
|
|
this.router.navigate(['/']);
|
|
|
|
|
}
|
2022-06-10 14:52:05 +01:00
|
|
|
}
|
2021-08-24 11:15:13 +01:00
|
|
|
|
2022-06-24 16:18:25 +01:00
|
|
|
}
|
2021-11-29 14:50:57 +01:00
|
|
|
|
2021-08-25 11:51:02 +01:00
|
|
|
}
|
2021-10-07 16:22:31 +01:00
|
|
|
|
2021-09-03 12:19:21 +01:00
|
|
|
goto(url) {
|
|
|
|
|
this.router.navigate([url])
|
|
|
|
|
}
|
2021-08-25 11:51:02 +01:00
|
|
|
|
2021-10-07 16:22:31 +01:00
|
|
|
refreshing() { }
|
2020-08-05 15:39:16 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-10-07 16:22:31 +01:00
|
|
|
|
2021-11-25 15:50:41 +01:00
|
|
|
this.logDeviceInfo();
|
|
|
|
|
|
2021-11-05 07:49:01 +01:00
|
|
|
this.notificationsService.onReciveForeground();
|
|
|
|
|
this.notificationsService.onReciveBackground();
|
2021-11-03 12:21:19 +01:00
|
|
|
|
2021-10-18 17:42:25 +01:00
|
|
|
window.addEventListener('online', () => {
|
2022-06-29 15:51:28 +01:00
|
|
|
// console.log('Became online')
|
2021-10-18 17:42:25 +01:00
|
|
|
this.backgroundservice.online()
|
2021-10-20 11:06:00 +01:00
|
|
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
|
|
|
} else {
|
2021-11-16 13:12:25 +01:00
|
|
|
this.synchWhenOnline()
|
2021-10-20 11:06:00 +01:00
|
|
|
}
|
2022-02-08 19:17:44 +01:00
|
|
|
|
2021-10-18 17:42:25 +01:00
|
|
|
});
|
|
|
|
|
window.addEventListener('offline', () => {
|
2022-06-29 15:51:28 +01:00
|
|
|
// console.log('Became offline')
|
2021-10-18 17:42:25 +01:00
|
|
|
this.backgroundservice.offline()
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-31 13:11:46 +01:00
|
|
|
this.updateList()
|
|
|
|
|
|
2021-11-03 12:21:19 +01:00
|
|
|
/* var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url));
|
2021-08-31 13:11:46 +01:00
|
|
|
|
2021-10-07 16:22:31 +01:00
|
|
|
myWorker.onmessage = function (oEvent) {
|
2021-08-31 13:11:46 +01:00
|
|
|
console.log('Worker said : ' + oEvent.data);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-03 12:21:19 +01:00
|
|
|
myWorker.postMessage('ali'); */
|
2022-01-04 15:34:03 +01:00
|
|
|
this.clearTabButtonSelection();
|
2022-03-30 15:08:23 +01:00
|
|
|
|
2022-01-04 15:34:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearTabButtonSelection(){
|
|
|
|
|
this.tabButton.home = false;
|
|
|
|
|
this.tabButton.agenda = false;
|
|
|
|
|
this.tabButton.gabinete = false;
|
|
|
|
|
this.tabButton.actions = false;
|
|
|
|
|
this.tabButton.chat = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selectedTab(url?:string){
|
|
|
|
|
this.clearTabButtonSelection();
|
|
|
|
|
if(url =='/home/events'){
|
|
|
|
|
this.tabButton.home = true;
|
|
|
|
|
}
|
|
|
|
|
else if(url == '/home/agenda'){
|
|
|
|
|
this.tabButton.agenda = true;
|
|
|
|
|
}
|
|
|
|
|
else if(url =='/home/gabinete-digital'){
|
|
|
|
|
this.tabButton.gabinete = true;
|
|
|
|
|
}
|
|
|
|
|
else if(url =='/home/publications'){
|
|
|
|
|
this.tabButton.actions = true;
|
|
|
|
|
}
|
|
|
|
|
else if(url == '/home/chat'){
|
|
|
|
|
this.tabButton.chat = true;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.clearTabButtonSelection();
|
|
|
|
|
}
|
2021-02-01 09:58:15 +01:00
|
|
|
}
|
2021-09-07 12:09:01 +01:00
|
|
|
|
2021-11-25 15:50:41 +01:00
|
|
|
logDeviceInfo = async () => {
|
|
|
|
|
const info = await Device.getInfo();
|
2022-01-07 16:39:46 +01:00
|
|
|
|
2021-11-25 15:50:41 +01:00
|
|
|
};
|
|
|
|
|
|
2022-01-06 11:21:20 +01:00
|
|
|
get pathname(){
|
|
|
|
|
return window.location.pathname
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get color() {
|
|
|
|
|
return '#797979'
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
updateList() {
|
2021-07-22 16:06:52 +01:00
|
|
|
|
2021-11-05 07:49:01 +01:00
|
|
|
/* this.notificationsService.registerCallback(
|
|
|
|
|
'despachos',
|
|
|
|
|
() => {
|
|
|
|
|
this.despachoRule.getList({ updateStore: true })
|
|
|
|
|
}
|
|
|
|
|
) */
|
2021-08-13 17:09:37 +01:00
|
|
|
|
2021-08-31 13:46:39 +01:00
|
|
|
document.addEventListener('pause', function () {
|
|
|
|
|
// console.log('App going to background');
|
|
|
|
|
});
|
2021-10-07 16:22:31 +01:00
|
|
|
|
2021-08-31 13:46:39 +01:00
|
|
|
document.addEventListener('resume', function () {
|
|
|
|
|
// console.log('App coming to foreground');
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-25 10:04:41 +01:00
|
|
|
}
|
2022-01-07 16:39:46 +01:00
|
|
|
|
2021-11-16 13:12:25 +01:00
|
|
|
async synchWhenOnline() {
|
|
|
|
|
try {
|
|
|
|
|
await this.storage.get('eventEdit').then((req) => {
|
|
|
|
|
JSON.parse(req).forEach(element => {
|
|
|
|
|
this.eventservice.editEvent(element, 2, 3).subscribe((res) => {
|
|
|
|
|
this.storage.remove('eventEdit')
|
2021-12-02 10:09:04 +01:00
|
|
|
//this.sqliteservice.deleteeventsTable();
|
2021-11-16 13:12:25 +01:00
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
} catch (error) {
|
2022-04-28 09:32:27 +01:00
|
|
|
console.log(error)
|
2021-11-16 13:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await this.storage.get('eventDelete').then((req) => {
|
|
|
|
|
JSON.parse(req).forEach(element => {
|
|
|
|
|
this.eventservice.deleteEvent(element.eventid, element.eventDeleteType, element.calendarName).subscribe((res) => {
|
|
|
|
|
this.storage.remove('eventDelete')
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
} catch (error) {
|
2022-04-28 09:32:27 +01:00
|
|
|
console.log(error)
|
2021-11-16 13:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await this.storage.get('event-listRever').then((req) => {
|
|
|
|
|
JSON.parse(req).forEach(element => {
|
|
|
|
|
this.processservice.PostTaskAction(element).subscribe((res) => {
|
|
|
|
|
this.storage.remove('event-listRever')
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
} catch (error) {
|
2022-04-28 09:32:27 +01:00
|
|
|
console.log(error)
|
2021-11-16 13:12:25 +01:00
|
|
|
}
|
2021-12-02 10:09:04 +01:00
|
|
|
|
|
|
|
|
this.sqliteservice.deleteAllTables();
|
2021-11-16 13:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
}
|
2022-01-07 09:03:15 +01:00
|
|
|
|