import {Injectable} from '@angular/core'; import {HttpClient} from "@angular/common/http"; import {EnvProperties} from '../properties/env-properties'; import {of} from "rxjs"; @Injectable() export class HelperService { constructor(private http: HttpClient) {} /** * @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); let url = properties.adminToolsAPIURL; if(div) { url += '/divhelpcontent?active=true&community='+communityId+'&page='+router+'&div=' + div; } else { url += '/pagehelpcontent?active=true&community='+communityId+'&page='+router+'&position=' + position; if(before) { url += '&before='+before; } } return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url); //.map(res => res.json()); } getPageHelpContents(properties:EnvProperties, communityId:string, router: string):any { if(!communityId) { communityId = properties.adminToolsCommunity; } if(!communityId) { communityId = 'openaire'; } 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.indexOf("/"+communityId+"/")!=-1 ) ? ("/" + page_route.split("/"+communityId+"/")[1]) : page_route); return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url); }else { return of(null); } } getDivHelpContents(properties:EnvProperties, communityId:string, router: string):any { if(!communityId) { communityId = properties.adminToolsCommunity; } if(!communityId) { communityId = 'openaire'; } if(typeof properties.useHelpTexts == "undefined" || properties.useHelpTexts) { let page_route: string = router.split('?')[0].substring(0); let url = properties.adminToolsAPIURL; url += '/'+properties.adminToolsPortalType+'/' + communityId + '/divhelpcontent/grouped?active=true&page='+ ((page_route.indexOf("/"+communityId+"/")!=-1 ) ? ("/" + page_route.split("/"+communityId+"/")[1]) : page_route); return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url); }else { return of(null); } } }