This commit is contained in:
tiago.kayaya
2021-06-16 16:55:47 +01:00
parent 16c8e27d34
commit a1911b4cfb
4 changed files with 136 additions and 47 deletions
+95 -40
View File
@@ -266,8 +266,8 @@ export class AgendaPage implements OnInit {
// calendar change date // calendar change date
this.eventSelectedDate = new Date(ev); this.eventSelectedDate = new Date(ev);
this.centralizeTimeline(500); /* this.centralizeTimeline(500);
this.timelineBoxCorrectHeight(500); this.timelineBoxCorrectHeight(500); */
}; };
// changedate // changedate
@@ -286,7 +286,7 @@ export class AgendaPage implements OnInit {
this.rangeStartDate = ev.startTime; this.rangeStartDate = ev.startTime;
this.rangeEndDate = ev.endTime; this.rangeEndDate = ev.endTime;
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate); //this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
} }
// for calendar // for calendar
@@ -515,7 +515,7 @@ export class AgendaPage implements OnInit {
return ((new Date(this.timelineDate)).getDate()).toString().padStart(2,'0') return ((new Date(this.timelineDate)).getDate()).toString().padStart(2,'0')
} }
async loadRangeEvents(startTime: Date, endTime: Date){ loadRangeEvents(startTime: Date, endTime: Date){
this.eventSelectedDate = new Date(startTime); this.eventSelectedDate = new Date(startTime);
@@ -530,15 +530,16 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource //Inicializa o array eventSource
//this.eventSource=[]; //this.eventSource=[];
if(this.loggeduser.Profile == 'MDGPR' ) {
let mdOficialEvents = await this.eventService.getAllMdOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR' ) {
let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); this.eventService.getAllMdEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).then(
(response:any) => {
// calendar // calendar
this.eventSource=[]; this.eventSource=[];
this.eventsList = mdOficialEvents.concat(mdPessoalEvents); this.eventsList = response;
// loop // loop
this.eventsList.forEach((element, eventIndex) => { this.eventsList.forEach((element, eventIndex) => {
@@ -573,17 +574,17 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(500); this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500); this.centralizeTimeline(500);
});
} }
else { else {
let prOficialEvents= await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); this.eventService.getAllPrEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then(
let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); (response:any) => {
// calendar // calendar
this.eventSource=[]; this.eventSource=[];
this.eventsList = prOficialEvents.concat(prPessoalEvents); this.eventsList = response;
// calendar // calendar
this.eventsList.forEach((element, eventIndex) => { this.eventsList.forEach((element, eventIndex) => {
@@ -617,6 +618,8 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(500); this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500); this.centralizeTimeline(500);
});
} }
break; break;
@@ -624,7 +627,7 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource //Inicializa o array eventSource
if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR') { if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR') {
this.eventService.getAllMdPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).subscribe(response => { this.eventService.getAllMdEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
this.eventSource=[]; this.eventSource=[];
this.eventsListPessoal= []; this.eventsListPessoal= [];
@@ -665,11 +668,10 @@ export class AgendaPage implements OnInit {
} }
else{ else{
let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise(); this.eventService.getAllPrEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
this.eventSource=[]; this.eventSource=[];
this.eventsListPessoal = prPessoalEvents.filter(data => data.CalendarName == "Pessoal"); this.eventsListPessoal = response.filter(data => data.CalendarName == "Pessoal");
this.eventsListPessoal.forEach(element => { this.eventsListPessoal.forEach(element => {
this.eventSource.push({ this.eventSource.push({
title: element.Subject, title: element.Subject,
@@ -699,7 +701,7 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(500); this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500); this.centralizeTimeline(500);
});
} }
break; break;
@@ -708,8 +710,8 @@ export class AgendaPage implements OnInit {
//Inicializa o array eventSource //Inicializa o array eventSource
this.eventsListOficial = []; this.eventsListOficial = [];
if(this.loggeduser.Profile == 'MDGPR') { if(this.profile == "mdgpr" && this.loggeduser.Profile == 'MDGPR') {
this.eventService.getAllMdOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).subscribe(res => { this.eventService.getAllMdEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((res:any) => {
this.eventSource=[]; this.eventSource=[];
this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial"); this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial");
@@ -742,11 +744,10 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(500); this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500); this.centralizeTimeline(500);
}); });
} } else {
else { this.eventService.getAllPrEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((res:any) => {
let prOficialEvents= await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
this.eventSource=[]; this.eventSource=[];
this.eventsListOficial = prOficialEvents.filter(data => data.CalendarName == "Oficial"); this.eventsListOficial = res.filter(data => data.CalendarName == "Oficial");
this.eventsListOficial.forEach(element => { this.eventsListOficial.forEach(element => {
this.eventSource.push({ this.eventSource.push({
title: element.Subject, title: element.Subject,
@@ -776,12 +777,12 @@ export class AgendaPage implements OnInit {
this.timelineBoxCorrectHeight(500); this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500); this.centralizeTimeline(500);
});
} }
break; break;
} }
} } else {
else {
//this.showTimelinePR = false; //this.showTimelinePR = false;
//this.showTimelineMD = false; //this.showTimelineMD = false;
@@ -790,16 +791,17 @@ export class AgendaPage implements OnInit {
let counter = 0; let counter = 0;
if(this.loggeduser.Profile == 'MDGPR') { if(this.loggeduser.Profile == 'MDGPR') {
console.log('MDGPR');
this.eventService.getAllMdEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).then( (response:any) => {
let mdOficialEvents = await this.eventService.getAllMdOficialEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).toPromise();
let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).toPromise();
if(this.segment == 'Oficial') { if(this.segment == 'Oficial') {
this.eventsList = mdOficialEvents; this.eventsList = response.filter(data => data.CalendarName == "Oficial");
} else if (this.segment == 'Pessoal') { } else if (this.segment == 'Pessoal') {
this.eventsList = mdPessoalEvents; this.eventsList = response.filter(data => data.CalendarName == "Pessoal");
} else { } else {
this.eventsList = mdOficialEvents.concat(mdPessoalEvents); this.eventsList = response;
} }
this.eventSource= this.eventSource.filter(e => e.profile != 'md'); this.eventSource= this.eventSource.filter(e => e.profile != 'md');
@@ -842,21 +844,16 @@ export class AgendaPage implements OnInit {
this.centralizeTimeline(500); this.centralizeTimeline(500);
} }
});
} this.eventService.getAllSharedEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
else{
let prOficialEvents= await this.eventService.getAllPrOficialEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).toPromise();
if(this.segment == 'Oficial') { if(this.segment == 'Oficial') {
this.eventsList = prOficialEvents; this.eventsList = response.filter(data => data.CalendarName == "Oficial");
} else if (this.segment == 'Pessoal') { } else if (this.segment == 'Pessoal') {
this.eventsList = prPessoalEvents; this.eventsList = response.filter(data => data.CalendarName == "Pessoal");
} else { } else {
this.eventsList = prOficialEvents.concat(prPessoalEvents); this.eventsList = response;
} }
this.eventSource = this.eventSource.filter(e => e.profile != 'pr'); this.eventSource = this.eventSource.filter(e => e.profile != 'pr');
@@ -896,6 +893,64 @@ export class AgendaPage implements OnInit {
this.centralizeTimeline(500); this.centralizeTimeline(500);
} }
});
}else{
console.log('PR');
this.eventService.getAllPrEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
if(this.segment == 'Oficial') {
this.eventsList = response.filter(data => data.CalendarName == "Oficial");
} else if (this.segment == 'Pessoal') {
this.eventsList = response.filter(data => data.CalendarName == "Pessoal");
} else {
this.eventsList = response;
}
this.eventSource = this.eventSource.filter(e => e.profile != 'pr');
this.eventsList.forEach((element, eventIndex) => {
// calendar
this.eventSource.push({
index: eventIndex,
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile:'pr',
id: element.EventId,
});
});
this.TimelinePR = this.timelineFilter(this.timelineFilterState, this.eventsList, 'pr');
this.TimelinePRList = this.eventListBox(this.TimelinePR)
this.myCal.update();
this.myCal.loadEvents();
this.showTimelinePR = true;
counter++;
if(counter==2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
this.timelineBoxCorrectHeight(500);
this.centralizeTimeline(500);
}
});
} }
} }
-1
View File
@@ -146,7 +146,6 @@ export class EventsPage implements OnInit {
let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(start, end).toPromise(); let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
this.eventsList = prOficialEvents.concat(prPessoalEvents); this.eventsList = prOficialEvents.concat(prPessoalEvents);
console.log(this.eventsList); console.log(this.eventsList);
console.log(this.eventsList);
if(this.eventsList.length > 0){ if(this.eventsList.length > 0){
this.currentEvent = this.eventsList[0].Subject; this.currentEvent = this.eventsList[0].Subject;
+35 -4
View File
@@ -149,7 +149,17 @@ export class EventsService {
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
} }
getAllMdOficialEvents(startdate:string, enddate:string): Observable<Event[]>{ async getAllPrEvents(startdate:string, enddate:string){
let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
console.log(resFinal);
return new Promise(resolve =>{
return resolve(resFinal)
})
}
getAllMdOficialEvents(startdate:string, enddate:string): any{
const geturl = environment.apiURL + 'calendar/md'; const geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams(); let params = new HttpParams();
@@ -160,10 +170,10 @@ export class EventsService {
headers: this.headersMdOficial, headers: this.headersMdOficial,
params: params params: params
}; };
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<any>(`${geturl}`, options);
} }
getAllMdPessoalEvents(startdate:string, enddate:string): Observable<Event[]>{ getAllMdPessoalEvents(startdate:string, enddate:string): any{
const geturl = environment.apiURL + 'calendar/md'; const geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams(); let params = new HttpParams();
@@ -174,7 +184,17 @@ export class EventsService {
headers: this.headersMdPessoal, headers: this.headersMdPessoal,
params: params params: params
}; };
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<any>(`${geturl}`, options);
}
async getAllMdEvents(startdate:string, enddate:string){
let prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
console.log(resFinal);
return new Promise(resolve =>{
return resolve(resFinal)
});
} }
@@ -207,6 +227,17 @@ export class EventsService {
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
} }
async getAllSharedEvents(startdate:string, enddate:string){
let prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllSharedPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
console.log(resFinal);
return new Promise(resolve =>{
return resolve(resFinal)
});
}
@@ -181,6 +181,8 @@ export class NewEventPage implements OnInit {
} }
if(this.loggeduser.Profile == 'MDGPR') { if(this.loggeduser.Profile == 'MDGPR') {
console.log('MD - Aqui');
console.log(this.postEvent);
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe( this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
async (id) => { async (id) => {
@@ -223,6 +225,8 @@ export class NewEventPage implements OnInit {
}); });
} }
else if(this.loggeduser.Profile == 'PR') { else if(this.loggeduser.Profile == 'PR') {
console.log('PR - Aqui');
console.log(this.postEvent);
this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe( this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe(
(id) => { (id) => {
console.log(id); console.log(id);