Project

General

Profile

1
import {Injectable} from '@angular/core';
2
import {HttpClient} from "@angular/common/http";
3

    
4

    
5

    
6
import{EnvProperties} from '../properties/env-properties';
7

    
8
@Injectable()
9
export class HelperService {
10
    constructor(private http: HttpClient) {}
11

    
12
    getHelper (router: string, position: string, before: boolean, div: string, properties:EnvProperties, communityId:string ):any {
13
        //console.info("get router helpText for : "+router+" - position="+position+" - before="+before + " - div="+div);
14

    
15
        let url = properties.adminToolsAPIURL;
16
        if(div) {
17
          url += '/divhelpcontent?active=true&community='+communityId+'&page='+router+'&div=' + div;
18
        } else {
19
          url += '/pagehelpcontent?active=true&community='+communityId+'&page='+router+'&position=' + position;
20
          if(before) {
21
            url += '&before='+before;
22
          }
23
        }
24

    
25
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
26
                    //.map(res => <any> res.json());
27

    
28
    }
29

    
30
    getPageHelpContents(router: string, properties:EnvProperties, communityId:string ):any {
31
      if(!communityId) {
32
        communityId = 'openaire';
33
      }
34
      router = router.split('?')[0].substring(0);
35
      let url = properties.adminToolsAPIURL;
36
      url += '/community/' + communityId + '/pagehelpcontent?active=true&page='+router;
37
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
38
    }
39

    
40
    getDivHelpContents(router: string, properties:EnvProperties, communityId:string ):any {
41
      if(!communityId) {
42
        communityId = 'openaire';
43
      }
44
      router = router.split('?')[0].substring(0);
45
      let url = properties.adminToolsAPIURL;
46
      url += '/community/' + communityId + '/divhelpcontent?active=true&page='+router;
47
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
48
    }
49

    
50
}
(3-3/4)