mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
save
This commit is contained in:
@@ -29,7 +29,7 @@ export class EventsService {
|
||||
headersMdPessoal: HttpHeaders;
|
||||
|
||||
headerOwnOficial: HttpHeaders;
|
||||
headersOwnPessoal: HttpHeaders;
|
||||
headerOwnPessoal: HttpHeaders;
|
||||
|
||||
headerSharedOficial: HttpHeaders;
|
||||
headerSharedPessoal: HttpHeaders;
|
||||
@@ -64,7 +64,7 @@ export class EventsService {
|
||||
|
||||
|
||||
this.headerOwnOficial= new HttpHeaders();
|
||||
this.headersOwnPessoal= new HttpHeaders();
|
||||
this.headerOwnPessoal= new HttpHeaders();
|
||||
|
||||
this.headerSharedOficial= new HttpHeaders();
|
||||
this.headerSharedPessoal= new HttpHeaders();
|
||||
@@ -83,7 +83,6 @@ export class EventsService {
|
||||
this.hasSharedCalendar = false
|
||||
this.hasOwnCalendar = false
|
||||
|
||||
|
||||
this.calendarOwnerIds = []
|
||||
|
||||
if (this.loggeduser) {
|
||||
@@ -166,11 +165,13 @@ export class EventsService {
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('CalendarId', calendar.CalendarId);
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('CalendarName', calendar.CalendarName);
|
||||
}
|
||||
else if (calendar.CalendarName == 'Pessoal') {
|
||||
this.headersOwnPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headersOwnPessoal.set('CalendarId', calendar.CalendarId);
|
||||
this.headersOwnPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
this.headerOwnPessoal = this.headerOwnPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headerOwnPessoal =this.headerOwnPessoal.set('CalendarId', calendar.CalendarId);
|
||||
this.headerOwnPessoal =this.headerOwnPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
this.headerOwnPessoal = this.headerOwnPessoal.set('CalendarName', calendar.CalendarName);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -185,18 +186,19 @@ export class EventsService {
|
||||
this.hasSharedCalendar = true
|
||||
|
||||
if (sharedCalendar.CalendarName == 'Oficial') {
|
||||
sharedCalendar.CalendarName
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('Authorization', 'Basic '+sharedCalendar.CalendarToken);
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('CalendarName', sharedCalendar.CalendarName);
|
||||
}
|
||||
else if (sharedCalendar.CalendarName == 'Pessoal') {
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('Authorization', 'Basic '+sharedCalendar.CalendarToken);
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarName', sharedCalendar.CalendarName);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(this.loggeduser.SharedCalendars)
|
||||
|
||||
}
|
||||
|
||||
@@ -321,7 +323,7 @@ export class EventsService {
|
||||
params = params.set("EndDate", enddate);
|
||||
|
||||
let options = {
|
||||
headers: this.headersOwnPessoal,
|
||||
headers: this.headerOwnPessoal,
|
||||
params: params
|
||||
};
|
||||
return this.http.get<any>(`${geturl}`, options)
|
||||
@@ -458,6 +460,39 @@ export class EventsService {
|
||||
return this.http.get<Event>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
|
||||
genericGetEvent(eventid: string, calendarId: string) {
|
||||
let geturl = environment.apiURL + 'calendar/GetEvent';
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("EventId", eventid);
|
||||
|
||||
const headers = [
|
||||
this.headerSharedOficial,
|
||||
this.headerSharedPessoal,
|
||||
this.headerOwnPessoal,
|
||||
this.headerOwnOficial
|
||||
]
|
||||
|
||||
const header = headers.find((header)=> {
|
||||
return header?.get('CalendarId')?.includes(calendarId)
|
||||
})
|
||||
|
||||
if(header) {
|
||||
let options = {
|
||||
headers: header,
|
||||
params: params
|
||||
}
|
||||
|
||||
return this.http.get<Event>(`${geturl}`, options);
|
||||
} else {
|
||||
alert('headr not found'+ calendarId)
|
||||
}
|
||||
|
||||
throw('error')
|
||||
|
||||
}
|
||||
|
||||
putEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, sharedagenda: string): Observable<Event> {
|
||||
const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PutEvent');
|
||||
|
||||
@@ -494,7 +529,12 @@ export class EventsService {
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
this.headers = this.headersPrOficial;
|
||||
} else {
|
||||
this.headers = this.headerOwnOficial
|
||||
|
||||
if(this.hasOwnCalendar) {
|
||||
this.headers = this.headerOwnOficial
|
||||
} else {
|
||||
this.headers = this.headerSharedOficial
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -505,7 +545,11 @@ export class EventsService {
|
||||
this.headers = this.headersPrPessoal;
|
||||
}
|
||||
else {
|
||||
this.headers = this.headersOwnPessoal
|
||||
if(this.hasSharedCalendar) {
|
||||
this.headers = this.headerSharedPessoal
|
||||
} else {
|
||||
this.headers = this.headerOwnPessoal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,6 +566,7 @@ export class EventsService {
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
changeAgenda(body: any) {
|
||||
const puturl = environment.apiURL + 'Calendar/MoveEvent';
|
||||
@@ -597,23 +642,45 @@ export class EventsService {
|
||||
|
||||
let options: any;
|
||||
|
||||
switch (calendarName) {
|
||||
case 'Oficial':
|
||||
options = {
|
||||
headers: this.headerSharedOficial,
|
||||
params: params
|
||||
};
|
||||
break;
|
||||
|
||||
case 'Pessoal':
|
||||
|
||||
options = {
|
||||
headers: this.headerSharedPessoal,
|
||||
params: params
|
||||
};
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return this.http.post<string>(`${puturl}`, event, options)
|
||||
}
|
||||
|
||||
@@ -673,6 +740,83 @@ export class EventsService {
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
genericDeleteEvent(eventid: string, eventDeleteType: number, calendarName: string, calendarId: string) {
|
||||
let arrayReq = [];
|
||||
let Object = {
|
||||
eventid: eventid,
|
||||
eventDeleteType: eventDeleteType,
|
||||
calendarName: calendarName
|
||||
}
|
||||
arrayReq.push(Object)
|
||||
const puturl = environment.apiURL + 'calendar/DeleteEvent';
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("EventId", eventid);
|
||||
// 0 for occurence and 1 for serie (delete all events)
|
||||
params = params.set("eventDeleteType", eventDeleteType.toString());
|
||||
|
||||
let options;
|
||||
|
||||
if(this.loggeduser.Profile == 'MDGPR') {
|
||||
if (calendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersMdPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if (calendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersMdOficial,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
if (calendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersPrPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if (calendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersPrOficial,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
const headers = [
|
||||
this.headerSharedOficial,
|
||||
this.headerSharedPessoal,
|
||||
this.headerOwnPessoal,
|
||||
this.headerOwnOficial
|
||||
]
|
||||
|
||||
const header = headers.find((header)=> {
|
||||
return header?.get('CalendarId')?.includes(calendarId)
|
||||
})
|
||||
|
||||
if (header) {
|
||||
return this.http.delete(`${puturl}`, options).pipe(
|
||||
catchError(err => {
|
||||
console.log('Event edit saved offline')
|
||||
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
|
||||
throw new Error(err);
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
throw('header not found')
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
postExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
|
||||
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event';
|
||||
let params = new HttpParams();
|
||||
|
||||
Reference in New Issue
Block a user