PushNotification param change name from service to Service and object to Object

This commit is contained in:
Eudes Inácio
2021-02-08 17:07:40 +01:00
parent 254efccdb7
commit 2cd41a69f7
49 changed files with 1031 additions and 501 deletions
+28 -4
View File
@@ -8,6 +8,7 @@ import { ModalController } from '@ionic/angular';
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 { ExpedienteDetailPage } from '../../app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page'
import { ViewEventPage } from '../../app/pages/agenda/view-event/view-event.page'
import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core';
import { Router } from '@angular/router';
@@ -97,9 +98,11 @@ export class HomePage implements OnInit {
PushNotifications.addListener(
'pushNotificationActionPerformed',
(notification: PushNotificationActionPerformed) => {
let service = notification.notification.data.service;
let object = notification.notification.data.object;
let idObject = notification.notification.data.idObject;
let service = notification.notification.data.Service;
let object = notification.notification.data.Object;
let idObject = notification.notification.data.IdObject;
console.log('Complete Object: ', notification )
console.log('Service: ', service);
console.log('Object: ', object);
@@ -127,7 +130,8 @@ export class HomePage implements OnInit {
service = "agenda" ? this.router.navigate(['/home/', service, idObject, 'home']) : */
if (service === "agenda") {
this.router.navigate(['/home/', service, idObject, 'home']);
//this.router.navigate(['/home/', service, idObject, 'home']);
this.viewEventDetail(idObject)
} else if (service === "gabinete-digital" && object != "expediente") {
this.router.navigate(['/home/', service]);
} else if (service === "gabinete-digital" && object === "expediente") {
@@ -195,6 +199,26 @@ export class HomePage implements OnInit {
});
}
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);
+187 -117
View File
@@ -68,24 +68,11 @@ export class AgendaPage implements OnInit {
showTimeline: boolean= false;
events: CalendarEvent[] = [
/* {
title: '123',
start: setHours(setMinutes(new Date(), 0), 3),
color: {
primary: 'red',
secondary: 'yellow'
},
},
{
title: '123123',
start: setHours(setMinutes(new Date(), 0), 5),
color: {
primary: 'red',
secondary: 'yellow'
},
}, */
];
// for timeline
events: CalendarEvent[] = [];
// timeline filter
timelineFilterState: string = 'Todos';
showTimelineFilterState: boolean= false;
/* List of events of our calendar */
eventSource = [];
@@ -131,14 +118,12 @@ export class AgendaPage implements OnInit {
private router: Router,
private alertCrontroller: AlertService
) {
this.timelineDate = formatDate(new Date,'dd MMMM yyyy', 'pt');
setTimeout(()=>{
// console.log(JSON.stringify(this.events));
// console.log(this.events);
},5000)
// timeline inicial date
this.timelineDate = new Date().toLocaleString();
//this.timelineDate = formatDate(new Date,'dd MMMM yyyy', 'pt');
// console.log(setHours(setMinutes(new Date(), 0), 12))
function setCookie(cname, cvalue, exdays) {
var d = new Date();
@@ -151,6 +136,7 @@ export class AgendaPage implements OnInit {
setCookie('searchModalAPPType','0', 99999999);
this.showLoader = false;
}
ngOnInit() {
@@ -170,11 +156,8 @@ export class AgendaPage implements OnInit {
}
}
});
}
timelineIsCurrentDate(): Boolean {
return formatDate(new Date(),'dd MMMM yyyy', 'pt') == formatDate(this.eventSelectedDate,'dd MMMM yyyy', 'pt');
}
//Go to the next view of the calendar month/week/day
@@ -190,33 +173,6 @@ export class AgendaPage implements OnInit {
this.viewTitle = title;
}
currentDayEventDisplayBorder(day: any, id: any){
const events = day[id].events;
if (events.length == 0) {
return "";
} else if (events.length >= 1) {
/** @description store all event type */
let eventType = {};
let eventTypeNum: number;
events.forEach(element => {
eventType[element.calendarName] = 1;
});
eventTypeNum = (Object.keys(eventType)).length
if (eventTypeNum == 2) {
return 'calendar-event-type-both';
} else {
return 'calendar-event-type-'+(Object.keys(eventType))[0];
}
}
return "";
}
// Show information of the event for timeline
eventClicked({ event }: { event: CalendarEvent }): void {
console.log('Event clicked', event);
@@ -234,18 +190,20 @@ export class AgendaPage implements OnInit {
onCurrentChanged = (ev: Date) => {
// timeline change date
this.timelineDate = formatDate(ev,'dd MMMM yyyy', 'pt');
this.viewDate = new Date(formatDate(ev,'yyyy-MM-dd', 'pt'));
this.timelineDate = new Date(ev).toLocaleString();
this.viewDate = new Date(ev);
// calendar change date
this.eventSelectedDate = new Date(ev);
this.centralizeTimeline(500);
this.timelineBoxCorrectHeight(500);
};
// changedate
dropDownChangeDate(id: string){
const currentCandarDayYear = formatDate(this.eventSelectedDate,'dd -- yyyy', 'pt');
/* const currentCandarDayYear = formatDate(this.eventSelectedDate,'dd -- yyyy', 'pt');
const newDate = new Date(currentCandarDayYear.replace('--',id));
this.onCurrentChanged(newDate);
this.onCurrentChanged(newDate); */
}
/* onTimeSelected = (ev: { selectedTime: Date, events: any[] }) => {
@@ -293,23 +251,158 @@ export class AgendaPage implements OnInit {
});
}
timeLineTemplate(startTime: string, eventlocation: string, eventDiscription: any, calendarName: string, subject: string): string{
// for calendar
currentDayEventDisplayBorder(day: any, id: any){
const events = day[id].events;
if (events.length == 0) {
return "";
} else if (events.length >= 1) {
/** @description store all event type */
let eventType = {};
let eventTypeNum: number;
events.forEach(element => {
eventType[element.calendarName] = 1;
});
eventTypeNum = (Object.keys(eventType)).length
if (eventTypeNum == 2) {
return ` calendar-event-border calendar-${this.profile}-event-type-both`;
} else {
return ` calendar-event-border calendar-${this.profile}-event-type-`+(Object.keys(eventType))[0];
}
}
return "";
}
// for timeline
centralizeTimeline(timeout: number) {
// auto scroll timeline
setTimeout(() => {
const timelineMarker = document.querySelector('.cal-current-time-marker');
const timelineContainer = document.querySelectorAll('ion-content')[2];
const shadowRoot = timelineContainer.shadowRoot;
const scrollContainer = shadowRoot.querySelector('main');
scrollContainer.scrollTop = timelineMarker['offsetTop'] - ((scrollContainer.offsetHeight/2) - 60);
}, timeout);
}
// for timeline
timelineIsCurrentDate(): Boolean {
return true;
//return formatDate(new Date(),'dd MMMM yyyy', 'pt') == formatDate(this.eventSelectedDate,'dd MMMM yyyy', 'pt');
}
// for timeline
timeLineTemplate(startTime: string, eventlocation: string, eventDiscription: any, calendarName: string, subject: string, startTimeWisthS: string, endTime: string, eventIndex: number): string{
const startHours = parseInt(startTimeWisthS.split(':')[0]);
const startMinutos = parseInt(startTimeWisthS.split(':')[1]);
const endHours = parseInt(endTime.split(':')[0]);
const endMinutos = parseInt(endTime.split(':')[1]);
let top = '0';
if(startHours < endHours){
if (startMinutos != 0 ){
top = `${ Math.abs((startMinutos - 60)) }`
}
}
return `
<div class="timeline-box timeline-box-${calendarName}">
<div class="timeline-box timeline-box-event-${eventIndex} timeline-${this.profile}-box-${calendarName} calendar-top${top}">
<div>
<span class="timeline-start-time">${startTime}</span><span class="timeline-location">${eventlocation}</span>
<span class="timeline-start-time">${startTimeWisthS}</span><span class="timeline-location">${eventlocation}</span>
</div>
<div class="timeline-event-discription">
${subject}
</div>
</div>
`;
`
}
// for timeline
timelineBoxCorrectHeight(timeout){
setTimeout(()=>{
this.eventSource.forEach((el, eventIndex)=>{
const startEvent = new Date(el.startTime);
const endEvent = new Date(el.endTime);
var minutes = ((endEvent.getTime() - startEvent.getTime()) / 1000) / 60;
const top = (startEvent.getTime() - (new Date(2020, 1, 3)).getTime()) /60;
document.querySelectorAll('.timeline-box').forEach(ele => {
if(ele.className.indexOf(`timeline-box-event-${eventIndex}`)>=0){
ele.setAttribute('style',`height:${minutes}px`);
}
});
});
},timeout)
}
// for timeline
timelineFilter(calendarName){
this.timelineFilterState = calendarName;
// remove all event
this.events = [];
this.eventsList.forEach((element, eventIndex) => {
// timeline start
const startHours = new Date(element.StartDate).getHours().toLocaleString();
const EndHours = new Date(element.EndDate).getHours().toLocaleString();
const startHoursOtherFormate = new Date(element.StartDate).getHours().toLocaleString()+':'+new Date(element.StartDate).getMinutes().toLocaleString();
const EndHoursOtherFormate = formatDate(new Date(element.EndDate), 'HH:mm', 'pt');
if (element.CalendarName == calendarName) {
this.events.push({
title: this.timeLineTemplate(startHours, element.Location, element.Body, element.CalendarName, element.Subject,startHoursOtherFormate,EndHoursOtherFormate, eventIndex),
start: setHours(setMinutes(new Date(element.StartDate), 0), parseInt(startHours)),
end: setHours(setMinutes(new Date(element.EndDate), 0), parseInt(EndHours)),
color: {
primary: 'white',
secondary: 'white'
},
id: element.EventId
});
} else if (calendarName == 'Todos'){
this.events.push({
title: this.timeLineTemplate(startHours, element.Location, element.Body, element.CalendarName, element.Subject,startHoursOtherFormate,EndHoursOtherFormate, eventIndex),
start: setHours(setMinutes(new Date(element.StartDate), 0), parseInt(startHours)),
end: setHours(setMinutes(new Date(element.EndDate), 0), parseInt(EndHours)),
color: {
primary: 'white',
secondary: 'white'
},
id: element.EventId
});
}
});
this.onCurrentChanged(this.eventSelectedDate);
//
this.showTimelineFilterState = false;
}
loadRangeEvents(startTime: Date, endTime: Date){
console.log('Update date');
console.log('start ',startTime,' end', endTime)
this.showTimeline = false;
this.showLoader = true;
@@ -319,15 +412,14 @@ export class AgendaPage implements OnInit {
case "Combinada":
//Inicializa o array eventSource
this.eventSource=[];
this.events=[];
if(this.profile == "mdgpr"){
this.eventService.getAllMdEvents(formatDate(startTime, 'yyyy-MM-dd', 'pt'), formatDate(endTime, 'yyyy-MM-dd', 'pt')).subscribe(
this.eventService.getAllMdEvents(new Date(startTime).toLocaleString(), new Date(endTime).toLocaleString()).subscribe(
response => {
this.eventsList = response;
// loop
this.eventsList.forEach(element => {
this.eventsList.forEach((element, eventIndex) => {
this.eventSource.push({
title: element.Subject,
@@ -337,39 +429,27 @@ export class AgendaPage implements OnInit {
event: element,
calendarName: element.CalendarName
});
// timeline start
const startHours = formatDate(new Date(element.StartDate), 'HH', 'pt');
const EndHours = formatDate(new Date(element.EndDate), 'HH', 'pt');
this.events.push({
title: this.timeLineTemplate(startHours, element.Location, element.Body, element.CalendarName, element.Subject),
start: setHours(setMinutes(new Date(element.StartDate), 0), parseInt(startHours)),
end: setHours(setMinutes(new Date(element.EndDate), 0), parseInt(EndHours)),
color: {
primary: 'white',
secondary: 'white'
},
id: element.EventId
});
// timeline end
});
// this.timelineFilter(this.timelineFilterState);
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500);
});
}
else{
this.eventService.getAllPrEvents(formatDate(startTime, 'yyyy-MM-dd HH:mm:ss', 'pt'), formatDate(endTime, 'yyyy-MM-dd HH:mm:ss', 'pt')).subscribe(
this.eventService.getAllPrEvents(new Date(startTime).toLocaleString(), new Date(endTime).toLocaleString()).subscribe(
response => {
this.eventsList = response;
this.eventsList.forEach(element => {
this.eventsList.forEach((element, eventIndex) => {
this.eventSource.push({
title: element.Subject,
startTime: new Date(element.StartDate),
@@ -379,30 +459,18 @@ export class AgendaPage implements OnInit {
calendarName: element.CalendarName
});
// timeline start
const startHours = formatDate(new Date(element.StartDate), 'HH', 'pt');
const EndHours = formatDate(new Date(element.EndDate), 'HH', 'pt');
this.events.push({
title: this.timeLineTemplate(startHours, element.Location, element.Body, element.CalendarName, element.Subject),
start: setHours(setMinutes(new Date(element.StartDate), 0), parseInt(startHours)),
end: setHours(setMinutes(new Date(element.EndDate), 0), parseInt(EndHours)),
color: {
primary: 'white',
secondary: 'white'
},
id: element.EventId
});
// timeline end
});
// this.timelineFilter(this.timelineFilterState);
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500);
});
}
break;
@@ -411,7 +479,7 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource
this.eventSource=[];
if(this.profile == "mdgpr"){
this.eventService.getAllMdEvents(formatDate(startTime, 'yyyy-MM-dd HH:mm:ss', 'pt'), formatDate(endTime, 'yyyy-MM-dd HH:mm:ss', 'pt')).subscribe(response => {
this.eventService.getAllMdEvents(new Date(startTime).toLocaleString(), new Date(endTime).toLocaleString()).subscribe(response => {
this.eventsListPessoal = response.filter(data => data.CalendarName == "Pessoal");
this.eventsListPessoal.forEach(element => {
this.eventSource.push({
@@ -428,7 +496,7 @@ export class AgendaPage implements OnInit {
});
}
else{
this.eventService.getAllPrEvents(formatDate(startTime, 'yyyy-MM-dd HH:mm:ss', 'pt'), formatDate(endTime, 'yyyy-MM-dd HH:mm:ss', 'pt')).subscribe(response => {
this.eventService.getAllPrEvents(new Date(startTime).toLocaleString(), new Date(endTime).toLocaleString()).subscribe(response => {
this.eventsListPessoal = response.filter(data => data.CalendarName == "Pessoal");
this.eventsListPessoal.forEach(element => {
this.eventSource.push({
@@ -450,7 +518,7 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource
this.eventSource=[];
if(this.profile == "mdgpr"){
this.eventService.getAllMdEvents(formatDate(startTime, 'yyyy-MM-dd HH:mm:ss', 'pt'), formatDate(endTime, 'yyyy-MM-dd HH:mm:ss', 'pt')).subscribe(res => {
this.eventService.getAllMdEvents(new Date(startTime).toLocaleString(), new Date(endTime).toLocaleString()).subscribe(res => {
this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial");
this.eventsListOficial.forEach(element => {
this.eventSource.push({
@@ -466,7 +534,7 @@ export class AgendaPage implements OnInit {
this.showLoader = false;
});
}else{
this.eventService.getAllPrEvents(formatDate(startTime, 'yyyy-MM-dd HH:mm:ss', 'pt'), formatDate(endTime, 'yyyy-MM-dd HH:mm:ss', 'pt')).subscribe(res => {
this.eventService.getAllPrEvents(new Date(startTime).toLocaleString(), new Date(endTime).toLocaleString()).subscribe(res => {
this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial");
this.eventsListOficial.forEach(element => {
this.eventSource.push({
@@ -495,12 +563,13 @@ export class AgendaPage implements OnInit {
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
setTimeout(() => {
ev.target.complete();
}, 250);
}, 250)
}
showAlert(){
this.alertCrontroller.presentAlert("Funcionalidade em desenvolvimento.");
}
changeProfile(){
if(this.profile == "mdgpr"){
console.log('pr');
this.profile ="pr";
@@ -511,6 +580,10 @@ export class AgendaPage implements OnInit {
this.profile ="mdgpr";
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
}
// change header profile picture
window['header'](this.profile);
}
async openAddEvent() {
@@ -519,7 +592,7 @@ export class AgendaPage implements OnInit {
componentProps:{
segment: this.segment,
profile: this.profile,
eventSelectedDate: this.eventSelectedDate,
eventSelectedDate: this.eventSelectedDate
},
cssClass: 'modal',
backdropDismiss: false
@@ -549,7 +622,7 @@ export class AgendaPage implements OnInit {
const modal = await this.modalCtrl.create({
component: ViewEventPage,
componentProps:{
eventId: eventId,
eventId: eventId
},
cssClass: 'modal',
backdropDismiss: false
@@ -573,8 +646,5 @@ export class AgendaPage implements OnInit {
});
await modal.present();
modal.onDidDismiss();
}
}
}
}