From 53b107e83c0737e2fbef0227ac4ba36d5d013888 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 12 May 2022 16:54:11 +0100 Subject: [PATCH] improve --- src/app/pages/agenda/agenda.page.html | 2 +- .../agenda/new-event/new-event.page.html | 30 ++---- .../pages/agenda/new-event/new-event.page.ts | 59 +++++++++--- src/app/services/auth.service.ts | 2 +- src/app/services/events.service.ts | 94 ++++++++++--------- .../agenda/new-event/new-event.page.html | 56 +++-------- .../shared/agenda/new-event/new-event.page.ts | 76 ++++++++++++--- .../shared/chat/messages/messages.page.html | 2 +- .../shared/chat/messages/messages.page.scss | 5 + 9 files changed, 191 insertions(+), 135 deletions(-) diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html index 77f5cd1ae..a0c9b11b5 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -298,7 +298,7 @@
- {{ TimelineDayEvent(events.key)}} + {{ TimelineDayEvent(events.key) }}
diff --git a/src/app/pages/agenda/new-event/new-event.page.html b/src/app/pages/agenda/new-event/new-event.page.html index a6b2c38c0..454ce5e1e 100644 --- a/src/app/pages/agenda/new-event/new-event.page.html +++ b/src/app/pages/agenda/new-event/new-event.page.html @@ -18,7 +18,7 @@
-
+
@@ -26,13 +26,12 @@
- - - - Calendário do Presidente da República - - - Calendário do MDGPR + + + +
Calendário de {{calendars}}
+
{{calendars}}
+
@@ -62,11 +61,8 @@ - - Oficial - - - Pessoal + + {{ calendars }} @@ -112,14 +108,6 @@
-
diff --git a/src/app/pages/agenda/new-event/new-event.page.ts b/src/app/pages/agenda/new-event/new-event.page.ts index 7a8277286..241e22819 100644 --- a/src/app/pages/agenda/new-event/new-event.page.ts +++ b/src/app/pages/agenda/new-event/new-event.page.ts @@ -82,11 +82,12 @@ export class NewEventPage implements OnInit { autoStartTime; autoEndTime; + CalendarNamesOptions = ['Oficial', 'Pessoal'] constructor( private modalController: ModalController, private navParams: NavParams, - private eventService: EventsService, + public eventService: EventsService, private attachmentsService: AttachmentsService, private toastService: ToastService, userService: AuthService, @@ -297,23 +298,21 @@ export class NewEventPage implements OnInit { try { - + const CalendarId = this.selectedCalendarId() if(this.loggeduser.Profile == 'MDGPR') { - - - - eventId = await this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).toPromise(); - - + eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise(); + } else if(this.loggeduser.Profile == 'PR') { - - eventId = await this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).toPromise(); + const CalendarId = this.selectedCalendarId() + eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise(); } else { - eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).toPromise(); + + const CalendarId = this.selectedCalendarId() + eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise(); } const DocumentToSave: EventAttachment[] = this.documents.map((e) => { @@ -351,6 +350,44 @@ export class NewEventPage implements OnInit { } + + selectedCalendarId () { + + if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) { + return this.eventService.calendarNamesType[this.CalendarName]['OficialId'] + + } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { + + return this.eventService.calendarNamesType[this.CalendarName]['PessoalId'] + + } else { + return '11:11' + } + } + + changeAgenda() { + + setTimeout(() => { + + if(this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { + + this.CalendarNamesOptions = ['Oficial', 'Pessoal'] + + } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) { + this.CalendarNamesOptions = ['Oficial'] + this.postEvent.CalendarName = 'Oficial' + + } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { + this.CalendarNamesOptions = ['Pessoal'] + this.postEvent.CalendarName = 'Pessoal' + + } else { + this.CalendarNamesOptions = ['Oficial', 'Pessoal'] + } + }, 50) + + } + async openAttendees() { const modal = await this.modalController.create({ diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 4e733933e..90602818c 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -137,7 +137,7 @@ export class AuthService { SessionStore.reset(session) this.ValidatedUser = SessionStore.user; - console.log('!!!::!!===', this.ValidatedUser) + // console.log('!!!::!!===', this.ValidatedUser) this.storageService.store(AuthConnstants.USER, response); return true; diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts index f2cc203fd..353e088c7 100644 --- a/src/app/services/events.service.ts +++ b/src/app/services/events.service.ts @@ -55,6 +55,11 @@ export class EventsService { userCalendarNameOwnPessoal = ''; calendarNames = {} + + calendarNamesAry = [] + calendarNamesType = {} + + myCalendarNames = {} constructor( private http: HttpClient, @@ -118,6 +123,10 @@ export class EventsService { this.userCalendarNameOwnPessoal = ''; this.calendarIds = []; + this.calendarNames = {} + + this.calendarNamesAry = [] + this.calendarNamesType = {} if (this.loggeduser) { if (this.loggeduser.Profile == 'MDGPR') { @@ -189,8 +198,6 @@ export class EventsService { }); } - - this.loggeduser.OwnerCalendars.forEach(calendar => { if(!this.calendarIds.includes(calendar.OwnerUserId)) { @@ -250,22 +257,42 @@ export class EventsService { if(sharedCalendar?.OwnerUserId) { this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> { this.calendarNames[sharedCalendar.CalendarId] = e.FullName + this.myCalendarNames[sharedCalendar.CalendarId] = e.FullName + + if(!this.calendarNamesAry.includes(e.FullName)) { + this.calendarNamesAry.push(e.FullName) + this.calendarNamesType[e.FullName] = {} + } + + this.calendarNamesType[e.FullName][sharedCalendar.CalendarName] = true + this.calendarNamesType[e.FullName][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId + }) } } for (let sharedCalendar of this.loggeduser.OwnerCalendars) { - if(sharedCalendar?.OwnerUserId) { - this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> { - this.calendarNames[sharedCalendar.CalendarId] = e.FullName - }) + + this.calendarNames[sharedCalendar.CalendarId] = 'Meu calendario' + + if(!this.calendarNamesAry.includes('Meu calendario')) { + this.calendarNamesAry.push('Meu calendario') + this.calendarNamesType['Meu calendario'] = {} } + + this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName] = true + this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId } } } } + + isMyCalendar(CalendarId) { + return this.myCalendarNames[CalendarId] || "" + } + getCalendarOwnNameByCalendarId(CalendarId) { return this.calendarNames[CalendarId] || "" } @@ -787,7 +814,7 @@ export class EventsService { - postEventGeneric(event: Event, calendarName: string) { + postEventGeneric(event: Event, calendarName: string, CalendarId) { const puturl = environment.apiURL + 'Calendar/PostEvent'; let params = new HttpParams(); @@ -795,48 +822,27 @@ export class EventsService { let options: any; + const headers = [ + this.headerSharedOficial, + this.headerSharedPessoal, + this.headerOwnPessoal, + this.headerOwnOficial + ] - if(this.hasOwnCalendar) { - switch (calendarName) { - case 'Oficial': - options = { - headers: this.headerOwnOficial, - params: params - }; - break; - - case 'Pessoal': - - options = { - headers: this.headerOwnPessoal, - params: params - }; - break; - } - } else { - switch (calendarName) { - case 'Oficial': - options = { - headers: this.headerSharedOficial, - params: params - }; - break; - - case 'Pessoal': - - options = { - headers: this.headerSharedPessoal, - params: params - }; - break; - } - } - - + const header = headers.find((header)=> { + return header?.get('CalendarId')?.includes(CalendarId) + }) + options = { + headers: header, + params: params + }; + return this.http.post(`${puturl}`, event, options) } + + deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) { let arrayReq = []; let Object = { diff --git a/src/app/shared/agenda/new-event/new-event.page.html b/src/app/shared/agenda/new-event/new-event.page.html index f5c683c3e..c51ac294f 100644 --- a/src/app/shared/agenda/new-event/new-event.page.html +++ b/src/app/shared/agenda/new-event/new-event.page.html @@ -28,8 +28,8 @@
- -
+ +
@@ -37,13 +37,11 @@
- - - - Calendário do Presidente da República - - - Calendário do MDGPR + + + +
Calendário de {{calendars}}
+
{{calendars}}
@@ -67,7 +65,7 @@
-
+
@@ -76,12 +74,11 @@ - - Oficial - - - Pessoal + + + {{ calendars }} + @@ -124,9 +121,6 @@
-
@@ -181,23 +175,6 @@
- -
@@ -210,7 +187,7 @@ [(ngModel)]="postEvent.EventRecurrence.Type" (ngModelChange)="onSelectedRecurringChanged($event)"> {{recurring.Description}} @@ -248,13 +225,6 @@
-
diff --git a/src/app/shared/agenda/new-event/new-event.page.ts b/src/app/shared/agenda/new-event/new-event.page.ts index f1cf48ff8..f30eedaf4 100644 --- a/src/app/shared/agenda/new-event/new-event.page.ts +++ b/src/app/shared/agenda/new-event/new-event.page.ts @@ -113,10 +113,13 @@ export class NewEventPage implements OnInit { showLoader = false CalendarName; + CalendarNameShow = true + + CalendarNamesOptions = ['Oficial', 'Pessoal'] constructor( private modalController: ModalController, - private eventService: EventsService, + public eventService: EventsService, private attachmentsService: AttachmentsService, private toastService: ToastService, private userService: AuthService, @@ -131,13 +134,13 @@ export class NewEventPage implements OnInit { let now = new Date(); - if(now.getMinutes() <= 30){ + if(now.getMinutes() <= 30) { this.autoStartTime = new Date(now.setMinutes(30)); this.postEvent.StartDate = this.autoStartTime; this.autoEndTime = new Date(this.autoStartTime.getTime() + 30 * 60000); this.postEvent.EndDate = this.autoEndTime; } - else{ + else { this.autoStartTime = new Date(now.setHours(now.getHours()+1)); this.autoStartTime = new Date(this.autoStartTime.setMinutes(0)); this.postEvent.StartDate = this.autoStartTime; @@ -176,7 +179,7 @@ export class NewEventPage implements OnInit { Organizer: '', Category: 'Reunião', HasAttachments: false, - EventRecurrence: {Type:'-1',LastOccurrence:this.autoEndTime}, + EventRecurrence: { Type:'-1', LastOccurrence: this.autoEndTime }, }; } else{ @@ -286,6 +289,33 @@ export class NewEventPage implements OnInit { } } + changeAgenda() { + + this.CalendarNameShow = false + + setTimeout(()=>{ + + this.CalendarNameShow = true + + if(this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { + + this.CalendarNamesOptions = ['Oficial', 'Pessoal'] + + } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) { + this.CalendarNamesOptions = ['Oficial'] + this.postEvent.CalendarName = 'Oficial' + + } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { + this.CalendarNamesOptions = ['Pessoal'] + this.postEvent.CalendarName = 'Pessoal' + + } else { + this.CalendarNamesOptions = ['Oficial', 'Pessoal'] + } + }, 50) + + } + openLastOccurrence() { let input: any = document.querySelector('#last-occurrence') if(input) { @@ -362,12 +392,12 @@ export class NewEventPage implements OnInit { } if(this.loggeduser.Profile == 'MDGPR') { - + const CalendarId = this.selectedCalendarId() this.showLoader = true; let loader = this.toastService.loading(); - this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe( + this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe( async (id) => { loader.remove() this.showLoader = false @@ -413,8 +443,9 @@ export class NewEventPage implements OnInit { } else if(this.loggeduser.Profile == 'PR') { + const CalendarId = this.selectedCalendarId() - this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe( + this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe( (id) => { @@ -447,10 +478,15 @@ export class NewEventPage implements OnInit { this.toastService.successMessage('Evento criado') }); } else { - this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).subscribe( + + this.postEvent.CalendarName + + + const CalendarId = this.selectedCalendarId() + + this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe( (id) => { - const eventId: any = id; const DocumentToSave: EventAttachment[] = this.documents.map((e) => { @@ -478,7 +514,22 @@ export class NewEventPage implements OnInit { this.afterSave(); } this.toastService.successMessage('Evento criado') - }); + }); + + } + } + + selectedCalendarId () { + + if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) { + return this.eventService.calendarNamesType[this.CalendarName]['OficialId'] + + } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { + + return this.eventService.calendarNamesType[this.CalendarName]['PessoalId'] + + } else { + return '11:11' } } @@ -492,7 +543,7 @@ export class NewEventPage implements OnInit { this.setIntervenientCC.emit([]); } - removeAttachment(index: number){ + removeAttachment(index: number) { this.documents = this.documents.filter( (e, i) => index != i); } @@ -534,7 +585,6 @@ export class NewEventPage implements OnInit { */ restoreTemporaryData(): boolean { - const restoredData = window['temp.path:/home/agenda/new-event.component.ts'] if(JSON.stringify(restoredData) != "{}" && undefined != restoredData) { @@ -551,7 +601,7 @@ export class NewEventPage implements OnInit { } } - deleteTemporaryData(){ + deleteTemporaryData() { window['temp.path:/home/agenda/new-event.component.ts'] = {} } diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 9d60246ff..a8c80b8b0 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -52,7 +52,7 @@
- {{msg.msg}} +
{{msg.msg}}
Apagou a mensagem diff --git a/src/app/shared/chat/messages/messages.page.scss b/src/app/shared/chat/messages/messages.page.scss index 9933b4de3..4490b9c02 100644 --- a/src/app/shared/chat/messages/messages.page.scss +++ b/src/app/shared/chat/messages/messages.page.scss @@ -341,3 +341,8 @@ display: block; border: 1px solid red !important; overflow: auto; } + +.message-box { + flex: auto; + margin-right: 9px; +}