[Library]: Layout Service: Fix some issues.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57311 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-10-08 13:37:11 +00:00
parent 52b34e317d
commit 23cb60446a
1 changed files with 7 additions and 12 deletions

View File

@ -1,8 +1,9 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {HttpClient, HttpErrorResponse} from '@angular/common/http'; import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {throwError} from 'rxjs'; import {Observable, throwError} from 'rxjs';
import {CustomOptions} from './servicesUtils/customOptions.class'; import {CustomOptions} from './servicesUtils/customOptions.class';
import {catchError} from 'rxjs/operators'; import {catchError} from 'rxjs/operators';
import {CustomizationOptions} from "../connect/community/CustomizationOptions";
@Injectable() @Injectable()
export class LayoutService { export class LayoutService {
@ -20,20 +21,14 @@ export class LayoutService {
} }
} }
saveLayout(pid: string, url: string, layout: any) { saveLayout(communityId: string, url: string, layout: CustomizationOptions): Observable<CustomizationOptions> {
LayoutService.removeNulls(layout); LayoutService.removeNulls(layout);
return this.http.post(url + 'community/' + pid + '/layout', JSON.stringify(layout), CustomOptions.getAuthOptionsWithBody()) return this.http.post<CustomizationOptions>(url
.pipe(catchError(this.handleError)); + communityId + '/layout', layout, CustomOptions.getAuthOptionsWithBody());
} }
getLayout(pid: string, url: string) { getLayout(communityId: string, url: string): Observable<CustomizationOptions> {
return this.http.get(url + 'community/' + pid + '/layout') return this.http.get<CustomizationOptions>(url + communityId + '/layout');
.pipe(catchError(this.handleError));
}
loadDefaultLayout(pid: string, url: string) {
return this.http.post(url + 'community/' + pid + '/resetLayout', null, CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
} }
mockLayout(): any { mockLayout(): any {