Fix event all day

This commit is contained in:
Peter Maquiran
2021-09-02 16:06:53 +01:00
parent dbe6a022f2
commit 1665b2e057
11 changed files with 49 additions and 331 deletions
-16
View File
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { HomeGuard } from './home.guard';
describe('HomeGuard', () => {
let guard: HomeGuard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(HomeGuard);
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});
-32
View File
@@ -1,32 +0,0 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { StorageService } from '../services/storage.service';
@Injectable({
providedIn: 'root'
})
export class HomeGuard implements CanActivate {
constructor(
public storageService:StorageService,
private router:Router
){}
canActivate(): Promise<boolean>{
return new Promise(resolve => {
/* this.storageService.get(AuthConnstants.AUTH).then(res => {
if(res){
resolve(true);
}
else{
this.router.navigate(['']);
resolve(false);
}
}).catch(err =>{
resolve(false);
}) */
});
}
}
-16
View File
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { IndexGuard } from './index.guard';
describe('IndexGuard', () => {
let guard: IndexGuard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(IndexGuard);
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});
-31
View File
@@ -1,31 +0,0 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { StorageService } from '../services/storage.service';
@Injectable({
providedIn: 'root'
})
export class IndexGuard implements CanActivate {
constructor(
public storageService:StorageService,
private router:Router
){}
canActivate(): Promise<boolean> {
return new Promise(resolve => {
/* this.storageService.get(AuthConnstants.AUTH).then(res => {
if(res){
this.router.navigate(['home']);
resolve(false);
}
else{
resolve(true);
}
}).catch(err =>{
resolve(false);
}) */
});
}
}
+2
View File
@@ -15,6 +15,8 @@ export class LoginGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
// console.log(SessionStore.exist, SessionStore.user.Inactivity, SessionStore.user.LoginPreference)
if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) {
this.router.navigate(['/home/events']);
return false
-1
View File
@@ -1,6 +1,5 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { IndexGuard } from '../guards/index.guard';
import { LoginGuard } from '../guards/login.guard';
import { IndexPage } from './index.page';
+11 -8
View File
@@ -1,11 +1,10 @@
export interface EventListStore {
title: string
startTime: Date
endTime: Date
allDay: boolean,
event: EventList,
calendarName: string
calendarName: "Oficial" |"Pessoal"
profile: "md" | "pr",
id: string
}
@@ -27,12 +26,16 @@ export interface EventList {
export interface CustomCalendarEvent {
start: Date
end: Date
color: {
primary: string,
secondary: string
},
id: string
index: number,
CalendarName: string
event: EventList
}
export interface days {
[days: string]: {
day: number
activeEvent: number
events: CustomCalendarEvent[]
}
}
+6 -8
View File
@@ -223,14 +223,13 @@
<div class="fs-timeline flex-grow-1 d-none d-md-block d-md-block text-black pr-20 width-100 height-100 overflow-y-auto" *ngIf="loggeduser.Profile == 'MDGPR'">
<div *ngFor="let events of TimelineMDList | keyvalue;" >
<div class="EventListBox-container" *ngIf="CalendarCurrentDay <= events.key">
<div class="day EventListBox-day mt-10" *ngIf="shoeEventDay(events.value)">
<div class="EventListBox-container" >
<div class="day EventListBox-day mt-10" >
{{ TimelineDayEvent(events.key)}}
</div>
<div *ngFor="let event of events.value" class="EventListBox" >
<div class="d-flex content-mdgpr-{{event.event.CalendarName}} mt-10 cursor-pointer" (click)="eventClicked(event)"
*ngIf="viewEventMonth <= dateMonth(event) && showEventBox(event)">
<div class="d-flex content-mdgpr-{{event.event.CalendarName}} mt-10 cursor-pointer" (click)="eventClicked(event)">
<div class="schedule-time" *ngIf="!event.event.IsAllDayEvent">
<div *ngIf="!event.endMany && !event.middle" class="time-start">{{event.event.StartDate | date: 'HH:mm'}}</div>
@@ -263,16 +262,15 @@
<div class="sd-timeline flex-grow-1 d-none d-md-block timeline-md text-black pl-20 pr-20 width-100 height-100 overflow-y-auto" >
<div *ngFor="let events of TimelinePRList | keyvalue;">
<div class="EventListBox-container" *ngIf="CalendarCurrentDay <= events.key">
<div class="EventListBox-container" >
<div class="day mt-10" *ngIf="shoeEventDay(events.value)">
<div class="day mt-10" >
{{ TimelineDayEvent(events.key)}}
</div>
<div *ngFor="let event of events.value" class="EventListBox" >
<div class="d-flex content-pr-{{event.event.CalendarName}} mt-10 cursor-pointer" (click)="eventClicked(event)"
*ngIf="viewEventMonth <= dateMonth(event) && showEventBox(event) ">
<div class="d-flex content-pr-{{event.event.CalendarName}} mt-10 cursor-pointer" (click)="eventClicked(event)">
<div class="schedule-time" *ngIf="!event.event.IsAllDayEvent">
<div *ngIf="!event.endMany && !event.middle" class="time-start">{{event.event.StartDate | date: 'HH:mm'}}</div>
+16 -194
View File
@@ -290,6 +290,7 @@ export class AgendaPage implements OnInit {
// calendar change date
this.eventSelectedDate = new Date(ev);
this.updateEventListBox()
};
// changedate
@@ -461,7 +462,7 @@ export class AgendaPage implements OnInit {
// loop
this.calendarService.pushEvent(response, 'md');
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
this.myCal.loadEvents();
@@ -482,7 +483,7 @@ export class AgendaPage implements OnInit {
// calendar
this.calendarService.pushEvent(response, 'pr');
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
this.myCal.loadEvents();
@@ -508,7 +509,7 @@ export class AgendaPage implements OnInit {
this.calendarService.pushEvent(response, 'pr');
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
@@ -536,7 +537,7 @@ export class AgendaPage implements OnInit {
this.calendarService.pushEvent(eventsList, 'md');
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
this.myCal.loadEvents();
@@ -556,7 +557,7 @@ export class AgendaPage implements OnInit {
const eventsList = response.filter(data => data.CalendarName == "Pessoal");
this.calendarService.pushEvent(eventsList, 'pr');
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
this.myCal.loadEvents();
@@ -607,7 +608,7 @@ export class AgendaPage implements OnInit {
this.calendarService.pushEvent(eventsList, 'pr');
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
this.myCal.loadEvents();
@@ -638,7 +639,7 @@ export class AgendaPage implements OnInit {
// loop
this.calendarService.pushEvent(eventsList, 'md');
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
this.myCal.loadEvents();
@@ -667,7 +668,7 @@ export class AgendaPage implements OnInit {
this.calendarService.pushEvent(eventsList, 'pr');
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
this.myCal.loadEvents();
@@ -705,7 +706,7 @@ export class AgendaPage implements OnInit {
this.calendarService.pushEvent(eventsList, 'pr');
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.myCal.update();
@@ -732,174 +733,11 @@ export class AgendaPage implements OnInit {
updateEventListBox() {
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
}
eventListBox(list, nice?) {
let days = {};
list.forEach( (event:any)=> {
var startDate: any = new Date(event.start);
var endDate: any = this.EventTretment({
startTime: startDate,
endTime: event.end
})
const day = (((new Date (event.start)).getDate())).toString().padStart(2,'0')
event.manyDays = false
event.todayOnly = new Date(event.start).toLocaleDateString() == new Date(event.end).toLocaleDateString()
if(!days.hasOwnProperty(day)) {
days[day] = []
}
if (new Date(startDate).toLocaleDateString() != new Date(endDate).toLocaleDateString()) {
// difference
const diffTime = Math.abs(endDate - startDate);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays <= 150 && !event.event.IsAllDayEvent ) {
if (diffDays >= 1) {
const StartEvent = Object.assign({}, {
title: event.title,
start: event.start,
end: event.end,
color: event.color,
id: event.id,
index: event.index,
profile: event.profile,
CalendarName: event.CalendarName,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
EndDate: event.event.EndDate,
Location: event.event.Location,
EventId: event.event.EventId,
CalendarName: event.event.CalendarName
},
startMany: true,
endMany: false,
middle: false
})
days[day].push(StartEvent)
let i = 1;
while (startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate()) {
const newDate = startDate.setDate(startDate.getDate()+ i)
let otherDays = (((new Date (newDate)).getDate())).toString().padStart(2,'0')
event.other = true
event.start = newDate
if(!days.hasOwnProperty(otherDays)) {
days[otherDays] = []
}
if (!(startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate())) {
// last push
const EndEvent = Object.assign({}, {
title: event.title,
start: event.start,
end: event.end,
color: event.color,
id: event.id,
index: event.index,
profile: event.profile,
CalendarName: event.CalendarName,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
EndDate: event.event.EndDate,
Location: event.event.Location,
EventId: event.event.EventId,
CalendarName: event.event.CalendarName
},
Subject: event.Subject,
startMany: false,
endMany: true,
middle: false
})
days[otherDays].push(EndEvent)
} else {
const EndEvent = Object.assign({}, {
title: event.title,
start: event.start,
end: event.end,
color: event.color,
id: event.id,
index: event.index,
profile: event.profile,
CalendarName: event.CalendarName,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
EndDate: event.event.EndDate,
Location: event.event.Location,
EventId: event.event.EventId,
CalendarName: event.event.CalendarName
},
Subject: event.Subject,
startMany: false,
endMany: true,
middle: true
})
days[otherDays].push(EndEvent)
}
}
} else {
days[day].push(event)
}
} else {
days[day].push(event)
}
}
days[day].push(event)
})
setTimeout(()=>{
document.querySelectorAll('.EventListBox-container .EventListBox').forEach((e)=>{
if(e.childElementCount == 0) {
e.parentElement.style.display = 'none'
} else {
e.parentElement.style.display = 'block'
}
})
}, 10)
return days
}
get viewEventMonth () {
return this.viewDate.getMonth()
@@ -932,13 +770,13 @@ export class AgendaPage implements OnInit {
if(this.profile == "mdgpr") {
this.profile ="pr";
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
}
else {
this.profile ="mdgpr";
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {segment:this.segment, selectedDate: this.eventSelectedDate})
}
}
@@ -1224,26 +1062,10 @@ export class AgendaPage implements OnInit {
}
this.showTimelineFilterState = false;
setTimeout(()=>{
document.querySelectorAll('.EventListBox-container .EventListBox').forEach((e)=>{
if(e.childElementCount == 0) {
e.parentElement.style.display = 'none'
} else {
e.parentElement.style.display = 'block'
}
})
}, 10)
// THIS LINE
this.updateEventListBox()
setTimeout(()=>{
document.querySelectorAll('.EventListBox-container .EventListBox').forEach((e)=>{
if(e.childElementCount == 0) {
e.parentElement.style.display = 'none'
} else {
e.parentElement.style.display = 'block'
}
})
}, 100)
}
+14 -23
View File
@@ -26,10 +26,23 @@ export class ListBoxService {
})
}
filterSegment(eventSource: EventListStore[], segment): EventListStore[] {
return eventSource.filter( data => data.calendarName == segment)
}
daysBetween(){ }
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'todo'}) {
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'Combinado', selectedDate= null}) {
if(selectedDate) {
eventSource = eventSource.filter(data => data.startTime.toLocaleDateString('pt')>= selectedDate.toLocaleDateString('pt'))
}
if(segment!='Combinado') {
eventSource = this.filterSegment(eventSource, segment)
}
if(profile != 'all') {
eventSource = this.filterProfile(eventSource, profile)
}
@@ -49,7 +62,6 @@ export class ListBoxService {
display(list: CustomCalendarEvent[]) {
let days = {};
console.log(list)
list.forEach( (event:CustomCalendarEvent, index)=> {
@@ -127,15 +139,6 @@ export class ListBoxService {
})
setTimeout(()=>{
document.querySelectorAll('.EventListBox-container .EventListBox').forEach((e)=>{
if(e.childElementCount == 0) {
e.parentElement.style.display = 'none'
} else {
e.parentElement.style.display = 'block'
}
})
}, 10)
return days
}
@@ -149,18 +152,10 @@ export class ListBoxService {
events.push({
start: new Date(element.startTime),
end: new Date(element.endTime),
color: {
primary: '#0000',
secondary: '#0000'
},
id: element.id,
index: eventIndex,
CalendarName: element.calendarName,
event: element.event,
});
console.log('element.event', element.event)
});
return events;
@@ -169,14 +164,10 @@ export class ListBoxService {
transForm(event: CustomCalendarEvent, {startMany, endMany, middle}) {
return Object.assign({}, {
title: event.event.Subject,
start: event.start,
end: event.end,
color: event.color,
id: event.id,
index: event.index,
profile: event,
CalendarName: event.CalendarName,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
-2
View File
@@ -22,7 +22,6 @@ export class CalendarService {
setTimeout(()=>{
restore.forEach((element:EventListStore, eventIndex) => {
this._eventSource.push({
title: element.title,
startTime: new Date(element.startTime),
endTime: new Date(element.endTime),
allDay: element.allDay,
@@ -67,7 +66,6 @@ export class CalendarService {
let news = []
eventsList.forEach((element, eventIndex) => {
news.push({
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,