Merge Angular 16 Irish Monitor to develop #33
|
@ -390,7 +390,7 @@ export class IndicatorUtils {
|
||||||
return (indicatorPath.chartObject ? indicatorPath.url + encodeURIComponent(replacedUrl) : 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 {
|
public getFullUrlWithFilters(stakeholder: Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null, coFunded: boolean = false, foslvl1:string[]=[], foslvl2:string[]=[] ): string {
|
||||||
indicatorPath.filtersApplied = 0;
|
indicatorPath.filtersApplied = 0;
|
||||||
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
||||||
if (stakeholder.statsProfile) {
|
if (stakeholder.statsProfile) {
|
||||||
|
@ -450,6 +450,20 @@ export class IndicatorUtils {
|
||||||
indicatorPath.filtersApplied += filterResults.filtersApplied;
|
indicatorPath.filtersApplied += filterResults.filtersApplied;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (foslvl1) {
|
||||||
|
if (indicatorPath.source == "stats-tool" && indicatorPath.chartObject) {
|
||||||
|
let filterResults = this.addFilter(replacedUrl, 'foslvl1', foslvl1);
|
||||||
|
replacedUrl = filterResults.url;
|
||||||
|
indicatorPath.filtersApplied +=filterResults.filtersApplied?foslvl1.length:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (foslvl2) {
|
||||||
|
if (indicatorPath.source == "stats-tool" && indicatorPath.chartObject) {
|
||||||
|
let filterResults = this.addFilter(replacedUrl, 'foslvl2', foslvl2);
|
||||||
|
replacedUrl = filterResults.url;
|
||||||
|
indicatorPath.filtersApplied += filterResults.filtersApplied?foslvl2.length:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//For numbers
|
//For numbers
|
||||||
if (replacedUrl.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) != -1) {
|
if (replacedUrl.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) != -1) {
|
||||||
|
@ -540,7 +554,7 @@ export class IndicatorUtils {
|
||||||
/*Chart with proper json object*/
|
/*Chart with proper json object*/
|
||||||
//apply the filter in any select fields
|
//apply the filter in any select fields
|
||||||
for (let select of queries["query"]["select"]) {
|
for (let select of queries["query"]["select"]) {
|
||||||
let filterString = IndicatorFilterUtils.getFilter(select["field"], filterType);
|
let filterString = IndicatorFilterUtils.getFilter(select["field"], filterType,filterValue);
|
||||||
if (filterString) {
|
if (filterString) {
|
||||||
let filter = JSON.parse(filterString);
|
let filter = JSON.parse(filterString);
|
||||||
//check if filter already exists
|
//check if filter already exists
|
||||||
|
|
|
@ -221,11 +221,11 @@ export class IndicatorPath {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded";
|
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded" | "foslvl1" | "foslvl2";
|
||||||
|
|
||||||
export class IndicatorFilterUtils {
|
export class IndicatorFilterUtils {
|
||||||
|
|
||||||
static getFilter(fieldPath: string, filterType:FilterType) {
|
static getFilter(fieldPath: string, filterType:FilterType, value:string|string[] =null) {
|
||||||
if ((filterType == "start_year" || filterType == "end_year") && (fieldPath.indexOf(".year") != -1 || fieldPath.indexOf(".start year") != -1)
|
if ((filterType == "start_year" || filterType == "end_year") && (fieldPath.indexOf(".year") != -1 || fieldPath.indexOf(".start year") != -1)
|
||||||
&& fieldPath.indexOf("indi_pub_downloads_year.year") == -1) {
|
&& fieldPath.indexOf("indi_pub_downloads_year.year") == -1) {
|
||||||
// make it work for any table with field year or start year no matter the type or the table name
|
// make it work for any table with field year or start year no matter the type or the table name
|
||||||
|
@ -236,6 +236,40 @@ export class IndicatorFilterUtils {
|
||||||
return '{"groupFilters":[{"field":"' + fieldPath + '","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"' + fieldPath + '","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((filterType == "foslvl1" || filterType == "foslvl2") ){
|
||||||
|
if (filterType == "foslvl1" && fieldPath.indexOf("result.result_fos.lvl1")!=-1 && value && value.length > 0) {
|
||||||
|
let filterString = '{"groupFilters":[' ;
|
||||||
|
let filters = [];
|
||||||
|
for(let v of value) {
|
||||||
|
filters.push('{"field":"' + fieldPath + '","type":"=","values":["' + v + '"]}');
|
||||||
|
}
|
||||||
|
filterString+=filters.join(", ")
|
||||||
|
filterString+='],"op":"OR"}'
|
||||||
|
return filterString;
|
||||||
|
}
|
||||||
|
if (filterType == "foslvl1" && fieldPath.indexOf("result.result_fos.lvl2")!=-1 && value && value.length > 0) {
|
||||||
|
let filterString = '{"groupFilters":[' ;
|
||||||
|
let filters = [];
|
||||||
|
for(let v of value) {
|
||||||
|
filters.push('{"field":"' + (fieldPath.replace(".lvl2",".lvl1")) + '","type":"=","values":["' + v + '"]}');
|
||||||
|
}
|
||||||
|
filterString+=filters.join(", ")
|
||||||
|
filterString+='],"op":"OR"}'
|
||||||
|
return filterString;
|
||||||
|
}
|
||||||
|
if (filterType == "foslvl2" && fieldPath.indexOf("result.result_fos.lvl2")!=-1 && value && value.length > 0) {
|
||||||
|
let filterString = '{"groupFilters":[' ;
|
||||||
|
let filters = [];
|
||||||
|
for(let v of value) {
|
||||||
|
filters.push('{"field":"' + fieldPath + '","type":"=","values":["' + v + '"]}');
|
||||||
|
}
|
||||||
|
filterString+=filters.join(", ")
|
||||||
|
filterString+='],"op":"OR"}'
|
||||||
|
return filterString;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
|
||||||
|
}
|
||||||
let table = fieldPath&&fieldPath.length > 0? fieldPath.split(".")[0]:"";
|
let table = fieldPath&&fieldPath.length > 0? fieldPath.split(".")[0]:"";
|
||||||
if(["publication", "software", "dataset", "other", "result"].indexOf(table)!=-1){
|
if(["publication", "software", "dataset", "other", "result"].indexOf(table)!=-1){
|
||||||
return this.getResultFilter(table,filterType);
|
return this.getResultFilter(table,filterType);
|
||||||
|
@ -260,6 +294,9 @@ export class IndicatorFilterUtils {
|
||||||
}
|
}
|
||||||
}else if (filterType == "co-funded") {
|
}else if (filterType == "co-funded") {
|
||||||
return '{"groupFilters":[{"field":"' + table + '.No of funders","type":">","values":["1"]}],"op":"AND"}';
|
return '{"groupFilters":[{"field":"' + table + '.No of funders","type":">","values":["1"]}],"op":"AND"}';
|
||||||
|
|
||||||
|
}else if (table == "publication" &&(filterType == "foslvl1" || filterType == "foslvl2") ){
|
||||||
|
return '{"groupFilters":[{"field":"' + (filterType == "foslvl1"?"publication.topics.result.result_fos.lvl1":"publication.topics.result.result_fos.lvl2") + '","type":"=","values":["' + ChartHelper.prefix + filterType + ChartHelper.suffix + '"]}],"op":"OR"}';
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ import {RangeFilterComponent} from "../utils/rangeFilter/rangeFilter.component";
|
||||||
import {Dates, StringUtils} from "../utils/string-utils.class";
|
import {Dates, StringUtils} from "../utils/string-utils.class";
|
||||||
import {Params} from "@angular/router";
|
import {Params} from "@angular/router";
|
||||||
import {StatisticsService} from "../monitor-admin/utils/services/statistics.service";
|
import {StatisticsService} from "../monitor-admin/utils/services/statistics.service";
|
||||||
|
import {SearchResearchResultsService} from "../services/searchResearchResults.service";
|
||||||
|
import {CustomFilterService} from "../../shared/customFilter.service";
|
||||||
|
|
||||||
@Directive()
|
@Directive()
|
||||||
export abstract class MonitorIndicatorStakeholderBaseComponent extends IndicatorStakeholderBaseComponent implements OnInit {
|
export abstract class MonitorIndicatorStakeholderBaseComponent extends IndicatorStakeholderBaseComponent implements OnInit {
|
||||||
|
@ -57,6 +59,8 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
|
||||||
protected cdr: ChangeDetectorRef;
|
protected cdr: ChangeDetectorRef;
|
||||||
protected layoutService: LayoutService;
|
protected layoutService: LayoutService;
|
||||||
protected statisticsService: StatisticsService;
|
protected statisticsService: StatisticsService;
|
||||||
|
protected searchResearchResultsService: SearchResearchResultsService;
|
||||||
|
protected customFilterService: CustomFilterService;
|
||||||
|
|
||||||
@HostListener('fullscreenchange', ['$event'])
|
@HostListener('fullscreenchange', ['$event'])
|
||||||
@HostListener('webkitfullscreenchange', ['$event'])
|
@HostListener('webkitfullscreenchange', ['$event'])
|
||||||
|
@ -74,6 +78,7 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
|
||||||
}
|
}
|
||||||
|
|
||||||
protected setView(params: Params) {
|
protected setView(params: Params) {
|
||||||
|
this.setSelectedFilters();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
if (params['topic']) {
|
if (params['topic']) {
|
||||||
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.hasPermission(topic.visibility));
|
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.hasPermission(topic.visibility));
|
||||||
|
@ -195,7 +200,8 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getFullUrl(indicatorPath: IndicatorPath) {
|
protected getFullUrl(indicatorPath: IndicatorPath) {
|
||||||
return this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath);
|
let fosValues = this.getSelectedFilterValues("fos");
|
||||||
|
return this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, indicatorPath,null, this.periodFilter.selectedFromValue, this.periodFilter.selectedToValue, false, fosValues?fosValues.lvl1:[],fosValues?fosValues.lvl2:[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected setIndicators() {
|
protected setIndicators() {
|
||||||
|
@ -271,15 +277,14 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
|
||||||
}
|
}
|
||||||
|
|
||||||
public filterChanged($event, navigate: boolean = true) {
|
public filterChanged($event, navigate: boolean = true) {
|
||||||
let selected = "";
|
let selected = [];
|
||||||
for (let value of $event.value.values) {
|
for (let value of $event.value.values) {
|
||||||
if (value.selected) {
|
if (value.selected) {
|
||||||
selected = value.id;
|
selected.push( StringUtils.quote(StringUtils.URIEncode(value.id)));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected) {
|
if (selected.length > 0) {
|
||||||
this.queryParams[$event.value.filterId] = StringUtils.quote(StringUtils.URIEncode(selected));
|
this.queryParams[$event.value.filterId] = selected.join(",");
|
||||||
} else {
|
} else {
|
||||||
delete this.queryParams[$event.value.filterId];
|
delete this.queryParams[$event.value.filterId];
|
||||||
}
|
}
|
||||||
|
@ -408,4 +413,57 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
|
||||||
indicator.descriptionOverlay = false;
|
indicator.descriptionOverlay = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Refine Type Filters
|
||||||
|
|
||||||
|
setSelectedFilters(){
|
||||||
|
for (var i = 0; i < this.filters.length; i++) {
|
||||||
|
var filter: Filter = this.filters[i];
|
||||||
|
filter.countSelectedValues = 0;
|
||||||
|
let parameterNames = Object.keys(this.queryParams);
|
||||||
|
if (parameterNames.indexOf(filter.filterId) != -1) {
|
||||||
|
let values = (decodeURIComponent(this.queryParams[filter.filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
|
||||||
|
for (let filterValue of filter.values) {
|
||||||
|
if (values.indexOf(StringUtils.quote(filterValue.id)) > -1) {
|
||||||
|
filterValue.selected = true;
|
||||||
|
filter.countSelectedValues++;
|
||||||
|
} else {
|
||||||
|
filterValue.selected = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (let filterValue of filter.values) {
|
||||||
|
filterValue.selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getSelectedFilterValues(filterId){
|
||||||
|
let values = null;
|
||||||
|
for (let filter of this.filters) {
|
||||||
|
if(filterId == filter.filterId && filter.countSelectedValues > 0) {
|
||||||
|
values =filterId == "fos"?{lvl1:[],lvl2:[]}:[];
|
||||||
|
for (let filterValue of filter.values) {
|
||||||
|
if (filterValue.selected) {
|
||||||
|
if(filterId == "fos"){
|
||||||
|
let code = filterValue.id.split(" ")[0];
|
||||||
|
if(code.length == 2){
|
||||||
|
values.lvl1.push(filterValue.id)
|
||||||
|
}else{
|
||||||
|
values.lvl2.push(filterValue.id)
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
values.push(filterValue.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,12 @@ export class LogService {
|
||||||
}
|
}
|
||||||
|
|
||||||
logUploadDOIs(properties: EnvProperties, dois:number){
|
logUploadDOIs(properties: EnvProperties, dois:number){
|
||||||
return this.http.post(properties.logServiceUrl, new UploadLog(dois) );
|
return this.http.post(properties.logServiceUrl+"logAction", new UploadLog(dois) );
|
||||||
}
|
}
|
||||||
logLink(properties: EnvProperties){
|
logLink(properties: EnvProperties){
|
||||||
return this.http.post(properties.logServiceUrl, new LinkLog() );
|
return this.http.post(properties.logServiceUrl+"logAction", new LinkLog() );
|
||||||
}
|
}
|
||||||
logOrcidLink(properties: EnvProperties, action:'added'|'removed', title: string, doi: string){
|
logOrcidLink(properties: EnvProperties, action:'added'|'removed', title: string, doi: string){
|
||||||
return this.http.post(properties.logServiceUrl, new OrcidLinkLog(action, title, doi) );
|
return this.http.post(properties.logServiceUrl+"logAction", new OrcidLinkLog(action, title, doi) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue