openaire-library/utils/helper/helper.service.ts

34 lines
1.2 KiB
TypeScript

import {Injectable, Inject} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../properties/env-properties';
@Injectable()
export class HelperService {
constructor(private http: Http) {}
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.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json());
}
}