diff --git a/utils/helper/helper.component.ts b/utils/helper/helper.component.ts index abf1e072..e33cfa3d 100644 --- a/utils/helper/helper.component.ts +++ b/utils/helper/helper.component.ts @@ -22,69 +22,19 @@ import {SafeHtmlPipe} from '../pipes/safeHTML.pipe'; ` }) export class HelperComponent { - texts=[]; + @Input() texts = []; @Input() style:boolean = false; - @Input() position:string = 'right'; - @Input() before: boolean; - @Input() div: string; @Input() styleName:string = ''; @Input() tooltip:boolean = false; - sub:any; - properties:EnvProperties; - communityId = null; - constructor (private _service: HelperService, private route: ActivatedRoute,) {} + constructor () {} - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe( - params => { - this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); - if(!this.communityId) { - this.communityId = params['communityId']; - } - - if(!this.communityId){ - this.communityId = this.properties.adminToolsCommunity; - } - if(this.properties.enableHelper && typeof document != 'undefined'){ - //this.sub = this._service.getHelper(location.pathname, this.properties).subscribe( - this.sub = this._service.getHelper(location.pathname, this.position, this.before, this.div, this.properties, this.communityId).subscribe( - data => { - //this.texts =(data && data.content && data.content[this.position] )? data.content[this.position]:[]; - this.texts = data; - }, - err => { - //console.log(err); - if(this.div) { - this.handleError("Error getting helper for route: "+location.pathname+" and div: "+this.div+" in community with id: "+this.communityId, err); - } else { - this.handleError("Error getting helper for route: "+location.pathname+", position: "+this.position+", before parameter:"+this.before+" in community with id: "+this.communityId, err); - } - } - ); - } - }); - }); - } - - ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); + buildTooltip(): string { + var text:string="
"; + for(var i=0; i< this.texts.length; i++){ + text+=this.texts[i].content; } + text+="
"; + return text; } -buildTooltip():string{ - var text:string="
"; - for(var i=0; i< this.texts.length; i++){ - text+=this.texts[i].content; - } - text+="
"; - return text; -} - - private handleError(message: string, error) { - console.error("Helper (component): "+message, error); - } } diff --git a/utils/helper/helper.service.ts b/utils/helper/helper.service.ts index bfd8833c..7d9d5432 100644 --- a/utils/helper/helper.service.ts +++ b/utils/helper/helper.service.ts @@ -1,7 +1,5 @@ -import {Injectable, Inject} from '@angular/core'; -import {Http, Response} from '@angular/http'; +import {Injectable} from '@angular/core'; import {HttpClient} from "@angular/common/http"; -import {Observable} from 'rxjs'; @@ -11,7 +9,7 @@ import{EnvProperties} from '../properties/env-properties'; export class HelperService { constructor(private http: HttpClient) {} - getHelper (router: string, position: string, before: boolean, div: string, properties:EnvProperties,communityId:string ):any { + 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; @@ -29,6 +27,16 @@ export class HelperService { } + getPageHelpContents(router: string, properties:EnvProperties, communityId:string ):any { + let url = properties.adminToolsAPIURL; + url += '/community/' + communityId + '/pagehelpcontent?active=true&page='+router; + return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url); + } + getDivHelpContents(router: string, properties:EnvProperties, communityId:string ):any { + let url = properties.adminToolsAPIURL; + url += '/community/' + communityId + '/divhelpcontent?active=true&page='+router; + return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url); + } }