mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Refacturation
This commit is contained in:
+1
-150
@@ -6,21 +6,8 @@ import { Event } from '../models/event.model';
|
||||
import { ProcessesService } from '../services/processes.service';
|
||||
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 { NavigationExtras,Router } from '@angular/router';
|
||||
|
||||
// import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
||||
import { ViewEventPage } from '../pages/agenda/view-event/view-event.page';
|
||||
import { ExpedienteDetailPage } from '../pages/gabinete-digital/expediente/expediente-detail/expediente-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';
|
||||
import { PublicationDetailPage } from '../pages/publications/view-publications/publication-detail/publication-detail.page';
|
||||
import { ToastService } from '../services/toast.service';
|
||||
import { SuccessMessagePage } from '../shared/popover/success-message/success-message.page';
|
||||
//import MFPPush from 'ibm-mfp-web-push';
|
||||
|
||||
/* const { PushNotifications, LocalNotifications, LocalNotificationAction } = Plugins; */
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -80,7 +67,7 @@ export class HomePage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
if(!this.platform.is('desktop')) {
|
||||
this.wlCommonInit();
|
||||
this.notificatinsservice.onReceviNotification();
|
||||
}
|
||||
this.count();
|
||||
|
||||
@@ -112,140 +99,4 @@ export class HomePage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
wlCommonInit() {
|
||||
|
||||
this.mobileFirstTest();
|
||||
this.mobileFirstPush();
|
||||
}
|
||||
|
||||
mobileFirstTest() {
|
||||
|
||||
}
|
||||
|
||||
mobileFirstPush() {
|
||||
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
MFPPush.initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
MFPPush.registerNotificationsCallback(notificationReceived);
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Push notification failure intialized: " + failureResponse);
|
||||
}
|
||||
);
|
||||
|
||||
MFPPush.registerDevice(null, function (successResponse) {
|
||||
console.log("Successfully registered: " + JSON.stringify(successResponse) );
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Successfully failue: " + failureResponse);
|
||||
}
|
||||
);
|
||||
var notificationReceived = (message) => {
|
||||
console.log(message);
|
||||
var data = JSON.parse(message.payload);
|
||||
console.log(data.Service);
|
||||
console.log(data.IdObject);
|
||||
console.log(data.Object);
|
||||
|
||||
if(message.actionName){
|
||||
this.notificatinsRoutes(data);
|
||||
} else {
|
||||
this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
|
||||
}
|
||||
|
||||
}
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
notificatinsRoutes = (data) => {
|
||||
if (data.Service === "agenda") {
|
||||
//this.router.navigate(['/home/', service, IdObject, 'home']);
|
||||
//this.router.navigate(['/home/agenda', data.IdObject, 'agenda']);
|
||||
this.zone.run(() => 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.zone.run(() =>this.openApproveModal(data.IdObject));
|
||||
}
|
||||
else if (data.Service === "gabinete-digital" && data.Object === "parecer") {
|
||||
// this.ngZone.run(() => {this.router.navigate(['/home/gabinete-digital/event-list', IdObject])})
|
||||
this.zone.run(() =>this.viewPedidoParecerDetail(data.IdObject));
|
||||
}
|
||||
else if (data.Service === "gabinete-digital" && data.Object === "deferimento") {
|
||||
// this.ngZone.run(() => {this.router.navigate(['/home/gabinete-digital/event-list', IdObject])})
|
||||
this.zone.run(() =>this.viewPedidoDefereimentoDetail(data.IdObject));
|
||||
}
|
||||
else if (data.Service === "accoes" && data.Object === "accao") {
|
||||
this.zone.run(() => this.viewPublications(data.IdObject));
|
||||
}
|
||||
else if (data.Service === "accoes" && data.Object === "publicacao") {
|
||||
this.zone.run(() => this.viewPublicationDetail(data.FolderId,data.IdObject));
|
||||
}
|
||||
}
|
||||
|
||||
async viewEventDetail(eventId: any) {
|
||||
console.log('home noti '+ eventId);
|
||||
this.router.navigate(['/home/agenda', eventId, 'agenda']);
|
||||
}
|
||||
|
||||
async openApproveModal(serialNumber) {
|
||||
this.router.navigate(['/home/gabinete-digital/event-list/approve-event',serialNumber, 'gabinete-digital'])
|
||||
}
|
||||
|
||||
async viewExpedientDetail(serialNumber:any) {
|
||||
this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']);
|
||||
}
|
||||
|
||||
async viewPublicationDetail(FolderId: string, publicationId: string ) {
|
||||
this.router.navigate(['/home/publications/view-publications', FolderId, publicationId]);
|
||||
}
|
||||
|
||||
|
||||
async viewPublications(folderId) {
|
||||
|
||||
this.router.navigate(['/home/publications',folderId]);
|
||||
}
|
||||
|
||||
async viewPedidoParecerDetail(serialNumber:any) {
|
||||
|
||||
let navigationExtras: NavigationExtras = {
|
||||
queryParams: {
|
||||
enterAnimation: "",
|
||||
serialNumber: serialNumber,
|
||||
}
|
||||
};
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos/pedido'], navigationExtras);
|
||||
|
||||
}
|
||||
|
||||
async viewPedidoDefereimentoDetail(serialNumber:any) {
|
||||
|
||||
let navigationExtras: NavigationExtras = {
|
||||
queryParams: {
|
||||
enterAnimation: "",
|
||||
serialNumber: serialNumber,
|
||||
}
|
||||
};
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos/pedido'], navigationExtras);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user