2021-04-13 15:43:44 +01:00
|
|
|
//<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
|
2021-02-09 20:20:36 +01:00
|
|
|
import { Component, OnInit, NgZone } from '@angular/core';
|
2020-09-08 11:17:07 +01:00
|
|
|
import { EventsService } from '../services/events.service';
|
|
|
|
|
import { Event } from '../models/event.model';
|
2020-09-08 11:25:00 +01:00
|
|
|
import { ProcessesService } from '../services/processes.service';
|
2021-04-08 22:54:15 +01:00
|
|
|
import { ModalController, AlertController, AnimationController } from '@ionic/angular';
|
2021-04-07 09:13:07 +01:00
|
|
|
//import { AlertController } from 'ionic-angular';
|
2021-02-23 16:10:14 +01:00
|
|
|
/* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core'; */
|
2021-01-26 17:00:41 +01:00
|
|
|
import { Router } from '@angular/router';
|
2021-01-20 17:00:56 +01:00
|
|
|
|
2021-04-13 11:42:54 +01:00
|
|
|
//import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
2021-04-08 22:54:15 +01:00
|
|
|
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 { ViewPublicationsPage } from '../pages/publications/view-publications/view-publications.page';
|
2021-04-13 15:43:44 +01:00
|
|
|
import { PublicationDetailPage } from '../pages/publications/view-publications/publication-detail/publication-detail.page';
|
2021-04-08 11:27:53 +01:00
|
|
|
|
2021-02-23 16:10:14 +01:00
|
|
|
/* const { PushNotifications, LocalNotifications, LocalNotificationAction } = Plugins; */
|
2021-01-20 17:00:56 +01:00
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-home',
|
|
|
|
|
templateUrl: './home.page.html',
|
|
|
|
|
styleUrls: ['./home.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class HomePage implements OnInit {
|
2020-09-08 11:17:07 +01:00
|
|
|
eventsList: Event[];
|
2020-11-20 13:36:35 +01:00
|
|
|
prEventList: Event[];
|
|
|
|
|
mdEventList: Event[];
|
|
|
|
|
|
2021-01-26 17:00:41 +01:00
|
|
|
totalEvent = 0;
|
|
|
|
|
totalExpediente = 0;
|
|
|
|
|
profile: string;
|
2020-08-05 15:39:16 +01:00
|
|
|
|
2021-04-08 22:54:15 +01:00
|
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
|
mobileComponent = {
|
|
|
|
|
showAddNewEvent: false,
|
|
|
|
|
showEditEvent: false,
|
|
|
|
|
showEventDetails: false,
|
|
|
|
|
showEventList: false,
|
|
|
|
|
transparentEventList: false,
|
|
|
|
|
transparentEventToApprove: false,
|
|
|
|
|
showEventToApprove: false,
|
|
|
|
|
showAttendees: false,
|
|
|
|
|
showAttendeeModal: false
|
|
|
|
|
}
|
|
|
|
|
eventToaprove: any = {
|
|
|
|
|
back: false,
|
|
|
|
|
serialNumber: "",
|
|
|
|
|
saveData: {}
|
|
|
|
|
}
|
|
|
|
|
selectedEvent: Event;
|
|
|
|
|
postEvent: any;
|
|
|
|
|
folderId: string;
|
|
|
|
|
|
2021-04-13 11:42:54 +01:00
|
|
|
constructor(private zone: NgZone,
|
|
|
|
|
private eventService: EventsService,
|
|
|
|
|
private processesbackend: ProcessesService,
|
|
|
|
|
private router: Router,
|
|
|
|
|
private modalController: ModalController,
|
|
|
|
|
public modalCtrl: AlertController,
|
|
|
|
|
//private fcm: FCM,
|
|
|
|
|
private animationController: AnimationController,) {
|
2021-04-08 22:54:15 +01:00
|
|
|
|
2021-03-04 16:07:09 +01:00
|
|
|
router.events.subscribe((val) => {
|
2021-04-08 22:54:15 +01:00
|
|
|
document.querySelectorAll('ion-modal').forEach((e) => e.remove())
|
2021-03-04 16:07:09 +01:00
|
|
|
});
|
2021-04-08 22:54:15 +01:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
//this.folderId = this.navParams.get('folderId');
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-04 16:07:09 +01:00
|
|
|
}
|
2020-08-05 15:39:16 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-04-09 00:10:07 +01:00
|
|
|
|
2021-04-13 15:27:46 +01:00
|
|
|
//Add a test
|
2021-04-13 11:42:54 +01:00
|
|
|
//this.pushCordova();
|
|
|
|
|
//Initialize profile as mdgpr
|
2021-04-08 22:54:15 +01:00
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
this.profile = "mdgpr";
|
|
|
|
|
if (this.profile == "mdgpr") {
|
|
|
|
|
this.eventService.getAllMdEvents(start, end).subscribe(res => {
|
|
|
|
|
this.eventsList = res;
|
|
|
|
|
this.totalEvent = this.eventsList.length;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.eventService.getAllPrEvents(start, end).subscribe(res => {
|
|
|
|
|
this.eventsList = res;
|
|
|
|
|
this.totalEvent = this.eventsList.length;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
this.processesbackend.GetTasksList("Expediente", true).subscribe(result => {
|
|
|
|
|
this.totalExpediente = result;
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-13 11:42:54 +01:00
|
|
|
|
2021-02-01 09:58:15 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-09 00:10:07 +01:00
|
|
|
pushCordova() {
|
2021-04-13 11:42:54 +01:00
|
|
|
/*
|
2021-04-09 00:10:07 +01:00
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} 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.onTokenRefresh().subscribe(token => {
|
|
|
|
|
// Register your new token in your back-end if you want
|
|
|
|
|
// backend.registerToken(token);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.ubscribeToTopic()
|
2021-04-13 11:42:54 +01:00
|
|
|
this.getToken() */
|
2021-04-09 00:10:07 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-13 11:42:54 +01:00
|
|
|
/* ubscribeToTopic() {
|
2021-04-09 00:10:07 +01:00
|
|
|
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);
|
2021-02-25 09:42:06 +01:00
|
|
|
});
|
2021-04-13 11:42:54 +01:00
|
|
|
} */
|
2021-04-09 00:10:07 +01:00
|
|
|
|
|
|
|
|
async viewEventDetail(eventId: any) {
|
|
|
|
|
console.log(this.profile);
|
|
|
|
|
|
|
|
|
|
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);
|
2021-02-25 09:42:06 +01:00
|
|
|
}
|
2021-04-09 00:10:07 +01:00
|
|
|
});
|
2021-04-05 14:17:11 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-09 00:10:07 +01:00
|
|
|
async openApproveModal(eventSerialNumber) {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ApproveEventModalPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
serialNumber: eventSerialNumber,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'cal-modal',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
2021-04-05 14:17:11 +01:00
|
|
|
|
2021-04-09 00:10:07 +01:00
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async viewExpedientDetail(serialNumber: any) {
|
|
|
|
|
let classs;
|
|
|
|
|
if (window.innerWidth <= 800) {
|
|
|
|
|
classs = 'modal'
|
|
|
|
|
} else {
|
|
|
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
|
|
|
}
|
|
|
|
|
/* console.log(this.profile);
|
|
|
|
|
console.log(serialNumber); */
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ExpedienteDetailPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
serialNumber: serialNumber,
|
|
|
|
|
profile: this.profile,
|
|
|
|
|
},
|
|
|
|
|
cssClass: classs,
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res) => {
|
|
|
|
|
if (res) {
|
|
|
|
|
console.log(res);
|
2021-04-05 14:17:11 +01:00
|
|
|
}
|
2021-04-09 00:10:07 +01:00
|
|
|
});
|
|
|
|
|
}
|
2021-04-05 14:17:11 +01:00
|
|
|
|
2021-04-09 00:10:07 +01:00
|
|
|
async viewPublicationDetail(publicationId: string) {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: PublicationDetailPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
publicationId: publicationId,
|
|
|
|
|
folderId: this.folderId,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'publication-detail',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then(() => {
|
|
|
|
|
//this.getPublications();
|
|
|
|
|
});
|
2021-04-05 14:17:11 +01:00
|
|
|
}
|
2021-02-25 09:42:06 +01:00
|
|
|
|
2021-04-07 09:13:07 +01:00
|
|
|
|
2021-04-09 00:10:07 +01:00
|
|
|
async viewPublications(folderId) {
|
|
|
|
|
|
|
|
|
|
const enterAnimation = (baseEl: any) => {
|
|
|
|
|
const backdropAnimation = this.animationController.create()
|
|
|
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
|
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
|
|
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
|
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
|
|
|
.keyframes([
|
|
|
|
|
{ offset: 0, opacity: '0', transform: 'scale(0)' },
|
|
|
|
|
{ offset: 1, opacity: '0.99', transform: 'scale(1)' }
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return this.animationController.create()
|
|
|
|
|
.addElement(baseEl)
|
|
|
|
|
.easing('ease-out')
|
|
|
|
|
.duration(500)
|
|
|
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
|
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewPublicationsPage,
|
|
|
|
|
enterAnimation,
|
|
|
|
|
leaveAnimation,
|
|
|
|
|
componentProps: {
|
|
|
|
|
folderId: folderId,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'new-action',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-04-07 09:13:07 +01:00
|
|
|
|
2021-04-09 00:06:17 +01:00
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
|
|
|
|
|
|
2020-09-08 11:17:07 +01:00
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
}
|