From a75fe0351116baee67502ba7c7818e779cc32692 Mon Sep 17 00:00:00 2001 From: Konstantinos Triantafyllou Date: Wed, 4 Nov 2020 15:53:08 +0000 Subject: [PATCH] [Monitor Dashboard | Trunk]: Add number preview on indicators component git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59770 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/topic/indicators.component.html | 3 +++ src/app/topic/indicators.component.ts | 33 ++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html index e21d73d..b915fcb 100644 --- a/src/app/topic/indicators.component.html +++ b/src/app/topic/indicators.component.html @@ -78,6 +78,9 @@
{{indicator.name ? indicator.name : 'No title available'}}
+

+ {{numberResults.get(i + '-' + j) | number}} +

{{indicator.description}}
diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts index d748c44..918909b 100644 --- a/src/app/topic/indicators.component.ts +++ b/src/app/topic/indicators.component.ts @@ -80,7 +80,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV public editing: boolean = false; /** Safe Urls*/ public safeUrls: Map = new Map([]); - + public numberResults: Map = new Map(); private subscriptions: any[] = []; private urlSubscriptions: any[] = []; @ViewChild('editChartModal') editChartModal: AlertModal; @@ -148,6 +148,36 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV this.setPreview(); } + setNumberIndicators() { + this.numberResults.clear(); + let urls: Map = new Map(); + this.numbers.forEach((section, i) => { + section.indicators.forEach((number, j) => { + let url =this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, number.indicatorPaths[0]); + const pair = JSON.stringify([number.indicatorPaths[0].source, url]); + const indexes = urls.get(pair) ? urls.get(pair) : []; + indexes.push([i, j]); + urls.set(pair, indexes); + }); + }); + urls.forEach((indexes, pair) => { + pair = JSON.parse(pair); + this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => { + indexes.forEach(([i, j]) => { + let result = JSON.parse(JSON.stringify(response)); + this.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => { + if (result) { + result = result[jsonPath]; + } + }); + if(typeof result == 'string') { + this.numberResults.set(i + '-' + j, Number(result)); + } + }); + }); + }); + } + setPreview() { if(this.stakeholder){ this.preview = '/' + this.stakeholder.alias; @@ -272,6 +302,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV this.filterByKeyword(HelperFunctions.copy(this.numbers), this.filters.value.keyword), this.filters.value.status); this.buildSections(); + this.setNumberIndicators(); } onChartTypeChange(value) {