diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html
index c97c56a84..2f90a689b 100644
--- a/src/app/pages/agenda/agenda.page.html
+++ b/src/app/pages/agenda/agenda.page.html
@@ -85,7 +85,7 @@
,
- private toastService: ToastService,
- public calendarService: CalendarService
+ private toastService: ToastService
) {
this.dateAdapter.setLocale('es');
@@ -181,10 +181,6 @@ export class AgendaPage implements OnInit {
if(this.loggeduser.Profile == 'MDGPR') {
this.mobileComponent.showEventList = true;
}
-
- setTimeout(()=>{
- this.updateEventListBox()
- }, 4000)
}
@@ -318,8 +314,22 @@ export class AgendaPage implements OnInit {
events.forEach(element => {
+ const startTimeSamp = new Date(element.startTime).toLocaleDateString()
+ const endTimeSamp = new Date(element.endTime).toLocaleDateString()
+
+ const endMinutes = new Date(element.endTime).getMinutes()
+ const endHours = new Date(element.endTime).getHours()
+ const endDay: number = new Date(element.endTime).getDate()
+ const startDay = new Date(element.startTime).getDate()
+
const profile_ = element.profile == 'md'? 'mdgpr': 'pr';
const eventtype = element.event.CalendarName;
+
+
+ // if (startTimeSamp < endTimeSamp && endDay == 29 && (endMinutes + endHours) == 0) {
+ // // console.log(id, (endMinutes + endHours))
+ // classs.push(`calendar-event-border`);
+ // }
classs.push(`calendar-event-border calendar-${profile_}-event-type-${eventtype}`);
@@ -335,6 +345,8 @@ export class AgendaPage implements OnInit {
get CalendarCurrentDay ():any {
+ /* console.log(this.viewDate.getDate(), '0_0') */
+ // console.log(this.viewDate.getDate(), '0_0')
return this.viewDate.getDate()
}
@@ -428,6 +440,7 @@ export class AgendaPage implements OnInit {
switch (this.segment) {
case "Combinado":
//Inicializa o array eventSource
+ //this.eventSource=[];
if(this.profile == "mdgpr" && this.loggeduser.Profile == '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(
@@ -435,12 +448,42 @@ export class AgendaPage implements OnInit {
(response:any) => {
// calendar
- this.calendarService.removeRange(startTime, endTime, 'md')
+ // this.eventSource=[];
+ // clear the current month only
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
+ return false
+ }
+ return true
+ })
+
+ const eventsList = response;
// loop
- this.calendarService.pushEvent(response, 'md');
+ eventsList.forEach((element, eventIndex) => {
+
+ this.eventSource.push({
+ title: element.Subject,
+ startTime: new Date(element.StartDate),
+ endTime: new Date(element.EndDate),
+ allDay: false,
+ event: element,
+ calendarName: element.CalendarName,
+ profile: 'md',
+ id: element.EventId,
+ });
+ });
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
+ const list = this.timelineFilter(this.timelineFilterState, eventsList, 'mdgpr');
+
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'md', startTime, endTime, 'date')
+
+ this.events = list;
+ // optional
+ this.TimelineMD = list;
+
+ console.log('TimelineMD', this.TimelineMD)
this.myCal.update();
this.myCal.loadEvents();
@@ -448,31 +491,60 @@ export class AgendaPage implements OnInit {
this.showLoader = false;
this.showTimeline = true;
+
}).finally(()=>{
this.showLoader = false;
})
}
else if(this.profile == "pr" && this.loggeduser.Profile == 'MDGPR') {
-
- 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) => {
-
- this.calendarService.removeRange(startTime, endTime, 'pr')
+ console.log('HERE PR');
+ 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) => {
+
// calendar
- this.calendarService.pushEvent(response, 'pr');
-
-
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
+ //this.eventSource=[];
- this.myCal.update();
- this.myCal.loadEvents();
-
- this.showLoader = false;
- this.showTimeline = true;
+ // clear the current month only
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
+ return false
+ }
+ return true
+ })
+ const eventsList = response;
+
+ // calendar
+ eventsList.forEach((element, eventIndex) => {
+ this.eventSource.push({
+ 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.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'pr', startTime, endTime, 'date')
+
+ this.myCal.update();
+ this.myCal.loadEvents();
+
+ this.showLoader = false;
+ this.showTimeline = true;
+
+
}).finally(()=>{
this.showLoader = false;
- })
+ })
+
}
else if(this.loggeduser.Profile == 'PR') {
@@ -483,13 +555,32 @@ export class AgendaPage implements OnInit {
// this.eventSource=[];
// clear the current month only
- this.calendarService.removeRange(startTime, endTime, 'pr')
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
+ return false
+ }
+ return true
+ })
- this.calendarService.pushEvent(response, 'pr');
-
-
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
-
+ const eventsList = response;
+
+ // calendar
+ eventsList.forEach((element, eventIndex) => {
+ this.eventSource.push({
+ 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.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'pr', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
@@ -497,7 +588,7 @@ export class AgendaPage implements OnInit {
this.showLoader = false;
this.showTimeline = true;
-
+
}).finally(()=>{
this.showLoader = false;
})
@@ -509,15 +600,36 @@ export class AgendaPage implements OnInit {
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')).then((response:any) => {
- this.calendarService.removeRange(startTime, endTime, 'md')
+ // this.eventSource=[];
+
+ // clear the current month only
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
+ return false
+ }
+ return true
+ })
const eventsList = response.filter(data => data.CalendarName == "Pessoal");
// loop
- this.calendarService.pushEvent(eventsList, 'md');
-
-
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
+ eventsList.forEach((element, eventIndex) => {
+
+ this.eventSource.push({
+ title: element.Subject,
+ startTime: new Date(element.StartDate),
+ endTime: new Date(element.EndDate),
+ allDay: false,
+ event: element,
+ calendarName: element.CalendarName,
+ profile: 'md',
+ id: element.EventId,
+ });
+ });
+
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'md', startTime, endTime, 'date')
+
this.myCal.update();
this.myCal.loadEvents();
@@ -533,15 +645,30 @@ export class AgendaPage implements OnInit {
//this.eventSource=[];
// clear the current month only
- this.calendarService.removeRange(startTime, endTime, 'pr')
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
+ return false
+ }
+ return true
+ })
const eventsList = response.filter(data => data.CalendarName == "Pessoal");
- this.calendarService.pushEvent(eventsList, 'pr');
+ eventsList.forEach(element => {
+ this.eventSource.push({
+ title: element.Subject,
+ startTime: new Date(element.StartDate),
+ endTime: new Date(element.EndDate),
+ allDay: false,
+ event: element,
+ profile: 'pr',
+ id: element.EventId,
+ });
+ });
+
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'pr', startTime, endTime, 'date')
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
-
-
this.myCal.update();
this.myCal.loadEvents();
@@ -563,14 +690,32 @@ export class AgendaPage implements OnInit {
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.calendarService.removeRange(startTime, endTime, 'md')
+ // this.eventSource=[];
+
+ // clear the current month only
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
+ return false
+ }
+ return true
+ })
const eventsList = res.filter(data => data.CalendarName == "Oficial");
- this.calendarService.pushEvent(eventsList, 'md');
+ eventsList.forEach(element => {
+ this.eventSource.push({
+ title: element.Subject,
+ startTime: new Date(element.StartDate),
+ endTime: new Date(element.EndDate),
+ allDay: false,
+ event: element,
+ profile: 'md',
+ id: element.EventId,
+ });
+ });
-
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'md', startTime, endTime, 'date')
this.myCal.update();
this.myCal.loadEvents();
@@ -586,14 +731,31 @@ export class AgendaPage implements OnInit {
// this.eventSource=[];
- this.calendarService.removeRange(startTime, endTime, 'pr')
+ // clear the current month only
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
+ return false
+ }
+ return true
+ })
const eventsList = res.filter(data => data.CalendarName == "Oficial");
- this.calendarService.pushEvent(eventsList, 'pr');
+ eventsList.forEach(element => {
+ this.eventSource.push({
+ title: element.Subject,
+ startTime: new Date(element.StartDate),
+ endTime: new Date(element.EndDate),
+ allDay: false,
+ event: element,
+ profile: 'pr',
+ id: element.EventId,
+ });
+ });
-
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'pr', startTime, endTime, 'date')
+
this.myCal.update();
this.myCal.loadEvents();
@@ -612,18 +774,43 @@ export class AgendaPage implements OnInit {
let counter = 0;
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 eventsList = response;
- this.calendarService.removeRange(startTime, endTime, 'md')
+ // clear the current month only
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'md') {
+ return false
+ }
+ return true
+ })
// loop
- this.calendarService.pushEvent(eventsList, 'md');
+ eventsList.forEach((element, eventIndex) => {
+
+ // calendar
+ this.eventSource.push({
+ title: element.Subject,
+ startTime: new Date(element.StartDate),
+ endTime: this.EventTretment({
+ startTime: element.StartDate,
+ endTime: element.EndDate
+ }),
+ allDay: false,
+ event: element,
+ calendarName: element.CalendarName,
+ profile: 'md',
+ id: element.EventId,
+ });
+
+ });
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', startTime, endTime, 'date')
-
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'md', startTime, endTime, 'date')
+
this.myCal.update();
this.myCal.loadEvents();
@@ -646,13 +833,31 @@ export class AgendaPage implements OnInit {
let eventsList = response;
// clear the current month only
- this.calendarService.removeRange(startTime, endTime, 'pr')
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
+ return false
+ }
+ return true
+ })
- this.calendarService.pushEvent(eventsList, 'pr');
+ eventsList.forEach((element, eventIndex) => {
+ // calendar
+ this.eventSource.push({
+ 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.TimelinePRList = this.eventListBoxComponent.list(this.eventSource, 'pr', startTime, endTime, 'date')
- this.TimelinePRList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
-
this.myCal.update();
this.myCal.loadEvents();
@@ -671,6 +876,7 @@ export class AgendaPage implements OnInit {
}
})
+
} 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((response:any) => {
@@ -685,13 +891,36 @@ export class AgendaPage implements OnInit {
}
// clear the current month only
- this.calendarService.removeRange(startTime, endTime, 'pr')
+ this.eventSource = this.eventSource.filter((e)=> {
+ if(new Date(startTime).getTime() <= new Date(e.startTime).getTime() &&
+ new Date(endTime).getTime() >= new Date(e.endTime).getTime() && e.profile == 'pr') {
+ console.log('remove from agenda')
+ return false
+ }
+ return true
+ })
- this.calendarService.pushEvent(eventsList, 'pr');
+ eventsList.forEach((element, eventIndex) => {
- this.TimelinePRList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', startTime, endTime, 'date')
+ // calendar
+ this.eventSource.push({
+ 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, eventsList, 'pr');
+ this.TimelinePRList = this.eventListBoxComponent.list(this.eventSource, 'pr', startTime, endTime, 'date')
+
this.myCal.update();
this.myCal.loadEvents();
@@ -715,8 +944,8 @@ export class AgendaPage implements OnInit {
}
updateEventListBox() {
- this.TimelinePRList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
+ this.TimelinePRList = this.eventListBoxComponent.list(this.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
}
eventListBox(list, nice?) {
@@ -746,12 +975,17 @@ export class AgendaPage implements OnInit {
if (new Date(startDate).toLocaleDateString() != new Date(endDate).toLocaleDateString()) {
+ console.log(new Date(startDate).toLocaleDateString(),'!=' , new Date(endDate).toLocaleDateString())
+ console.log(startDate.toISOString(),'iso' , endDate.toISOString() )
+ console.log(new Date(startDate).toLocaleTimeString('pt'),'time' , new Date(endDate).toLocaleTimeString('pt'))
+
// difference
const diffTime = Math.abs(endDate - startDate);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays <= 150 && !event.event.IsAllDayEvent ) {
+ console.log(event)
if (diffDays >= 1) {
@@ -914,13 +1148,13 @@ export class AgendaPage implements OnInit {
if(this.profile == "mdgpr") {
this.profile ="pr";
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
}
else {
this.profile ="mdgpr";
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
- this.TimelineMDList = this.eventListBoxComponent.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
+ this.TimelineMDList = this.eventListBoxComponent.list(this.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
}
}
@@ -983,7 +1217,7 @@ export class AgendaPage implements OnInit {
// open component
async viewEventDetail(eventId:any) {
-
+ console.log('View event '+eventId)
this.router.navigate(['/home/agenda', eventId, 'agenda']);
/* console.log(this.profile);
@@ -1225,7 +1459,7 @@ export class AgendaPage implements OnInit {
}
async showEventBox(event) {
-
+
if ( event.event.CalendarName == this.segment || this.segment == 'Combinado') {
return true
}
diff --git a/src/app/store/calendar.service.spec.ts b/src/app/store/calendar.service.spec.ts
deleted file mode 100644
index 18ba1f660..000000000
--- a/src/app/store/calendar.service.spec.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-
-import { CalendarService } from './calendar.service';
-
-describe('CalendarService', () => {
- let service: CalendarService;
-
- beforeEach(() => {
- TestBed.configureTestingModule({});
- service = TestBed.inject(CalendarService);
- });
-
- it('should be created', () => {
- expect(service).toBeTruthy();
- });
-});
diff --git a/src/app/store/calendar.service.ts b/src/app/store/calendar.service.ts
deleted file mode 100644
index cbeff654f..000000000
--- a/src/app/store/calendar.service.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import { Injectable } from '@angular/core';
-import { eventSource } from '../models/agenda/eventSource';
-import { SHA1, SHA256, AES, enc } from 'crypto-js'
-import { LocalstoreService } from './localstore.service'
-
-@Injectable({
- providedIn: 'root'
-})
-
-export class CalendarService {
-
- private _eventSource : eventSource[] = []
-
- constructor(localstoreService: LocalstoreService) {
-
- const keyName = (SHA1(this.constructor.name+ 'eventSource')).toString()
-
- let restore = localstoreService.get(keyName, [])
-
- setTimeout(()=>{
- restore.forEach((element, eventIndex) => {
- this._eventSource.push({
- title: element.title,
- startTime: new Date(element.startTime),
- endTime: new Date(element.endTime),
- allDay: element.allDay,
- event: element.event,
- calendarName: element.calendarName,
- profile: element.profile,
- id: element.id,
- });
-
- });
- },1)
-
- setTimeout(() => {
- setInterval(()=> {
-
- localstoreService.set(keyName, this._eventSource)
-
- }, 5000)
- }, 10000)
-
- }
-
- ResetList(eventSource: eventSource[]) {
- this._eventSource = eventSource
- }
-
- get eventSource() {
- return this._eventSource
- }
-
- removeRange(rangeStartDate, rangeEndDate, profile) {
- this._eventSource = this._eventSource.filter((e)=> {
- if(new Date(rangeStartDate).getTime() <= new Date(e.startTime).getTime() &&
- new Date(rangeEndDate).getTime() >= new Date(e.endTime).getTime() && e.profile == profile) {
- return false
- }
- return true
- })
- }
-
- pushEvent(eventsList, profile: 'pr' | 'md') {
-
- let news = []
- eventsList.forEach((element, eventIndex) => {
- news.push({
- title: element.Subject,
- startTime: new Date(element.StartDate),
- endTime: new Date(element.EndDate),
- allDay: false,
- event: element,
- calendarName: element.CalendarName,
- profile: profile,
- id: element.EventId,
- });
-
- });
-
- let instance = this._eventSource.concat(news)
-
- const ids = instance.map(o => o.id)
- const filtered = instance.filter(({id}, index) => !ids.includes(id, index + 1))
-
- this._eventSource = (filtered)
-
- }
-
-}
\ No newline at end of file