This commit is contained in:
Peter Maquiran
2022-04-29 15:31:27 +01:00
parent b2d141c709
commit 7862cfb1df
6 changed files with 192 additions and 18 deletions
+71 -10
View File
@@ -42,6 +42,10 @@ export class EventsService {
calendarIds = []
hasSharedOficial: boolean = false;
hasSharedPessoal: boolean = false;
hasOwnOficial: boolean = false;
hasOwnPessoal: boolean = false;
constructor(
private http: HttpClient,
@@ -81,7 +85,13 @@ export class EventsService {
setHeader() {
this.hasSharedCalendar = false
this.hasSharedOficial = false
this.hasSharedPessoal = false
this.hasOwnCalendar = false
this.hasOwnOficial = false
this.hasOwnPessoal = false
this.headerOwnOficial= new HttpHeaders();
this.headerOwnPessoal= new HttpHeaders();
@@ -96,11 +106,18 @@ export class EventsService {
this.loggeduser.OwnerCalendars.forEach(calendar => {
if (calendar.CalendarName == 'Oficial') {
this.hasOwnOficial = true
this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId);
this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
else if (calendar.CalendarName == 'Pessoal') {
this.hasOwnPessoal = true
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
@@ -111,11 +128,17 @@ export class EventsService {
this.loggeduser.SharedCalendars.forEach(sharedCalendar => {
if (sharedCalendar.CalendarName == 'Oficial') {
this.hasSharedOficial = true
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
}
else if (sharedCalendar.CalendarName == 'Pessoal') {
this.hasSharedPessoal = true
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
@@ -128,11 +151,17 @@ export class EventsService {
this.loggeduser.OwnerCalendars.forEach(calendar => {
if (calendar.CalendarName == 'Oficial') {
this.hasOwnOficial = true
this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId);
this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
else if (calendar.CalendarName == 'Pessoal') {
this.hasOwnPessoal = true
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
@@ -151,12 +180,18 @@ export class EventsService {
this.hasOwnCalendar = true
if (calendar.CalendarName == 'Oficial') {
this.hasOwnOficial = true
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.hasOwnPessoal = true
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);
@@ -175,13 +210,17 @@ export class EventsService {
this.hasSharedCalendar = true
if (sharedCalendar.CalendarName == 'Oficial') {
sharedCalendar.CalendarName
this.hasSharedOficial = true
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.hasSharedPessoal = true
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);
@@ -248,8 +287,11 @@ export class EventsService {
}
async getAllPrEvents(startdate: string, enddate: string): Promise<EventList[]> {
let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise();
let prO = [], prP = [];
prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise();
prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
return new Promise(resolve => {
return resolve(resFinal)
@@ -287,8 +329,11 @@ export class EventsService {
}
async getAllMdEvents(startdate: string, enddate: string) {
let prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise();
let prO = [], prP = [];
prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise();
prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
return new Promise(resolve => {
return resolve(resFinal)
@@ -297,8 +342,17 @@ export class EventsService {
async getAllOwnEvents(startdate: string, enddate: string) {
let ownO = await this.getAllOwnOficialEvents(startdate, enddate).toPromise();
let ownP = await this.getAllOwnPessoalEvents(startdate, enddate).toPromise();
let ownO = [], ownP = [];
if(this.hasOwnOficial) {
ownO = await this.getAllOwnOficialEvents(startdate, enddate).toPromise();
}
if(this.hasOwnPessoal) {
ownP = await this.getAllOwnPessoalEvents(startdate, enddate).toPromise();
}
const resFinal = ownO.concat(ownP);
return new Promise(resolve => {
return resolve(resFinal)
@@ -338,8 +392,16 @@ export class EventsService {
async genericGetAllSharedEvents(startdate: string, enddate: string) {
let prO = await this.genericGetAllSharedOficialEvents(startdate, enddate).toPromise();
let prP = await this.genericGetAllSharedPessoalEvents(startdate, enddate).toPromise();
let prO = [], prP = [];
if(this.hasSharedOficial) {
prO = await this.genericGetAllSharedOficialEvents(startdate, enddate).toPromise();
}
if(this.hasSharedPessoal) {
prP = await this.genericGetAllSharedPessoalEvents(startdate, enddate).toPromise();
}
const resFinal = prO.concat(prP);
return new Promise(resolve => {
@@ -497,7 +559,6 @@ export class EventsService {
}
throw('error')
}
putEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, sharedagenda: string): Observable<Event> {