From 7d57db25e03c381d13c8b1b6eaf443bb5e5fcbea Mon Sep 17 00:00:00 2001 From: Argiro Kokogiannaki Date: Thu, 6 Aug 2020 07:34:41 +0000 Subject: [PATCH] [Monitor Dashboard | Trunk] Indicators Page: - keep parameters - add feadback link Admin manage number indicators: - add message when stakeholder parameterization is not applied - preview the number API url (similar to charts) - json path: auto generate if the first one has comma separated values - fix stakeholder parameterization for numbers from stats-tool Filtering: - fixes git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59224 d315682c-612b-4755-9ff5-7f18f6832af3 --- package.json | 3 +- src/app/app.component.html | 2 +- src/app/monitor/monitor.component.html | 17 +++++-- src/app/monitor/monitor.component.ts | 16 +++++-- src/app/topic/indicators.component.html | 7 ++- src/app/topic/indicators.component.ts | 50 +++++++++++++++++--- src/app/utils/indicator-utils.ts | 19 +++++--- src/app/utils/services/statistics.service.ts | 3 ++ src/assets/monitor-custom.css | 5 +- src/assets/theme-assets/dashboard-custom.css | 1 + src/environments/environment.beta.ts | 2 +- 11 files changed, 95 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 7f75255..99565c1 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "generate:prerender": "cd dist && node prerender", "webpack:server": "webpack --config webpack.server.config.js --progress --colors", "serve:prerender": "cd dist/browser && http-server", - "serve:ssr": "node dist/server" + "serve:ssr": "node dist/server", + "after-build-clean": "rm -rf src node_modules .idea/ installOpenaireLib.sh deploy dist/browser/assets/common-assets/.svn/ dist/browser/stats.json ; " }, "private": true, "dependencies": { diff --git a/src/app/app.component.html b/src/app/app.component.html index 74fc481..9bffc35 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -50,7 +50,7 @@ [activeItem]="activeTopic?activeTopic.alias:null" [showHeader]=true [searchLink]="(properties.showContent)?properties.searchLinkToResults:null" [searchParams]="createSearchParameters()" - [headerUrl]="properties.baseLink" + [headerUrl]="properties.baseLink" queryParamsHandling="preserve" > +
- +
Filtered: + {{indicator.indicatorPaths[0].filtersApplied}} + out of + {{countSelectedFilters()}}
{{indicator.name}}

{{numberResults.get(i + '-' + j) | number}} @@ -181,8 +184,8 @@ {{indicatorPath.type}}

- +
Filtered: {{chartsActiveType.get(i + '-' + j).filtersApplied}} out of + {{countSelectedFilters()}}
@@ -199,6 +202,12 @@
+
+ Send us your feedback. + +
+
diff --git a/src/app/monitor/monitor.component.ts b/src/app/monitor/monitor.component.ts index 456d711..7cf73fa 100644 --- a/src/app/monitor/monitor.component.ts +++ b/src/app/monitor/monitor.component.ts @@ -200,7 +200,8 @@ export class MonitorComponent implements OnInit, OnDestroy { }else{ delete this.queryParams["year"]; } - this.location.go(location.pathname, this.routerHelper.createQueryParamsString( Object.keys(this.queryParams), Object.values(this.queryParams))); + // this.location.go(location.pathname, this.routerHelper.createQueryParamsString( Object.keys(this.queryParams), Object.values(this.queryParams))); + this.router.navigate([], {queryParams: this.queryParams }); this.setIndicators(); } } @@ -329,7 +330,7 @@ export class MonitorComponent implements OnInit, OnDestroy { delete this.queryParams[$event.value.filterId]; } if(navigate) { - this.location.go(location.pathname, this.routerHelper.createQueryParamsString( Object.keys(this.queryParams), Object.values(this.queryParams))); + this.router.navigate([], {queryParams: this.queryParams }); this.setIndicators(); } @@ -416,7 +417,7 @@ export class MonitorComponent implements OnInit, OnDestroy { public navigateTo(stakeholder: string, topic: string, category: string = null, subcategory: string = null) { let url = stakeholder + '/' + topic + ((category) ? ('/' + category) : '') + ((subcategory) ? ('/' + subcategory) : ''); - return this._router.navigate([url]); + return this._router.navigate([url],{ queryParams: this.queryParams}); } public quote(param: string): string { @@ -460,4 +461,13 @@ export class MonitorComponent implements OnInit, OnDestroy { } return counter; } + /* + Feedback mail + */ + public get mailText() { + return "mailto:"+this.properties.feedbackmail+"?subject=%5BOpenAIRE%20Monitor%5D%20"+(this.stakeholder?this.stakeholder.name:"")+"%20dashboard%20feedback" + } + mailMe(){ + window.location.href = this.mailText; + } } diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html index aeb8023..b1a957e 100644 --- a/src/app/topic/indicators.component.html +++ b/src/app/topic/indicators.component.html @@ -430,11 +430,14 @@
- +
diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts index a169a9e..c6410f1 100644 --- a/src/app/topic/indicators.component.ts +++ b/src/app/topic/indicators.component.ts @@ -391,6 +391,17 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV } public addJsonPath(index: number) { + if(index==0 && this.getJsonPath(index).getRawValue()[index].indexOf(",")!=-1){ + //if in the first path there are more than one paaths comma separated, split them and autogenerate the forms + let paths = this.getJsonPath(index).getRawValue()[index].split(","); + for(let i = 0; i< paths.length; i++){ + if(i !=0){ + this.getJsonPath(index).push(this.fb.control('', Validators.required)); + } + } + this.getJsonPath(index).setValue(paths) + return; + } this.getJsonPath(index).push(this.fb.control('', Validators.required)); } @@ -435,20 +446,44 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV this.subscriptions.push(this.numberIndicatorPaths.at(index).get('url').valueChanges.subscribe(value => { if (this.numberIndicatorPaths.at(index).get('url').valid) { let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(value), value, this.stakeholder,this.numberIndicatorPaths.at(index).get('jsonPath').value ); - // if(indicatorPath.url.indexOf("index_id") ==-1 && indicatorPath.url.indexOf("index_name") ==-1 && (indicatorPath.url).indexOf("index_shortName") ==-1 ){ - // - // }else { - // this.urlParameterizedMessage = ""; - // } + 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 ) + || (!indicatorPath.chartObject && indicatorPath.url.indexOf("index_id") ==-1 && indicatorPath.url.indexOf("index_name") ==-1 && (indicatorPath.url).indexOf("index_shortName") ==-1 )){ + // default profile + if(this.stakeholder.defaultId == null){ + this.urlParameterizedMessage = "This indicator couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly." + }else{ + this.urlParameterizedMessage = "This indicator couldn't be generated properly. Please make sure chart data is for the current stakeholder." + } + }else { + this.urlParameterizedMessage = ""; + } /* if(value != indicatorPath.url) { (this.numberIndicatorPaths.at(index) as FormGroup).get('url').setValue( indicatorPath.url); }*/ - if (!this.indicator.indicatorPaths[index]) { this.indicator.indicatorPaths[index] = indicatorPath; } else { this.indicator.indicatorPaths[index] = indicatorPath; } + (this.numberIndicatorPaths.at(index) as FormGroup).get('source').setValue(indicatorPath.source); + + } + }) + ); + + this.subscriptions.push(this.numberIndicatorPaths.at(index).get('jsonPath').valueChanges.subscribe(value => { + if (!this.indicator.indicatorPaths[index]) { + this.indicator.indicatorPaths[index].jsonPath = value; + } else { + this.indicator.indicatorPaths[index].jsonPath = value; + } + }) + ); + this.subscriptions.push(this.numberIndicatorPaths.at(index).get('source').valueChanges.subscribe(value => { + if (!this.indicator.indicatorPaths[index]) { + this.indicator.indicatorPaths[index].source = value; + } else { + this.indicator.indicatorPaths[index].source = value; } }) ); @@ -534,6 +569,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV } public editNumberIndicatorOpen(section: Section, id = null) { + this.urlParameterizedMessage = ""; this.section = section; this.index = (id) ? section.indicators.findIndex(value => value._id === id) : -1; if (this.index !== -1) { @@ -550,7 +586,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV defaultId: this.fb.control(this.indicator.defaultId) }); this.indicator.indicatorPaths.forEach(indicatorPath => { - this.addNumberIndicatorPath(indicatorPath.url,indicatorPath.parameters, indicatorPath.source, this.getJsonPathAsFormArray(indicatorPath)); + this.addNumberIndicatorPath(this.statisticsService.getNumberUrl(indicatorPath.source,this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)),indicatorPath.parameters, indicatorPath.source, this.getJsonPathAsFormArray(indicatorPath)); }); } else { this.indicator = new Indicator('', '', 'number', 'small', true, true, []); diff --git a/src/app/utils/indicator-utils.ts b/src/app/utils/indicator-utils.ts index 5914ba7..8734e0e 100644 --- a/src/app/utils/indicator-utils.ts +++ b/src/app/utils/indicator-utils.ts @@ -224,7 +224,7 @@ export class IndicatorUtils { ]); public getFullUrl(stakeholder:Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null): string { - let replacedUrl = indicatorPath.chartObject; + let replacedUrl =indicatorPath.chartObject?indicatorPath.chartObject:indicatorPath.url; if (indicatorPath.parameters) { Object.keys(indicatorPath.parameters).forEach(key => { let replacedValue = indicatorPath.parameters[key]; @@ -294,7 +294,7 @@ export class IndicatorUtils { if(indicatorPath.url.indexOf(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix) !=- 1){ indicatorPath.url = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName)) } - return indicatorPath.url + encodeURIComponent(replacedUrl); + return (indicatorPath.chartObject?indicatorPath.url + encodeURIComponent(replacedUrl):replacedUrl); } public getFullUrlWithFilters(stakeholder:Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null, coFunded:boolean=false): string { indicatorPath.filtersApplied = 0; @@ -377,7 +377,7 @@ export class IndicatorUtils { } if(filterType == 'fundingL0') { let paramFields = queries["query"]["name"].split(".").slice(3); - let filterPosition = queries["query"]["name"].split(".").indexOf(filterType == "fundingL0" ? 'fl0' : filterType) ; + let filterPosition = queries["query"]["name"].split(".").indexOf(filterType == "fundingL0" ? 'fl0' : filterType) ; if (filterPosition != -1) { //already filtered //TODO double check if we need to override if the fl0 is already filtered @@ -400,6 +400,9 @@ export class IndicatorUtils { filterApplied = true; } } else { + if((paramFields.length*2) == queries["query"]["parameters"].length){ + queries["query"]["parameters"].splice(paramFields.length, 0, filterValue); + } if((paramFields.length*2 + 4) == queries["query"]["parameters"].length){ queries["query"]["parameters"].splice(paramFields.length + 1, 0, filterValue); } @@ -439,7 +442,7 @@ export class IndicatorUtils { queries["query"]["filters"] = []; } let field = queries["query"]["select"][0]["field"]; - let filterString = IndicatorFilterUtils.getFilter(field,filterType); + let filterString = IndicatorFilterUtils.getFilter(field&&field.length > 0? field.split(".")[0]:"",filterType); if(filterString){ let filter = JSON.parse(filterString); let filterposition = IndicatorFilterUtils.filterIndexOf(filter,queries["query"]["filters"]) @@ -484,10 +487,11 @@ export class IndicatorUtils { let filterposition = IndicatorFilterUtils.filterIndexOf(filter, queries["query"]["filters"]); if (filterposition) { if (values.indexOf(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0]) == -1) { - values.push(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0]) + values.push(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0]); } } } + console.debug(values); return values.length > 1; } generateIndicatorByForm(form: any, indicatorPaths: IndicatorPath[], type:IndicatorType, addParameters:boolean = true ): Indicator { @@ -515,6 +519,7 @@ export class IndicatorUtils { indicatorPath.chartObject = decodeURIComponent(url.indexOf("json=")!=-1?url.split("json=")[1]:""); let chart = JSON.parse(indicatorPath.chartObject); this.extractStakeHolders(chart, indicatorPath, stakeholder); + indicatorPath.chartObject = JSON.stringify(chart); // this.addResultFilters(chart, indicatorPath); }else { try { @@ -649,7 +654,7 @@ export class IndicatorUtils { if(stakeholder.type != "ri"){ return; } - for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) { + for (let query of this.getQueryObjectName(obj)?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]:obj[this.getDescriptionObjectName(obj)]) { if (!query["query"]["filters"]) { return; } @@ -671,7 +676,7 @@ export class IndicatorUtils { if(stakeholder.type != "organization"){ return; } - for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) { + for (let query of this.getQueryObjectName(obj)?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]:obj[this.getDescriptionObjectName(obj)]) { if (!query["query"]["filters"]) { return; } diff --git a/src/app/utils/services/statistics.service.ts b/src/app/utils/services/statistics.service.ts index 614b2d2..f06f2ae 100644 --- a/src/app/utils/services/statistics.service.ts +++ b/src/app/utils/services/statistics.service.ts @@ -42,6 +42,9 @@ export class StatisticsService { getChartUrl(source: SourceType, url: string): string { return this.chartSources.get(source)[0] + url; } + getNumberUrl(source: string, url: string): string { + return this.numberSources.get(this.getSourceType(source))[0] + url; + } getNumberSource(url: string): SourceType { let source: SourceType = 'search'; this.numberSources.forEach((values, key) => { diff --git a/src/assets/monitor-custom.css b/src/assets/monitor-custom.css index a439a9e..a40a98c 100644 --- a/src/assets/monitor-custom.css +++ b/src/assets/monitor-custom.css @@ -294,10 +294,7 @@ bottom a:not(.license), bottom a > :not(svg) { opacity: 0.5; } .stakeholderPage:not(.sidebar_mini) #sidebar_main .menu_section > ul.searchLink { - bottom: 120px; - right:0; - left:0; - position:fixed; + margin-top: 80px !important; } .stakeholderPage #page_content.greyOut:before { diff --git a/src/assets/theme-assets/dashboard-custom.css b/src/assets/theme-assets/dashboard-custom.css index 9d784f9..a150484 100644 --- a/src/assets/theme-assets/dashboard-custom.css +++ b/src/assets/theme-assets/dashboard-custom.css @@ -72,6 +72,7 @@ html .dashboard { .dashboard .sidebar_mini #sidebar_main .sidebar_main_header .portalLogo{ background: url("/assets/logo-small-monitor.png") no-repeat !important; + background-size: 50px 50px !important; /* background-size: contain !important; margin-left: 5px;*/ diff --git a/src/environments/environment.beta.ts b/src/environments/environment.beta.ts index 4b6cd78..fa49217 100644 --- a/src/environments/environment.beta.ts +++ b/src/environments/environment.beta.ts @@ -53,7 +53,7 @@ export let properties: EnvProperties = { cookieDomain: ".openaire.eu", - feedbackmail: "openaire.test@gmail.com", + feedbackmail: "feedback@openaire.eu", cacheUrl: "https://demo.openaire.eu/cache/get?url=",