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 => {
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}`);
});
return classs.join(' ');
}
@@ -422,6 +436,25 @@ export class AgendaPage implements OnInit {
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){
this.eventSelectedDate = new Date(startTime);
@@ -753,7 +786,10 @@ export class AgendaPage implements OnInit {
index: eventIndex,
title: element.Subject,
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
endTime: this.EventTretment({
startTime: element.StartDate,
endTime: element.EndDate
}),
allDay: false,
event: element,
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.TimelineMD = MDEventList;
@@ -776,13 +812,13 @@ export class AgendaPage implements OnInit {
this.showTimelineMD = true;
counter++;
if(counter==2){
if(counter==2) {
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') {
this.eventsList = response.filter(data => data.CalendarName == "Oficial");
@@ -827,59 +863,56 @@ export class AgendaPage implements OnInit {
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) => {
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');
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.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.TimelinePR = this.timelineFilter(this.timelineFilterState, this.eventsList, 'pr');
this.myCal.update();
this.myCal.loadEvents();
this.TimelinePRList = this.eventListBox(this.TimelinePR)
this.showTimelinePR = true;
counter++;
this.myCal.update();
this.myCal.loadEvents();
if(counter==2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
this.showTimelinePR = true;
counter++;
if(counter==2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
});
@@ -894,13 +927,16 @@ export class AgendaPage implements OnInit {
list.forEach( (event:any)=> {
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')
event.manyDays = false
if(!days.hasOwnProperty(day)) {
days[day] = []
}
@@ -952,7 +988,6 @@ export class AgendaPage implements OnInit {
event.start = newDate
if(!days.hasOwnProperty(otherDays)) {
days[otherDays] = []
}
@@ -36,7 +36,7 @@
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<div class="ion-input-class">
<ion-select disabled placeholder="Selecione agenda*"
<ion-select placeholder="Selecione agenda*"
selectedText="{{postEvent.CalendarName}}"
[(ngModel)]="postEvent.CalendarName"
interface="action-sheet" Cancel-text="Cancelar"
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AlertController, AnimationController, ModalController, NavParams } from '@ionic/angular';
import { Attachment } from 'src/app/models/attachment.model';
import { EventBody } from 'src/app/models/eventbody.model';
@@ -28,6 +29,8 @@ export class EditEventPage implements OnInit {
selectedSegment: string;
selectedDate: Date;
minDate: string;
initCalendarName: string;
caller:string;
loadedEventAttachments: Attachment[];
@@ -46,9 +49,12 @@ export class EditEventPage implements OnInit {
private attachmentsService: AttachmentsService,
private animationController: AnimationController,
private toastService: ToastService,
private router: Router,
) {
this.isEventEdited = false;
this.postEvent = this.navParams.get('event');
this.caller = this.navParams.get('caller');
this.initCalendarName = this.postEvent.CalendarName;
if(this.postEvent){
if( this.postEvent.Body){
@@ -78,13 +84,13 @@ export class EditEventPage implements OnInit {
else {
this.isRecurring = "Repete";
}
this.profile = this.navParams.get('profile');
this.getAttachments(this.postEvent.EventId);
}
ngOnInit() {
console.log(this.caller);
window.onresize = (event) => {
// if not mobile remove all component
@@ -102,25 +108,31 @@ export class EditEventPage implements OnInit {
this.modalController.dismiss();
}
goBack() {
console.log(this.caller);
this.router.navigate(['/home',this.caller]);
}
save() {
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc)
try{
this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
/* const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Evento actualizado',
buttons: ['OK']
});
await alert.present(); */
if(this.initCalendarName != this.postEvent.CalendarName){
let body = {
"EventId": this.postEvent.EventId,
"CalendarDestinationName": this.postEvent.CalendarName,
}
console.log(body);
await this.eventsService.changeAgenda(body).toPromise();
}
this.toastService.successMessage();
this.toastService.successMessage()
}, error => {
this.toastService.badRequest()
});
this.isEventEdited = true;
this.goBack();
this.modalController.dismiss(this.isEventEdited);
} catch (error) {
@@ -179,7 +191,7 @@ export class EditEventPage implements OnInit {
}
addParticipantsCC(){
this.adding = 'CC'
this.adding = 'CC';
this.openAttendees();
}
@@ -35,6 +35,7 @@ export class ViewEventPage implements OnInit {
profile:string;
eventId:string;
caller:string;
customDate:any;
today:any;
@@ -62,8 +63,12 @@ export class ViewEventPage implements OnInit {
this.eventBody = { BodyType : "1", Text : ""};
this.loadedEvent.Body = this.eventBody;
this.activatedRoute.paramMap.subscribe(paramMap =>{
this.eventId = paramMap['params'].eventId;
this.activatedRoute.paramMap.subscribe(params =>{
this.eventId = params['params'].eventId;
if(params["params"].caller){
this.caller = (params["params"].caller);
}
});
/* this.activatedRoute.queryParams.subscribe(params => {
@@ -76,7 +81,6 @@ export class ViewEventPage implements OnInit {
}
ngOnInit() {
console.log('Notifi teste '+this.eventId);
this.loadEvent();
this.getAttachments();
@@ -136,8 +140,8 @@ export class ViewEventPage implements OnInit {
setTimeout(()=>{
alert.dismiss();
}, 1500);
this.goBack();
this.toastService.successMessage('Evento apagado');
this.close();
});
}
@@ -154,11 +158,14 @@ export class ViewEventPage implements OnInit {
async editEventDetail() {
console.log(this.caller);
const modal = await this.modalController.create({
component: EditEventPage,
componentProps: {
eventId: this.loadedEvent.EventId,
profile: this.profile,
caller: this.caller,
},
cssClass: 'modal modal-desktop',
@@ -192,7 +199,7 @@ export class ViewEventPage implements OnInit {
component: EditEventPage,
componentProps:{
event: this.loadedEvent,
profile: this.profile,
caller: this.caller,
},
cssClass: classs,
});
+1 -1
View File
@@ -74,7 +74,7 @@
Entrar com senha
</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
</div>
+8 -5
View File
@@ -90,11 +90,6 @@ export class EventsService {
this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
}
/* getAllEvents(startdate:string, enddate:string): Observable<Event[]>{
@@ -297,6 +292,14 @@ export class EventsService {
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)
{
const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PostEvent');
@@ -25,6 +25,7 @@ export class EditEventPage implements OnInit {
isRecurring:string;
isEventEdited: boolean;
loadedEvent: Event;
initCalendarName: string;
eventBody: EventBody;
segment:string = "true";
eventAttendees: EventPerson[];
@@ -157,19 +158,16 @@ export class EditEventPage implements OnInit {
this.showLoader = true
await this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
this.showLoader = false
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Evento actualizado',
buttons: ['OK']
});
if(this.initCalendarName != this.postEvent.CalendarName){
let body = {
"EventId": this.postEvent.EventId,
"CalendarDestinationName": this.postEvent.CalendarName,
}
console.log(body);
await this.eventsService.changeAgenda(body).toPromise();
}
this.showLoader = false;
this.toastService.successMessage()
setTimeout(()=>{
alert.dismiss();
}, 1500);
},
error => {
this.showLoader = false
@@ -330,7 +330,7 @@ export class NewEventPage implements OnInit {
this.runValidation()
// dont runt this function
if (!this.Form.valid) return false
// if (!this.Form.valid) return false
this.getDatepickerData()
@@ -104,15 +104,6 @@ export class ViewEventPage implements OnInit {
deleteEvent(){
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.close();
});