2021-07-08 14:07:33 +01:00
|
|
|
/* eslint-disable */
|
2021-07-08 14:45:38 +01:00
|
|
|
/* tslint:disable */
|
2021-06-11 17:27:31 +01:00
|
|
|
///<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
|
|
|
|
|
///<reference path="../../../plugins/cordova-plugin-mfp-push/typings/mfppush.d.ts" />
|
2021-08-25 10:40:17 +01:00
|
|
|
import { Component, OnInit, NgZone } 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-25 16:29:15 +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-07-30 14:01:50 +01:00
|
|
|
import { DocumentCounterService } from 'src/app/OtherService/document-counter.service'
|
|
|
|
|
import { PermissionService } from '../OtherService/permission.service';
|
2021-08-25 10:40:17 +01:00
|
|
|
import { TotalDocumentStore } from '../store/total-document.service';
|
2021-08-30 10:24:46 +01:00
|
|
|
import { synchro } from '../services/socket/synchro.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-08-31 11:10:40 +01:00
|
|
|
import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service';
|
2021-07-26 11:34:46 +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-08-30 10:24:46 +01:00
|
|
|
synchro = synchro
|
2021-08-25 10:40:17 +01:00
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
constructor(
|
|
|
|
|
private zone: NgZone,
|
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-08-25 16:29:15 +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-08-31 11:10:40 +01:00
|
|
|
private storageService: StorageService,
|
|
|
|
|
private webNotificationPopupService: WebNotificationPopupService) {
|
|
|
|
|
|
|
|
|
|
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-03-04 16:07:09 +01:00
|
|
|
});
|
2021-04-08 22:54:15 +01:00
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
this.updateList()
|
|
|
|
|
|
2021-08-30 10:24:46 +01:00
|
|
|
window['platform'] = platform
|
2021-08-27 13:39:52 +01:00
|
|
|
window['inactivity/function'] = () => {
|
2021-08-30 11:41:21 +01:00
|
|
|
|
2021-08-27 17:11:05 +01:00
|
|
|
if(window.location.pathname != '/inactivity') {
|
|
|
|
|
|
|
|
|
|
const pathname = window.location.pathname
|
|
|
|
|
SessionStore.setUrlBeforeInactivity(pathname)
|
|
|
|
|
this.router.navigate(['/inactivity']);
|
|
|
|
|
}
|
2021-08-27 13:39:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-30 10:24:46 +01:00
|
|
|
var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url) );
|
|
|
|
|
|
|
|
|
|
myWorker.onmessage = function(oEvent) {
|
|
|
|
|
console.log('Worker said : ' + oEvent.data);
|
|
|
|
|
}
|
2021-08-24 11:15:13 +01:00
|
|
|
|
2021-08-30 10:24:46 +01:00
|
|
|
myWorker.postMessage('ali');
|
2021-08-24 11:15:13 +01:00
|
|
|
|
2021-08-25 11:51:02 +01:00
|
|
|
}
|
2021-08-27 13:39:52 +01:00
|
|
|
|
2021-08-25 11:51:02 +01:00
|
|
|
|
2021-08-30 10:24:46 +01:00
|
|
|
refreshing() {}
|
2020-08-05 15:39:16 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-08-22 01:24:45 +01:00
|
|
|
/* this.network.checkNetworkConnection;
|
|
|
|
|
this.network.checkNetworkDisconnection; */
|
2021-07-31 22:04:09 +01:00
|
|
|
console.log('Active route ', this.router.url)
|
|
|
|
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
2021-08-25 16:29:15 +01:00
|
|
|
this.webnotification.webconnection();
|
|
|
|
|
this.webnotification.onReceviNotificationWeb();
|
2021-06-25 14:37:52 +01:00
|
|
|
} else {
|
2021-07-31 22:04:09 +01:00
|
|
|
this.mobilefirstConnect();
|
2021-08-25 11:51:02 +01:00
|
|
|
this.notificationsService.getAndpostToken2();
|
|
|
|
|
this.notificationsService.onReceviNotification();
|
2021-06-25 14:37:52 +01:00
|
|
|
}
|
2021-04-15 15:16:14 +01:00
|
|
|
|
2021-02-01 09:58:15 +01:00
|
|
|
}
|
2021-06-25 10:04:41 +01:00
|
|
|
mobilefirstConnect() {
|
2021-07-22 16:06:52 +01:00
|
|
|
|
2021-08-13 17:31:01 +01:00
|
|
|
if(window['WLAuthorizationManager']) {
|
2021-08-13 17:09:37 +01:00
|
|
|
if(window['WLAuthorizationManager'].obtainAccessToken) {
|
|
|
|
|
window['WLAuthorizationManager'].obtainAccessToken("").then((token) => {
|
2021-08-13 16:55:35 +01:00
|
|
|
|
2021-08-13 17:09:37 +01:00
|
|
|
console.log('MobileFirst Server connect: Success ' + token);
|
|
|
|
|
|
|
|
|
|
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
|
|
|
|
|
WLResourceRequest.GET
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
resourceRequest.setQueryParameter("name", "world");
|
|
|
|
|
resourceRequest.send().then(
|
|
|
|
|
(response) => {
|
|
|
|
|
// Will display "Hello world" in an alert dialog.
|
|
|
|
|
console.log("Connect with JavaAdapter Success: " + response.responseText);
|
|
|
|
|
//this.MFPushNotification();
|
|
|
|
|
},
|
|
|
|
|
(error) => {
|
2021-08-18 15:42:36 +01:00
|
|
|
console.log("Connect with JavaAdapter Failure: " + JSON.stringify(error));
|
2021-08-13 17:09:37 +01:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}, (error) => {
|
|
|
|
|
console.log('MobileFirst Server connect: failure ' + error.responseText);
|
|
|
|
|
console.log(JSON.stringify(error))
|
|
|
|
|
/* this.zone.run(() => {
|
2021-08-18 15:57:19 +01:00
|
|
|
console.log("Bummer...");
|
|
|
|
|
console.log("Failed to connect to MobileFirst Server");
|
2021-08-13 17:09:37 +01:00
|
|
|
}); */
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-08-13 16:55:35 +01:00
|
|
|
}
|
2021-08-26 13:48:29 +01:00
|
|
|
}
|
2021-07-31 22:04:09 +01:00
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
updateList() {
|
2021-07-22 16:06:52 +01:00
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
this.notificationsService.registerCallback(
|
2021-08-30 12:17:20 +01:00
|
|
|
'despachos',
|
2021-08-26 13:48:29 +01:00
|
|
|
() => {
|
|
|
|
|
this.despachoRule.getList({updateStore: true})
|
2021-08-31 10:19:45 +01:00
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
)
|
2021-08-13 17:09:37 +01:00
|
|
|
|
2021-08-31 10:19:45 +01:00
|
|
|
|
2021-08-31 09:16:59 +01:00
|
|
|
synchro.registerCallback('Online',()=>{
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
synchro.registerCallback('Offline',()=>{
|
2021-08-31 10:19:45 +01:00
|
|
|
|
2021-08-31 09:16:59 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
2021-08-31 09:00:33 +01:00
|
|
|
synchro.registerCallback('Notification', (DataArray)=> {
|
|
|
|
|
|
2021-08-31 11:10:40 +01:00
|
|
|
this.webNotificationPopupService.sendNotification(DataArray.Object)
|
|
|
|
|
|
2021-08-31 09:00:33 +01:00
|
|
|
this.storageService.get('Notifications').then((data)=>{
|
|
|
|
|
data.push(DataArray)
|
|
|
|
|
this.storageService.store("Notifications", data)
|
|
|
|
|
}).catch(()=>{
|
|
|
|
|
|
|
|
|
|
const a = []
|
|
|
|
|
a.push(DataArray)
|
|
|
|
|
this.storageService.store("Notifications",a)
|
|
|
|
|
})
|
|
|
|
|
|
2021-08-30 12:17:20 +01:00
|
|
|
}, 'any')
|
2021-08-30 10:24:46 +01:00
|
|
|
|
2021-06-25 10:04:41 +01:00
|
|
|
}
|
|
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
}
|