2019-07-18 13:34:19 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
2019-06-03 15:20:36 +02:00
|
|
|
import {HttpClient} from "@angular/common/http";
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
import{EnvProperties} from '../properties/env-properties';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HelperService {
|
2019-06-03 15:20:36 +02:00
|
|
|
constructor(private http: HttpClient) {}
|
2018-02-13 15:52:23 +01:00
|
|
|
|
2019-07-18 13:34:19 +02:00
|
|
|
getHelper (router: string, position: string, before: boolean, div: string, properties:EnvProperties, communityId:string ):any {
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("get router helpText for : "+router+" - position="+position+" - before="+before + " - div="+div);
|
2018-02-13 15:52:23 +01:00
|
|
|
|
|
|
|
let url = properties.adminToolsAPIURL;
|
|
|
|
if(div) {
|
2018-03-29 10:23:36 +02:00
|
|
|
url += '/divhelpcontent?active=true&community='+communityId+'&page='+router+'&div=' + div;
|
2018-02-13 15:52:23 +01:00
|
|
|
} else {
|
2018-03-29 10:23:36 +02:00
|
|
|
url += '/pagehelpcontent?active=true&community='+communityId+'&page='+router+'&position=' + position;
|
2018-02-13 15:52:23 +01:00
|
|
|
if(before) {
|
|
|
|
url += '&before='+before;
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-06-03 15:20:36 +02:00
|
|
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
|
|
|
//.map(res => <any> res.json());
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-18 13:34:19 +02:00
|
|
|
getPageHelpContents(router: string, properties:EnvProperties, communityId:string ):any {
|
2019-07-22 11:16:50 +02:00
|
|
|
if(!communityId) {
|
|
|
|
communityId = 'openaire';
|
|
|
|
}
|
|
|
|
router = router.split('?')[0].substring(0);
|
2019-07-18 13:34:19 +02:00
|
|
|
let url = properties.adminToolsAPIURL;
|
|
|
|
url += '/community/' + communityId + '/pagehelpcontent?active=true&page='+router;
|
|
|
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-18 13:34:19 +02:00
|
|
|
getDivHelpContents(router: string, properties:EnvProperties, communityId:string ):any {
|
2019-07-22 11:16:50 +02:00
|
|
|
if(!communityId) {
|
|
|
|
communityId = 'openaire';
|
|
|
|
}
|
|
|
|
router = router.split('?')[0].substring(0);
|
2019-07-18 13:34:19 +02:00
|
|
|
let url = properties.adminToolsAPIURL;
|
|
|
|
url += '/community/' + communityId + '/divhelpcontent?active=true&page='+router;
|
|
|
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|