Fix indicatator path undefiend in dashboard if subcategory is changed quickly.

This commit is contained in:
Konstantinos Triantafyllou 2023-03-28 14:23:05 +03:00
parent a9a849a309
commit cc788e95dc
1 changed files with 14 additions and 12 deletions

View File

@ -487,21 +487,23 @@ export class MonitorComponent implements OnInit, OnDestroy {
this.subscriptions.push(this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => { this.subscriptions.push(this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => {
if(activeSubcategory === this.activeSubCategory._id) { if(activeSubcategory === this.activeSubCategory._id) {
indexes.forEach(([i, j]) => { indexes.forEach(([i, j]) => {
let result = JSON.parse(JSON.stringify(response)); if( this.activeSubCategory?.numbers[i]?.indicators[j]) {
this.activeSubCategory.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => { let result = JSON.parse(JSON.stringify(response));
if (result) { this.activeSubCategory.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
result = result[jsonPath]; if (result) {
} result = result[jsonPath];
}); }
if (typeof result === 'string' || typeof result === 'number') { });
result = Number(result); if (typeof result === 'string' || typeof result === 'number') {
if (result === Number.NaN) { result = Number(result);
if (result === Number.NaN) {
result = 0;
}
} else {
result = 0; result = 0;
} }
} else { this.numberResults.set(i + '-' + j, result);
result = 0;
} }
this.numberResults.set(i + '-' + j, result);
}); });
} }
})); }));