This commit is contained in:
Peter Maquiran
2022-05-02 14:36:08 +01:00
157 changed files with 1076 additions and 1144 deletions
+57 -14
View File
@@ -47,6 +47,15 @@ export class EventsService {
hasOwnOficial: boolean = false;
hasOwnPessoal: boolean = false;
userCalendarNameSharedOficial = '';
userCalendarNameSharedPessoal = '';
userCalendarNameOwnOficial = '';
userCalendarNameOwnPessoal = '';
constructor(
private http: HttpClient,
public user: AuthService,
@@ -56,7 +65,8 @@ export class EventsService {
private backgroundservice: BackgroundService) {
this.loggeduser = this.user.ValidatedUser;
this.headers = new HttpHeaders();
this.headersMdOficial = new HttpHeaders();
this.headersMdPessoal = new HttpHeaders();
@@ -82,7 +92,7 @@ export class EventsService {
}
setHeader() {
async setHeader () {
this.hasSharedCalendar = false
this.hasSharedOficial = false
@@ -92,13 +102,22 @@ export class EventsService {
this.hasOwnOficial = false
this.hasOwnPessoal = false
this.headers = new HttpHeaders();
this.headerOwnOficial= new HttpHeaders();
this.headerOwnPessoal= new HttpHeaders();
this.headerSharedOficial= new HttpHeaders();
this.headerSharedPessoal= new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
this.userCalendarNameSharedOficial = '';
this.userCalendarNameSharedPessoal = '';
this.userCalendarNameOwnOficial = '';
this.userCalendarNameOwnPessoal = '';
this.calendarIds = []
this.calendarIds = [];
if (this.loggeduser) {
if (this.loggeduser.Profile == 'MDGPR') {
@@ -226,10 +245,15 @@ export class EventsService {
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarName', sharedCalendar.CalendarName);
}
this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> {
console.log(e)
})
}
this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
}
}
@@ -328,6 +352,23 @@ export class EventsService {
return this.http.get<any>(`${geturl}`, options)
}
GetCalendarName(userid:string) {
let geturl = environment.apiURL + 'userauthentication/single';
let params = new HttpParams();
params = params.set("id", userid);
let options = {
headers: this.headers,
params: params
}
return this.http.get<any>(`${geturl}`, options)
}
async getAllMdEvents(startdate: string, enddate: string) {
let prO = [], prP = [];
@@ -341,6 +382,8 @@ export class EventsService {
}
async getAllOwnEvents(startdate: string, enddate: string) {
let ownO = [], ownP = [];
@@ -469,7 +512,7 @@ export class EventsService {
headers: this.headersSharedOficial,
params: params
};
console.log(options);
return this.http.get<Event[]>(`${geturl}`, options);
}
@@ -642,7 +685,7 @@ export class EventsService {
return this.http.put<Event>(`${puturl}`, event, options).pipe(
catchError(err => {
console.log('Event edit saved offline')
this.offlinemanager.storeRequestData('eventEdit', arrayReq);
throw new Error(err);
})
@@ -667,7 +710,7 @@ export class EventsService {
let options: any;
switch (calendarName) {
case 'Oficial':
console.log(calendarName);
options = {
headers: this.headersMdOficial,
params: params
@@ -675,14 +718,14 @@ export class EventsService {
break;
case 'Pessoal':
console.log(calendarName);
options = {
headers: this.headersMdPessoal,
params: params
};
break;
}
console.log(options);
return this.http.post<string>(`${puturl}`, event, options)
}
@@ -695,7 +738,7 @@ export class EventsService {
let options: any;
switch (calendarName) {
case 'Oficial':
console.log(calendarName);
options = {
headers: this.headersPrOficial,
params: params
@@ -703,7 +746,7 @@ export class EventsService {
break;
case 'Pessoal':
console.log(calendarName);
options = {
headers: this.headersPrPessoal,
params: params
@@ -816,7 +859,7 @@ export class EventsService {
return this.http.delete(`${puturl}`, options).pipe(
catchError(err => {
console.log('Event edit saved offline')
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
throw new Error(err);
})
@@ -891,7 +934,7 @@ export class EventsService {
return this.http.delete(`${puturl}`, options).pipe(
catchError(err => {
console.log('Event edit saved offline')
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
throw new Error(err);
})