[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
This commit is contained in:
Konstantinos Triantafyllou 2020-11-04 15:53:08 +00:00
parent f0bf5934dc
commit a75fe03511
2 changed files with 35 additions and 1 deletions

View File

@ -78,6 +78,9 @@
<div class="uk-text-center uk-text-bold"> <div class="uk-text-center uk-text-bold">
{{indicator.name ? indicator.name : 'No title available'}} {{indicator.name ? indicator.name : 'No title available'}}
</div> </div>
<h3 *ngIf="numberResults.get(i + '-' + j)" class="uk-margin-medium-top uk-text-center uk-text-bold">
<span>{{numberResults.get(i + '-' + j) | number}}</span>
</h3>
<div *ngIf="indicator.description" class="uk-width-1-1 uk-text-muted uk-text-small uk-margin-small-top"> <div *ngIf="indicator.description" class="uk-width-1-1 uk-text-muted uk-text-small uk-margin-small-top">
{{indicator.description}} {{indicator.description}}
</div> </div>

View File

@ -80,7 +80,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
public editing: boolean = false; public editing: boolean = false;
/** Safe Urls*/ /** Safe Urls*/
public safeUrls: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>([]); public safeUrls: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>([]);
public numberResults: Map<string, number> = new Map<string, number>();
private subscriptions: any[] = []; private subscriptions: any[] = [];
private urlSubscriptions: any[] = []; private urlSubscriptions: any[] = [];
@ViewChild('editChartModal') editChartModal: AlertModal; @ViewChild('editChartModal') editChartModal: AlertModal;
@ -148,6 +148,36 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.setPreview(); this.setPreview();
} }
setNumberIndicators() {
this.numberResults.clear();
let urls: Map<string, [number, number][]> = new Map<string, [number, number][]>();
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() { setPreview() {
if(this.stakeholder){ if(this.stakeholder){
this.preview = '/' + this.stakeholder.alias; 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.filterByKeyword(HelperFunctions.copy(this.numbers), this.filters.value.keyword),
this.filters.value.status); this.filters.value.status);
this.buildSections(); this.buildSections();
this.setNumberIndicators();
} }
onChartTypeChange(value) { onChartTypeChange(value) {