mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve
This commit is contained in:
@@ -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<string>(`${puturl}`, event, options)
|
||||
}
|
||||
|
||||
|
||||
|
||||
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
|
||||
let arrayReq = [];
|
||||
let Object = {
|
||||
|
||||
Reference in New Issue
Block a user