[Monitor]: Add indicators.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor@57363 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2019-10-14 12:31:00 +00:00
parent e0e2e4741b
commit 6232905500
5 changed files with 48 additions and 7 deletions

View File

@ -31,5 +31,8 @@
</div> </div>
<div uk-grid> <div uk-grid>
<sidebar [menuItems]="sideMenuItems" class="uk-width-1-5 sidebar"></sidebar> <sidebar [menuItems]="sideMenuItems" class="uk-width-1-5 sidebar"></sidebar>
<div class="uk-width-expand uk-padding">
<h5 class="uk-margin-bottom">Indicators</h5>
</div>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@ import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.com
import {HelperService} from "../openaireLibrary/utils/helper/helper.service"; import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service"; import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
import {StakeholderService} from "../services/stakeholder.service"; import {StakeholderService} from "../services/stakeholder.service";
import {Category, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder"; import {Category, Indicator, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
import {MenuItem, RootMenuItem, SideMenuItem} from "../openaireLibrary/sharedComponents/menu"; import {MenuItem, RootMenuItem, SideMenuItem} from "../openaireLibrary/sharedComponents/menu";
@Component({ @Component({
@ -30,6 +30,8 @@ export class MonitorComponent {
public sideMenuItems: SideMenuItem[] = null; public sideMenuItems: SideMenuItem[] = null;
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
public stakeholder: Stakeholder; public stakeholder: Stakeholder;
public numbers: Indicator[] = [];
public charts: Indicator[] = [];
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
properties: EnvProperties; properties: EnvProperties;
@ -115,6 +117,7 @@ export class MonitorComponent {
} }
if(this.activeSubCategory) { if(this.activeSubCategory) {
this.setSideBar(); this.setSideBar();
this.setIndicators();
return; return;
} }
} }
@ -152,6 +155,15 @@ export class MonitorComponent {
}); });
} }
private setIndicators() {
this.stakeholderService.getIndicators(this.activeSubCategory.numbers).subscribe( numbers => {
this.numbers = numbers;
});
this.stakeholderService.getIndicators(this.activeSubCategory.charts).subscribe( charts => {
this.charts = charts;
});
}
public navigateToError() { public navigateToError() {
this._router.navigate(['/error'],{queryParams: {'page': this._router.url}}); this._router.navigate(['/error'],{queryParams: {'page': this._router.url}});
} }

View File

@ -1,8 +1,10 @@
import {Injectable} from "@angular/core"; import {Injectable} from "@angular/core";
import {HttpClient, HttpErrorResponse} from "@angular/common/http"; import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable} from "rxjs"; import {Observable} from "rxjs";
import {Stakeholder} from "../utils/entities/stakeholder"; import {Indicator, Stakeholder} from "../utils/entities/stakeholder";
import {map} from "rxjs/operators"; import {map} from "rxjs/operators";
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
import {response} from "express";
@Injectable() @Injectable()
export class StakeholderService { export class StakeholderService {
@ -26,4 +28,28 @@ export class StakeholderService {
} }
})); }));
} }
getIndicator(id: string): Observable<Indicator> {
return this.http.get<any>('./assets/stakeholders.json').pipe(map(json => {
return json.indicators.filter(indicator => indicator.id === id)[0];
}))
}
getIndicators(ids: string[]): Observable<Indicator[]> {
return this.http.get<any>('./assets/stakeholders.json').pipe(map(json => {
return json.indicators.filter(indicator => ids.indexOf(indicator.id) !== -1);
}))
}
getNumber(properties: EnvProperties, url: string, jsonPath: string[], stakeholder: Stakeholder): Observable<any> {
const statsUrl = url.replace('{index_shortName}', stakeholder.index_shortName).
replace('{index_id}', stakeholder.index_id).
replace('{index_name}', stakeholder.index_name);
return this.http.get<any>(properties.statisticsAPIURL + statsUrl).pipe(map(response => {
jsonPath.forEach(field => {
response = response[field];
});
return response;
}));
}
} }

View File

@ -49,7 +49,7 @@ export class Indicator {
tags:string[]; tags:string[];
isActive: boolean; isActive: boolean;
isPublic: boolean; isPublic: boolean;
urls:IndicatorPath[]; indicatorPaths:IndicatorPath[];
} }
export class IndicatorPath { export class IndicatorPath {

View File

@ -235,7 +235,7 @@
"indicatorPaths": [ "indicatorPaths": [
{ {
"type": "", "type": "",
"url": "/stats-api/funders/{index_shortname}", "url": "/funders/{index_shortName}",
"jsonPath": [ "jsonPath": [
"statistics", "statistics",
"publications" "publications"
@ -256,7 +256,7 @@
"indicatorPaths": [ "indicatorPaths": [
{ {
"type": "", "type": "",
"url": "/stats-api/funders/{index_shortname}", "url": "/funders/{index_shortName}",
"jsonPath": [ "jsonPath": [
"statistics", "statistics",
"open" "open"
@ -277,7 +277,7 @@
"indicatorPaths": [ "indicatorPaths": [
{ {
"type": "", "type": "",
"url": "/stats-api/funders/{index_shortname}", "url": "/funders/{index_shortName}",
"jsonPath": [ "jsonPath": [
"statistics", "statistics",
"embargo" "embargo"
@ -303,7 +303,7 @@
}, },
{ {
"type": "table", "type": "table",
"url": "https://www.openaire.eu/stats/gtable.php?com=query&data={%22table%22:%22result%22,%22fields%22:[{%22fld%22:%22number%22,%22agg%22:%22count%22,%22type%22:%22pie%22,%22yaxis%22:1,%22c%22:false}],%22xaxis%22:{%22name%22:%22result_projects-project-title%22,%22agg%22:%22avg%22},%22group%22:%22%22,%22color%22:%22%22,%22type%22:%22chart%22,%22size%22:%2230%22,%22sort%22:%22count-number%22,%22yaxisheaders%22:[%22%22],%22fieldsheaders%22:[%22publications%22],%22in%22:[],%22filters%22:[{%22name%22:%22result_projects-project-funder%22,%22values%22:[%22{index_name}%22],%22to%22:%22-1%22},{%22name%22:%22type%22,%22values%22:[%22publication%22],%22to%22:%22-1%22}],%22having%22:[],%22xStyle%22:{%22r%22:-90,%22s%22:%22-%22,%22l%22:%22-%22,%22ft%22:10,%22wt%22:%22-%22},%22title%22:%22{index_shortname}%20Publications%20by%20project%20(top%2030)%22,%22subtitle%22:%22%22,%22xaxistitle%22:%22project%22,%22order%22:%22d%22}", "url": "https://www.openaire.eu/stats/gtable.php?com=query&data={%22table%22:%22result%22,%22fields%22:[{%22fld%22:%22number%22,%22agg%22:%22count%22,%22type%22:%22pie%22,%22yaxis%22:1,%22c%22:false}],%22xaxis%22:{%22name%22:%22result_projects-project-title%22,%22agg%22:%22avg%22},%22group%22:%22%22,%22color%22:%22%22,%22type%22:%22chart%22,%22size%22:%2230%22,%22sort%22:%22count-number%22,%22yaxisheaders%22:[%22%22],%22fieldsheaders%22:[%22publications%22],%22in%22:[],%22filters%22:[{%22name%22:%22result_projects-project-funder%22,%22values%22:[%22{index_name}%22],%22to%22:%22-1%22},{%22name%22:%22type%22,%22values%22:[%22publication%22],%22to%22:%22-1%22}],%22having%22:[],%22xStyle%22:{%22r%22:-90,%22s%22:%22-%22,%22l%22:%22-%22,%22ft%22:10,%22wt%22:%22-%22},%22title%22:%22{index_shortName}%20Publications%20by%20project%20(top%2030)%22,%22subtitle%22:%22%22,%22xaxistitle%22:%22project%22,%22order%22:%22d%22}",
"jsonPath": [] "jsonPath": []
} }
] ]