Route notification fixed

This commit is contained in:
Eudes Inácio
2021-06-18 11:08:55 +01:00
parent 0a9544f26a
commit 24954f184e
6 changed files with 47 additions and 178 deletions
+1 -1
View File
@@ -134,7 +134,7 @@
</mfp:windows10> </mfp:windows10>
<mfp:appChecksum>0</mfp:appChecksum> <mfp:appChecksum>0</mfp:appChecksum>
</mfp:windows> </mfp:windows>
<mfp:platformVersion>8.0.0.00-20210214-154410</mfp:platformVersion> <mfp:platformVersion>8.0.0.00-20210308-063916</mfp:platformVersion>
<mfp:clientCustomInit enabled="false" /> <mfp:clientCustomInit enabled="false" />
<mfp:server runtime="mfp" url="http://gpr-dev-10.gabinetedigital.local:9080" /> <mfp:server runtime="mfp" url="http://gpr-dev-10.gabinetedigital.local:9080" />
<mfp:serverUri url="" /> <mfp:serverUri url="" />
+5
View File
@@ -2341,6 +2341,11 @@
"@types/cordova": "^0.0.34" "@types/cordova": "^0.0.34"
} }
}, },
"@ionic-native/local-notifications": {
"version": "4.20.0",
"resolved": "https://registry.npmjs.org/@ionic-native/local-notifications/-/local-notifications-4.20.0.tgz",
"integrity": "sha512-Ht/0zau8/2+G/bH/okXXhhWB6YrkCNL2QxVJHQ2dophXFGxQPOZAN3CKWhuQSjfbr76fa2nvQXF6jsXLpIR/ng=="
},
"@ionic-native/splash-screen": { "@ionic-native/splash-screen": {
"version": "5.31.1", "version": "5.31.1",
"resolved": "https://registry.npmjs.org/@ionic-native/splash-screen/-/splash-screen-5.31.1.tgz", "resolved": "https://registry.npmjs.org/@ionic-native/splash-screen/-/splash-screen-5.31.1.tgz",
+1
View File
@@ -35,6 +35,7 @@
"@ionic-native/http": "^5.31.1", "@ionic-native/http": "^5.31.1",
"@ionic-native/in-app-browser": "^5.28.0", "@ionic-native/in-app-browser": "^5.28.0",
"@ionic-native/ionic-webview": "^5.30.0", "@ionic-native/ionic-webview": "^5.30.0",
"@ionic-native/local-notifications": "^4.20.0",
"@ionic-native/splash-screen": "^5.31.1", "@ionic-native/splash-screen": "^5.31.1",
"@ionic-native/sqlite": "^5.31.1", "@ionic-native/sqlite": "^5.31.1",
"@ionic-native/sqlite-porter": "^5.31.1", "@ionic-native/sqlite-porter": "^5.31.1",
+37 -175
View File
@@ -8,7 +8,7 @@ import { NotificationsService } from '../services/notifications.service';
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
//import { AlertController } from 'ionic-angular'; //import { AlertController } from 'ionic-angular';
/* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core'; */ /* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core'; */
import { Router } from '@angular/router'; import { NavigationExtras,Router } from '@angular/router';
// import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx'; // import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
import { ViewEventPage } from '../pages/agenda/view-event/view-event.page'; import { ViewEventPage } from '../pages/agenda/view-event/view-event.page';
@@ -87,7 +87,7 @@ export class HomePage implements OnInit {
} }
async count(){ async count() {
let date = new Date(); let date = new Date();
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
@@ -172,33 +172,17 @@ export class HomePage implements OnInit {
console.log("Successfully failue: " + failureResponse); console.log("Successfully failue: " + failureResponse);
} }
); );
async function notificationReceived(message) { var notificationReceived = (message) => {
alert(message.alert); console.log(message);
console.log(message)
var data = JSON.parse(message.payload); var data = JSON.parse(message.payload);
console.log(data.Service); console.log(data.Service);
console.log(data.IdObject); console.log(data.IdObject);
console.log(data.Object); console.log(data.Object);
if (data.Service === "agenda") { if(message.actionName){
//this.router.navigate(['/home/', service, IdObject, 'home']); this.notificatinsRoutes(data);
this.viewEventDetail(data.IdObject) } else {
} this.toastService.successMessage(message.alert);
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)
} }
} }
@@ -210,167 +194,45 @@ export class HomePage implements OnInit {
} }
async successMessage(message?: any, callback?) { notificatinsRoutes(data) {
if (data.Service === "agenda") {
const enterAnimation = (baseEl: any) => { //this.router.navigate(['/home/', service, IdObject, 'home']);
const backdropAnimation = this.animationController.create() //this.router.navigate(['/home/agenda', data.IdObject, 'agenda']);
.addElement(baseEl.querySelector('ion-backdrop')!) this.zone.run(() => this.viewEventDetail(data.IdObject));
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
const wrapperAnimation = this.animationController.create()
.addElement(baseEl.querySelector('.modal-wrapper')!)
.keyframes([
{ offset: 0, opacity: '1', right: '-100%' },
{ offset: 1, opacity: '1', right: '0px' }
]);
return this.animationController.create()
.addElement(baseEl)
.easing('ease-out')
.duration(500)
.addAnimation([backdropAnimation, wrapperAnimation]);
} }
else if (data.Service === "gabinete-digital" && data.Object === "expediente") {
const leaveAnimation = (baseEl: any) => { console.log('expediante 1')
return enterAnimation(baseEl).direction('reverse'); 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.zone.run(() =>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)
} }
const modal = await this.modalController.create({
enterAnimation,
leaveAnimation,
component: SuccessMessagePage,
componentProps: {
message: message || 'Processo efetuado',
},
cssClass: 'notification-modal'
});
modal.present()
setTimeout(() => {
if (callback) {
callback()
}
modal.dismiss()
}, 7000)
} }
// pushCordova() {
// if(this.platform.is('desktop')) {
// console.log('Notifications not supported')
// } else {
// this.fcm.onNotification().subscribe(data => {
// 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)
// }
// 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)
// }
// } else {
// console.log("Received in foreground: ", data);
// console.log(data.Service)
// console.log(data.Object)
// console.log(data.IdObject)
// };
// });
// }
// }
async viewEventDetail(eventId: any) { async viewEventDetail(eventId: any) {
console.log(this.profile); console.log('home noti '+ eventId);
this.router.navigate(['/home/agenda', eventId, 'agenda']);
const modal = await this.modalController.create({
component: ViewEventPage,
componentProps: {
eventId: eventId,
adding: this.adding
},
cssClass: 'modal modal-desktop',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss().then((res) => {
if (res) {
//this.viewEventDetailDismiss(res);
}
});
} }
async openApproveModal(eventSerialNumber) { async openApproveModal(eventSerialNumber) {
let classs; let navigationExtras: NavigationExtras = {
if (window.innerWidth <= 1024) { queryParams: {
classs = 'cal-modal modal modal-desktop' "serialNumber": eventSerialNumber,
} else { }
classs = 'gabinete-digital-mobile-modal-to-Desktop' };
} this.router.navigate(['/home/gabinete-digital/event-list/approve-event'], navigationExtras)
const modal = await this.modalController.create({
component: ApproveEventModalPage,
componentProps: {
serialNumber: eventSerialNumber,
},
cssClass: 'event-list',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
} }
async viewExpedientDetail(serialNumber: any) { async viewExpedientDetail(serialNumber:any) {
let classs; this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']);
if (window.innerWidth <= 800) {
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
console.log(this.profile);
console.log(serialNumber);
console.log('expediante 2')
const modal = await this.modalController.create({
component: ExpedienteDetailPage,
componentProps: {
serialNumber: serialNumber,
profile: "MDGPR",
},
cssClass: classs,
});
await modal.present();
modal.onDidDismiss().then((res) => {
if (res) {
console.log(res);
}
});
} }
async viewPublicationDetail(publicationId: string) { async viewPublicationDetail(publicationId: string) {
+1
View File
@@ -1176,6 +1176,7 @@ export class AgendaPage implements OnInit {
// open component // open component
async viewEventDetail(eventId:any) { async viewEventDetail(eventId:any) {
console.log('View event '+eventId)
this.router.navigate(['/home/agenda', eventId, 'agenda']); this.router.navigate(['/home/agenda', eventId, 'agenda']);
/* console.log(this.profile); /* console.log(this.profile);
@@ -74,7 +74,7 @@ export class ViewEventPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
/* console.log(this.eventId); */ console.log('Notifi teste '+this.eventId);
this.loadEvent(); this.loadEvent();
this.getAttachments(); this.getAttachments();