[Library | Trunk]: Add custom option on stakeholder service

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59748 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-11-03 10:03:58 +00:00
parent 36bfc07747
commit 57e7c0fa85
1 changed files with 9 additions and 27 deletions

View File

@ -43,13 +43,7 @@ export class StakeholderService {
await this.promise;
return this.stakeholderSubject.getValue();
}
getAllStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder/all' + ((type)?('?type=' + type):'')).pipe(map(stakeholders => {
return this.formalize(stakeholders);
}));
}
getStakeholders(url: string, type: string = null): Observable<(Stakeholder & StakeholderInfo)[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder' + ((type)?('?type=' + type):''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
return this.formalize(stakeholders);
@ -69,31 +63,19 @@ export class StakeholderService {
}
buildStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> {
return this.http.post<Stakeholder>(url + '/build-stakeholder', stakeholder).pipe(map(stakeholder => {
return this.http.post<Stakeholder>(url + '/build-stakeholder', stakeholder, CustomOptions.registryOptions()).pipe(map(stakeholder => {
return this.formalize(stakeholder);
}));
}
saveStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> {
return this.http.post<Stakeholder>(url + '/stakeholder/save', stakeholder).pipe(map(stakeholder => {
return this.formalize(stakeholder);
}));
}
toggleVisibility(url: string, path: string[], visibility:Visibility): Observable<Visibility> {
return this.http.post<Visibility>(url + '/' + path.join('/') + '/change-visibility'+'?visibility=' + visibility, null);
}
toggleStatus(url: string, path: string[]): Observable<boolean> {
return this.http.post<boolean>(url + '/' + path.join('/') + '/toggle-status', null);
}
toggleAccess(url: string, path: string[]): Observable<boolean> {
return this.http.post<boolean>(url + '/' + path.join('/') + '/toggle-access', null);
changeVisibility(url: string, path: string[], visibility:Visibility): Observable<any> {
return this.http.post<Visibility>(url + '/' + path.join('/') + '/change-visibility'+'?visibility=' + visibility, null, CustomOptions.registryOptions());
}
saveElement(url: string, element: any, path: string[] = []): Observable<any> {
path = HelperFunctions.encodeArray(path);
return this.http.post<any>(url + ((path.length > 0)?'/':'') + path.join('/') +
'/save', element).pipe(map(element => {
'/save', element, CustomOptions.registryOptions()).pipe(map(element => {
return this.formalize(element);
}));
}
@ -101,7 +83,7 @@ export class StakeholderService {
saveSection(url: string, element: any, path: string[] = [], index: number = -1): Observable<Section> {
path = HelperFunctions.encodeArray(path);
return this.http.post<Section>(url + ((path.length > 0)?'/':'') + path.join('/') +
'/save/' + index, element).pipe(map(element => {
'/save/' + index, element, CustomOptions.registryOptions()).pipe(map(element => {
return this.formalize(element);
}));
}
@ -112,12 +94,12 @@ export class StakeholderService {
if(childrenAction) {
params = "?children="+childrenAction;
}
return this.http.delete<any>(url + '/' + path.join('/') + '/delete'+params);
return this.http.delete<any>(url + '/' + path.join('/') + '/delete'+params, CustomOptions.registryOptions());
}
reorderIndicators(url: string, path: string[], indicatorIds: string[], type: string = 'chart'): Observable<Indicator[]> {
path = HelperFunctions.encodeArray(path);
return this.http.post<Indicator[]>(url + '/' + path.join('/') + '/' + type + '/reorder', indicatorIds).pipe(map(indicators => {
return this.http.post<Indicator[]>(url + '/' + path.join('/') + '/' + type + '/reorder', indicatorIds, CustomOptions.registryOptions()).pipe(map(indicators => {
return this.formalize(indicators);
}));
}