This commit is contained in:
Eudes Inácio
2021-06-29 11:45:11 +01:00
9 changed files with 145 additions and 99 deletions
+86 -51
View File
@@ -303,13 +303,27 @@ export class AgendaPage implements OnInit {
events.forEach(element => { 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 profile_ = element.profile == 'md'? 'mdgpr': 'pr';
const eventtype = element.event.CalendarName; 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}`); classs.push(`calendar-event-border calendar-${profile_}-event-type-${eventtype}`);
}); });
return classs.join(' '); return classs.join(' ');
} }
@@ -422,6 +436,25 @@ 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')
} }
EventTretment ({startTime, endTime}) {
const startTimeSamp = new Date(startTime).toLocaleDateString()
const endTimeSamp = new Date(endTime).toLocaleDateString()
const endMinutes = new Date(endTime).getMinutes()
const endHours = new Date(endTime).getHours()
if (startTimeSamp < endTimeSamp && (endMinutes + endHours) == 0) {
endTime = new Date(endTime);
endTime.setSeconds(endTime.getSeconds() - 1);
return new Date(endTime)
} else {
return new Date(endTime)
}
}
loadRangeEvents(startTime: Date, endTime: Date){ loadRangeEvents(startTime: Date, endTime: Date){
this.eventSelectedDate = new Date(startTime); this.eventSelectedDate = new Date(startTime);
@@ -753,7 +786,10 @@ export class AgendaPage implements OnInit {
index: eventIndex, index: eventIndex,
title: element.Subject, title: element.Subject,
startTime: new Date(element.StartDate), startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate), endTime: this.EventTretment({
startTime: element.StartDate,
endTime: element.EndDate
}),
allDay: false, allDay: false,
event: element, event: element,
calendarName: element.CalendarName, calendarName: element.CalendarName,
@@ -762,11 +798,11 @@ export class AgendaPage implements OnInit {
}); });
}); });
const MDEventList = this.timelineFilter(this.timelineFilterState, this.eventsList, 'mdgpr');
this.TimelineMDList = this.eventListBox(MDEventList, 'md')
const MDEventList = this.timelineFilter(this.timelineFilterState, this.eventsList, 'mdgpr');
this.TimelineMDList = this.eventListBox(MDEventList, 'md')
this.events = MDEventList; this.events = MDEventList;
this.TimelineMD = MDEventList; this.TimelineMD = MDEventList;
@@ -776,13 +812,13 @@ export class AgendaPage implements OnInit {
this.showTimelineMD = true; this.showTimelineMD = true;
counter++; counter++;
if(counter==2){ if(counter==2) {
this.showLoader = false; this.showLoader = false;
} }
}); });
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.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) => {
if(this.segment == 'Oficial') { if(this.segment == 'Oficial') {
this.eventsList = response.filter(data => data.CalendarName == "Oficial"); this.eventsList = response.filter(data => data.CalendarName == "Oficial");
@@ -827,59 +863,56 @@ export class AgendaPage implements OnInit {
this.showLoader = false; this.showLoader = false;
} }
}); });
} else {
}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) => { 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') { if(this.segment == 'Oficial') {
this.eventsList = response.filter(data => data.CalendarName == "Oficial"); this.eventsList = response.filter(data => data.CalendarName == "Oficial");
} else if (this.segment == 'Pessoal') { } else if (this.segment == 'Pessoal') {
this.eventsList = response.filter(data => data.CalendarName == "Pessoal"); this.eventsList = response.filter(data => data.CalendarName == "Pessoal");
} else { } else {
this.eventsList = response; this.eventsList = response;
} }
this.eventSource = this.eventSource.filter(e => e.profile != 'pr'); this.eventSource = this.eventSource.filter(e => e.profile != 'pr');
this.eventsList.forEach((element, eventIndex) => { 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,
});
// 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.TimelinePR = this.timelineFilter(this.timelineFilterState, this.eventsList, 'pr');
this.myCal.update(); this.TimelinePRList = this.eventListBox(this.TimelinePR)
this.myCal.loadEvents();
this.showTimelinePR = true; this.myCal.update();
this.myCal.loadEvents();
counter++;
if(counter==2 || this.loggeduser.Profile == 'PR') { this.showTimelinePR = true;
this.showLoader = false;
} counter++;
if(counter==2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
}); });
@@ -894,13 +927,16 @@ export class AgendaPage implements OnInit {
list.forEach( (event:any)=> { list.forEach( (event:any)=> {
var startDate: any = new Date(event.start); var startDate: any = new Date(event.start);
var endDate: any = new Date(event.end);
var endDate: any = this.EventTretment({
startTime: startDate,
endTime: event.end
})
const day = (((new Date (event.start)).getDate())).toString().padStart(2,'0') const day = (((new Date (event.start)).getDate())).toString().padStart(2,'0')
event.manyDays = false event.manyDays = false
if(!days.hasOwnProperty(day)) { if(!days.hasOwnProperty(day)) {
days[day] = [] days[day] = []
} }
@@ -952,7 +988,6 @@ export class AgendaPage implements OnInit {
event.start = newDate event.start = newDate
if(!days.hasOwnProperty(otherDays)) { if(!days.hasOwnProperty(otherDays)) {
days[otherDays] = [] days[otherDays] = []
} }
@@ -36,7 +36,7 @@
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon> <ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div> </div>
<div class="ion-input-class"> <div class="ion-input-class">
<ion-select disabled placeholder="Selecione agenda*" <ion-select placeholder="Selecione agenda*"
selectedText="{{postEvent.CalendarName}}" selectedText="{{postEvent.CalendarName}}"
[(ngModel)]="postEvent.CalendarName" [(ngModel)]="postEvent.CalendarName"
interface="action-sheet" Cancel-text="Cancelar" interface="action-sheet" Cancel-text="Cancelar"
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AlertController, AnimationController, ModalController, NavParams } from '@ionic/angular'; import { AlertController, AnimationController, ModalController, NavParams } from '@ionic/angular';
import { Attachment } from 'src/app/models/attachment.model'; import { Attachment } from 'src/app/models/attachment.model';
import { EventBody } from 'src/app/models/eventbody.model'; import { EventBody } from 'src/app/models/eventbody.model';
@@ -28,6 +29,8 @@ export class EditEventPage implements OnInit {
selectedSegment: string; selectedSegment: string;
selectedDate: Date; selectedDate: Date;
minDate: string; minDate: string;
initCalendarName: string;
caller:string;
loadedEventAttachments: Attachment[]; loadedEventAttachments: Attachment[];
@@ -46,9 +49,12 @@ export class EditEventPage implements OnInit {
private attachmentsService: AttachmentsService, private attachmentsService: AttachmentsService,
private animationController: AnimationController, private animationController: AnimationController,
private toastService: ToastService, private toastService: ToastService,
private router: Router,
) { ) {
this.isEventEdited = false; this.isEventEdited = false;
this.postEvent = this.navParams.get('event'); this.postEvent = this.navParams.get('event');
this.caller = this.navParams.get('caller');
this.initCalendarName = this.postEvent.CalendarName;
if(this.postEvent){ if(this.postEvent){
if( this.postEvent.Body){ if( this.postEvent.Body){
@@ -78,13 +84,13 @@ export class EditEventPage implements OnInit {
else { else {
this.isRecurring = "Repete"; this.isRecurring = "Repete";
} }
this.profile = this.navParams.get('profile');
this.getAttachments(this.postEvent.EventId); this.getAttachments(this.postEvent.EventId);
} }
ngOnInit() { ngOnInit() {
console.log(this.caller);
window.onresize = (event) => { window.onresize = (event) => {
// if not mobile remove all component // if not mobile remove all component
@@ -102,25 +108,31 @@ export class EditEventPage implements OnInit {
this.modalController.dismiss(); this.modalController.dismiss();
} }
goBack() {
console.log(this.caller);
this.router.navigate(['/home',this.caller]);
}
save() { save() {
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc) this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc)
try{ try{
this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => { this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
/* const alert = await this.alertController.create({ if(this.initCalendarName != this.postEvent.CalendarName){
cssClass: 'my-custom-class', let body = {
header: 'Evento actualizado', "EventId": this.postEvent.EventId,
buttons: ['OK'] "CalendarDestinationName": this.postEvent.CalendarName,
}); }
await alert.present(); */ console.log(body);
await this.eventsService.changeAgenda(body).toPromise();
}
this.toastService.successMessage();
this.toastService.successMessage()
}, error => { }, error => {
this.toastService.badRequest() this.toastService.badRequest()
}); });
this.isEventEdited = true; this.isEventEdited = true;
this.goBack();
this.modalController.dismiss(this.isEventEdited); this.modalController.dismiss(this.isEventEdited);
} catch (error) { } catch (error) {
@@ -179,7 +191,7 @@ export class EditEventPage implements OnInit {
} }
addParticipantsCC(){ addParticipantsCC(){
this.adding = 'CC' this.adding = 'CC';
this.openAttendees(); this.openAttendees();
} }
@@ -35,6 +35,7 @@ export class ViewEventPage implements OnInit {
profile:string; profile:string;
eventId:string; eventId:string;
caller:string;
customDate:any; customDate:any;
today:any; today:any;
@@ -62,8 +63,12 @@ export class ViewEventPage implements OnInit {
this.eventBody = { BodyType : "1", Text : ""}; this.eventBody = { BodyType : "1", Text : ""};
this.loadedEvent.Body = this.eventBody; this.loadedEvent.Body = this.eventBody;
this.activatedRoute.paramMap.subscribe(paramMap =>{ this.activatedRoute.paramMap.subscribe(params =>{
this.eventId = paramMap['params'].eventId; this.eventId = params['params'].eventId;
if(params["params"].caller){
this.caller = (params["params"].caller);
}
}); });
/* this.activatedRoute.queryParams.subscribe(params => { /* this.activatedRoute.queryParams.subscribe(params => {
@@ -76,7 +81,6 @@ export class ViewEventPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
console.log('Notifi teste '+this.eventId);
this.loadEvent(); this.loadEvent();
this.getAttachments(); this.getAttachments();
@@ -136,8 +140,8 @@ export class ViewEventPage implements OnInit {
setTimeout(()=>{ setTimeout(()=>{
alert.dismiss(); alert.dismiss();
}, 1500); }, 1500);
this.goBack();
this.toastService.successMessage('Evento apagado'); this.toastService.successMessage('Evento apagado');
this.close();
}); });
} }
@@ -154,11 +158,14 @@ export class ViewEventPage implements OnInit {
async editEventDetail() { async editEventDetail() {
console.log(this.caller);
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: EditEventPage, component: EditEventPage,
componentProps: { componentProps: {
eventId: this.loadedEvent.EventId, eventId: this.loadedEvent.EventId,
profile: this.profile, caller: this.caller,
}, },
cssClass: 'modal modal-desktop', cssClass: 'modal modal-desktop',
@@ -192,7 +199,7 @@ export class ViewEventPage implements OnInit {
component: EditEventPage, component: EditEventPage,
componentProps:{ componentProps:{
event: this.loadedEvent, event: this.loadedEvent,
profile: this.profile, caller: this.caller,
}, },
cssClass: classs, cssClass: classs,
}); });
+1 -1
View File
@@ -74,7 +74,7 @@
Entrar com senha Entrar com senha
</div> </div>
<div *ngIf="setPint" class="voltar d-flex align-center justify-center pt-25 clear" (click)="pin=!pin;"> <div *ngIf="setPint" class="voltar d-flex align-center justify-center pt-25 clear" (click)="clearCode()">
Limpar Limpar
</div> </div>
+8 -5
View File
@@ -90,11 +90,6 @@ export class EventsService {
this.headers = new HttpHeaders(); this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
} }
/* getAllEvents(startdate:string, enddate:string): Observable<Event[]>{ /* getAllEvents(startdate:string, enddate:string): Observable<Event[]>{
@@ -297,6 +292,14 @@ export class EventsService {
return this.http.put<Event>(`${puturl}`, event, options) return this.http.put<Event>(`${puturl}`, event, options)
} }
changeAgenda(body:any){
const puturl = environment.apiURL + 'Calendar/MoveEvent';
let options = {
headers: this.headers,
};
return this.http.post<any>(`${puturl}`, body, options);
}
/* postEvent(event:Event, calendarName:string, sharedagenda:string) /* postEvent(event:Event, calendarName:string, sharedagenda:string)
{ {
const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PostEvent'); const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PostEvent');
@@ -25,6 +25,7 @@ export class EditEventPage implements OnInit {
isRecurring:string; isRecurring:string;
isEventEdited: boolean; isEventEdited: boolean;
loadedEvent: Event; loadedEvent: Event;
initCalendarName: string;
eventBody: EventBody; eventBody: EventBody;
segment:string = "true"; segment:string = "true";
eventAttendees: EventPerson[]; eventAttendees: EventPerson[];
@@ -157,19 +158,16 @@ export class EditEventPage implements OnInit {
this.showLoader = true this.showLoader = true
await this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => { await this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
this.showLoader = false if(this.initCalendarName != this.postEvent.CalendarName){
let body = {
const alert = await this.alertController.create({ "EventId": this.postEvent.EventId,
cssClass: 'my-custom-class', "CalendarDestinationName": this.postEvent.CalendarName,
header: 'Evento actualizado', }
buttons: ['OK'] console.log(body);
}); await this.eventsService.changeAgenda(body).toPromise();
}
this.showLoader = false;
this.toastService.successMessage() this.toastService.successMessage()
setTimeout(()=>{
alert.dismiss();
}, 1500);
}, },
error => { error => {
this.showLoader = false this.showLoader = false
@@ -330,7 +330,7 @@ export class NewEventPage implements OnInit {
this.runValidation() this.runValidation()
// dont runt this function // dont runt this function
if (!this.Form.valid) return false // if (!this.Form.valid) return false
this.getDatepickerData() this.getDatepickerData()
@@ -104,15 +104,6 @@ export class ViewEventPage implements OnInit {
deleteEvent(){ deleteEvent(){
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async () => this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async () =>
{ {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Evento removido',
buttons: ['OK']
});
setTimeout(()=>{
alert.dismiss();
}, 1500);
this.toastService.successMessage('Evento apagado'); this.toastService.successMessage('Evento apagado');
this.close(); this.close();
}); });