This commit is contained in:
Peter Maquiran
2022-12-22 11:01:58 +01:00
parent 7168788b3c
commit e6caab4aaf
45 changed files with 7182 additions and 4145 deletions
+3 -442
View File
@@ -1,450 +1,11 @@
import { Component, OnInit, EventEmitter, Output } from '@angular/core';
import { EventsService } from 'src/app/services/events.service';
import { NavigationExtras, Router } from '@angular/router';
import { ActivatedRoute, NavigationEnd } from '@angular/router';
import { ModalController, Platform } from '@ionic/angular';
import { EventDetailPage } from './event-detail/event-detail.page';
import { ProcessesService } from '../../services/processes.service';
import { ToDayEventStorage } from 'src/app/store/to-day-event-storage.service';
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { momentG } from 'src/plugin/momentG';
import { ThemeService } from 'src/app/services/theme.service'
import { Storage } from '@ionic/storage';
import { PermissionService } from 'src/app/services/permission.service';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { SessionStore } from 'src/app/store/session.service';
@Component({
selector: 'app-events',
templateUrl: './events.page.html',
styleUrls: ['./events.page.scss'],
})
export class EventsPage implements OnInit {
today = new Date();
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
grettings = ["Bom dia", "Boa tarde", "Boa noite"];
greetting = '';
timeDate = this.today.getHours() + ":" + this.today.getMinutes();
segment: string;
public profile: string;
currentEvent: any;
maxSubjectLength = 30;
customText = false;
totalEvent = 0;
currentHoursMinutes: Date | string;
showLoader: boolean;
expedientList: any;
hideSearchBtn: boolean = false;
// shared data
toDayEventStorage = ToDayEventStorage
expedienteGdStore = ExpedienteGdStore
listToPresent = [];
listToPresentexpediente = []
expedienteTaskPipe = new ExpedienteTaskPipe()
@Output() openExpedientListPage: EventEmitter<any> = new EventEmitter<any>();
sessoStore = SessionStore;
showAgendaLoader = false
showCorrespondenciasLoader = false
constructor(
private eventService: EventsService,
private router: Router,
public activatedRoute: ActivatedRoute,
private processes: ProcessesService,
private modalController: ModalController,
public platform: Platform,
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService,
private storage: Storage,
public p: PermissionService,
private changeProfileService: ChangeProfileService,
) {
// window['zipPhoneCallback'] = function (zipphone) {
// var frame = document.getElementById('home-iframe');
// if(frame) {
// frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }});
// }
// }
// this.changeProfileService.registerCallback(() => {
// this.listToPresent = [];
// this.listToPresentexpediente = []
// })
}
ngOnInit() {
// this.showGreeting();
// this.router.events.forEach((event) => {
// if (event instanceof NavigationEnd && event.url == '/home/events') {
// this.RefreshEvents();
// setTimeout(() => {
// this.LoadList();
// }, 1500)
// }
// });
// this.hideSearch();
// this.backgroundservice.registerBackService('Online', () => {
// this.showGreeting();
// this.RefreshEvents();
// this.LoadList();
// this.hideSearch();
// });
}
hideSearch() {
// if (this.router.url == '/home/events') {
// this.hideSearchBtn = true;
// }
}
doRefresh() {
// this.RefreshEvents();
// this.LoadList();
}
onSegmentChange() {
// this.doRefresh();
}
async RefreshEvents() {
// this.currentEvent = "";
// this.showLoader = true;
// this.showAgendaLoader = true;
// let date = new Date();
// let month = date.getMonth() + 1;
// let start = date.getFullYear() + "-" + month + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
// let end = date.getFullYear() + "-" + month + "-" + date.getDate() + " 23:59:59";
// if(SessionStore.user) {
// let onwEvent:any = await this.eventService.getAllOwnEvents(start, end).catch((error) => {
// this.showAgendaLoader = false;
// console.error(error)
// })
// this.listToPresent = onwEvent;
// this.totalEvent = onwEvent.length;
// this.showLoader = false;
// this.showAgendaLoader = false;
// } else {
// }
}
addEventToDb(list) {
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
// this.storage.set('events', list).then(() => {
// //
// })
// } else {
// if (list.length > 0) {
// list.forEach(element => {
// this.sqliteservice.addEvent(element)
// this.sqliteservice.getAllEvents().then((event: any[] = []) => {
// let todayEvents = new Array()
// event.forEach((element) => {
// let eventObject = {
// AppointmentState: element.AppointmentState,
// Attachments: element.Attachments,
// Attendees: element.Attendees,
// CalendarId: element.CalendarId,
// CalendarName: element.CalendarName,
// Category: element.Category,
// EndDate: element.EndDate,
// EventId: element.EventId,
// EventRecurrence: element.EventRecurrence,
// EventType: element.EventType,
// HasAttachments: element.HasAttachments,
// HumanDate: element.HumanDate,
// IsAllDayEvent: element.IsAllDayEvent,
// IsMeeting: element.IsMeeting,
// IsRecurring: element.IsRecurring,
// Location: element.Location,
// Organizer: element.Organizer,
// Profile: element.Profile,
// StartDate: element.StartDate,
// Subject: element.Subject
// }
// todayEvents.push(eventObject);
// })
// })
// });
// }
// }
}
addProcessToDb(list) {
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
// this.storage.set('process', list).then(() => {
// //
// })
// } else {
// if (list.length > 0) {
// list.forEach(element => {
// this.sqliteservice.addProcess(element)
// });
// }
// }
}
getEventsFromLocalDb() {
// let date = new Date();
// let month = date.getMonth() + 1;
// //date.setMonth(date.getMonth() + 1);
// let dateToday = date.getFullYear() + "-" + month + "-" + date.getDate();
// // ('dateeeeee', dateToday)
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
// this.storage.get('events').then((events: any[] = []) => {
// //
// let todayEvents = new Array()
// this.listToPresent = events
// this.totalEvent = this.listToPresent.length
// this.currentEvent = this.listToPresent[0].Subject
// this.currentHoursMinutes = this.listToPresent[0].StartDate
// //
// })
// this.storage.get('process').then((process: any[] = []) => {
// //
// const ExpedienteTask = process.map(e => this.expedienteTaskPipe.transform(e))
// this.listToPresentexpediente = ExpedienteTask;
// })
// this.showLoader = false;
// } else {
// this.sqliteservice.getAllEvents().then((event: any[] = []) => {
// let todayEvents = new Array()
// event.forEach((element) => {
// let eventObject = {
// AppointmentState: element.AppointmentState,
// Attachments: element.Attachments,
// Attendees: element.Attendees,
// CalendarId: element.CalendarId,
// CalendarName: element.CalendarName,
// Category: element.Category,
// EndDate: element.EndDate,
// EventId: element.EventId,
// EventRecurrence: element.EventRecurrence,
// EventType: element.EventType,
// HasAttachments: element.HasAttachments,
// HumanDate: element.HumanDate,
// IsAllDayEvent: element.IsAllDayEvent,
// IsMeeting: element.IsMeeting,
// IsRecurring: element.IsRecurring,
// Location: element.Location,
// Organizer: element.Organizer,
// Profile: element.Profile,
// StartDate: element.StartDate,
// Subject: element.Subject
// }
// let starteDate = momentG(new Date(element.StartDate), 'yyyy-MM-dd');
// //
// if (dateToday == starteDate) {
// todayEvents.push(eventObject);
// }
// })
// this.listToPresent = todayEvents
// this.totalEvent = this.listToPresent.length
// this.currentEvent = this.listToPresent[0].Subject
// this.currentHoursMinutes = this.listToPresent[0].StartDate
// //
// })
// this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[] = []) => {
// //
// if (process.length > 0 || process != undefined) {
// var expedientlist: any = new Array();
// process.forEach((element) => {
// if(JSON.parse(element.workflowInstanceDataFields).TaskMessage || JSON.parse(element.workflowInstanceDataFields).Note) {
// let task = {
// activityInstanceName: element.activityInstanceName,
// deadline: null,
// serialNumber: element.serialNumber,
// taskStartDate: element.taskStartDate,
// totalDocuments: element.totalDocuments,
// workflowDisplayName: element.workflowDisplayName,
// workflowInstanceDataFields: JSON.parse(element.workflowInstanceDataFields)
// }
// expedientlist.push(task);
// }
// })
// //
// const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
// this.listToPresentexpediente = ExpedienteTask;
// }
// this.showLoader = false;
// })
// }
// // });
}
showGreeting() {
// if (this.today.getHours() >= 6 && this.today.getHours() < 12) {
// this.greetting = this.grettings[0];
// }
// else if (this.today.getHours() >= 12 && this.today.getHours() < 18) {
// this.greetting = this.grettings[1];
// }
// else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */ {
// this.greetting = this.grettings[2];
// }
}
gotTo() {
this.router.navigate(['/home/events']);
}
changeProfile() {
// if (this.profile == "mdgpr") {
// //
// this.profile = "pr";
// this.RefreshEvents();
// }
// else {
// //
// this.profile = "mdgpr";
// this.RefreshEvents();
// }
}
async openEventDetail1(id: any) {
//
const modal = await this.modalController.create({
component: EventDetailPage,
componentProps: {
eventId: id,
},
cssClass: 'event-detail',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
}
async openEventDetail(id: any) {
//
const modal = await this.modalController.create({
component: ViewEventPage,
componentProps: {
eventId: id,
},
cssClass: 'view-event',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
}
LoadList() {
this.showCorrespondenciasLoader = true
this.processes.GetTaskListExpediente(false).subscribe(result => {
this.addProcessToDb(result);
let ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
this.showCorrespondenciasLoader = false
}, ((error) => {
this.showCorrespondenciasLoader = false
//
this.getEventsFromLocalDb();
}));
}
sortArrayISODate(myArray: any) {
return myArray.sort(function (a, b) {
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
});
}
goToEvent(event: any) {
let navigationExtras: NavigationExtras = { queryParams: { CalendarId: event.CalendarId } }
this.router.navigate(['/home/events', event.EventId, 'agenda'], navigationExtras);
}
goToExpediente(SerialNumber: any) {
this.router.navigate(['/home/events/expediente', SerialNumber, 'events']);
}
viewExpedientListPage() {
if (this.sessoStore.user.Profile == 'PR') {
if (window.innerWidth < 701) {
this.router.navigate(['/home/gabinete-digital/expedientes-pr']);
}
else {
let navigationExtras: NavigationExtras = { queryParams: { "expedientes-pr": true, } };
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
}
} else {
if (window.innerWidth < 701) {
this.router.navigate(['/home/gabinete-digital/expediente']);
}
else {
let navigationExtras: NavigationExtras = { queryParams: { "expedientes": true, } };
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
}
}
}
}
constructor() {}
ngOnInit() {}
}