mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Merge branch 'feature/PushNotification_COrdova' into developer
This commit is contained in:
+68
-83
@@ -3,17 +3,18 @@ import { Component, OnInit, NgZone } from '@angular/core';
|
||||
import { EventsService } from '../services/events.service';
|
||||
import { Event } from '../models/event.model';
|
||||
import { ProcessesService } from '../services/processes.service';
|
||||
import { ModalController, AlertController, AnimationController } from '@ionic/angular';
|
||||
import { NotificationsService } from '../services/notifications.service';
|
||||
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
|
||||
//import { AlertController } from 'ionic-angular';
|
||||
/* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core'; */
|
||||
import { 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 { ApproveEventModalPage } from '../pages/agenda/approve-event-modal/approve-event-modal.page';
|
||||
import { ExpedienteDetailPage } from '../pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page';
|
||||
import { PublicationDetailPage } from '../pages/publications/publication-detail/publication-detail.page';
|
||||
import { ViewPublicationsPage } from '../pages/publications/view-publications/view-publications.page';
|
||||
import { ApproveEventModalPage } from '../pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page';
|
||||
|
||||
/* const { PushNotifications, LocalNotifications, LocalNotificationAction } = Plugins; */
|
||||
|
||||
@@ -58,8 +59,10 @@ export class HomePage implements OnInit {
|
||||
private router: Router,
|
||||
private modalController: ModalController,
|
||||
public modalCtrl: AlertController,
|
||||
//private fcm: FCM,
|
||||
private animationController: AnimationController,) {
|
||||
private fcm: FCM,
|
||||
private animationController: AnimationController,
|
||||
private notificatinsservice: NotificationsService,
|
||||
private platform: Platform) {
|
||||
|
||||
router.events.subscribe((val) => {
|
||||
document.querySelectorAll('ion-modal').forEach((e) => e.remove())
|
||||
@@ -73,11 +76,10 @@ export class HomePage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
//Add a test
|
||||
//this.pushCordova();
|
||||
//Initialize profile as mdgpr
|
||||
this.pushCordova();
|
||||
//Initialize profile as mdgpr
|
||||
|
||||
let date = new Date();
|
||||
/* 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";
|
||||
@@ -97,81 +99,56 @@ export class HomePage implements OnInit {
|
||||
|
||||
}
|
||||
this.processesbackend.GetTasksList("Expediente", true).subscribe(result => {
|
||||
this.totalExpediente = result;
|
||||
});
|
||||
this.totalExpediente = result;
|
||||
});*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
pushCordova() {
|
||||
/*
|
||||
this.fcm.onNotification().subscribe(data => {
|
||||
this.viewEventDetail(data.idObject)
|
||||
if (data.click_action) {
|
||||
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") {
|
||||
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)
|
||||
}
|
||||
if(this.platform.is('desktop')) {
|
||||
console.log('Notifications not supported')
|
||||
} else {
|
||||
|
||||
} else {
|
||||
console.log("Received in foreground: ", 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") {
|
||||
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)
|
||||
}
|
||||
else if (data.service === "accoes" && data.object === "publicacao") {
|
||||
this.viewPublicationDetail(data.idObject)
|
||||
}
|
||||
};
|
||||
});
|
||||
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)
|
||||
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
this.fcm.onTokenRefresh().subscribe(token => {
|
||||
// Register your new token in your back-end if you want
|
||||
// backend.registerToken(token);
|
||||
});
|
||||
|
||||
this.ubscribeToTopic()
|
||||
this.getToken() */
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* ubscribeToTopic() {
|
||||
this.fcm.subscribeToTopic('enappd');
|
||||
}
|
||||
getToken() {
|
||||
this.fcm.getToken().then(token => {
|
||||
console.log('token: ', token)
|
||||
// Register your new token in your back-end if you want
|
||||
// backend.registerToken(token);
|
||||
});
|
||||
} */
|
||||
|
||||
async viewEventDetail(eventId: any) {
|
||||
console.log(this.profile);
|
||||
|
||||
@@ -192,17 +169,25 @@ export class HomePage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
async openApproveModal(eventSerialNumber) {
|
||||
async openApproveModal(eventSerialNumber){
|
||||
let classs;
|
||||
if( window.innerWidth <= 1024){
|
||||
classs = 'cal-modal modal modal-desktop'
|
||||
} else {
|
||||
classs = 'gabinete-digital-mobile-modal-to-Desktop'
|
||||
}
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: ApproveEventModalPage,
|
||||
componentProps: {
|
||||
componentProps:{
|
||||
serialNumber: eventSerialNumber,
|
||||
},
|
||||
cssClass: 'cal-modal',
|
||||
cssClass: 'event-list',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
await modal.present();
|
||||
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
@@ -213,14 +198,14 @@ 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,
|
||||
componentProps: {
|
||||
serialNumber: serialNumber,
|
||||
profile: this.profile,
|
||||
profile: "MDGPR",
|
||||
},
|
||||
cssClass: classs,
|
||||
});
|
||||
@@ -244,7 +229,7 @@ export class HomePage implements OnInit {
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(() => {
|
||||
//this.getPublications();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user