Project

General

Profile

« Previous | Next » 

Revision 57311

[Library]: Layout Service: Fix some issues.

View differences:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/layout.service.ts
1 1
import {Injectable} from '@angular/core';
2 2
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
3
import {throwError} from 'rxjs';
3
import {Observable, throwError} from 'rxjs';
4 4
import {CustomOptions} from './servicesUtils/customOptions.class';
5 5
import {catchError} from 'rxjs/operators';
6
import {CustomizationOptions} from "../connect/community/CustomizationOptions";
6 7

  
7 8
@Injectable()
8 9
export class LayoutService {
......
20 21
        }
21 22
    }
22 23

  
23
    saveLayout(pid: string, url: string, layout: any) {
24
    saveLayout(communityId: string, url: string, layout: CustomizationOptions): Observable<CustomizationOptions> {
24 25
        LayoutService.removeNulls(layout);
25
        return this.http.post(url + 'community/' + pid + '/layout', JSON.stringify(layout), CustomOptions.getAuthOptionsWithBody())
26
            .pipe(catchError(this.handleError));
26
        return this.http.post<CustomizationOptions>(url
27
          + communityId + '/layout', layout, CustomOptions.getAuthOptionsWithBody());
27 28
    }
28 29

  
29
    getLayout(pid: string, url: string) {
30
        return this.http.get(url + 'community/' + pid + '/layout')
31
            .pipe(catchError(this.handleError));
30
    getLayout(communityId: string, url: string): Observable<CustomizationOptions> {
31
        return this.http.get<CustomizationOptions>(url + communityId + '/layout');
32 32
    }
33 33

  
34
    loadDefaultLayout(pid: string, url: string) {
35
        return this.http.post(url + 'community/' + pid + '/resetLayout', null, CustomOptions.getAuthOptionsWithBody())
36
            .pipe(catchError(this.handleError));
37
    }
38

  
39 34
    mockLayout(): any {
40 35
        return this.http.get('./assets/customizationOptions.json') ;
41 36

  

Also available in: Unified diff