mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
update home ts
This commit is contained in:
+72
-45
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, NgZone } from '@angular/core';
|
||||||
import { EventsService } from '../services/events.service';
|
import { EventsService } from '../services/events.service';
|
||||||
import { formatDate } from '@angular/common';
|
import { formatDate } from '@angular/common';
|
||||||
import { Event } from '../models/event.model';
|
import { Event } from '../models/event.model';
|
||||||
@@ -8,6 +8,8 @@ import { ModalController } from '@ionic/angular';
|
|||||||
import { PublicationDetailPage } from '../../app/pages/publications/view-publications/publication-detail/publication-detail.page';
|
import { PublicationDetailPage } from '../../app/pages/publications/view-publications/publication-detail/publication-detail.page';
|
||||||
import { ViewPublicationsPage } from '../../app/pages/publications/view-publications/view-publications.page';
|
import { ViewPublicationsPage } from '../../app/pages/publications/view-publications/view-publications.page';
|
||||||
import { ExpedienteDetailPage } from '../../app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page'
|
import { ExpedienteDetailPage } from '../../app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page'
|
||||||
|
import { ViewEventPage } from '../../app/pages/agenda/view-event/view-event.page'
|
||||||
|
import { ApproveEventModalPage } from '../../app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page';
|
||||||
|
|
||||||
import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core';
|
import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
@@ -21,9 +23,6 @@ const { PushNotifications, LocalNotifications, LocalNotificationAction } = Plugi
|
|||||||
styleUrls: ['./home.page.scss'],
|
styleUrls: ['./home.page.scss'],
|
||||||
})
|
})
|
||||||
export class HomePage implements OnInit {
|
export class HomePage implements OnInit {
|
||||||
today = new Date();
|
|
||||||
todayEnd = new Date();
|
|
||||||
|
|
||||||
eventsList: Event[];
|
eventsList: Event[];
|
||||||
prEventList: Event[];
|
prEventList: Event[];
|
||||||
mdEventList: Event[];
|
mdEventList: Event[];
|
||||||
@@ -32,19 +31,19 @@ export class HomePage implements OnInit {
|
|||||||
totalExpediente = 0;
|
totalExpediente = 0;
|
||||||
profile: string;
|
profile: string;
|
||||||
|
|
||||||
constructor(private eventService: EventsService, private processesbackend: ProcessesService, private router: Router, private modalController: ModalController,) { }
|
constructor(private ngZone: NgZone,private eventService: EventsService, private processesbackend: ProcessesService, private router: Router, private modalController: ModalController,) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
//Initialize profile as mdgpr
|
//Initialize profile as mdgpr
|
||||||
this.profile = "mdgpr";
|
this.profile = "mdgpr";
|
||||||
if (this.profile == "mdgpr") {
|
if (this.profile == "mdgpr") {
|
||||||
this.eventService.getAllMdEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
this.eventService.getAllMdEvents(formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss', 'pt'), formatDate(new Date(), 'yyyy-MM-dd', 'pt') + ' 23:59:59').subscribe(res => {
|
||||||
this.eventsList = res;
|
this.eventsList = res;
|
||||||
this.totalEvent = this.eventsList.length;
|
this.totalEvent = this.eventsList.length;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.eventService.getAllPrEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
this.eventService.getAllPrEvents(formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss', 'pt'), formatDate(new Date(), 'yyyy-MM-dd', 'pt') + ' 23:59:59').subscribe(res => {
|
||||||
this.eventsList = res;
|
this.eventsList = res;
|
||||||
this.totalEvent = this.eventsList.length;
|
this.totalEvent = this.eventsList.length;
|
||||||
});
|
});
|
||||||
@@ -53,10 +52,6 @@ export class HomePage implements OnInit {
|
|||||||
this.processesbackend.GetTasksList("Expediente", true).subscribe(result => {
|
this.processesbackend.GetTasksList("Expediente", true).subscribe(result => {
|
||||||
this.totalExpediente = result;
|
this.totalExpediente = result;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
(PushNotifications as any).requestPermission().then(result => {
|
(PushNotifications as any).requestPermission().then(result => {
|
||||||
PushNotifications.register();
|
PushNotifications.register();
|
||||||
@@ -73,11 +68,11 @@ export class HomePage implements OnInit {
|
|||||||
|
|
||||||
console.log(this.storageService.get(this.username)) */
|
console.log(this.storageService.get(this.username)) */
|
||||||
|
|
||||||
/* PushNotifications.addListener('registrationError', (error: any) => {
|
PushNotifications.addListener('registrationError', (error: any) => {
|
||||||
alert('Error on registration: ' + JSON.stringify(error));
|
alert('Error on registration: ' + JSON.stringify(error));
|
||||||
}); */
|
});
|
||||||
|
|
||||||
/* PushNotifications.addListener('pushNotificationReceived', notification => {
|
PushNotifications.addListener('pushNotificationReceived', notification => {
|
||||||
|
|
||||||
//const isPushNotification = !!notification.title || !!notification.body;
|
//const isPushNotification = !!notification.title || !!notification.body;
|
||||||
|
|
||||||
@@ -85,28 +80,19 @@ export class HomePage implements OnInit {
|
|||||||
//if (isAndroid && isPushNotification) {
|
//if (isAndroid && isPushNotification) {
|
||||||
|
|
||||||
// We schedule a LocalNotification 1 second later since Capacitor for Android doesn't show anything in this case
|
// We schedule a LocalNotification 1 second later since Capacitor for Android doesn't show anything in this case
|
||||||
LocalNotifications.schedule({
|
console.log('Recived: ', notification)
|
||||||
notifications: [{
|
|
||||||
title: notification.title,
|
|
||||||
body: notification.body,
|
|
||||||
id: new Date().getUTCMilliseconds(),
|
|
||||||
schedule: {
|
|
||||||
at: new Date(Date.now() + 1000)
|
|
||||||
},
|
|
||||||
extra: notification.data,
|
|
||||||
channelId: 'pop-notifications'
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
//}
|
//}
|
||||||
}); */
|
});
|
||||||
|
|
||||||
|
|
||||||
/* PushNotifications.addListener(
|
PushNotifications.addListener(
|
||||||
'pushNotificationActionPerformed',
|
'pushNotificationActionPerformed',
|
||||||
(notification: PushNotificationActionPerformed) => {
|
(notification: PushNotificationActionPerformed) => {
|
||||||
let service = notification.notification.data.service;
|
let service = notification.notification.data.Service;
|
||||||
let object = notification.notification.data.object;
|
let object = notification.notification.data.Object;
|
||||||
let idObject = notification.notification.data.idObject;
|
let idObject = notification.notification.data.IdObject;
|
||||||
|
|
||||||
|
console.log('Complete Object: ', notification.notification )
|
||||||
|
|
||||||
console.log('Service: ', service);
|
console.log('Service: ', service);
|
||||||
console.log('Object: ', object);
|
console.log('Object: ', object);
|
||||||
@@ -133,18 +119,22 @@ export class HomePage implements OnInit {
|
|||||||
|
|
||||||
service = "agenda" ? this.router.navigate(['/home/', service, idObject, 'home']) : */
|
service = "agenda" ? this.router.navigate(['/home/', service, idObject, 'home']) : */
|
||||||
|
|
||||||
/* if (service === "agenda") {
|
if (service === "agenda") {
|
||||||
this.router.navigate(['/home/', service, idObject, 'home']);
|
//this.router.navigate(['/home/', service, idObject, 'home']);
|
||||||
} else if (service === "gabinete-digital" && object != "expediente") {
|
this.viewEventDetail(idObject)
|
||||||
this.router.navigate(['/home/', service]);
|
} else if (service === "gabinete-digital" && object != "expediente" || object != "event-list") {
|
||||||
|
this.router.navigate(['/home/gabinete-digital']);
|
||||||
} else if (service === "gabinete-digital" && object === "expediente") {
|
} else if (service === "gabinete-digital" && object === "expediente") {
|
||||||
this.viewExpedientDetail(idObject)
|
this.viewExpedientDetail(idObject)
|
||||||
|
} else if (service === "gabinete-digital" && object === "event-list") {
|
||||||
|
/* this.ngZone.run(() => {this.router.navigate(['/home/gabinete-digital/event-list', idObject])}) */
|
||||||
|
this.openApproveModal(idObject);
|
||||||
} else if (service === "accoes" && object === "accao") {
|
} else if (service === "accoes" && object === "accao") {
|
||||||
this.viewPublications(idObject)
|
this.viewPublications(idObject)
|
||||||
} else if (service === "accoes" && object === "publicacao") {
|
} else if (service === "accoes" && object === "publicacao") {
|
||||||
this.viewPublicationDetail(idObject)
|
this.viewPublicationDetail(idObject)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -177,11 +167,11 @@ export class HomePage implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* },
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/* async localNotificationPresent(notification) {
|
async localNotificationPresent(notification) {
|
||||||
|
|
||||||
LocalNotificationAction.
|
LocalNotificationAction.
|
||||||
|
|
||||||
@@ -200,9 +190,44 @@ export class HomePage implements OnInit {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
} */
|
}
|
||||||
|
|
||||||
/* async viewExpedientDetail(serialNumber:any) {
|
async openApproveModal(eventSerialNumber){
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: ApproveEventModalPage,
|
||||||
|
componentProps:{
|
||||||
|
serialNumber: eventSerialNumber,
|
||||||
|
},
|
||||||
|
cssClass: 'cal-modal',
|
||||||
|
backdropDismiss: false
|
||||||
|
});
|
||||||
|
|
||||||
|
await modal.present();
|
||||||
|
|
||||||
|
modal.onDidDismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
async viewEventDetail(eventId:any) {
|
||||||
|
console.log(this.profile);
|
||||||
|
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: ViewEventPage,
|
||||||
|
componentProps:{
|
||||||
|
eventId: eventId,
|
||||||
|
},
|
||||||
|
cssClass: 'modal',
|
||||||
|
backdropDismiss: false
|
||||||
|
});
|
||||||
|
await modal.present();
|
||||||
|
modal.onDidDismiss().then((res)=>{
|
||||||
|
if(res){
|
||||||
|
console.log(res);
|
||||||
|
//this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async viewExpedientDetail(serialNumber:any) {
|
||||||
console.log(this.profile);
|
console.log(this.profile);
|
||||||
|
|
||||||
const modal = await this.modalController.create({
|
const modal = await this.modalController.create({
|
||||||
@@ -244,12 +269,14 @@ export class HomePage implements OnInit {
|
|||||||
component: ViewPublicationsPage,
|
component: ViewPublicationsPage,
|
||||||
/* enterAnimation,
|
/* enterAnimation,
|
||||||
leaveAnimation, */
|
leaveAnimation, */
|
||||||
/* componentProps: { */
|
componentProps: {
|
||||||
/* item: folderId,
|
item: folderId,
|
||||||
},
|
},
|
||||||
cssClass: 'new-action',
|
cssClass: 'new-action',
|
||||||
backdropDismiss: false
|
backdropDismiss: false
|
||||||
});
|
});
|
||||||
await modal.present();
|
await modal.present();
|
||||||
modal.onDidDismiss();
|
modal.onDidDismiss();
|
||||||
} */
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user