[Monitor Dashboard|Trunk]
Number indicators: edit available only for portal admins parsing the url to parameterize and work for other indicators when requesting to get the numbers use the getNumberUrl to properly set the stakeholder id git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@58924 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
89ab45bc63
commit
28e432bf54
|
@ -311,7 +311,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
|
|||
});
|
||||
urls.forEach((indexes, pair) => {
|
||||
pair = JSON.parse(pair);
|
||||
this.statisticsService.getNumbers(pair[0], pair[1]).subscribe(response => {
|
||||
this.statisticsService.getNumbers(pair[0], IndicatorUtils.getNumberUrl(this.stakeholder, pair[1])).subscribe(response => {
|
||||
indexes.forEach(([i, j]) => {
|
||||
let result = JSON.parse(JSON.stringify(response));
|
||||
this.activeSubCategory.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
||||
|
|
|
@ -408,6 +408,24 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
source: this.fb.control(source, Validators.required)
|
||||
}
|
||||
));
|
||||
|
||||
for(let index = 0; index < this.numberIndicatorPaths.length; index++) {
|
||||
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('url').valueChanges.subscribe(value => {
|
||||
if (this.numberIndicatorPaths.at(index).get('url').valid) {
|
||||
let indicatorPath: IndicatorPath = this.indicatorUtils.parseNumberIndicatortUrl(this.numberIndicatorPaths.at(index).get('source').value, value, this.stakeholder);
|
||||
// if(indicatorPath.url.indexOf("index_id") ==-1 && indicatorPath.url.indexOf("index_name") ==-1 && (indicatorPath.url).indexOf("index_shortName") ==-1 ){
|
||||
//
|
||||
// }else {
|
||||
// this.urlParameterizedMessage = "";
|
||||
// }
|
||||
if(value != indicatorPath.url) {
|
||||
(this.numberIndicatorPaths.at(index) as FormGroup).get('url').setValue( indicatorPath.url);
|
||||
}
|
||||
this.indicator.indicatorPaths[index] = indicatorPath;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public addChartIndicatorPath(value: string = '', parameters: FormArray = new FormArray([]), disableUrl: boolean = false, type:string=null) {
|
||||
|
@ -658,7 +676,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
}
|
||||
|
||||
public get isAdministrator(): boolean {
|
||||
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user)
|
||||
return Session.isPortalAdministrator(this.user);
|
||||
// return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user)
|
||||
}
|
||||
|
||||
refreshIndicator() {
|
||||
|
|
|
@ -261,7 +261,20 @@ export class IndicatorUtils {
|
|||
}
|
||||
return indicatorPath.url + encodeURIComponent(replacedUrl);
|
||||
}
|
||||
public static getNumberUrl(stakeholder:Stakeholder,url:string): string {
|
||||
let replacedUrl = url;
|
||||
|
||||
if(url.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) !=- 1){
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
|
||||
}
|
||||
if(url.indexOf(ChartHelper.prefix + 'index_name' + ChartHelper.suffix) !=- 1){
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_name' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_name))
|
||||
}
|
||||
if(url.indexOf(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix) !=- 1){
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
|
||||
}
|
||||
return replacedUrl;
|
||||
}
|
||||
generateIndicatorByForm(form: any, indicatorPaths: IndicatorPath[]): Indicator {
|
||||
let indicator: Indicator = new Indicator(form.name, form.description, 'chart',
|
||||
form.width, form.isActive, form.isPublic, indicatorPaths, form.defaultId);
|
||||
|
@ -277,7 +290,25 @@ export class IndicatorUtils {
|
|||
});
|
||||
return indicator;
|
||||
}
|
||||
|
||||
parseNumberIndicatortUrl(source: SourceType, url: string, stakeholder:Stakeholder): IndicatorPath {
|
||||
let indicatorPath = new IndicatorPath(null, source, url, null, []);
|
||||
try {
|
||||
if (url.indexOf(encodeURIComponent(stakeholder.index_id)) !== -1) {
|
||||
url = url.split(encodeURIComponent(stakeholder.index_id)).join(ChartHelper.prefix + "index_id" + ChartHelper.suffix);
|
||||
}
|
||||
if (url.indexOf(encodeURIComponent(stakeholder.index_name)) !== -1) {
|
||||
url = url.split(encodeURIComponent(stakeholder.index_name)).join(ChartHelper.prefix + "index_name" + ChartHelper.suffix);
|
||||
}
|
||||
if (url.indexOf(encodeURIComponent(stakeholder.index_shortName)) !== -1) {
|
||||
url = url.split(encodeURIComponent(stakeholder.index_shortName)).join(ChartHelper.prefix + "index_shortName" + ChartHelper.suffix);
|
||||
}
|
||||
indicatorPath.url = url;
|
||||
}
|
||||
catch(e){
|
||||
console.error(e);
|
||||
}
|
||||
return indicatorPath;
|
||||
}
|
||||
generateIndicatorByChartUrl(source: SourceType, url: string, type: IndicatorPathType = null, stakeholder:Stakeholder): IndicatorPath {
|
||||
let indicatorPath = new IndicatorPath(type, source, "", "", []);
|
||||
try {
|
||||
|
@ -502,7 +533,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
private extractDataTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let index = 0;
|
||||
if(obj[this.getDescriptionObjectName(obj)] && obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]){
|
||||
if(!obj[this.getDescriptionObjectName(obj)] || !obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]){
|
||||
return;
|
||||
}
|
||||
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
||||
|
|
Loading…
Reference in New Issue