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
This commit is contained in:
myrto.koukouli 2018-04-11 13:54:06 +00:00
parent 3b4a925203
commit f452a63947
3 changed files with 37 additions and 13 deletions

View File

@ -3,6 +3,9 @@
<span>Most recent statistics</span>
</h2>
</div>
<div *ngIf="!statisticsSum || (statisticsSum.total_projects==0) || (allowedEntities.length == 0)" class="uk-alert uk-alert-info" style="margin-top:40px;">
No statistics are available for {{ communityId.toUpperCase() }}
</div>
<div>
<div *ngFor="let entity of allowedEntities">
<div *ngIf="statisticsSum[entity].total>0 && allowedCharts[entity].length>0">

View File

@ -3,13 +3,13 @@
<div class="uk-container uk-margin-bottom">
<article class="uk-article ">
<div *ngIf="!statisticsSum || (statisticsSum.total_projects==0)" class="uk-alert uk-alert-info" style="margin-top:40px; padding-left:40px;">
<div *ngIf="!statisticsSum || (statisticsSum.total_projects==0) || (allowedEntities.length == 0)" class="uk-alert uk-alert-info" style="margin-top:40px; padding-left:40px;">
No statistics are available for {{ communityId.toUpperCase() }}
</div>
<div *ngIf="statisticsSum && (statisticsSum.total_projects>0) && statisticsDisplay && chartsUrlMap" class="uk-margin uk-margin-top">
<div *ngIf="statisticsSum && (statisticsSum.total_projects>0) && statisticsDisplay" class="uk-margin uk-margin-top">
<div class="uk-grid">
<ul class="uk-tab uk-tab-left uk-width-1-6 uk-margin-top" data-uk-tab="{connect:'#tabs'}">
<li *ngFor="let entity of entitiesList"
<li *ngFor="let entity of allowedEntities"
(click)="onChangeEntity(entity)">
<a href="#">{{ entitiesMap.get(entity) }}</a>
@ -17,7 +17,7 @@
</ul>
<ul id="tabs" class="uk-switcher uk-margin uk-width-5-6" style="min-height:450px; padding-left:40px;">
<li *ngFor="let entity of entitiesList">
<li *ngFor="let entity of allowedEntities">
<div *ngIf="(displayedEntity == entity) && statisticsSum[entity]">
<div class="uk-text-uppercase uk-text-bold uk-heading-divider">
<h2>{{ entitiesMap.get(entity) }} statistics</h2>

View File

@ -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<string,string> = 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<this.communityInfo.entities.length; i++){
if (this.communityInfo.entities[i]["isEnabled"] ) {
this.entitiesList.push(this.communityInfo.entities[i]['pid']);
}
}
console.log(this.entitiesList);*/
},
error => 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);
}
}
}
}