From 529c9ce93319c6f374e8220ace2d0c6c97df06e8 Mon Sep 17 00:00:00 2001 From: Argiro Kokogiannaki Date: Thu, 5 Dec 2019 16:10:00 +0000 Subject: [PATCH] [Monitor-Dashboard|Trunk] add more charts about Open science. Get full url: replace parameters more than once add subtitle in indicator parameters/form git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57821 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/topic/indicators.component.html | 5 +++ src/app/topic/indicators.component.ts | 5 ++- src/app/utils/entities/stakeholderCreator.ts | 41 ++++++++++++++++++++ src/app/utils/indicator-utils.ts | 18 +++++++-- 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html index 228d2b7..67a011d 100644 --- a/src/app/topic/indicators.component.html +++ b/src/app/topic/indicators.component.html @@ -243,6 +243,11 @@ [formInput]="getParameter(i, 'title').get('value')" label="Chart Title"> +
+
+
{ let parameters = this.fb.array([]); if (indicatorPath.parameters) { + console.info(indicatorPath.parameters); Object.keys(indicatorPath.parameters).forEach(key => { if (this.indicatorUtils.ignoredParameters.indexOf(key) === -1) { if (this.indicatorUtils.parametersValidators.has(key)) { @@ -328,7 +329,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV } else { parameters.push(this.fb.group({ key: this.fb.control(key), - value: this.fb.control(indicatorPath.parameters[key], Validators.required) + value: this.fb.control(indicatorPath.parameters[key]) })); } } diff --git a/src/app/utils/entities/stakeholderCreator.ts b/src/app/utils/entities/stakeholderCreator.ts index a70fc8e..1093b79 100644 --- a/src/app/utils/entities/stakeholderCreator.ts +++ b/src/app/utils/entities/stakeholderCreator.ts @@ -1,4 +1,5 @@ import {Stakeholder,Topic,Category,SubCategory,Indicator, IndicatorPath, ChartHelper} from "./stakeholder"; +import {IndicatorUtils} from "../indicator-utils"; export class StakeholderCreator { @@ -189,8 +190,48 @@ export class StakeholderCreator { } static createOASub(stakeholder:Stakeholder,typePlural, typeSingl, dbType, dbTypePlural ):SubCategory { let sub:SubCategory = new SubCategory(typePlural, null, dbTypePlural, true, true); + // sub.charts = sub.charts.concat( this.createOAPerType(stakeholder,typePlural, typeSingl, dbType, dbTypePlural, 0 )); + // sub.charts = sub.charts.concat( this.createOAPerType(stakeholder,typePlural, typeSingl, dbType, dbTypePlural, 1 )); + // sub.charts = sub.charts.concat( this.createOAPerType(stakeholder,typePlural, typeSingl, dbType, dbTypePlural, 2 )); return sub; } + static createOAPerType(stakeholder:Stakeholder,typePlural, typeSingl, dbType, dbTypePlural, index:number):Indicator[] { + + let fundingFilter = ['', ',{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["FP7"]}],"op":"AND"}', + ',{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["H2020"]}],"op":"AND"}']; + let categoryTitle = ["Overview", "FP7", "H2020"]; + let chartTitle = ["", "FP7 ", "H2020 "]; + let indicators:Indicator[]=[]; + let utils = new IndicatorUtils(); + + let open_non_url = "http://88.197.53.71:8080/stats-api/chart?json="+encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Data","type":"pie","color":"#e62020ee","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix +(index==2?".h2020":(index==1?".fp7":""))+ '.' + dbTypePlural+'.oavsnonoa"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+chartTitle[index]+' Open Access vs Non Open Access"},"subtitle":{},"yAxis":{"title":{}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'); + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Data","type":"pie","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix +(index==2?".h2020":(index==1?".fp7":""))+ '.' + dbTypePlural+'.greenvsgold"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{},"subtitle":{},"yAxis":{"title":{}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'); + let open_non_ind:Indicator = new Indicator(categoryTitle[index], "", "column", "small", true, true, [utils.generateIndicatorByChartUrl("stats-tool", open_non_url, "pie")]) + open_non_ind.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase(); + indicators.push(open_non_ind); + + let gold_vs_green_url = "http://88.197.53.71:8080/stats-api/chart?json="+ encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Data","type":"pie","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix +(index==2?".h2020":(index==1?".fp7":""))+ '.' + dbTypePlural+'.greenvsgold"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{},"subtitle":{},"yAxis":{"title":{}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'); + let gold_vs_green_ind:Indicator = (new Indicator("", "", "column", "small", true, true, [utils.generateIndicatorByChartUrl("stats-tool", gold_vs_green_url, "pie")])); + gold_vs_green_ind.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase(); + indicators.push(gold_vs_green_ind); + + let gold_vs_green_time_url = "http://88.197.53.71:8080/stats-api/chart?json="+ encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Gold OA","type":"column","color":"#F8B500","query":{"name":"monitor.'+ ChartHelper.prefix + 'id' + ChartHelper.suffix +(index==2?".h2020":(index==1?".fp7":""))+ '.' + dbTypePlural+'.gold.year"}},{"name":"Green OA","type":"column","color":"#239D60","query":{"name":"monitor.'+ ChartHelper.prefix + 'id' + ChartHelper.suffix +(index==2?".h2020":(index==1?".fp7":""))+ '.' + dbTypePlural+'.green.year"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Green vs Gold Open Access"},"subtitle":{"text":"by year"},"yAxis":{"title":{}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'); + let gold_vs_green_time_ind:Indicator = (new Indicator("", "", "column", "small", true, true, [utils.generateIndicatorByChartUrl("stats-tool", gold_vs_green_time_url, "column")])); + gold_vs_green_time_ind.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase(); + indicators.push(gold_vs_green_time_ind); + + let top_project_url = "http://88.197.53.71:8080/stats-api/chart?json="+ encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Data","type":"bar","query":{"name":"monitor.'+ ChartHelper.prefix + 'id' + ChartHelper.suffix +(index==2?".h2020":(index==1?".fp7":""))+ '.' + dbTypePlural+'.top10projects"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Top 15 projects"},"subtitle":{"text":"by publications"},"yAxis":{"title":{}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'); + let top_project_ind:Indicator = (new Indicator("", "", "column", "medium", true, true, [utils.generateIndicatorByChartUrl("stats-tool", top_project_url, "column")])); + top_project_ind.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase(); + indicators.push(top_project_ind); + if(index == 0) { + let top_datasources_url = "http://88.197.53.71:8080/stats-api/chart?json=" + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Data","type":"bar","color":"#e62020ee","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.top10datasources"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Top 10 Datasources"},"subtitle":{},"yAxis":{"title":{}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'); + let top_datasources_ind: Indicator = (new Indicator("By Content Providers", "", "column", "large", true, true, [utils.generateIndicatorByChartUrl("stats-tool", top_datasources_url, "column")])); + top_datasources_ind.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase(); + indicators.push(top_datasources_ind); + } + return indicators; + } static createOSTopic(stakeholder:Stakeholder):Topic{ let topic = new Topic("Open Science","Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...","open-science",true,true); topic.categories.push(this.createOpenAccessTopic(stakeholder)); diff --git a/src/app/utils/indicator-utils.ts b/src/app/utils/indicator-utils.ts index 9ba3c4a..6801c84 100644 --- a/src/app/utils/indicator-utils.ts +++ b/src/app/utils/indicator-utils.ts @@ -148,9 +148,10 @@ export class IndicatorUtils { if (endDate && key == "end_year" && indicatorPath.filters["end_year"]) { replacedValue = (replacedValue > endDate) ? endDate : replacedValue; } - replacedUrl = replacedUrl.replace(ChartHelper.prefix + key + ChartHelper.suffix, replacedValue); + replacedUrl = replacedUrl.split(ChartHelper.prefix + key + ChartHelper.suffix).join(replacedValue) }); } + console.info("replacedUrl:"+replacedUrl) if (indicatorPath.chartObject) { if (fundingL0 && indicatorPath.filters["fundingL0"]) { let newJsonObject = JSON.parse(replacedUrl); @@ -191,6 +192,7 @@ export class IndicatorUtils { let chart = JSON.parse(indicatorPath.chartObject); indicatorPath.type = this.extractType(chart, indicatorPath); this.extractTitle(chart, indicatorPath); + this.extractSubTitle(chart,indicatorPath); this.extractXTitle(chart, indicatorPath); this.extractYTitle(chart, indicatorPath); this.extractFunder(chart, indicatorPath); @@ -283,17 +285,25 @@ export class IndicatorUtils { if (obj["chartDescription"]["title"]) { title = obj["chartDescription"]["title"]["text"]; obj["chartDescription"]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix; - indicatorPath.parameters["title"] = title; + indicatorPath.parameters["title"] = title?title:""; } } + private extractSubTitle(obj, indicatorPath: IndicatorPath) { + let subtitle = ""; + if (obj["chartDescription"]["subtitle"]) { + subtitle = obj["chartDescription"]["subtitle"]["text"]; + obj["chartDescription"]["subtitle"]["text"]= ChartHelper.prefix + "subtitle" + ChartHelper.suffix; + indicatorPath.parameters["subtitle"] = subtitle?subtitle:""; + } + } private extractXTitle(obj, indicatorPath: IndicatorPath) { let title = ""; if (obj["chartDescription"]["xAxis"]["title"]) { title = obj["chartDescription"]["xAxis"]["title"]["text"]; obj["chartDescription"]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; - indicatorPath.parameters["xAxisTitle"] = title; + indicatorPath.parameters["xAxisTitle"] = title?title:"" } } @@ -302,7 +312,7 @@ export class IndicatorUtils { if (obj["chartDescription"]["yAxis"]["title"]) { title = obj["chartDescription"]["yAxis"]["title"]["text"]; obj["chartDescription"]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix; - indicatorPath.parameters["yAxisTitle"] = title; + indicatorPath.parameters["yAxisTitle"] = title?title:"" } }