diff --git a/package-lock.json b/package-lock.json index f17e6ae72..e1cf0a49d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10569,7 +10569,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, "requires": { "is-glob": "^4.0.1" } diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index bff4258d7..0eed07791 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -56,12 +56,12 @@ export class HomePage implements OnInit { postEvent: any; folderId: string; - constructor(private zone: NgZone, - private eventService: EventsService, - private processesbackend: ProcessesService, - private router: Router, - private modalController: ModalController, - public modalCtrl: AlertController, + constructor(private zone: NgZone, + private eventService: EventsService, + private processesbackend: ProcessesService, + private router: Router, + private modalController: ModalController, + public modalCtrl: AlertController, private toastService: ToastService, private animationController: AnimationController, private notificatinsservice: NotificationsService, @@ -78,7 +78,11 @@ export class HomePage implements OnInit { } ngOnInit() { - this.wlCommonInit(); + if (this.platform.is('desktop')) { + console.log('Notifications not supported') + } else { + this.wlCommonInit(); + } //Add a test //this.pushCordova(); @@ -86,8 +90,8 @@ export class HomePage implements OnInit { let date = new Date(); date.setMonth(date.getMonth() + 1); - let start = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); - let end = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" 23:59:59"; + let start = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); + let end = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " 23:59:59"; this.profile = "mdgpr"; if (this.profile == "mdgpr") { @@ -107,7 +111,7 @@ export class HomePage implements OnInit { } wlCommonInit() { - + this.mobileFirstTest(); this.mobileFirstPush(); } @@ -115,7 +119,7 @@ export class HomePage implements OnInit { mobileFirstTest() { WLAuthorizationManager.obtainAccessToken("").then( (token) => { - console.log('MobileFirst Server connect: Success '+ token); + console.log('MobileFirst Server connect: Success ' + token); var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/", WLResourceRequest.GET @@ -133,7 +137,7 @@ export class HomePage implements OnInit { } ); }, (error) => { - console.log('MobileFirst Server connect: failure '+ error.responseText); + console.log('MobileFirst Server connect: failure ' + error.responseText); console.log(JSON.stringify(error)) /* this.zone.run(() => { alert("Bummer..."); @@ -146,45 +150,65 @@ export class HomePage implements OnInit { mobileFirstPush() { WLAuthorizationManager.obtainAccessToken("push.mobileclient").then( (token) => { - console.log('Push Notification: Success '+ token); + console.log('Push Notification: Success ' + token); - MFPPush.initialize ( - function(successResponse) { - console.log("Push notification Successfully intialized: " + successResponse); - MFPPush.registerNotificationsCallback(notificationReceived); + MFPPush.initialize( + function (successResponse) { + console.log("Push notification Successfully intialized: " + successResponse); + MFPPush.registerNotificationsCallback(notificationReceived); }, - function(failureResponse) { + function (failureResponse) { console.log("Push notification failure intialized: " + failureResponse); } - ); + ); - MFPPush.registerDevice(null, function(successResponse) { - console.log("Successfully registered: "+ successResponse); - }, - function(failureResponse) { - console.log("Successfully failue: "+ failureResponse); - } -); + MFPPush.registerDevice(null, function (successResponse) { + console.log("Successfully registered: " + successResponse); + }, + function (failureResponse) { + console.log("Successfully failue: " + failureResponse); + } + ); async function notificationReceived(message) { - alert(message.alert); - console.log(message) + alert(message.alert); + console.log(message) - var jsonObject = JSON.parse(message.payload); - console.log(jsonObject.service); - console.log(jsonObject.IdObject); - console.log(jsonObject.object); - -} + var data = JSON.parse(message.payload); + console.log(data.Service); + console.log(data.IdObject); + console.log(data.Object); + + if (data.Service === "agenda") { + //this.router.navigate(['/home/', service, IdObject, 'home']); + this.viewEventDetail(data.IdObject) + } + else if (data.Service === "gabinete-digital" && data.Object === "expediente") { + console.log('expediante 1') + this.viewExpedientDetail(data.IdObject) + } + else if (data.Service === "gabinete-digital" && data.Object === "event-list") { + // this.ngZone.run(() => {this.router.navigate(['/home/gabinete-digital/event-list', IdObject])}) + this.openApproveModal(data.IdObject); + } + else if (data.Service === "accoes" && data.Object === "accao") { + this.viewPublications(data.IdObject) + alert(data.IdObject) + } + else if (data.Service === "accoes" && data.Object === "publicacao") { + this.viewPublicationDetail(data.IdObject) + } + + } }, (error) => { - console.log('Push notification recived: failure '+ error.responseText); - console.log(JSON.stringify(error)) + console.log('Push notification recived: failure ' + error.responseText); + console.log(JSON.stringify(error)); } ); } async successMessage(message?: any, callback?) { - + const enterAnimation = (baseEl: any) => { const backdropAnimation = this.animationController.create() .addElement(baseEl.querySelector('ion-backdrop')!) @@ -207,31 +231,31 @@ export class HomePage implements OnInit { const leaveAnimation = (baseEl: any) => { return enterAnimation(baseEl).direction('reverse'); } - + const modal = await this.modalController.create({ enterAnimation, leaveAnimation, component: SuccessMessagePage, - componentProps: { - message: message || 'Processo efetuado' , + componentProps: { + message: message || 'Processo efetuado', }, cssClass: 'notification-modal' }); modal.present() - - setTimeout(()=>{ + + setTimeout(() => { if (callback) { callback() } modal.dismiss() - },7000) - - } - + }, 7000) + + } + + - // pushCordova() { // if(this.platform.is('desktop')) { @@ -242,7 +266,7 @@ export class HomePage implements OnInit { // this.viewEventDetail(data.IdObject) // if (data.wasTapped === true) { // console.log("Received in background: ", data); - + // if (data.Service === "agenda") { // //this.router.navigate(['/home/', service, IdObject, 'home']); // this.viewEventDetail(data.IdObject) @@ -262,19 +286,19 @@ export class HomePage implements OnInit { // else if (data.Service === "accoes" && data.Object === "publicacao") { // this.viewPublicationDetail(data.IdObject) // } - + // } else { // console.log("Received in foreground: ", data); - + // console.log(data.Service) // console.log(data.Object) // console.log(data.IdObject) - + // }; // }); // } - + // } @@ -298,17 +322,17 @@ export class HomePage implements OnInit { }); } - async openApproveModal(eventSerialNumber){ + async openApproveModal(eventSerialNumber) { let classs; - if( window.innerWidth <= 1024){ + if (window.innerWidth <= 1024) { classs = 'cal-modal modal modal-desktop' - } else { + } else { classs = 'gabinete-digital-mobile-modal-to-Desktop' } const modal = await this.modalController.create({ component: ApproveEventModalPage, - componentProps:{ + componentProps: { serialNumber: eventSerialNumber, }, cssClass: 'event-list', @@ -327,8 +351,8 @@ export class HomePage implements OnInit { } else { classs = 'modal modal-desktop showAsideOptions' } - console.log(this.profile); - console.log(serialNumber); + console.log(this.profile); + console.log(serialNumber); console.log('expediante 2') const modal = await this.modalController.create({ component: ExpedienteDetailPage, @@ -358,7 +382,7 @@ export class HomePage implements OnInit { }); await modal.present(); modal.onDidDismiss().then(() => { - + }); } @@ -402,9 +426,9 @@ export class HomePage implements OnInit { modal.onDidDismiss(); } - - + +