2020-08-21 16:18:37 +01:00
|
|
|
import { Component, OnInit, LOCALE_ID } from '@angular/core';
|
2020-08-18 23:32:12 +01:00
|
|
|
|
|
|
|
|
import { Event } from '../../models/event.model';
|
|
|
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
|
|
|
import { Router } from '@angular/router';
|
2020-08-21 18:26:03 +01:00
|
|
|
import { ActivatedRoute, NavigationEnd } from '@angular/router';
|
2020-08-21 16:18:37 +01:00
|
|
|
import { formatDate } from '@angular/common';
|
2020-08-28 11:37:28 +01:00
|
|
|
import { AlertService } from 'src/app/services/alert.service';
|
2020-08-28 15:28:38 +01:00
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
2020-11-24 13:46:13 +01:00
|
|
|
import { StorageService } from 'src/app/services/storage.service';
|
|
|
|
|
import { AuthConnstants } from 'src/app/config/auth-constants';
|
|
|
|
|
import { ModalController } from '@ionic/angular';
|
|
|
|
|
import { EventDetailPage } from './event-detail/event-detail.page';
|
|
|
|
|
import { EventDetailModalPage } from './event-detail-modal/event-detail-modal.page';
|
2021-01-04 10:37:13 +01:00
|
|
|
import { ProcessesService } from '../../services/processes.service';
|
2021-01-05 09:24:16 +01:00
|
|
|
import { DailyWorkTask } from '../../models/dailyworktask.model';
|
2021-01-31 16:14:42 +01:00
|
|
|
import { ViewEventPage } from '../agenda/view-event/view-event.page';
|
2021-02-01 09:17:38 +01:00
|
|
|
import { ExpedientePage } from '../gabinete-digital/expediente/expediente.page';
|
2021-02-01 13:21:41 +01:00
|
|
|
import { ExpedienteDetailPage } from '../gabinete-digital/expediente/expediente-detail/expediente-detail.page';
|
2020-08-18 23:32:12 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-events',
|
|
|
|
|
templateUrl: './events.page.html',
|
|
|
|
|
styleUrls: ['./events.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class EventsPage implements OnInit {
|
2020-08-21 16:18:37 +01:00
|
|
|
/* Get current system date */
|
|
|
|
|
today = new Date();
|
2021-02-08 16:55:55 +01:00
|
|
|
todayEnd = new Date();
|
2020-08-21 16:18:37 +01:00
|
|
|
|
|
|
|
|
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"];
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-21 16:18:37 +01:00
|
|
|
customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-21 16:18:37 +01:00
|
|
|
/* Setting appropriate greeting according to the time */
|
|
|
|
|
grettings = ["Bom dia", "Boa tarde", "Boa noite"];
|
|
|
|
|
greetting='';
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-21 16:18:37 +01:00
|
|
|
timeDate = this.today.getHours() + ":" + this.today.getMinutes();
|
|
|
|
|
/* Set segment variable */
|
|
|
|
|
segment:string;
|
2020-11-20 13:36:35 +01:00
|
|
|
public profile:string;
|
2021-01-05 13:58:15 +01:00
|
|
|
currentEvent: any;
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-21 18:26:03 +01:00
|
|
|
eventsList: Event[];
|
|
|
|
|
officialeventsList: Event[];
|
|
|
|
|
personaleventsList: Event[];
|
|
|
|
|
|
2020-11-20 10:55:51 +01:00
|
|
|
prEventList: Event[];
|
|
|
|
|
mdEventList: Event[];
|
|
|
|
|
|
|
|
|
|
combinedEvents: Event[];
|
|
|
|
|
|
2020-08-28 10:10:46 +01:00
|
|
|
customText = false;
|
2021-01-04 10:37:13 +01:00
|
|
|
totalEvent=0;
|
2021-01-04 11:34:43 +01:00
|
|
|
currentHoursMinutes: String;
|
2020-08-28 10:10:46 +01:00
|
|
|
|
2020-08-28 11:45:50 +01:00
|
|
|
showLoader: boolean;
|
2021-01-05 09:24:16 +01:00
|
|
|
|
|
|
|
|
taskslist:DailyWorkTask[];
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-28 11:37:28 +01:00
|
|
|
constructor(private eventService: EventsService,
|
|
|
|
|
private router: Router,
|
2020-11-24 13:46:13 +01:00
|
|
|
private storageService:StorageService,
|
2020-08-28 11:37:28 +01:00
|
|
|
public activatedRoute: ActivatedRoute,
|
2020-08-28 15:28:38 +01:00
|
|
|
private alertController: AlertService,
|
2020-11-24 13:46:13 +01:00
|
|
|
private modalController: ModalController,
|
2021-01-05 09:24:16 +01:00
|
|
|
private authService: AuthService,
|
|
|
|
|
private processes:ProcessesService) {
|
2020-11-20 10:55:51 +01:00
|
|
|
this.prEventList = null;
|
2021-01-05 09:24:16 +01:00
|
|
|
|
|
|
|
|
// update hours and minutes
|
2021-01-04 11:34:43 +01:00
|
|
|
setInterval(()=> {
|
2021-01-05 09:24:16 +01:00
|
|
|
this.currentHoursMinutes = formatDate(new Date(), 'HH:MM', 'pt');
|
2021-01-04 11:34:43 +01:00
|
|
|
}, 1000);
|
|
|
|
|
|
2021-01-05 09:24:16 +01:00
|
|
|
// list
|
|
|
|
|
this.LoadList();
|
2021-02-08 16:55:55 +01:00
|
|
|
|
|
|
|
|
this.todayEnd = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 23, 59, 59);
|
2021-01-04 11:34:43 +01:00
|
|
|
|
2020-11-20 10:55:51 +01:00
|
|
|
}
|
2020-08-21 16:18:37 +01:00
|
|
|
|
2021-01-16 17:44:38 +01:00
|
|
|
|
|
|
|
|
swipe(){
|
|
|
|
|
console.log('!!!!');
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 16:18:37 +01:00
|
|
|
ngOnInit() {
|
|
|
|
|
//Inicializar segment
|
2020-08-21 18:26:03 +01:00
|
|
|
this.segment = "Combinada";
|
2020-11-20 10:55:51 +01:00
|
|
|
//Initialize profile as mdgpr
|
2020-11-26 09:04:22 +01:00
|
|
|
this.profile = "mdgpr";
|
2020-11-24 13:46:13 +01:00
|
|
|
console.log(this.profile);
|
2021-01-04 10:37:13 +01:00
|
|
|
|
|
|
|
|
// set event list
|
2021-01-05 11:35:02 +01:00
|
|
|
/* if(this.profile == "mdgpr"){
|
|
|
|
|
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 => {
|
2021-01-04 10:37:13 +01:00
|
|
|
this.eventsList = res;
|
2021-01-05 11:35:02 +01:00
|
|
|
console.log(this.eventsList);
|
2021-01-04 10:37:13 +01:00
|
|
|
this.totalEvent = this.eventsList.length;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
2021-01-05 11:35:02 +01:00
|
|
|
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 => {
|
2021-01-04 10:37:13 +01:00
|
|
|
this.eventsList = res;
|
|
|
|
|
this.totalEvent = this.eventsList.length;
|
|
|
|
|
});
|
|
|
|
|
|
2021-01-05 11:35:02 +01:00
|
|
|
} */
|
2020-11-20 10:55:51 +01:00
|
|
|
|
2021-01-19 10:44:55 +01:00
|
|
|
this.storageService.get(AuthConnstants.USER).then(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
|
2020-08-21 16:18:37 +01:00
|
|
|
this.showGreeting();
|
|
|
|
|
|
2020-08-21 18:26:03 +01:00
|
|
|
this.router.events.forEach((event) => {
|
|
|
|
|
if(event instanceof NavigationEnd && event.url == this.router.url) {
|
|
|
|
|
this.RefreshEvents();
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-11-24 13:46:13 +01:00
|
|
|
/* this.storageService.get(AuthConnstants.PROFILE).then(res=>{
|
|
|
|
|
this.profile = res;
|
|
|
|
|
}); */
|
|
|
|
|
|
2020-08-21 18:26:03 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-20 10:55:51 +01:00
|
|
|
|
2020-08-21 18:26:03 +01:00
|
|
|
doRefresh(event) {
|
|
|
|
|
this.RefreshEvents();
|
2020-08-28 13:38:10 +01:00
|
|
|
event.target.complete();
|
2020-08-21 18:26:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSegmentChange(){
|
|
|
|
|
this.RefreshEvents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefreshEvents(){
|
|
|
|
|
this.showLoader = true;
|
2020-11-20 10:55:51 +01:00
|
|
|
|
2020-08-21 18:26:03 +01:00
|
|
|
switch (this.segment)
|
|
|
|
|
{
|
|
|
|
|
case "Combinada":
|
2020-11-20 10:55:51 +01:00
|
|
|
if(this.profile == "mdgpr"){
|
2021-02-08 16:55:55 +01:00
|
|
|
this.eventService.getAllMdEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
2020-11-20 13:36:35 +01:00
|
|
|
this.eventsList = res;
|
2021-01-19 08:52:43 +01:00
|
|
|
|
2021-01-13 10:02:30 +01:00
|
|
|
if(res.length > 0){
|
|
|
|
|
this.currentEvent = res[0].Subject;
|
|
|
|
|
}
|
2021-01-19 08:52:43 +01:00
|
|
|
|
2021-01-05 13:58:15 +01:00
|
|
|
this.totalEvent = this.eventsList.length;
|
2020-08-28 11:45:50 +01:00
|
|
|
this.showLoader = false;
|
2020-11-20 13:36:35 +01:00
|
|
|
});
|
2020-11-20 10:55:51 +01:00
|
|
|
}else{
|
2021-02-08 16:55:55 +01:00
|
|
|
this.eventService.getAllPrEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
2020-11-20 17:02:48 +01:00
|
|
|
this.eventsList = res;
|
2020-11-20 13:36:35 +01:00
|
|
|
console.log(this.eventsList);
|
2021-01-15 08:16:36 +01:00
|
|
|
console.log(res)
|
|
|
|
|
console.log(res[0])
|
2021-01-05 13:58:15 +01:00
|
|
|
this.currentEvent = res[0].Subject;
|
|
|
|
|
this.totalEvent = this.eventsList.length;
|
2020-11-20 10:55:51 +01:00
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 18:26:03 +01:00
|
|
|
break;
|
|
|
|
|
case "Pessoal":
|
2020-11-20 10:55:51 +01:00
|
|
|
if(this.profile == "mdgpr"){
|
2021-02-08 16:55:55 +01:00
|
|
|
this.eventService.getAllMdEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
2020-11-20 13:36:35 +01:00
|
|
|
this.personaleventsList = res.filter(data => data.CalendarName == "Pessoal");
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
2020-11-20 10:55:51 +01:00
|
|
|
}else{
|
2021-02-08 16:55:55 +01:00
|
|
|
this.eventService.getAllPrEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
2020-11-20 17:02:48 +01:00
|
|
|
this.personaleventsList = res.filter(data => data.CalendarName == "Pessoal");
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
2020-11-20 10:55:51 +01:00
|
|
|
}
|
|
|
|
|
|
2020-08-21 18:26:03 +01:00
|
|
|
break;
|
|
|
|
|
case "Oficial":
|
2020-11-20 10:55:51 +01:00
|
|
|
if(this.profile == "mdgpr"){
|
2021-02-08 16:55:55 +01:00
|
|
|
this.eventService.getAllMdEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
2020-11-20 13:36:35 +01:00
|
|
|
this.officialeventsList = res.filter(data => data.CalendarName == "Oficial");;
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
2020-11-20 10:55:51 +01:00
|
|
|
}else{
|
2021-02-08 16:55:55 +01:00
|
|
|
this.eventService.getAllPrEvents(this.today.toLocaleString(), this.todayEnd.toLocaleString()).subscribe(res => {
|
2020-11-20 17:02:48 +01:00
|
|
|
this.officialeventsList = res.filter(data => data.CalendarName == "Oficial");;
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
2020-11-20 10:55:51 +01:00
|
|
|
}
|
2020-08-21 18:26:03 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2020-08-18 23:32:12 +01:00
|
|
|
}
|
2020-08-21 16:18:37 +01:00
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
}
|
2020-08-18 23:32:12 +01:00
|
|
|
}
|
|
|
|
|
|
2020-08-21 16:18:37 +01:00
|
|
|
gotTo(){
|
|
|
|
|
this.router.navigate(['/home/events']);
|
2020-08-18 23:32:12 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-20 10:55:51 +01:00
|
|
|
changeProfile(){
|
|
|
|
|
if(this.profile == "mdgpr"){
|
|
|
|
|
console.log('pr');
|
|
|
|
|
this.profile ="pr";
|
|
|
|
|
this.RefreshEvents();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
console.log('mdgpr');
|
|
|
|
|
this.profile ="mdgpr";
|
|
|
|
|
this.RefreshEvents();
|
|
|
|
|
}
|
2020-08-28 11:37:28 +01:00
|
|
|
}
|
|
|
|
|
|
2020-08-28 15:28:38 +01:00
|
|
|
logout()
|
|
|
|
|
{
|
|
|
|
|
this.authService.ValidatedUser.BasicAuthKey = "";
|
|
|
|
|
this.router.navigate(['/home/login']);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-24 13:46:13 +01:00
|
|
|
async openEventDetail1(id:any){
|
|
|
|
|
console.log(id);
|
|
|
|
|
|
|
|
|
|
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: EventDetailModalPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
eventId: id,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'my-custom-class'
|
|
|
|
|
});
|
|
|
|
|
return await modal.present();
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-04 11:34:43 +01:00
|
|
|
|
|
|
|
|
/**
|
2021-01-05 09:24:16 +01:00
|
|
|
* @returns time in format HH:MM
|
2021-01-04 11:34:43 +01:00
|
|
|
*/
|
|
|
|
|
get hoursMinutes():String {
|
|
|
|
|
|
|
|
|
|
return this.currentHoursMinutes;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-05 09:24:16 +01:00
|
|
|
LoadList()
|
|
|
|
|
{
|
|
|
|
|
this.processes.GetTasksList("Expediente", false).subscribe(result => {
|
2021-01-19 08:52:43 +01:00
|
|
|
|
|
|
|
|
const AllResult = new Array();
|
|
|
|
|
|
2021-01-05 09:24:16 +01:00
|
|
|
result.forEach(element => {
|
|
|
|
|
let task: DailyWorkTask = {
|
|
|
|
|
"SerialNumber": element.serialNumber,
|
|
|
|
|
"Folio": element.workflowInstanceFolio,
|
|
|
|
|
"Senders": element.originator.email,
|
2021-02-08 16:55:55 +01:00
|
|
|
"CreateDate": new Date(element.taskStartDate).toLocaleString(),
|
2021-01-05 09:24:16 +01:00
|
|
|
"DocumentURL": element.formURL,
|
|
|
|
|
"Remetente": element.workflowInstanceDataFields.Remetente
|
|
|
|
|
}
|
2021-01-19 08:52:43 +01:00
|
|
|
// CreateDate
|
|
|
|
|
AllResult.push(task);
|
2021-01-05 09:24:16 +01:00
|
|
|
});
|
2021-01-19 08:52:43 +01:00
|
|
|
|
|
|
|
|
console.log(AllResult);
|
|
|
|
|
|
|
|
|
|
this.taskslist = this.sortArrayISODate(AllResult).reverse()
|
|
|
|
|
|
2021-01-05 09:24:16 +01:00
|
|
|
});
|
|
|
|
|
}
|
2021-01-19 08:52:43 +01:00
|
|
|
|
|
|
|
|
sortArrayISODate(myArray: any){
|
|
|
|
|
return myArray.sort(function(a, b) {
|
|
|
|
|
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
|
2021-01-05 09:24:16 +01:00
|
|
|
});
|
|
|
|
|
}
|
2021-01-19 16:44:39 +01:00
|
|
|
|
2021-01-31 16:14:42 +01:00
|
|
|
async viewEventDetail(eventId:any) {
|
|
|
|
|
console.log(this.profile);
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewEventPage,
|
|
|
|
|
componentProps:{
|
|
|
|
|
eventId: eventId,
|
|
|
|
|
profile: this.profile,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'modal',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
|
if(res){
|
|
|
|
|
console.log(res);
|
|
|
|
|
this.RefreshEvents();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-01 13:21:41 +01:00
|
|
|
async viewExpedientDetail(serialNumber:any) {
|
2021-02-01 09:17:38 +01:00
|
|
|
console.log(this.profile);
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
2021-02-01 13:21:41 +01:00
|
|
|
component: ExpedienteDetailPage,
|
2021-02-01 09:17:38 +01:00
|
|
|
componentProps:{
|
|
|
|
|
serialNumber: serialNumber,
|
|
|
|
|
profile: this.profile,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'modal',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
|
if(res){
|
|
|
|
|
console.log(res);
|
|
|
|
|
this.RefreshEvents();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 08:52:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-18 23:32:12 +01:00
|
|
|
}
|
|
|
|
|
|