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";
|
2024-03-27 08:29:07 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HelperService {
|
2024-06-27 14:36:38 +02:00
|
|
|
constructor(private http: HttpClient) {
|
|
|
|
}
|
2018-02-13 15:52:23 +01:00
|
|
|
|
2024-06-27 14:36:38 +02:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
getHelper(router: string, position: string, before: boolean, div: string, properties: EnvProperties, communityId: string): any {
|
|
|
|
//console.info("get router helpText for : "+router+" - position="+position+" - before="+before + " - div="+div);
|
2018-02-13 15:52:23 +01:00
|
|
|
|
2024-06-27 14:36:38 +02:00
|
|
|
let url = properties.adminToolsAPIURL;
|
|
|
|
if (div) {
|
2024-09-05 11:59:25 +02:00
|
|
|
url += 'divhelpcontent?active=true&community=' + communityId + '&page=' + router + '&div=' + div;
|
2024-06-27 14:36:38 +02:00
|
|
|
} else {
|
2024-09-05 11:59:25 +02:00
|
|
|
url += 'pagehelpcontent?active=true&community=' + communityId + '&page=' + router + '&position=' + position;
|
2024-06-27 14:36:38 +02:00
|
|
|
if (before) {
|
|
|
|
url += '&before=' + before;
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2024-06-27 14:36:38 +02:00
|
|
|
return this.http.get(/*(properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)+ (properties.forceCacheReload?'&forceReload=true':'')):*/ url);
|
|
|
|
//.map(res => <any> res.json());
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2024-06-27 14:36:38 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2024-06-27 14:36:38 +02:00
|
|
|
getPageHelpContents(properties: EnvProperties, portal: string, router: string, portalType = properties.adminToolsPortalType): any {
|
|
|
|
if (!portal) {
|
|
|
|
portal = properties.adminToolsCommunity;
|
2019-07-18 13:34:19 +02:00
|
|
|
}
|
2024-06-27 14:36:38 +02:00
|
|
|
if (!portal) {
|
|
|
|
portal = 'openaire';
|
|
|
|
}
|
|
|
|
if (typeof properties.useHelpTexts == "undefined" || properties.useHelpTexts) {
|
|
|
|
let page_route: string = router.split('?')[0].substring(0);
|
|
|
|
let url = properties.adminToolsAPIURL;
|
2024-09-05 11:59:25 +02:00
|
|
|
url += portalType + '/' + portal + '/pagehelpcontent/grouped?active=true&page=' +
|
2024-06-27 14:36:38 +02:00
|
|
|
((page_route.indexOf("/" + portal + "/") != -1) ? ("/" + page_route.split("/" + portal + "/")[1]) : page_route);
|
|
|
|
return this.http.get(/*(properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)+ (properties.forceCacheReload?'&forceReload=true':'')) :*/ url);
|
|
|
|
} else {
|
|
|
|
return of(null);
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2024-06-27 14:36:38 +02:00
|
|
|
getDivHelpContents(properties: EnvProperties, communityId: string, router: string): any {
|
|
|
|
if (!communityId) {
|
|
|
|
communityId = properties.adminToolsCommunity;
|
|
|
|
}
|
|
|
|
if (!communityId) {
|
|
|
|
communityId = 'openaire';
|
|
|
|
}
|
|
|
|
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;
|
2024-09-05 11:59:25 +02:00
|
|
|
url += properties.adminToolsPortalType + '/' + communityId + '/divhelpcontent/grouped?active=true&page=' +
|
2024-06-27 14:36:38 +02:00
|
|
|
((page_route.indexOf("/" + communityId + "/") != -1) ? ("/" + page_route.split("/" + communityId + "/")[1]) : page_route);
|
|
|
|
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url) + (properties.forceCacheReload ? '&forceReload=true' : '')) : url);
|
|
|
|
} else {
|
|
|
|
return of(null);
|
2019-07-18 13:34:19 +02:00
|
|
|
}
|
2024-06-27 14:36:38 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|