[MOnitor Dashboard|Trunk]

Indicator utils:
	support highmaps
	make code more generic (eliminate using library name in if-then-else)
properties:
	update with proper login service
remove routing to 'ec' when no stakeholder defined




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@58909 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Argiro Kokogiannaki 2020-06-12 17:32:41 +00:00
parent 2da590e0fc
commit 06ec6b383f
5 changed files with 64 additions and 52 deletions

View File

@ -31,10 +31,10 @@
# read -n1 ans # read -n1 ans
# pico ../src/robots.txt; # pico ../src/robots.txt;
# echo -n "Pressed"; # echo -n "Pressed";
rm -rf ../src/assets/common-assets/.svn/; # rm -rf ../src/assets/common-assets/.svn/;
rm -rf ../src/app/openaireLibrary/.svn/; # rm -rf ../src/app/openaireLibrary/.svn/;
# cd ..; npm run build:ssr; cd deploy; # cd ..; npm run build:ssr; cd deploy;
rm -rf ../src ../node_modules ../.idea/ ../installOpenaireLib.sh; cd ../; rm -rf deploy; rm -rf ../src ../node_modules ../.idea/ ../installOpenaireLib.sh; rm -rf ../dist/assets/common-assets/.svn/; cd ../; rm -rf deploy;
# echo 'Now copy to the server!' # echo 'Now copy to the server!'
##<-- to here ##<-- to here

View File

@ -13,7 +13,7 @@ enableProdMode();
// Express server // Express server
const app = express(); const app = express();
const PORT = 5000; const PORT = 4000;
const DIST_FOLDER = join(process.cwd(), 'dist'); const DIST_FOLDER = join(process.cwd(), 'dist');
// Our index.html we'll use as our template // Our index.html we'll use as our template

View File

@ -8,7 +8,7 @@ import {CanExitGuard} from "../openaireLibrary/utils/can-exit.guard";
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', redirectTo: '/ec', pathMatch: 'full'}, { path: '', redirectTo: '/admin', pathMatch: 'full'},
{ {
path: ':stakeholder', path: ':stakeholder',
component: MonitorComponent, component: MonitorComponent,

View File

@ -249,7 +249,7 @@ export class IndicatorUtils {
if (indicatorPath.chartObject) { if (indicatorPath.chartObject) {
if (fundingL0 && indicatorPath.filters["fundingL0"]) { if (fundingL0 && indicatorPath.filters["fundingL0"]) {
let newJsonObject = JSON.parse(replacedUrl); let newJsonObject = JSON.parse(replacedUrl);
for (let queries of newJsonObject["chartDescription"]["queries"]) { for (let queries of newJsonObject[this.getDescriptionObjectName(newJsonObject)]["queries"]) {
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) { if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
queries["query"]["filters"] = []; queries["query"]["filters"] = [];
} }
@ -288,7 +288,8 @@ export class IndicatorUtils {
let chart = JSON.parse(indicatorPath.chartObject); let chart = JSON.parse(indicatorPath.chartObject);
// console.debug(indicatorPath); // console.debug(indicatorPath);
if (indicatorPath.url == "chart?json=") { if (indicatorPath.url == "chart?json=") {
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" )) {
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" || chart["library"] == "HighMaps" )) {
indicatorPath.type = this.extractType(chart, indicatorPath); indicatorPath.type = this.extractType(chart, indicatorPath);
} else { } else {
indicatorPath.type = this.defaultChartType; indicatorPath.type = this.defaultChartType;
@ -337,18 +338,27 @@ export class IndicatorUtils {
return indicatorPath; return indicatorPath;
} }
private getQueryObjectName(obj){ private getQueryObjectName(obj){
if(obj["library"] && obj["library"] == "GoogleCharts"){ if((obj[this.getDescriptionObjectName(obj)]).hasOwnProperty("queriesInfo")){
return "queriesInfo"; return "queriesInfo";
}else if(obj["library"] && ( obj["library"] == "HighCharts" || obj["library"] == "eCharts")) { }else if((obj[this.getDescriptionObjectName(obj)]).hasOwnProperty("queries")) {
return "queries"; return "queries";
} }
} }
private getDescriptionObjectName(obj){
if(obj.hasOwnProperty("mapDescription")){
return "mapDescription";
}else if(obj.hasOwnProperty("chartDescription")) {
return "chartDescription";
}else if(obj.hasOwnProperty("tableDescription") ){
return "tableDescription";
}
}
private extractType(obj, indicatorPath: IndicatorPath): IndicatorPathType { private extractType(obj, indicatorPath: IndicatorPath): IndicatorPathType {
let type = obj["chartDescription"]["queries"][0]["type"]; let type = (obj[this.getDescriptionObjectName(obj)] && obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"])?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"]:"";
if (this.basicChartTypes.indexOf(type) == -1) { if (this.basicChartTypes.indexOf(type) == -1) {
type = this.defaultChartType; type = this.defaultChartType;
} else { } else {
obj["chartDescription"]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix;
indicatorPath.parameters['type'] = type; indicatorPath.parameters['type'] = type;
} }
return type; return type;
@ -362,7 +372,7 @@ export class IndicatorUtils {
if(stakeholder.type != "funder"){ if(stakeholder.type != "funder"){
return; return;
} }
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) { for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
if (!query["query"]["filters"]) { if (!query["query"]["filters"]) {
return; return;
} }
@ -382,7 +392,7 @@ export class IndicatorUtils {
if(stakeholder.type != "ri"){ if(stakeholder.type != "ri"){
return; return;
} }
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) { for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
if (!query["query"]["filters"]) { if (!query["query"]["filters"]) {
return; return;
} }
@ -404,7 +414,7 @@ export class IndicatorUtils {
if(stakeholder.type != "organization"){ if(stakeholder.type != "organization"){
return; return;
} }
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) { for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
if (!query["query"]["filters"]) { if (!query["query"]["filters"]) {
return; return;
} }
@ -421,7 +431,7 @@ export class IndicatorUtils {
} }
private extractStartYear(obj, indicatorPath: IndicatorPath) { private extractStartYear(obj, indicatorPath: IndicatorPath) {
let start_year; let start_year;
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) { for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
if (!query["query"]["filters"]) { if (!query["query"]["filters"]) {
return; return;
} }
@ -439,7 +449,7 @@ export class IndicatorUtils {
private extractEndYear(obj, indicatorPath: IndicatorPath) { private extractEndYear(obj, indicatorPath: IndicatorPath) {
let end_year; let end_year;
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) { for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
if (!query["query"]["filters"]) { if (!query["query"]["filters"]) {
return; return;
} }
@ -457,8 +467,7 @@ export class IndicatorUtils {
private parameterizeDefaultQuery(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) { private parameterizeDefaultQuery(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) {
let name = ""; let name = "";
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
//monitor.{{stakeholderType}}.{{queryname}} //monitor.{{stakeholderType}}.{{queryname}}
//parameters: stakeholderId*, type //parameters: stakeholderId*, type
if (query["query"]["name"]) { if (query["query"]["name"]) {
@ -493,7 +502,10 @@ export class IndicatorUtils {
} }
private extractDataTitle(obj, indicatorPath: IndicatorPath) { private extractDataTitle(obj, indicatorPath: IndicatorPath) {
let index = 0; let index = 0;
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) { if(obj[this.getDescriptionObjectName(obj)] && obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]){
return;
}
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
if (query["name"]) { if (query["name"]) {
let name = query["name"]; let name = query["name"];
query["name"] = ChartHelper.prefix + "data_title_"+index + ChartHelper.suffix; query["name"] = ChartHelper.prefix + "data_title_"+index + ChartHelper.suffix;
@ -504,55 +516,55 @@ export class IndicatorUtils {
} }
private extractTitle(obj, indicatorPath: IndicatorPath) { private extractTitle(obj, indicatorPath: IndicatorPath) {
let title = ""; let title = "";
if (obj["library"] && ( obj["library"] == "HighCharts" || obj["library"] == "eCharts") && obj["chartDescription"]["title"]) { if (obj[this.getDescriptionObjectName(obj)]["title"]) {
title = obj["chartDescription"]["title"]["text"]; title = obj[this.getDescriptionObjectName(obj)]["title"]["text"];
obj["chartDescription"]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
}else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["title"]) { }else if (obj[this.getDescriptionObjectName(obj)]["options"] && obj[this.getDescriptionObjectName(obj)]["options"]["title"]) {
title = obj["chartDescription"]["options"]["title"]; title = obj[this.getDescriptionObjectName(obj)]["options"]["title"];
obj["chartDescription"]["options"]["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["options"]["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
} }
indicatorPath.parameters["title"] = title ? title : ""; indicatorPath.parameters["title"] = title ? title : "";
} }
private extractSubTitle(obj, indicatorPath: IndicatorPath) { private extractSubTitle(obj, indicatorPath: IndicatorPath) {
let subtitle = ""; let subtitle = "";
if (obj["chartDescription"]["subtitle"]) { if (obj[this.getDescriptionObjectName(obj)]["subtitle"]) {
subtitle = obj["chartDescription"]["subtitle"]["text"]; subtitle = obj[this.getDescriptionObjectName(obj)]["subtitle"]["text"];
obj["chartDescription"]["subtitle"]["text"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["subtitle"]["text"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
indicatorPath.parameters["subtitle"] = subtitle ? subtitle : ""; indicatorPath.parameters["subtitle"] = subtitle ? subtitle : "";
}else if (obj["chartDescription"]["title"] && obj["chartDescription"]["title"]["subtext"]) { }else if (obj[this.getDescriptionObjectName(obj)]["title"] && obj[this.getDescriptionObjectName(obj)]["title"] && obj[this.getDescriptionObjectName(obj)]["title"]["subtext"]) {
subtitle = obj["chartDescription"]["title"]["subtext"]; subtitle = obj[this.getDescriptionObjectName(obj)]["title"]["subtext"];
obj["chartDescription"]["title"]["subtext"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["title"]["subtext"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
indicatorPath.parameters["subtitle"] = subtitle ? subtitle : ""; indicatorPath.parameters["subtitle"] = subtitle ? subtitle : "";
} }
} }
private extractXTitle(obj, indicatorPath: IndicatorPath) { private extractXTitle(obj, indicatorPath: IndicatorPath) {
let title = ""; let title = "";
if (obj["library"] && obj["library"] == "HighCharts" && obj["chartDescription"]["xAxis"]["title"]) { if (obj[this.getDescriptionObjectName(obj)]["xAxis"] && obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]) {
title = obj["chartDescription"]["xAxis"]["title"]["text"]; title = obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]["text"];
obj["chartDescription"]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
}else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["hAxis"]["title"]) { }else if (obj[this.getDescriptionObjectName(obj)]["options"] && obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"] && obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"]) {
title = obj["chartDescription"]["options"]["hAxis"]["title"]; title = obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"];
obj["chartDescription"]["options"]["hAxis"]["title"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
}else if (obj["library"] && obj["library"] == "eCharts" && obj["chartDescription"]["xAxis"]["name"]) { }else if (obj[this.getDescriptionObjectName(obj)]["xAxis"] && obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"]) {
title = obj["chartDescription"]["xAxis"]["name"]; title = obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"];
obj["chartDescription"]["xAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
} }
indicatorPath.parameters["xAxisTitle"] = title ? title : ""; indicatorPath.parameters["xAxisTitle"] = title ? title : "";
} }
private extractYTitle(obj, indicatorPath: IndicatorPath) { private extractYTitle(obj, indicatorPath: IndicatorPath) {
let title = ""; let title = "";
if (obj["library"] && obj["library"] == "HighCharts" && obj["chartDescription"]["yAxis"]["title"]) { if (obj[this.getDescriptionObjectName(obj)]["yAxis"] && obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"] ) {
title = obj["chartDescription"]["yAxis"]["title"]["text"]; title = obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"]["text"];
obj["chartDescription"]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
}else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["vAxis"]["title"]) { }else if (obj[this.getDescriptionObjectName(obj)]["options"]&& obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"] && obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"]) {
title = obj["chartDescription"]["options"]["vAxis"]["title"]; title = obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"];
obj["chartDescription"]["options"]["vAxis"]["title"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
}else if (obj["library"] && obj["library"] == "eCharts" && obj["chartDescription"]["yAxis"]["name"]) { }else if (obj[this.getDescriptionObjectName(obj)]["yAxis"] && obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"]) {
title = obj["chartDescription"]["yAxis"]["name"]; title = obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"];
obj["chartDescription"]["yAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
} }
indicatorPath.parameters["yAxisTitle"] = title ? title : ""; indicatorPath.parameters["yAxisTitle"] = title ? title : "";
} }
@ -560,7 +572,7 @@ export class IndicatorUtils {
private addResultFilters(obj, indicatorPath: IndicatorPath) { private addResultFilters(obj, indicatorPath: IndicatorPath) {
let resultTypes = ["publication", "software", "dataset", "other"]; let resultTypes = ["publication", "software", "dataset", "other"];
let index = -1; let index = -1;
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) { for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
if (!query["query"]["select"]) { if (!query["query"]["select"]) {
return; return;
} }

View File

@ -38,7 +38,7 @@ export let properties: EnvProperties = {
piwikBaseUrl: "https://analytics.openaire.eu/piwik.php?idsite=", piwikBaseUrl: "https://analytics.openaire.eu/piwik.php?idsite=",
piwikSiteId: "298", piwikSiteId: "298",
loginUrl: "https://beta.services.openaire.eu/monitor-login/openid_connect_login", loginUrl: "https://beta.services.openaire.eu/monitor-dashboard-login/openid_connect_login",
userInfoUrl : "https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=", userInfoUrl : "https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=",
logoutUrl: "https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=", logoutUrl: "https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=",
@ -64,7 +64,7 @@ export let properties: EnvProperties = {
resultsPerPage: 10, resultsPerPage: 10,
baseLink: "https://beta.monitor.openaire.eu", baseLink: "https://beta.monitor.openaire.eu",
afterLoginRedirectLink: "/myCommunities",
searchLinkToPublication: "/search/publication?articleId=", searchLinkToPublication: "/search/publication?articleId=",
searchLinkToProject: "/search/project?projectId=", searchLinkToProject: "/search/project?projectId=",
searchLinkToDataProvider: "/search/dataprovider?datasourceId=", searchLinkToDataProvider: "/search/dataprovider?datasourceId=",