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
|
|
|
|
2020-04-07 13:15:28 +02:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-07 13:15:28 +02:00
|
|
|
getPageHelpContents(properties:EnvProperties, communityId:string, router: string):any {
|
2019-07-22 11:16:50 +02:00
|
|
|
if(!communityId) {
|
|
|
|
communityId = 'openaire';
|
|
|
|
}
|
2020-04-07 13:15:28 +02:00
|
|
|
let page_route: string = router.split('?')[0].substring(0);
|
2019-07-18 13:34:19 +02:00
|
|
|
let url = properties.adminToolsAPIURL;
|
2020-04-07 13:15:28 +02:00
|
|
|
url += '/community/' + communityId + '/pagehelpcontent?active=true&page='+page_route;
|
2019-07-18 13:34:19 +02:00
|
|
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-04-07 13:15:28 +02:00
|
|
|
getDivHelpContents(properties:EnvProperties, communityId:string, router: string):any {
|
2019-07-22 11:16:50 +02:00
|
|
|
if(!communityId) {
|
|
|
|
communityId = 'openaire';
|
|
|
|
}
|
2020-04-07 13:15:28 +02:00
|
|
|
let page_route: string = router.split('?')[0].substring(0);
|
2019-07-18 13:34:19 +02:00
|
|
|
let url = properties.adminToolsAPIURL;
|
2020-04-07 13:15:28 +02:00
|
|
|
url += '/community/' + communityId + '/divhelpcontent?active=true&page='+page_route;
|
2019-07-18 13:34:19 +02:00
|
|
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|