Production release February 2024 [CONNECT] #34

Merged
konstantina.galouni merged 168 commits from develop into master 2024-02-15 11:04:20 +01:00
4 changed files with 125 additions and 16 deletions
Showing only changes of commit 704f52c969 - Show all commits

View File

@ -390,7 +390,7 @@ export class IndicatorUtils {
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;
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
if (stakeholder.statsProfile) {
@ -450,6 +450,20 @@ export class IndicatorUtils {
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
if (replacedUrl.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) != -1) {
@ -540,7 +554,7 @@ export class IndicatorUtils {
/*Chart with proper json object*/
//apply the filter in any select fields
for (let select of queries["query"]["select"]) {
let filterString = IndicatorFilterUtils.getFilter(select["field"], filterType);
let filterString = IndicatorFilterUtils.getFilter(select["field"], filterType,filterValue);
if (filterString) {
let filter = JSON.parse(filterString);
//check if filter already exists

View File

@ -221,13 +221,13 @@ 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 {
static getFilter(fieldPath: string, filterType:FilterType) {
if((filterType == "start_year" || filterType == "end_year") && (fieldPath.indexOf(".year") != -1 || fieldPath.indexOf(".start year") != -1)
&& fieldPath.indexOf("indi_pub_downloads_year.year") == -1){
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)
&& 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
//exclude indi_pub_downloads_year.year because it throws errors. when there is a solution remove the exclusion
if (filterType == "start_year") {
@ -236,6 +236,40 @@ export class IndicatorFilterUtils {
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]:"";
if(["publication", "software", "dataset", "other", "result"].indexOf(table)!=-1){
return this.getResultFilter(table,filterType);
@ -260,7 +294,10 @@ export class IndicatorFilterUtils {
}
}else if (filterType == "co-funded") {
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 "";
}
static getProjectFilter( filterType:FilterType) {

View File

@ -20,6 +20,8 @@ import {RangeFilterComponent} from "../utils/rangeFilter/rangeFilter.component";
import {Dates, StringUtils} from "../utils/string-utils.class";
import {Params} from "@angular/router";
import {StatisticsService} from "../monitor-admin/utils/services/statistics.service";
import {SearchResearchResultsService} from "../services/searchResearchResults.service";
import {CustomFilterService} from "../../shared/customFilter.service";
@Directive()
export abstract class MonitorIndicatorStakeholderBaseComponent extends IndicatorStakeholderBaseComponent implements OnInit {
@ -57,6 +59,8 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
protected cdr: ChangeDetectorRef;
protected layoutService: LayoutService;
protected statisticsService: StatisticsService;
protected searchResearchResultsService: SearchResearchResultsService;
protected customFilterService: CustomFilterService;
@HostListener('fullscreenchange', ['$event'])
@HostListener('webkitfullscreenchange', ['$event'])
@ -74,6 +78,7 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
}
protected setView(params: Params) {
this.setSelectedFilters();
this.loading = false;
if (params['topic']) {
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) {
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() {
@ -271,15 +277,14 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
}
public filterChanged($event, navigate: boolean = true) {
let selected = "";
let selected = [];
for (let value of $event.value.values) {
if (value.selected) {
selected = value.id;
break;
selected.push( StringUtils.quote(StringUtils.URIEncode(value.id)));
}
}
if (selected) {
this.queryParams[$event.value.filterId] = StringUtils.quote(StringUtils.URIEncode(selected));
if (selected.length > 0) {
this.queryParams[$event.value.filterId] = selected.join(",");
} else {
delete this.queryParams[$event.value.filterId];
}
@ -408,4 +413,57 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator
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;
}
}

View File

@ -36,12 +36,12 @@ export class LogService {
}
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){
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){
return this.http.post(properties.logServiceUrl, new OrcidLinkLog(action, title, doi) );
return this.http.post(properties.logServiceUrl+"logAction", new OrcidLinkLog(action, title, doi) );
}
}