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-11-05 07:49:01 +01:00
|
|
|
/*import { WebNotificationsService } from '../services/webnotifications.service'; */
|
2021-08-30 10:24:46 +01:00
|
|
|
import { AlertController, Platform } from '@ionic/angular';
|
2021-08-23 10:24:29 +01:00
|
|
|
import { Router, ActivatedRoute } 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 { DespachoService } from '../Rules/despacho.service';
|
|
|
|
|
import { ExpedienteGdStore } from '../store/expedientegd-store.service';
|
2021-08-27 13:39:52 +01:00
|
|
|
import { InativityService } from '../services/inativity.service';
|
2021-08-27 17:11:05 +01:00
|
|
|
import { SessionStore } from '../store/session.service';
|
2021-08-30 10:24:46 +01:00
|
|
|
import { StorageService } from '../services/storage.service';
|
2021-09-07 12:09:01 +01:00
|
|
|
import { File } from '@ionic-native/file/ngx';
|
2021-11-05 07:49:01 +01:00
|
|
|
/* import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service'; */
|
2021-09-30 15:56:04 +01:00
|
|
|
import { DocumentCounterService } from '../services/worker/document-counter.service';
|
|
|
|
|
import { PermissionService } from '../services/worker/permission.service';
|
2021-10-07 16:22:31 +01:00
|
|
|
import { Network } from '@ionic-native/network/ngx';
|
|
|
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
2021-10-18 07:44:24 +01:00
|
|
|
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
|
|
|
|
|
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';
|
2021-10-28 09:30:28 +01:00
|
|
|
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
|
2021-11-16 13:12:25 +01:00
|
|
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
2021-11-25 15:50:41 +01:00
|
|
|
import { Device } from '@capacitor/device';
|
2021-10-07 16:22:31 +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
|
|
|
|
|
}
|
|
|
|
|
eventToaprove: any = {
|
|
|
|
|
back: false,
|
|
|
|
|
serialNumber: "",
|
|
|
|
|
saveData: {}
|
|
|
|
|
}
|
|
|
|
|
selectedEvent: Event;
|
|
|
|
|
postEvent: any;
|
|
|
|
|
folderId: string;
|
|
|
|
|
|
2021-10-07 16:22:31 +01:00
|
|
|
status: string = "";
|
|
|
|
|
audioName: string = "";
|
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,
|
2021-07-07 15:28:29 +01:00
|
|
|
private platform: Platform,
|
2021-07-30 14:01:50 +01:00
|
|
|
private activeroute: ActivatedRoute,
|
2021-11-04 06:39:39 +01:00
|
|
|
/* private webnotification: WebNotificationsService, */
|
2021-08-25 08:51:52 +01:00
|
|
|
public p: PermissionService,
|
2021-08-26 13:48:29 +01:00
|
|
|
public documentCounterService: DocumentCounterService,
|
2021-08-27 13:39:52 +01:00
|
|
|
private despachoRule: DespachoService,
|
2021-08-30 10:24:46 +01:00
|
|
|
private inativityService: InativityService,
|
2021-09-07 12:09:01 +01:00
|
|
|
private storageService: StorageService,
|
2021-11-05 07:49:01 +01:00
|
|
|
/* private webNotificationPopupService: WebNotificationPopupService, */
|
2021-10-18 07:44:24 +01:00
|
|
|
private backgroundservice: BackgroundService,
|
|
|
|
|
private offlinemanager: OfflineManagerService,
|
|
|
|
|
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,
|
|
|
|
|
private screenOrientation: ScreenOrientation,
|
|
|
|
|
private sqliteservice: SqliteService) {
|
2021-08-31 11:10:40 +01:00
|
|
|
|
2021-11-05 07:49:01 +01:00
|
|
|
/* this.webNotificationPopupService.askNotificationPermission() */
|
2021-04-08 22:54:15 +01:00
|
|
|
|
2021-07-08 10:43:40 +01:00
|
|
|
this.router.events.subscribe((val) => {
|
|
|
|
|
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
|
2021-11-22 15:46:17 +01:00
|
|
|
document.querySelectorAll('popover-viewport').forEach((e: any) => e.remove())
|
2021-03-04 16:07:09 +01:00
|
|
|
});
|
2021-04-08 22:54:15 +01:00
|
|
|
|
2021-08-30 10:24:46 +01:00
|
|
|
window['platform'] = platform
|
2021-11-29 14:50:57 +01:00
|
|
|
|
2021-08-27 13:39:52 +01:00
|
|
|
window['inactivity/function'] = () => {
|
2021-08-30 11:41:21 +01:00
|
|
|
|
2021-10-07 16:22:31 +01:00
|
|
|
if (window.location.pathname != '/inactivity') {
|
2021-08-27 17:11:05 +01:00
|
|
|
|
2021-11-22 15:46:17 +01:00
|
|
|
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
|
2021-11-29 16:21:29 +01:00
|
|
|
document.querySelectorAll('.popover-viewport').forEach((e: any) => e.remove())
|
2021-11-22 15:46:17 +01:00
|
|
|
|
2021-08-27 17:11:05 +01:00
|
|
|
const pathname = window.location.pathname
|
|
|
|
|
SessionStore.setUrlBeforeInactivity(pathname)
|
|
|
|
|
this.router.navigate(['/inactivity']);
|
|
|
|
|
}
|
2021-08-27 13:39:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:15:13 +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', () => {
|
|
|
|
|
console.log('Became online')
|
|
|
|
|
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
|
|
|
}
|
2021-10-18 17:42:25 +01:00
|
|
|
});
|
|
|
|
|
window.addEventListener('offline', () => {
|
|
|
|
|
console.log('Became offline')
|
|
|
|
|
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'); */
|
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();
|
|
|
|
|
|
|
|
|
|
console.log('Device info',info);
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
console.log('eventEdit synchnize', res)
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('error synch eventedit')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await this.storage.get('eventDelete').then((req) => {
|
|
|
|
|
JSON.parse(req).forEach(element => {
|
|
|
|
|
console.log('DELETE data SYNC', element)
|
|
|
|
|
this.eventservice.deleteEvent(element.eventid, element.eventDeleteType, element.calendarName).subscribe((res) => {
|
|
|
|
|
this.storage.remove('eventDelete')
|
|
|
|
|
console.log('eventDelete synchnize', res)
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('error delete event synch')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await this.storage.get('event-listRever').then((req) => {
|
|
|
|
|
JSON.parse(req).forEach(element => {
|
|
|
|
|
console.log('REVER data SYNC', element)
|
|
|
|
|
this.processservice.PostTaskAction(element).subscribe((res) => {
|
|
|
|
|
this.storage.remove('event-listRever')
|
|
|
|
|
console.log('event-listRever synchnize', res)
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('error event-list rever synch')
|
|
|
|
|
}
|
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
|
|
|
}
|