[Trunk|Library]: 1. Helper Service: Add two new functions to get page contents of a page, mapping by posistion, and div contents, mapping by id. 2. Helper Component: Remove call to api to avoid multi requests. Make texts as parameters.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56620 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e189697ed9
commit
df37f2328f
|
@ -22,58 +22,11 @@ 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,) {}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
constructor () {}
|
||||
|
||||
buildTooltip(): string {
|
||||
var text:string="<div class='uk-padding-small uk-width-xxlarge'>";
|
||||
|
@ -84,7 +37,4 @@ buildTooltip():string{
|
|||
return text;
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Helper (component): "+message, error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue