From 31824bf208423adf6a5bdf9c3ad0eb05df53f2bb Mon Sep 17 00:00:00 2001 From: Argiro Kokogiannaki Date: Tue, 2 Jun 2020 12:45:08 +0000 Subject: [PATCH] [Monitor|Dashboard] Links to Admin available for monitor Curators, Community Curators and portal administrators Indicators page: Admin: Indicators: add tooltips for active/public show message when stakeholder values couln't be parsed allow urls from different installations of stats-tool indicator Utils: add parsing for echarts library build the chart url using the current stakeholder values (index_id, index_name, etc) git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@58823 d315682c-612b-4755-9ff5-7f18f6832af3 --- package.json | 2 +- src/app/app.component.ts | 7 +++- src/app/monitor/monitor.component.html | 12 ++++--- src/app/monitor/monitor.component.ts | 24 ++++++++------ src/app/topic/indicators.component.html | 22 +++++++----- src/app/topic/indicators.component.ts | 21 +++++++++--- src/app/utils/indicator-utils.ts | 35 +++++++++++++++----- src/app/utils/services/statistics.service.ts | 32 +++++++++--------- src/assets/env-properties.json | 2 +- src/index.html | 16 --------- 10 files changed, 105 insertions(+), 68 deletions(-) diff --git a/package.json b/package.json index 9bd2362..8c940e8 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "start:ssr": "npm run build:ssr && npm run serve:ssr", "start:prerender": "npm run build:prerender && npm run serve:prerender", "build": "ng build", - "build:client-and-server-bundles": "ng build --prod --sourceMap --stats-json=true && ng run ng-universal-demo:server:production", + "build:client-and-server-bundles": "ng build --prod --sourceMap --stats-json=true --base-href /monitor/dashboard/ && ng run ng-universal-demo:server:production", "build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender", "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server", "generate:prerender": "cd dist && node prerender", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index cf98d00..0cb22db 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -112,10 +112,15 @@ export class AppComponent implements OnInit, OnDestroy { buildMenu() { this.userMenuItems = []; - if (Session.isPortalAdministrator(this.user)) { +/* if (Session.isPortalAdministrator(this.user)) { this.userMenuItems.push(new MenuItem("", "Manage helptexts", "", "/helptexts", true, [], [], {communityId:'openaire'})) + }*/ + if (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user)) { + this.userMenuItems.push(new MenuItem("", "Manage Stakeholders", + "", "/admin", true, [], [], {communityId:'openaire'})) + } if (this.user) { this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); diff --git a/src/app/monitor/monitor.component.html b/src/app/monitor/monitor.component.html index 8167223..85054df 100644 --- a/src/app/monitor/monitor.component.html +++ b/src/app/monitor/monitor.component.html @@ -173,10 +173,14 @@ - -
settings
-
+
+
+ + settings + + settings +
+
diff --git a/src/app/monitor/monitor.component.ts b/src/app/monitor/monitor.component.ts index 55e4dea..ba37faa 100644 --- a/src/app/monitor/monitor.component.ts +++ b/src/app/monitor/monitor.component.ts @@ -21,6 +21,7 @@ import {Subscription} from "rxjs"; import {Session, User} from "../openaireLibrary/login/utils/helper.class"; import {MenuItem} from "../openaireLibrary/sharedComponents/menu"; import {UserManagementService} from "../openaireLibrary/services/user-management.service"; +import {StakeholderCreator} from "../utils/entities/stakeholderCreator"; @Component({ selector: 'monitor', @@ -114,18 +115,18 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent // if (params['stakeholder'] == "fwf") { // stakeholder = new Stakeholder(null, "funder", "fwf_________::FWF", "Austrian Science Fund (FWF)", "FWF", // "fwf", true, true, null); - // stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics); + // stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile(stakeholder).topics); // stakeholder.logoUrl = "./assets/fwf.png"; // } else if (params['stakeholder'] == "arc") { // stakeholder = new Stakeholder(null, "funder", "arc_________::ARC", // "Australian Research Council (ARC)", "ARC", "arc", true, true, null); - // stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics); + // stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile(stakeholder).topics); // stakeholder.logoUrl = "./assets/arc1.gif"; - // } else { + // } else if (params['stakeholder'] == "ec") { // stakeholder = new Stakeholder(null, "funder", "ec__________::EC", // "European Commission", "EC", // "ec", true, true, null); - // stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics); + // stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile(stakeholder).topics); // stakeholder.logoUrl = "./assets/ec.png"; // } if (stakeholder) { @@ -346,7 +347,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent public getUrlByStakeHolder(indicatorPath: IndicatorPath) { return this.sanitizer.bypassSecurityTrustResourceUrl( - this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath, this.fundingL0, this.startYear, this.endYear))); + this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath, this.fundingL0, this.startYear, this.endYear))); } public setActiveChart(i: number, j: number, type: string) { @@ -377,10 +378,13 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent buildMenu() { this.userMenuItems = []; - if (Session.isPortalAdministrator(this.user)) { - this.userMenuItems.push(new MenuItem("", "Manage helptexts", - ((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {})) - + // if (Session.isPortalAdministrator(this.user)) { + // this.userMenuItems.push(new MenuItem("", "Manage helptexts", + // ((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {})) + // + // } + if (this.user) { + this.userMenuItems.push(new MenuItem("", "Manage Stakeholders", "", "/admin", false, [], [], {})); } if (this.user) { this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); @@ -388,7 +392,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent } isAdmin(){ - return this.user && Session.isPortalAdministrator(this.user); + return this.user && (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isMonitorCurator(this.user)); } isLoggedIn() { diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html index 317ea62..c6c1e10 100644 --- a/src/app/topic/indicators.component.html +++ b/src/app/topic/indicators.component.html @@ -137,11 +137,11 @@
{{indicator.description}}
-
+
{{indicatorUtils.isPublicIcon.get(indicator.isPublic)}}
{{(indicator.isPublic) ? 'Public' : 'Private'}}
-
+
{{indicatorUtils.isActiveIcon}}
{{(indicator.isActive) ? 'Active' : 'Inactive'}}
@@ -198,13 +198,13 @@ {{indicatorPath.type + ' Chart'}}
-
+
{{indicatorUtils.isPublicIcon.get(indicator.isPublic)}} {{(indicator.isPublic) ? 'Public' : 'Private'}}
-
+
{{indicatorUtils.isActiveIcon}} @@ -247,21 +247,23 @@
{{indicatorPath.type + ' Chart'}}
-
+
{{indicatorUtils.isPublicIcon.get(indicator.isPublic)}}
{{(indicator.isPublic) ? 'Public' : 'Private'}}
-
+
{{indicatorUtils.isActiveIcon}}
{{(indicator.isActive) ? 'Active' : 'Inactive'}}
@@ -338,8 +340,12 @@
+
+ {{urlParameterizedMessage}} +
{ section.indicators.forEach(indicator => { indicator.indicatorPaths.forEach(indicatorPath => { - let url = this.indicatorUtils.getFullUrl(indicatorPath); + let url = this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath); if (!this.safeUrls.get('url')) { indicatorPath.safeResourceUrl = this.getSecureUrlByStakeHolder(indicatorPath); this.safeUrls.set(url, indicatorPath.safeResourceUrl); @@ -357,11 +358,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV private getSecureUrlByStakeHolder(indicatorPath: IndicatorPath) { return this.sanitizer.bypassSecurityTrustResourceUrl( - this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath))); + this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath))); } private getUrlByStakeHolder(indicatorPath: IndicatorPath) { - return this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath)); + return this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)); } public addIndicatorPath(value: string = '', parameters: FormArray = new FormArray([]), disableUrl: boolean = false) { @@ -382,6 +383,17 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV this.urlSubscriptions.push(this.indicatorPaths.at(index).get('url').valueChanges.subscribe(value => { if (this.indicatorPaths.at(index).get('url').valid) { let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(value), value, 'bar', this.stakeholder); + if(indicatorPath.chartObject && Object.keys(indicatorPath.parameters).indexOf("index_id") ==-1 && Object.keys(indicatorPath.parameters).indexOf("index_name") ==-1 && Object.keys(indicatorPath.parameters).indexOf("index_shortName") ==-1 ){ + // default profile + if(this.stakeholder.defaultId == null){ + this.urlParameterizedMessage = "This chart couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly." + }else{ + this.urlParameterizedMessage = "This chart couldn't be generated properly. Please make sure chart data is for the current stakeholder." + } + }else { + this.urlParameterizedMessage = ""; + } + console.debug(this.urlParameterizedMessage); let parameters = this.getParametersAsFormArray(indicatorPath); (this.indicatorPaths.at(index) as FormGroup).setControl('parameters', parameters); if (!this.indicator.indicatorPaths[index]) { @@ -421,6 +433,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV } public editChartIndicatorOpen(section: Section, id = null) { + this.urlParameterizedMessage = ""; this.urlSubscriptions.forEach(value => { if (value instanceof Subscriber) { value.unsubscribe(); diff --git a/src/app/utils/indicator-utils.ts b/src/app/utils/indicator-utils.ts index 5afff2b..57c388f 100644 --- a/src/app/utils/indicator-utils.ts +++ b/src/app/utils/indicator-utils.ts @@ -196,8 +196,7 @@ export class IndicatorUtils { ['end_year', [Validators.required, Validators.pattern('^\\d+$')]] ]); - public getFullUrl(indicatorPath: IndicatorPath, fundingL0: string = null, startDate: string = null, endDate: string = null): string { - + public getFullUrl(stakeholder:Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startDate: string = null, endDate: string = null): string { let replacedUrl = indicatorPath.chartObject; if (indicatorPath.parameters) { Object.keys(indicatorPath.parameters).forEach(key => { @@ -208,6 +207,16 @@ export class IndicatorUtils { if (endDate && key == "end_year" && indicatorPath.filters["end_year"]) { replacedValue = (replacedValue > endDate) ? endDate : replacedValue; } + if (key == "index_id") { + replacedValue = stakeholder.index_id; + } + if (key == "index_name") { + replacedValue = stakeholder.index_name; + } + if (key == "index_shortName") { + replacedValue = stakeholder.index_shortName.toLowerCase(); + } + replacedUrl = replacedUrl.split(ChartHelper.prefix + key + ChartHelper.suffix).join(replacedValue) }); } @@ -299,7 +308,7 @@ export class IndicatorUtils { private getQueryObjectName(obj){ if(obj["library"] && obj["library"] == "GoogleCharts"){ return "queriesInfo"; - }else if(obj["library"] && obj["library"] == "HighCharts") { + }else if(obj["library"] && ( obj["library"] == "HighCharts" || obj["library"] == "eCharts")) { return "queries"; } } @@ -425,8 +434,8 @@ export class IndicatorUtils { let parameters = (query["query"]["parameters"])?query["query"]["parameters"]:[]; if(name.split('.')[0] == "rcd" && parameters.length > 0 && stakeholder.type=="ri") { //rcd.{{queryname}} - parameters[0] = ChartHelper.prefix + "index_shortName" + ChartHelper.suffix; - indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName.toLowerCase(); + parameters[0] = ChartHelper.prefix + "index_id" + ChartHelper.suffix; + indicatorPath.parameters["index_id"] = stakeholder.index_id; }else if(name.split('.')[0] == "monitor" && parameters.length == 0 && stakeholder.type=="funder"){ // old saved queries without params //monitor.{{funder_shortName}}.{{type}}.{{queryname}} @@ -441,7 +450,7 @@ export class IndicatorUtils { indicatorPath.parameters["index_id"] = stakeholder.index_id; }else if( name.split('.').length > 3 && name.split('.')[3] == "shortname") { parameters[0] = ChartHelper.prefix + "index_shortName" + ChartHelper.suffix; - indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName; + indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName.toLowerCase(); }else if( name.split('.').length > 3 && name.split('.')[3] == "name") { parameters[0] = ChartHelper.prefix + "index_name" + ChartHelper.suffix; indicatorPath.parameters["index_name"] = stakeholder.index_name; @@ -463,7 +472,7 @@ export class IndicatorUtils { } private extractTitle(obj, indicatorPath: IndicatorPath) { let title = ""; - if (obj["library"] && obj["library"] == "HighCharts" &&obj["chartDescription"]["title"]) { + if (obj["library"] && ( obj["library"] == "HighCharts" || obj["library"] == "eCharts") && obj["chartDescription"]["title"]) { title = obj["chartDescription"]["title"]["text"]; obj["chartDescription"]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix; }else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["title"]) { @@ -479,17 +488,24 @@ export class IndicatorUtils { subtitle = obj["chartDescription"]["subtitle"]["text"]; obj["chartDescription"]["subtitle"]["text"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix; indicatorPath.parameters["subtitle"] = subtitle ? subtitle : ""; + }else if (obj["chartDescription"]["title"] && obj["chartDescription"]["title"]["subtext"]) { + subtitle = obj["chartDescription"]["title"]["subtext"]; + obj["chartDescription"]["title"]["subtext"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix; + indicatorPath.parameters["subtitle"] = subtitle ? subtitle : ""; } } private extractXTitle(obj, indicatorPath: IndicatorPath) { let title = ""; - if (obj["library"] && obj["library"] == "HighCharts" && obj["chartDescription"]["xAxis"]["title"]) { + if (obj["library"] && obj["library"] == "HighCharts" && obj["chartDescription"]["xAxis"]["title"]) { title = obj["chartDescription"]["xAxis"]["title"]["text"]; obj["chartDescription"]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; }else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["hAxis"]["title"]) { title = obj["chartDescription"]["options"]["hAxis"]["title"]; obj["chartDescription"]["options"]["hAxis"]["title"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; + }else if (obj["library"] && obj["library"] == "eCharts" && obj["chartDescription"]["xAxis"]["name"]) { + title = obj["chartDescription"]["xAxis"]["name"]; + obj["chartDescription"]["xAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; } indicatorPath.parameters["xAxisTitle"] = title ? title : ""; } @@ -502,6 +518,9 @@ export class IndicatorUtils { }else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["vAxis"]["title"]) { title = obj["chartDescription"]["options"]["vAxis"]["title"]; obj["chartDescription"]["options"]["vAxis"]["title"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix; + }else if (obj["library"] && obj["library"] == "eCharts" && obj["chartDescription"]["yAxis"]["name"]) { + title = obj["chartDescription"]["yAxis"]["name"]; + obj["chartDescription"]["yAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; } indicatorPath.parameters["yAxisTitle"] = title ? title : ""; } diff --git a/src/app/utils/services/statistics.service.ts b/src/app/utils/services/statistics.service.ts index 05e970c..8e95521 100644 --- a/src/app/utils/services/statistics.service.ts +++ b/src/app/utils/services/statistics.service.ts @@ -10,35 +10,37 @@ import {SourceType} from "../entities/stakeholder"; }) export class StatisticsService { - numberSources: Map = new Map(); - chartSources: Map = new Map(); + numberSources: Map = new Map(); + chartSources: Map = new Map(); - constructor(private http:HttpClient, private environmentSpecificService: EnvironmentSpecificService) { - this.environmentSpecificService.subscribeEnvironment().subscribe(properties => { - this.numberSources.set('statistics', properties.statisticsAPIURL); - this.numberSources.set('search', properties.searchAPIURLLAst); - this.numberSources.set('metrics', properties.metricsAPIURL); - this.chartSources.set('stats-tool', properties.statisticsFrameNewAPIURL); - this.chartSources.set('old', properties.statisticsFrameAPIURL); - this.chartSources.set('metrics', properties.metricsAPIURL); - this.chartSources.set('image', ''); - }) - } + constructor(private http:HttpClient, private environmentSpecificService: EnvironmentSpecificService) { + this.environmentSpecificService.subscribeEnvironment().subscribe(properties => { + this.numberSources.set('statistics', [properties.statisticsAPIURL]); + this.numberSources.set('search', [properties.searchAPIURLLAst]); + this.numberSources.set('metrics', [properties.metricsAPIURL]); + this.chartSources.set('stats-tool', [properties.statisticsFrameNewAPIURL, "http://marilyn.athenarc.gr:8080/stats-api/", "http://88.197.53.71:8080/stats-api/", "https://stats.madgik.di.uoa.gr/stats-api/"]); + this.chartSources.set('old', [properties.statisticsFrameAPIURL]); + this.chartSources.set('metrics', [properties.metricsAPIURL]); + this.chartSources.set('image', [""]); + }) + } getNumbers(source: string, url: string): Observable { return this.http.get(this.numberSources.get(source) + url); } getChartUrl(source: SourceType, url: string): string { - return this.chartSources.get(source) + url; + return this.chartSources.get(source)[0] + url; } getChartSource(url: string): SourceType { let source: SourceType = 'image'; - this.chartSources.forEach((value, key) => { + this.chartSources.forEach((values, key) => { + values.forEach((value) => { if(value !== '' && url.indexOf(value) !== -1) { source = key; } + }); }); return source; } diff --git a/src/assets/env-properties.json b/src/assets/env-properties.json index 5b9f66d..c7d04fc 100644 --- a/src/assets/env-properties.json +++ b/src/assets/env-properties.json @@ -7,7 +7,7 @@ "framesAPIURL" : "https://beta.openaire.eu/stats3/", "statisticsAPIURL" : "https://beta.services.openaire.eu/stats-api/", "statisticsFrameAPIURL":"https://beta.openaire.eu/stats/", - "statisticsFrameNewAPIURL": "http://88.197.53.71:8080/stats-api/", + "statisticsFrameNewAPIURL": "https://stats.madgik.di.uoa.gr/stats-api/", "useNewStatistisTool":false, "claimsAPIURL" : "http://scoobydoo.di.uoa.gr:8080/dnet-claims-service-2.0.0-SNAPSHOT/rest/claimsService/", "searchAPIURLLAst" : "https://beta.services.openaire.eu/search/v2/api/", diff --git a/src/index.html b/src/index.html index 2b7b0cb..d8ac7db 100644 --- a/src/index.html +++ b/src/index.html @@ -6,7 +6,6 @@ - @@ -51,17 +50,6 @@
- - - - -