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";
|
|
|
|
|
|
|
|
|
2020-04-23 17:58:04 +02:00
|
|
|
import {EnvProperties} from '../properties/env-properties';
|
2020-11-25 18:12:31 +01:00
|
|
|
import {of} from "rxjs";
|
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
|
|
|
|
2020-07-13 00:14:50 +02:00
|
|
|
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
2019-06-03 15:20:36 +02:00
|
|
|
//.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-11-25 18:12:31 +01:00
|
|
|
if(typeof properties.useHelpTexts == "undefined" || properties.useHelpTexts) {
|
|
|
|
let page_route: string = router.split('?')[0].substring(0);
|
|
|
|
let url = properties.adminToolsAPIURL;
|
|
|
|
url += '/' + properties.adminToolsPortalType + '/' + communityId + '/pagehelpcontent/grouped?active=true&page=' + page_route;
|
|
|
|
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
|
|
|
}else {
|
|
|
|
return of(null);
|
|
|
|
}
|
2019-07-18 13:34:19 +02:00
|
|
|
}
|
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-11-25 18:12:31 +01:00
|
|
|
if(typeof properties.useHelpTexts == "undefined" || properties.useHelpTexts) {
|
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-09-24 13:18:24 +02:00
|
|
|
url += '/'+properties.adminToolsPortalType+'/' + communityId + '/divhelpcontent/grouped?active=true&page='+page_route;
|
2020-07-13 00:14:50 +02:00
|
|
|
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
2020-11-25 18:12:31 +01:00
|
|
|
}else {
|
|
|
|
return of(null);
|
|
|
|
}
|
2019-07-18 13:34:19 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|