From f452a63947844c226b302242443dd084edc51238 Mon Sep 17 00:00:00 2001 From: "myrto.koukouli" Date: Wed, 11 Apr 2018 13:54:06 +0000 Subject: [PATCH] in statistics: added check if entity is deactivated git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@51758 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../statistics-for-dashboard.component.html | 3 ++ src/app/statistics/statistics.component.html | 8 ++-- src/app/statistics/statistics.component.ts | 39 ++++++++++++++----- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/app/statistics/statistics-for-dashboard.component.html b/src/app/statistics/statistics-for-dashboard.component.html index 590ebbe..6ee23a9 100644 --- a/src/app/statistics/statistics-for-dashboard.component.html +++ b/src/app/statistics/statistics-for-dashboard.component.html @@ -3,6 +3,9 @@ Most recent statistics +
+ No statistics are available for {{ communityId.toUpperCase() }} +
diff --git a/src/app/statistics/statistics.component.html b/src/app/statistics/statistics.component.html index 10d8634..81fc5c3 100644 --- a/src/app/statistics/statistics.component.html +++ b/src/app/statistics/statistics.component.html @@ -3,13 +3,13 @@
-
+
No statistics are available for {{ communityId.toUpperCase() }}
-
+
    -
  • +
  • {{ entitiesMap.get(entity) }} statistics

    diff --git a/src/app/statistics/statistics.component.ts b/src/app/statistics/statistics.component.ts index ffa248a..958090c 100644 --- a/src/app/statistics/statistics.component.ts +++ b/src/app/statistics/statistics.component.ts @@ -35,9 +35,9 @@ export class StatisticsComponent { properties:EnvProperties; @Input() communityId = null; - public communityInfo = null; @Input() currentMode = 'showInMonitor'; + communityInfo: any = null; entitiesList: string[] = []; entitiesMap: Map = availableEntitiesMap; chartCatsList: string[] = availableCharts; @@ -66,6 +66,7 @@ export class StatisticsComponent { private _communityService:CommunityService, private _communitiesService:CommunitiesService, private _statisticsService: StatisticsService, + private _configService: ConfigurationService, private titleCase: TitleCasePipe, private sanitizer: DomSanitizer ) { @@ -105,7 +106,7 @@ export class StatisticsComponent { } -d + public ngOnDestroy() { if(this.piwiksub){ this.piwiksub.unsubscribe(); @@ -143,21 +144,37 @@ d }, () => { this.createChartUrlMap(); - this.initializeDisplayedCharts(); + this.getCommunityInfo(); } ); } + getCommunityInfo() { + console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`); + this._configService.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe( + res => { + this.communityInfo = res; + /*for(let i=0; i console.log(error), + () => this.initializeDisplayedCharts() + ); + } + initializeDisplayedCharts() { let firstEntity: string; this.entitiesList = Array.from( this.entitiesMap.keys() ); console.log('this.entitiesList is',this.entitiesList); console.log(`my current mode is: ${this.currentMode}`); for (let entity of this.entitiesList) { - if (this.statisticsDisplay.entities[entity] && this.statisticsSum[entity].total) { - console.log(`added ${entity} to allowedEntities`); - this.allowedEntities.push(entity); + if (this.statisticsDisplay.entities[entity] && this.statisticsSum[entity].total && this.communityInfo.entities.filter(x => x['pid'] == entity && x['isEnabled']===true).length ) { this.allowedCharts[entity] = []; for (let chart of this.chartCatsList){ if (this.statisticsSum[entity].total && @@ -169,9 +186,13 @@ d /*console.log(`added ${entity} - ${chart} to allowedCharts`);*/ } } - if (!firstEntity){ - firstEntity = entity; - this.onChangeEntity(entity); + if (this.allowedCharts[entity].length) { + console.log(`added ${entity} to allowedEntities`); + this.allowedEntities.push(entity); + if (!firstEntity){ + firstEntity = entity; + this.onChangeEntity(entity); + } } } }