2020-01-08 12:00:50 +01:00
|
|
|
import {
|
2020-07-07 16:08:47 +02:00
|
|
|
ChartHelper, FilterType,
|
|
|
|
Indicator, IndicatorFilterUtils,
|
|
|
|
IndicatorPath, IndicatorPathType, IndicatorType,
|
2020-01-08 12:00:50 +01:00
|
|
|
SourceType,
|
|
|
|
Stakeholder,
|
|
|
|
SubCategory,
|
2020-10-23 15:58:16 +02:00
|
|
|
Topic, Visibility
|
2020-06-03 15:44:03 +02:00
|
|
|
} from "../openaireLibrary/monitor/entities/stakeholder";
|
2019-12-06 14:52:26 +01:00
|
|
|
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
2020-11-12 18:57:57 +01:00
|
|
|
import {Option} from "../openaireLibrary/sharedComponents/input/input.component";
|
2020-11-03 10:42:47 +01:00
|
|
|
import {Session} from "../openaireLibrary/login/utils/helper.class";
|
2019-11-13 15:27:07 +01:00
|
|
|
|
2019-11-29 13:14:49 +01:00
|
|
|
export class StakeholderUtils {
|
2020-10-19 11:07:43 +02:00
|
|
|
statuses: Option[] = [
|
|
|
|
{value: 'PUBLIC', label: 'Public'},
|
|
|
|
{value: 'RESTRICTED', label: 'Restricted'},
|
|
|
|
{value: 'PRIVATE', label: 'Private'}
|
2020-11-03 10:42:47 +01:00
|
|
|
];
|
2020-05-15 14:26:59 +02:00
|
|
|
|
2019-11-29 13:14:49 +01:00
|
|
|
types: Option[] = [
|
2020-05-15 14:26:59 +02:00
|
|
|
{value: 'funder', label: 'Funder'},
|
|
|
|
{value: 'ri', label: 'Reasearch Initiative'},
|
|
|
|
{value: 'project', label: 'Project'},
|
|
|
|
{value: 'organization', label: 'Organization'}
|
2019-11-29 13:14:49 +01:00
|
|
|
];
|
2020-11-03 11:59:48 +01:00
|
|
|
getTypesByUserRoles(user, id:string = null):Option[]{
|
2020-11-03 10:42:47 +01:00
|
|
|
let types = [];
|
|
|
|
for(let type of this.types){
|
2020-11-04 17:04:29 +01:00
|
|
|
if(Session.isCurator(type.value, user)|| Session.isPortalAdministrator(user)|| (id && Session.isManager(type.value, id, user))){
|
2020-11-03 10:42:47 +01:00
|
|
|
types.push(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return types;
|
|
|
|
}
|
2020-10-23 15:58:16 +02:00
|
|
|
visibility: Option[] = [
|
|
|
|
{icon: 'world', value: "PUBLIC", label: 'Public'},
|
|
|
|
{icon: 'lock', value: "RESTRICTED", label: 'Restricted'},
|
|
|
|
{icon: 'users', value: "PRIVATE", label: 'Private'},
|
2019-11-29 13:14:49 +01:00
|
|
|
];
|
|
|
|
|
2019-11-29 14:35:13 +01:00
|
|
|
isActive: Option[] = [
|
2019-11-29 13:14:49 +01:00
|
|
|
{icon: 'brightness_1', iconClass: '', value: true, label: 'Active'},
|
|
|
|
{icon: 'brightness_1', value: false, label: 'Inactive'},
|
|
|
|
];
|
|
|
|
|
2020-10-31 17:02:30 +01:00
|
|
|
visibilityIcon: Map<Visibility, string> = new Map<Visibility, string> ([
|
|
|
|
["PUBLIC", 'earth'],
|
2020-10-23 15:58:16 +02:00
|
|
|
["PRIVATE", 'lock'],
|
2020-10-31 17:02:30 +01:00
|
|
|
["RESTRICTED", 'group']
|
2019-11-29 13:14:49 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
isActiveIcon: string = 'brightness_1';
|
2019-11-29 14:35:13 +01:00
|
|
|
|
2019-11-29 15:46:40 +01:00
|
|
|
public createFunderFromDefaultProfile(funder: Stakeholder, defaultTopics: Topic[]): Stakeholder {
|
|
|
|
funder.topics = defaultTopics;
|
2019-11-29 14:35:13 +01:00
|
|
|
for (let topic of funder.topics) {
|
2020-01-09 15:31:55 +01:00
|
|
|
// console.log('id:' + topic._id);
|
2020-01-09 14:15:39 +01:00
|
|
|
topic.defaultId = topic._id;
|
2019-12-05 13:01:27 +01:00
|
|
|
topic._id = null;
|
2020-01-09 15:31:55 +01:00
|
|
|
// console.log('defaultId:' + topic.defaultId);
|
2019-11-29 14:35:13 +01:00
|
|
|
for (let category of topic.categories) {
|
2020-01-09 14:15:39 +01:00
|
|
|
category.defaultId = category._id;
|
2019-12-05 13:01:27 +01:00
|
|
|
category._id = null;
|
2019-11-29 14:35:13 +01:00
|
|
|
let subTokeep: SubCategory[] = [];
|
|
|
|
for (let subCategory of category.subCategories) {
|
2020-01-09 14:15:39 +01:00
|
|
|
subCategory.defaultId = subCategory._id;
|
2019-12-05 13:01:27 +01:00
|
|
|
subCategory._id = null;
|
2020-01-09 14:15:39 +01:00
|
|
|
if (!subCategory.recommendedFor || subCategory.recommendedFor.length == 0 || subCategory.recommendedFor.indexOf(funder.index_id) != -1) {
|
2019-11-29 14:35:13 +01:00
|
|
|
subTokeep.push(subCategory);
|
|
|
|
}
|
2020-01-08 12:00:50 +01:00
|
|
|
for (let section of subCategory.charts) {
|
|
|
|
let chartsTokeep: Indicator[] = [];
|
2020-01-09 14:15:39 +01:00
|
|
|
section.defaultId = section._id;
|
|
|
|
section.stakeholderAlias = funder.alias;
|
2020-01-08 12:00:50 +01:00
|
|
|
section._id = null;
|
|
|
|
for (let indicator of section.indicators) {
|
2020-01-09 14:15:39 +01:00
|
|
|
indicator.defaultId = indicator._id;
|
2020-01-08 12:00:50 +01:00
|
|
|
indicator._id = null;
|
2020-01-09 14:15:39 +01:00
|
|
|
if (!indicator.recommendedFor || indicator.recommendedFor.length == 0 || indicator.recommendedFor.indexOf(funder.index_id) != -1) {
|
2020-01-08 12:00:50 +01:00
|
|
|
chartsTokeep.push(indicator);
|
|
|
|
}
|
|
|
|
for (let indicatorPath of indicator.indicatorPaths) {
|
|
|
|
if (indicatorPath.parameters) {
|
|
|
|
Object.keys(indicatorPath.parameters).forEach(key => {
|
2020-01-10 12:32:23 +01:00
|
|
|
//TODO check before delete
|
|
|
|
/*if (indicatorPath.parameters[key].indexOf("_funder_name_") != -1) {
|
2020-01-08 12:00:50 +01:00
|
|
|
indicatorPath.parameters[key] = indicatorPath.parameters[key].replace("_funder_name_", funder.index_name);
|
|
|
|
} else if (indicatorPath.parameters[key].indexOf("_funder_id_") != -1) {
|
|
|
|
indicatorPath.parameters[key] = indicatorPath.parameters[key].replace("_funder_id_", funder.index_id);
|
|
|
|
} else if (indicatorPath.parameters[key].indexOf("_fsn_") != -1) {
|
|
|
|
indicatorPath.parameters[key] = indicatorPath.parameters[key].toString().replace("_fsn_", funder.index_shortName.toLowerCase());
|
2020-01-10 12:32:23 +01:00
|
|
|
}*/
|
|
|
|
if (key == "index_name") {
|
|
|
|
indicatorPath.parameters[key] = funder.index_name;
|
|
|
|
} else if (key == "index_id" ) {
|
|
|
|
indicatorPath.parameters[key] = funder.index_id;
|
|
|
|
} else if (key == "index_shortName" ) {
|
|
|
|
indicatorPath.parameters[key] = funder.index_shortName.toLowerCase();
|
2020-01-08 12:00:50 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-11-29 14:35:13 +01:00
|
|
|
}
|
|
|
|
}
|
2020-01-08 12:00:50 +01:00
|
|
|
section.indicators = chartsTokeep;
|
2019-11-29 14:35:13 +01:00
|
|
|
}
|
2020-01-08 12:00:50 +01:00
|
|
|
for (let section of subCategory.numbers) {
|
2020-01-09 14:15:39 +01:00
|
|
|
section.defaultId = section._id;
|
|
|
|
section.stakeholderAlias = funder.alias;
|
2020-01-08 12:00:50 +01:00
|
|
|
section._id = null;
|
|
|
|
for(let indicator of section.indicators) {
|
2020-01-09 14:15:39 +01:00
|
|
|
indicator.defaultId = indicator._id;
|
2020-01-08 12:00:50 +01:00
|
|
|
indicator._id = null;
|
|
|
|
for (let indicatorPath of indicator.indicatorPaths) {
|
2020-06-18 14:03:26 +02:00
|
|
|
/* indicatorPath.url = indicatorPath.url.replace("index_id", encodeURIComponent(funder.index_id));
|
2020-01-10 12:32:23 +01:00
|
|
|
indicatorPath.url = indicatorPath.url.replace("index_name", encodeURIComponent(funder.index_name));
|
2020-06-18 14:03:26 +02:00
|
|
|
indicatorPath.url = indicatorPath.url.replace("index_shortName", encodeURIComponent(funder.index_shortName));*/
|
2020-01-08 12:00:50 +01:00
|
|
|
// if(indicatorPath.parameters) {
|
|
|
|
// indicatorPath.parameters.forEach((value: string, key: string) => {
|
|
|
|
// if (value.indexOf("_funder_name_")!=-1) {
|
|
|
|
// indicatorPath.parameters.set(key,value.toString().replace("_funder_name_", funder.index_name));
|
|
|
|
// }else if (value.indexOf("_fsn_")!=-1) {
|
|
|
|
// indicatorPath.parameters.set(key,value.toString().replace("_fsn_", funder.index_shortName.toLowerCase()));
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
}
|
2019-11-29 14:35:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
category.subCategories = subTokeep;
|
|
|
|
}
|
|
|
|
}
|
2020-01-10 12:32:23 +01:00
|
|
|
console.log (funder)
|
2019-11-29 14:35:13 +01:00
|
|
|
return funder;
|
|
|
|
}
|
2019-12-06 14:52:26 +01:00
|
|
|
|
|
|
|
aliasValidator(elements: any[]): ValidatorFn {
|
2020-11-05 00:11:00 +01:00
|
|
|
return (control: AbstractControl): { [key: string]: string } | null => {
|
2019-12-23 14:54:37 +01:00
|
|
|
if (control.value && elements.find(element =>
|
|
|
|
element.alias === control.value
|
2019-12-06 14:52:26 +01:00
|
|
|
)) {
|
2020-11-05 00:11:00 +01:00
|
|
|
return {'error': 'Alias already in use'};
|
2019-12-06 14:52:26 +01:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 18:26:58 +02:00
|
|
|
|
2019-12-06 14:52:26 +01:00
|
|
|
generateAlias(name: string): string {
|
2019-12-23 14:54:37 +01:00
|
|
|
let alias = name.toLowerCase();
|
2020-06-29 18:26:58 +02:00
|
|
|
while (alias.includes('/') || alias.includes(' ')) {
|
2019-12-23 14:54:37 +01:00
|
|
|
alias = alias.replace(' / ', '-');
|
2020-06-29 18:26:58 +02:00
|
|
|
alias = alias.replace('/', '-');
|
2019-12-23 14:54:37 +01:00
|
|
|
alias = alias.replace(' ', '-');
|
|
|
|
}
|
|
|
|
return alias;
|
2019-12-06 14:52:26 +01:00
|
|
|
}
|
2019-11-29 13:14:49 +01:00
|
|
|
}
|
|
|
|
|
2019-11-08 16:47:47 +01:00
|
|
|
export class IndicatorUtils {
|
|
|
|
|
2020-06-02 17:44:45 +02:00
|
|
|
allChartTypes: Option[] = [
|
2019-11-24 17:30:04 +01:00
|
|
|
{value: 'pie', label: 'Pie'},
|
|
|
|
{value: 'table', label: 'Table'},
|
|
|
|
{value: 'line', label: 'Line'},
|
|
|
|
{value: 'column', label: 'Column'},
|
|
|
|
{value: 'bar', label: 'Bar'},
|
|
|
|
{value: 'other', label: 'Other'}
|
|
|
|
];
|
2020-06-02 17:44:45 +02:00
|
|
|
basicChartTypes:IndicatorPathType[] =["pie", "line", "column", "bar"];
|
|
|
|
defaultChartType:IndicatorPathType = "other";
|
2020-06-09 16:49:52 +02:00
|
|
|
indicatorSizes: Option[] = [
|
2019-11-24 17:30:04 +01:00
|
|
|
{value: 'small', label: 'Small'},
|
|
|
|
{value: 'medium', label: 'Medium'},
|
|
|
|
{value: 'large', label: 'Large'}
|
|
|
|
];
|
|
|
|
|
2020-06-09 16:49:52 +02:00
|
|
|
sourceTypes: Option[] = [
|
|
|
|
{value: 'search', label: 'Search'},
|
|
|
|
{value: 'statistics', label: 'Statistics'},
|
2020-07-07 16:08:47 +02:00
|
|
|
{value: 'metrics', label: 'Metrics'},
|
|
|
|
{value: 'stats-tool', label: 'Statistics tool'}
|
|
|
|
];
|
2020-06-09 16:49:52 +02:00
|
|
|
|
2019-11-29 14:35:13 +01:00
|
|
|
isPublic: Option[] = [
|
2019-11-24 17:30:04 +01:00
|
|
|
{icon: 'public', value: true, label: 'Public'},
|
|
|
|
{icon: 'lock', value: false, label: 'Private'},
|
|
|
|
];
|
|
|
|
|
2019-11-29 14:35:13 +01:00
|
|
|
isActive: Option[] = [
|
2019-11-24 17:30:04 +01:00
|
|
|
{icon: 'brightness_1', iconClass: '', value: true, label: 'Active'},
|
|
|
|
{icon: 'brightness_1', value: false, label: 'Inactive'},
|
|
|
|
];
|
|
|
|
|
|
|
|
chartTypesIcons: Map<string, string> = new Map([
|
2019-11-08 16:47:47 +01:00
|
|
|
['pie', 'pie_chart'],
|
|
|
|
['table', 'table_chart'],
|
|
|
|
['line', 'show_chart'],
|
|
|
|
['column', 'bar_chart'],
|
2019-11-28 11:30:56 +01:00
|
|
|
['bar', 'notes'],
|
2019-11-24 17:30:04 +01:00
|
|
|
['other', 'perm_media']
|
2019-11-08 16:47:47 +01:00
|
|
|
]);
|
2020-06-02 17:44:45 +02:00
|
|
|
getChartTypes(initialType){
|
|
|
|
let types: Option[]= [];
|
|
|
|
if(this.basicChartTypes.indexOf(initialType) != -1){
|
|
|
|
(this.allChartTypes).forEach(option => {
|
|
|
|
if(this.basicChartTypes.indexOf(option.value)!=-1){
|
|
|
|
types.push(option);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return types;
|
|
|
|
}else if(initialType == "table") {
|
|
|
|
(this.allChartTypes).forEach(option => {
|
|
|
|
if (initialType == option.value) {
|
|
|
|
types.push(option);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return types;
|
|
|
|
}else {
|
|
|
|
return this.allChartTypes;
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 16:47:47 +01:00
|
|
|
isPublicIcon: Map<boolean, string> = new Map([
|
|
|
|
[true, 'public'],
|
|
|
|
[false, 'lock']
|
|
|
|
]);
|
|
|
|
|
|
|
|
isActiveIcon: string = 'brightness_1';
|
2019-11-13 15:27:07 +01:00
|
|
|
|
2020-01-10 12:32:23 +01:00
|
|
|
ignoredParameters = ['index_name','index_id','index_shortName'];
|
2019-11-20 11:32:28 +01:00
|
|
|
|
2019-11-24 17:30:04 +01:00
|
|
|
parametersValidators: Map<string, any> = new Map<string, any>([
|
|
|
|
['start_year', [Validators.required, Validators.pattern('^\\d+$')]],
|
|
|
|
['end_year', [Validators.required, Validators.pattern('^\\d+$')]]
|
|
|
|
]);
|
|
|
|
|
2020-07-07 16:08:47 +02:00
|
|
|
public getFullUrl(stakeholder:Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null): string {
|
2020-08-06 09:34:41 +02:00
|
|
|
let replacedUrl =indicatorPath.chartObject?indicatorPath.chartObject:indicatorPath.url;
|
2019-11-19 15:25:19 +01:00
|
|
|
if (indicatorPath.parameters) {
|
2019-11-24 17:30:04 +01:00
|
|
|
Object.keys(indicatorPath.parameters).forEach(key => {
|
|
|
|
let replacedValue = indicatorPath.parameters[key];
|
2020-07-07 16:08:47 +02:00
|
|
|
if (startYear && key == "start_year" && indicatorPath.filters["start_year"]) {
|
|
|
|
replacedValue = (replacedValue < startYear) ? startYear : replacedValue;
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
if (endYear && key == "end_year" && indicatorPath.filters["end_year"]) {
|
|
|
|
replacedValue = (replacedValue > endYear) ? endYear : replacedValue;
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
2020-06-02 14:45:08 +02:00
|
|
|
if (key == "index_id") {
|
|
|
|
replacedValue = stakeholder.index_id;
|
|
|
|
}
|
|
|
|
if (key == "index_name") {
|
|
|
|
replacedValue = stakeholder.index_name;
|
|
|
|
}
|
|
|
|
if (key == "index_shortName") {
|
|
|
|
replacedValue = stakeholder.index_shortName.toLowerCase();
|
|
|
|
}
|
|
|
|
|
2019-12-05 17:10:00 +01:00
|
|
|
replacedUrl = replacedUrl.split(ChartHelper.prefix + key + ChartHelper.suffix).join(replacedValue)
|
2019-11-14 16:20:51 +01:00
|
|
|
});
|
|
|
|
}
|
2019-11-24 17:30:04 +01:00
|
|
|
if (indicatorPath.chartObject) {
|
|
|
|
if (fundingL0 && indicatorPath.filters["fundingL0"]) {
|
2019-11-20 13:55:23 +01:00
|
|
|
let newJsonObject = JSON.parse(replacedUrl);
|
2020-07-07 16:08:47 +02:00
|
|
|
for (let queries of this.getQueryObjectName(newJsonObject)?newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)]:newJsonObject[this.getDescriptionObjectName(newJsonObject)]) {
|
2019-11-24 17:30:04 +01:00
|
|
|
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
|
2019-11-20 13:55:23 +01:00
|
|
|
queries["query"]["filters"] = [];
|
|
|
|
}
|
|
|
|
//TODO check how it works if the query already has a filter
|
2019-11-29 14:35:13 +01:00
|
|
|
queries["query"]["filters"].push(JSON.parse(indicatorPath.filters["fundingL0"].replace(ChartHelper.prefix + "fundingL0" + ChartHelper.suffix, fundingL0)));
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
|
|
|
replacedUrl = JSON.stringify(newJsonObject);
|
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
if (startYear && indicatorPath.filters["start_year"]) {
|
|
|
|
let newJsonObject = JSON.parse(replacedUrl);
|
|
|
|
|
|
|
|
for (let queries of this.getQueryObjectName(newJsonObject)?newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)]:newJsonObject[this.getDescriptionObjectName(newJsonObject)]) {
|
|
|
|
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
|
|
|
|
queries["query"]["filters"] = [];
|
|
|
|
}
|
|
|
|
//TODO check how it works if the query already has a filter
|
|
|
|
queries["query"]["filters"].push(JSON.parse(indicatorPath.filters["start_year"].replace(ChartHelper.prefix + "start_year" + ChartHelper.suffix, startYear)));
|
|
|
|
}
|
|
|
|
replacedUrl = JSON.stringify(newJsonObject);
|
|
|
|
}
|
|
|
|
if (endYear && indicatorPath.filters["end_year"]) {
|
|
|
|
let newJsonObject = JSON.parse(replacedUrl);
|
|
|
|
for (let queries of this.getQueryObjectName(newJsonObject)?newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)]:newJsonObject[this.getDescriptionObjectName(newJsonObject)]) {
|
|
|
|
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
|
|
|
|
queries["query"]["filters"] = [];
|
|
|
|
}
|
|
|
|
//TODO check how it works if the query already has a filter
|
|
|
|
queries["query"]["filters"].push(JSON.parse(indicatorPath.filters["end_year"].replace(ChartHelper.prefix + "end_year" + ChartHelper.suffix, endYear)));
|
|
|
|
}
|
|
|
|
replacedUrl = JSON.stringify(newJsonObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//For numbers
|
|
|
|
if(indicatorPath.url.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) !=- 1){
|
|
|
|
indicatorPath.url = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
|
|
|
|
}
|
|
|
|
if(indicatorPath.url.indexOf(ChartHelper.prefix + 'index_name' + ChartHelper.suffix) !=- 1){
|
|
|
|
indicatorPath.url = replacedUrl.split(ChartHelper.prefix + 'index_name' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_name))
|
|
|
|
}
|
|
|
|
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))
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
2020-08-06 09:34:41 +02:00
|
|
|
return (indicatorPath.chartObject?indicatorPath.url + encodeURIComponent(replacedUrl):replacedUrl);
|
2019-11-14 16:20:51 +01:00
|
|
|
}
|
2020-07-28 17:56:48 +02:00
|
|
|
public getFullUrlWithFilters(stakeholder:Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null, coFunded:boolean=false): string {
|
2020-07-28 16:57:17 +02:00
|
|
|
indicatorPath.filtersApplied = 0;
|
2020-07-07 16:08:47 +02:00
|
|
|
let replacedUrl = indicatorPath.chartObject?indicatorPath.chartObject:indicatorPath.url;
|
|
|
|
if (indicatorPath.parameters) {
|
|
|
|
Object.keys(indicatorPath.parameters).forEach(key => {
|
|
|
|
let replacedValue = indicatorPath.parameters[key];
|
|
|
|
if (startYear && key == "start_year") {
|
|
|
|
replacedValue = (replacedValue < startYear) ? startYear : replacedValue;
|
|
|
|
}
|
|
|
|
if (endYear && key == "end_year") {
|
|
|
|
replacedValue = (replacedValue > endYear) ? endYear : replacedValue;
|
|
|
|
}
|
|
|
|
if (key == "index_id") {
|
|
|
|
replacedValue = stakeholder.index_id;
|
|
|
|
}
|
|
|
|
if (key == "index_name") {
|
|
|
|
replacedValue = stakeholder.index_name;
|
|
|
|
}
|
|
|
|
if (key == "index_shortName") {
|
|
|
|
replacedValue = stakeholder.index_shortName.toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
replacedUrl = replacedUrl.split(ChartHelper.prefix + key + ChartHelper.suffix).join(replacedValue)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (fundingL0) {
|
|
|
|
if(indicatorPath.source == "stats-tool" && indicatorPath.chartObject) {
|
|
|
|
let filterResults = this.addFilter(replacedUrl, 'fundingL0', fundingL0);
|
|
|
|
replacedUrl = filterResults.url;
|
2020-07-28 16:57:17 +02:00
|
|
|
indicatorPath.filtersApplied += filterResults.filtersApplied;
|
2020-07-07 16:08:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (startYear) {
|
|
|
|
if(indicatorPath.source == "stats-tool" && indicatorPath.chartObject) {
|
|
|
|
let filterResults = this.addFilter(replacedUrl, 'start_year', startYear);
|
|
|
|
replacedUrl = filterResults.url;
|
2020-07-28 16:57:17 +02:00
|
|
|
indicatorPath.filtersApplied += filterResults.filtersApplied;
|
2020-07-07 16:08:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (endYear ) {
|
|
|
|
if(indicatorPath.source == "stats-tool" && indicatorPath.chartObject) {
|
|
|
|
let filterResults = this.addFilter(replacedUrl, 'end_year', endYear);
|
|
|
|
replacedUrl = filterResults.url;
|
2020-07-28 16:57:17 +02:00
|
|
|
indicatorPath.filtersApplied += filterResults.filtersApplied;
|
2020-07-07 16:08:47 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-28 17:56:48 +02:00
|
|
|
if (coFunded ) {
|
|
|
|
if(indicatorPath.source == "stats-tool" && indicatorPath.chartObject) {
|
|
|
|
let filterResults = this.addFilter(replacedUrl, 'co-funded', endYear);
|
|
|
|
replacedUrl = filterResults.url;
|
|
|
|
indicatorPath.filtersApplied += filterResults.filtersApplied;
|
|
|
|
}
|
|
|
|
}
|
2019-11-13 15:27:07 +01:00
|
|
|
|
2020-07-07 16:08:47 +02:00
|
|
|
//For numbers
|
|
|
|
if (replacedUrl.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) != -1) {
|
2020-06-16 09:30:45 +02:00
|
|
|
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
|
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
if (replacedUrl.indexOf(ChartHelper.prefix + 'index_name' + ChartHelper.suffix) != -1) {
|
2020-06-16 09:30:45 +02:00
|
|
|
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_name' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_name))
|
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
if (replacedUrl.indexOf(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix) != -1) {
|
2020-06-16 09:30:45 +02:00
|
|
|
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
|
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
|
|
|
|
return (indicatorPath.chartObject?indicatorPath.url + encodeURIComponent(replacedUrl):replacedUrl);
|
|
|
|
|
|
|
|
}
|
|
|
|
private addFilter(replacedUrl, filterType:FilterType, filterValue){
|
|
|
|
let newJsonObject = JSON.parse(replacedUrl);
|
|
|
|
let filterApplied:boolean = false;
|
2020-07-28 16:57:17 +02:00
|
|
|
let queryIndex = 0;
|
2020-07-07 16:08:47 +02:00
|
|
|
for (let queries of this.getQueryObjectName(newJsonObject)?newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)]:newJsonObject[this.getDescriptionObjectName(newJsonObject)]) {
|
|
|
|
|
|
|
|
if(queries["query"]["name"] && !queries["query"]["select"]){
|
2020-07-10 10:37:51 +02:00
|
|
|
|
2020-07-28 16:57:17 +02:00
|
|
|
if(queries["query"]["name"].indexOf("monitor.")==-1 || !queries["query"]["parameters"]){
|
2020-07-07 16:08:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-07-10 10:37:51 +02:00
|
|
|
if(filterType == 'fundingL0') {
|
2020-07-15 12:06:15 +02:00
|
|
|
let paramFields = queries["query"]["name"].split(".").slice(3);
|
2020-08-06 09:34:41 +02:00
|
|
|
let filterPosition = queries["query"]["name"].split(".").indexOf(filterType == "fundingL0" ? 'fl0' : filterType) ;
|
2020-07-15 12:06:15 +02:00
|
|
|
if (filterPosition != -1) {
|
2020-08-04 09:57:51 +02:00
|
|
|
//already filtered
|
2020-07-15 12:06:15 +02:00
|
|
|
//TODO double check if we need to override if the fl0 is already filtered
|
|
|
|
filterPosition -=3;
|
2020-08-04 09:57:51 +02:00
|
|
|
/* //update the value
|
|
|
|
if(paramFields.length == queries["query"]["parameters"].length ){
|
2020-07-15 12:06:15 +02:00
|
|
|
//ok
|
|
|
|
queries["query"]["parameters"][filterPosition] = filterValue;
|
|
|
|
}else if((paramFields.length + 2) == queries["query"]["parameters"].length || (paramFields.length*2 + 4) == queries["query"]["parameters"].length){
|
|
|
|
queries["query"]["parameters"][filterPosition + 2]=filterValue;
|
|
|
|
filterApplied = true;
|
|
|
|
}
|
|
|
|
if((paramFields.length*2 + 4) == queries["query"]["parameters"].length){
|
|
|
|
queries["query"]["parameters"][(2* filterPosition) + 5]=filterValue;
|
2020-08-04 09:57:51 +02:00
|
|
|
}*/
|
|
|
|
//if applied with the same value mark as filtered
|
|
|
|
if(paramFields.length == queries["query"]["parameters"].length && queries["query"]["parameters"][filterPosition] == filterValue){
|
|
|
|
filterApplied = true;
|
|
|
|
}else if((paramFields.length + 2) == queries["query"]["parameters"].length || (paramFields.length*2 + 4) == queries["query"]["parameters"].length && queries["query"]["parameters"][filterPosition + 2]==filterValue){
|
|
|
|
filterApplied = true;
|
2020-07-10 10:37:51 +02:00
|
|
|
}
|
2020-07-15 12:06:15 +02:00
|
|
|
} else {
|
2020-10-06 14:22:59 +02:00
|
|
|
// if((paramFields.length*2) == queries["query"]["parameters"].length){
|
|
|
|
// queries["query"]["parameters"].splice(paramFields.length, 0, filterValue);
|
|
|
|
// }
|
2020-07-15 12:06:15 +02:00
|
|
|
if((paramFields.length*2 + 4) == queries["query"]["parameters"].length){
|
|
|
|
queries["query"]["parameters"].splice(paramFields.length + 1, 0, filterValue);
|
2020-07-10 10:37:51 +02:00
|
|
|
}
|
2020-07-15 12:06:15 +02:00
|
|
|
queries["query"]["name"] = queries["query"]["name"] + ".fl0";
|
|
|
|
queries["query"]["parameters"].push(filterValue);
|
2020-08-04 09:57:51 +02:00
|
|
|
filterApplied = true;
|
2020-07-15 12:06:15 +02:00
|
|
|
}
|
2020-07-10 10:37:51 +02:00
|
|
|
}else{
|
|
|
|
let paramFields = queries["query"]["name"].split(".").slice(3);
|
|
|
|
// console.debug("Field Params length:" + paramFields.length)
|
|
|
|
// console.debug(paramFields)
|
|
|
|
// console.debug("Parameters length:" + queries["query"]["parameters"].length)
|
|
|
|
console.debug("Parameters length:" + queries["query"]["parameters"].length)
|
|
|
|
|
|
|
|
if((paramFields.length + 2) == queries["query"]["parameters"].length || (paramFields.length*2 + 4) == queries["query"]["parameters"].length){
|
2020-10-06 14:22:59 +02:00
|
|
|
filterApplied = true;
|
2020-07-10 10:37:51 +02:00
|
|
|
if(filterType == "start_year"){
|
2020-10-06 14:22:59 +02:00
|
|
|
queries["query"]["parameters"][0] = parseInt(filterValue);
|
2020-07-10 10:37:51 +02:00
|
|
|
}else if(filterType == "end_year"){
|
2020-10-06 14:22:59 +02:00
|
|
|
queries["query"]["parameters"][1] = parseInt(filterValue);
|
2020-07-10 10:37:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if((paramFields.length*2 + 4) == queries["query"]["parameters"].length){
|
2020-10-06 14:22:59 +02:00
|
|
|
filterApplied = true;
|
2020-07-10 10:37:51 +02:00
|
|
|
if(filterType == "start_year"){
|
2020-10-06 14:22:59 +02:00
|
|
|
queries["query"]["parameters"][paramFields.length + 2] = parseInt(filterValue);
|
2020-07-10 10:37:51 +02:00
|
|
|
}else if(filterType == "end_year"){
|
2020-10-06 14:22:59 +02:00
|
|
|
queries["query"]["parameters"][paramFields.length + 3] = parseInt(filterValue);
|
2020-07-10 10:37:51 +02:00
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-10 10:37:51 +02:00
|
|
|
// console.debug(queries["query"])
|
2020-07-07 16:08:47 +02:00
|
|
|
// it is a name query
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
|
|
|
|
queries["query"]["filters"] = [];
|
|
|
|
}
|
|
|
|
let field = queries["query"]["select"][0]["field"];
|
2020-08-06 09:34:41 +02:00
|
|
|
let filterString = IndicatorFilterUtils.getFilter(field&&field.length > 0? field.split(".")[0]:"",filterType);
|
2020-07-07 16:08:47 +02:00
|
|
|
if(filterString){
|
|
|
|
let filter = JSON.parse(filterString);
|
2020-07-28 16:57:17 +02:00
|
|
|
let filterposition = IndicatorFilterUtils.filterIndexOf(filter,queries["query"]["filters"])
|
2020-07-07 16:08:47 +02:00
|
|
|
if(filterposition){
|
2020-07-28 16:57:17 +02:00
|
|
|
if(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0] != filter['groupFilters'][0]["values"][0].replace(ChartHelper.prefix + filterType + ChartHelper.suffix, filterValue)){
|
|
|
|
//change filter value
|
|
|
|
// queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0] = filter['groupFilters'][0]["values"][0].replace(ChartHelper.prefix + filterType + ChartHelper.suffix, filterValue);
|
|
|
|
//add user filter value
|
|
|
|
// queries["query"]["filters"].push(JSON.parse(filterString.replace(ChartHelper.prefix + filterType + ChartHelper.suffix, filterValue)));
|
|
|
|
// update colors
|
|
|
|
//if noit a pie, map and chart has more than one query
|
|
|
|
//
|
2020-08-04 09:57:51 +02:00
|
|
|
if(!newJsonObject.hasOwnProperty("mapDescription") && queries["type"]!="pie" && this.isComparingChart(newJsonObject, filter)) {
|
2020-07-28 16:57:17 +02:00
|
|
|
let activeColors = ["#7CB5EC", "#434348", "#8bbc21", "#910000", "#1aadce", "#492970", "#f28f43", "#77a1e5", "#c42525", "#a6c96a"];
|
|
|
|
let inActiveColors = ["#E4EFFB", "#D8D8D9", "#8bbc21", "#910000", "#1aadce", "#492970", "#f28f43", "#77a1e5", "#c42525", "#a6c96a"];
|
|
|
|
if (!newJsonObject[this.getDescriptionObjectName(newJsonObject)]["colors"]) {
|
|
|
|
newJsonObject[this.getDescriptionObjectName(newJsonObject)]["colors"] = activeColors;
|
|
|
|
}
|
|
|
|
newJsonObject[this.getDescriptionObjectName(newJsonObject)]["colors"][queryIndex] = inActiveColors[queryIndex];
|
|
|
|
filterApplied = true;
|
2020-10-06 14:22:59 +02:00
|
|
|
}else if (filterType == "start_year" || filterType == "end_year") {
|
|
|
|
//if has date filter already
|
|
|
|
if(filterType == "start_year" && parseInt(filterValue) > parseInt(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0])){
|
|
|
|
queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0] = filterValue;
|
|
|
|
}else if(filterType == "end_year" && parseInt(filterValue) < parseInt(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0])) {
|
|
|
|
queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0] = filterValue;
|
|
|
|
}
|
|
|
|
filterApplied = true;
|
2020-07-28 16:57:17 +02:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
filterApplied = true;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
queries["query"]["filters"].push(JSON.parse(filterString.replace(ChartHelper.prefix + filterType + ChartHelper.suffix, filterValue)));
|
|
|
|
filterApplied = true;
|
2020-07-07 16:08:47 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-28 16:57:17 +02:00
|
|
|
queryIndex++;
|
2020-07-07 16:08:47 +02:00
|
|
|
}
|
2020-07-28 16:57:17 +02:00
|
|
|
return { "url":JSON.stringify(newJsonObject), "filtersApplied":(filterApplied)?1:0};
|
2020-06-16 09:30:45 +02:00
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
|
2020-08-04 09:57:51 +02:00
|
|
|
isComparingChart(newJsonObject, filter,){
|
|
|
|
let queriesCount = this.getQueryObjectName(newJsonObject)?newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)].length:newJsonObject[this.getDescriptionObjectName(newJsonObject)].length;
|
|
|
|
let values = [];
|
|
|
|
if(queriesCount < 2){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (let queries of this.getQueryObjectName(newJsonObject)?newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)]:newJsonObject[this.getDescriptionObjectName(newJsonObject)]) {
|
|
|
|
let filterposition = IndicatorFilterUtils.filterIndexOf(filter, queries["query"]["filters"]);
|
|
|
|
if (filterposition) {
|
|
|
|
if (values.indexOf(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0]) == -1) {
|
2020-08-06 09:34:41 +02:00
|
|
|
values.push(queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0]);
|
2020-08-04 09:57:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-06 09:34:41 +02:00
|
|
|
console.debug(values);
|
2020-08-04 09:57:51 +02:00
|
|
|
return values.length > 1;
|
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
generateIndicatorByForm(form: any, indicatorPaths: IndicatorPath[], type:IndicatorType, addParameters:boolean = true ): Indicator {
|
2020-10-29 10:17:39 +01:00
|
|
|
let indicator: Indicator = new Indicator(form.name, form.description, form.additionalDescription, type,
|
2020-10-23 15:58:16 +02:00
|
|
|
form.width, form.visibility, indicatorPaths, form.defaultId);
|
2020-06-16 09:58:36 +02:00
|
|
|
indicator._id = form._id;
|
2019-11-24 17:30:04 +01:00
|
|
|
form.indicatorPaths.forEach((indicatorPath, index) => {
|
2020-06-02 17:44:45 +02:00
|
|
|
indicator.indicatorPaths[index].type = indicatorPath.type;
|
2020-07-07 16:08:47 +02:00
|
|
|
if(addParameters) {
|
|
|
|
indicatorPath.parameters.forEach(parameter => {
|
|
|
|
indicator.indicatorPaths[index].parameters[parameter.key] = parameter.value;
|
|
|
|
if (parameter.key === 'type') {
|
|
|
|
indicator.indicatorPaths[index].type = parameter.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-11-24 17:30:04 +01:00
|
|
|
});
|
|
|
|
return indicator;
|
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
generateIndicatorByNumberUrl(source: SourceType, url: string, stakeholder:Stakeholder, jsonPath = []): IndicatorPath {
|
|
|
|
let indicatorPath = new IndicatorPath(null, source, url, null, jsonPath);
|
|
|
|
if (source === 'stats-tool') {
|
|
|
|
indicatorPath.url = url.split("json=")[0] + "json=";
|
|
|
|
indicatorPath.url = indicatorPath.url.split("/")[indicatorPath.url.split("/").length - 1];
|
|
|
|
indicatorPath.chartObject = decodeURIComponent(url.indexOf("json=")!=-1?url.split("json=")[1]:"");
|
|
|
|
let chart = JSON.parse(indicatorPath.chartObject);
|
2020-10-06 14:22:59 +02:00
|
|
|
this.parameterizeDefaultQuery(chart, indicatorPath, stakeholder);
|
2020-07-07 16:08:47 +02:00
|
|
|
this.extractStakeHolders(chart, indicatorPath, stakeholder);
|
2020-08-06 09:34:41 +02:00
|
|
|
indicatorPath.chartObject = JSON.stringify(chart);
|
2020-07-07 16:08:47 +02:00
|
|
|
// this.addResultFilters(chart, indicatorPath);
|
|
|
|
}else {
|
|
|
|
try {
|
|
|
|
if (url.indexOf(encodeURIComponent(stakeholder.index_id)) !== -1) {
|
|
|
|
url = url.split(encodeURIComponent(stakeholder.index_id)).join(ChartHelper.prefix + "index_id" + ChartHelper.suffix);
|
|
|
|
}
|
|
|
|
if (url.indexOf(encodeURIComponent(stakeholder.index_name)) !== -1) {
|
|
|
|
url = url.split(encodeURIComponent(stakeholder.index_name)).join(ChartHelper.prefix + "index_name" + ChartHelper.suffix);
|
|
|
|
}
|
|
|
|
if (url.indexOf(encodeURIComponent(stakeholder.index_shortName)) !== -1) {
|
|
|
|
url = url.split(encodeURIComponent(stakeholder.index_shortName)).join(ChartHelper.prefix + "index_shortName" + ChartHelper.suffix);
|
|
|
|
}
|
|
|
|
indicatorPath.url = url;
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2020-06-16 09:30:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return indicatorPath;
|
|
|
|
}
|
2020-01-08 12:00:50 +01:00
|
|
|
generateIndicatorByChartUrl(source: SourceType, url: string, type: IndicatorPathType = null, stakeholder:Stakeholder): IndicatorPath {
|
2020-11-11 10:20:54 +01:00
|
|
|
let indicatorPath = new IndicatorPath(type, source, null, null, []);
|
2020-05-28 11:35:57 +02:00
|
|
|
try {
|
|
|
|
if (source === 'stats-tool') {
|
|
|
|
indicatorPath.url = url.split("json=")[0] + "json=";
|
|
|
|
indicatorPath.url = indicatorPath.url.split("/")[indicatorPath.url.split("/").length - 1];
|
|
|
|
indicatorPath.chartObject = decodeURIComponent(url.split("json=")[1]);
|
|
|
|
let chart = JSON.parse(indicatorPath.chartObject);
|
|
|
|
// console.debug(indicatorPath);
|
|
|
|
if (indicatorPath.url == "chart?json=") {
|
2020-06-12 19:32:41 +02:00
|
|
|
|
|
|
|
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" || chart["library"] == "HighMaps" )) {
|
2020-05-28 11:35:57 +02:00
|
|
|
indicatorPath.type = this.extractType(chart, indicatorPath);
|
|
|
|
} else {
|
2020-06-02 17:44:45 +02:00
|
|
|
indicatorPath.type = this.defaultChartType;
|
2020-05-28 11:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.extractTitle(chart, indicatorPath);
|
|
|
|
this.extractSubTitle(chart, indicatorPath);
|
|
|
|
this.extractXTitle(chart, indicatorPath);
|
|
|
|
this.extractYTitle(chart, indicatorPath);
|
2020-06-02 17:44:45 +02:00
|
|
|
}else if(indicatorPath.url == "table?json="){
|
|
|
|
indicatorPath.type = "table";
|
2020-05-28 11:35:57 +02:00
|
|
|
}
|
|
|
|
if (indicatorPath.url == "chart?json=" || indicatorPath.url == "table?json=") {
|
|
|
|
// common for tables and other chart types
|
|
|
|
this.extractDataTitle(chart, indicatorPath);
|
|
|
|
this.parameterizeDefaultQuery(chart, indicatorPath, stakeholder);
|
|
|
|
this.extractStakeHolders(chart, indicatorPath, stakeholder);
|
|
|
|
this.extractStartYear(chart, indicatorPath);
|
|
|
|
this.extractEndYear(chart, indicatorPath);
|
|
|
|
indicatorPath.chartObject = JSON.stringify(chart);
|
|
|
|
}
|
|
|
|
} else if (source === 'old') {
|
|
|
|
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
|
|
|
|
indicatorPath.chartObject = decodeURIComponent(url.split("data=")[1].split("&")[0]);
|
|
|
|
indicatorPath.type = type;
|
|
|
|
let chart = JSON.parse(indicatorPath.chartObject);
|
|
|
|
this.extractOldToolTitle(chart, indicatorPath);
|
|
|
|
this.extractOldToolXTitle(chart, indicatorPath);
|
|
|
|
this.extractOldToolYTitle(chart, indicatorPath);
|
|
|
|
indicatorPath.chartObject = JSON.stringify(chart);
|
|
|
|
} else {
|
|
|
|
indicatorPath.url = url;
|
|
|
|
indicatorPath.type = type;
|
|
|
|
}
|
|
|
|
}catch(e){
|
|
|
|
console.error(e);
|
2019-11-19 15:25:19 +01:00
|
|
|
indicatorPath.url = url;
|
|
|
|
indicatorPath.type = type;
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
// console.debug(indicatorPath.parameters);
|
|
|
|
// console.debug(indicatorPath.chartObject);
|
2020-06-02 17:44:45 +02:00
|
|
|
if(indicatorPath.type == null){
|
|
|
|
indicatorPath.type = this.defaultChartType;
|
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
return indicatorPath;
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
private getQueryObjectName(obj){
|
2020-06-12 19:32:41 +02:00
|
|
|
if((obj[this.getDescriptionObjectName(obj)]).hasOwnProperty("queriesInfo")){
|
2020-05-28 11:35:57 +02:00
|
|
|
return "queriesInfo";
|
2020-06-12 19:32:41 +02:00
|
|
|
}else if((obj[this.getDescriptionObjectName(obj)]).hasOwnProperty("queries")) {
|
2020-05-28 11:35:57 +02:00
|
|
|
return "queries";
|
|
|
|
}
|
|
|
|
}
|
2020-06-12 19:32:41 +02:00
|
|
|
private getDescriptionObjectName(obj){
|
|
|
|
if(obj.hasOwnProperty("mapDescription")){
|
|
|
|
return "mapDescription";
|
|
|
|
}else if(obj.hasOwnProperty("chartDescription")) {
|
|
|
|
return "chartDescription";
|
|
|
|
}else if(obj.hasOwnProperty("tableDescription") ){
|
|
|
|
return "tableDescription";
|
2020-07-07 16:08:47 +02:00
|
|
|
}else if(obj.hasOwnProperty("series") ){
|
|
|
|
return "series";
|
2020-06-12 19:32:41 +02:00
|
|
|
}
|
|
|
|
}
|
2020-01-08 12:00:50 +01:00
|
|
|
private extractType(obj, indicatorPath: IndicatorPath): IndicatorPathType {
|
2020-06-12 19:32:41 +02:00
|
|
|
let type = (obj[this.getDescriptionObjectName(obj)] && obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"])?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"]:"";
|
2020-06-02 17:44:45 +02:00
|
|
|
if (this.basicChartTypes.indexOf(type) == -1) {
|
|
|
|
type = this.defaultChartType;
|
2019-11-19 15:25:19 +01:00
|
|
|
} else {
|
2020-06-12 19:32:41 +02:00
|
|
|
obj[this.getDescriptionObjectName(obj)]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix;
|
2019-11-24 17:30:04 +01:00
|
|
|
indicatorPath.parameters['type'] = type;
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
private extractStakeHolders(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) {
|
|
|
|
this.extractFunder(obj, indicatorPath, stakeholder);
|
|
|
|
this.extractRI(obj, indicatorPath, stakeholder);
|
|
|
|
this.extractOrganization(obj, indicatorPath, stakeholder);
|
|
|
|
}
|
2019-12-23 14:54:37 +01:00
|
|
|
private extractFunder(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) {
|
2020-05-28 11:35:57 +02:00
|
|
|
if(stakeholder.type != "funder"){
|
|
|
|
return;
|
|
|
|
}
|
2020-07-07 16:08:47 +02:00
|
|
|
for (let query of this.getQueryObjectName(obj)?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]:obj[this.getDescriptionObjectName(obj)]) {
|
2019-11-24 17:30:04 +01:00
|
|
|
if (!query["query"]["filters"]) {
|
2019-11-20 13:55:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let filter of query["query"]["filters"]) {
|
|
|
|
if (filter["groupFilters"][0]["field"].indexOf(".funder") != -1) {
|
2020-01-10 12:32:23 +01:00
|
|
|
filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "index_name" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_name"] = stakeholder.index_name;
|
2020-05-28 11:35:57 +02:00
|
|
|
}else if (filter["groupFilters"][0]["field"].indexOf(".funder.id") != -1) {
|
|
|
|
filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "index_shortName" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private extractRI(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) {
|
|
|
|
if(stakeholder.type != "ri"){
|
|
|
|
return;
|
|
|
|
}
|
2020-08-06 09:34:41 +02:00
|
|
|
for (let query of this.getQueryObjectName(obj)?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]:obj[this.getDescriptionObjectName(obj)]) {
|
2020-05-28 11:35:57 +02:00
|
|
|
if (!query["query"]["filters"]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let filter of query["query"]["filters"]) {
|
|
|
|
if (filter["groupFilters"][0]["field"].indexOf(".context.name") != -1) {
|
|
|
|
filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "index_name" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_name"] = stakeholder.index_name;
|
|
|
|
}else if (filter["groupFilters"][0]["field"].indexOf(".context.id") != -1) {
|
|
|
|
filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "index_shortName" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName;
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
|
2020-05-28 11:35:57 +02:00
|
|
|
private extractOrganization(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) {
|
2020-06-11 19:06:45 +02:00
|
|
|
// works for publication.project.organization.name
|
|
|
|
// and publication.organization.name
|
2020-05-28 11:35:57 +02:00
|
|
|
if(stakeholder.type != "organization"){
|
|
|
|
return;
|
|
|
|
}
|
2020-08-06 09:34:41 +02:00
|
|
|
for (let query of this.getQueryObjectName(obj)?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]:obj[this.getDescriptionObjectName(obj)]) {
|
2020-05-28 11:35:57 +02:00
|
|
|
if (!query["query"]["filters"]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let filter of query["query"]["filters"]) {
|
|
|
|
if (filter["groupFilters"][0]["field"].indexOf(".organization.name") != -1) {
|
|
|
|
filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "index_name" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_name"] = stakeholder.index_name;
|
|
|
|
}else if (filter["groupFilters"][0]["field"].indexOf(".organization.id") != -1) {
|
|
|
|
filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "index_shortName" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
private extractStartYear(obj, indicatorPath: IndicatorPath) {
|
2019-11-13 15:27:07 +01:00
|
|
|
let start_year;
|
2020-06-12 19:32:41 +02:00
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
2019-11-24 17:30:04 +01:00
|
|
|
if (!query["query"]["filters"]) {
|
2019-11-20 13:55:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let filter of query["query"]["filters"]) {
|
|
|
|
for (let gfilter of filter["groupFilters"]) {
|
|
|
|
if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf(">") != -1) {
|
|
|
|
start_year = gfilter["values"][0];
|
|
|
|
gfilter["values"][0] = ChartHelper.prefix + "start_year" + ChartHelper.suffix;
|
2019-11-29 14:35:13 +01:00
|
|
|
indicatorPath.parameters["start_year"] = start_year;
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
|
|
|
|
private extractEndYear(obj, indicatorPath: IndicatorPath) {
|
2019-11-13 15:27:07 +01:00
|
|
|
let end_year;
|
2020-06-12 19:32:41 +02:00
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
2019-11-24 17:30:04 +01:00
|
|
|
if (!query["query"]["filters"]) {
|
2019-11-20 13:55:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let filter of query["query"]["filters"]) {
|
|
|
|
for (let gfilter of filter["groupFilters"]) {
|
|
|
|
if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf("<") != -1) {
|
|
|
|
end_year = gfilter["values"][0];
|
|
|
|
gfilter["values"][0] = ChartHelper.prefix + "end_year" + ChartHelper.suffix;
|
2019-11-29 14:35:13 +01:00
|
|
|
indicatorPath.parameters["end_year"] = end_year;
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
|
2019-12-23 14:54:37 +01:00
|
|
|
private parameterizeDefaultQuery(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) {
|
|
|
|
let name = "";
|
2020-10-06 14:22:59 +02:00
|
|
|
for (let query of this.getQueryObjectName(obj)?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]:obj[this.getDescriptionObjectName(obj)]) {
|
2020-05-28 11:35:57 +02:00
|
|
|
//monitor.{{stakeholderType}}.{{queryname}}
|
|
|
|
//parameters: stakeholderId*, type
|
2019-12-23 14:54:37 +01:00
|
|
|
if (query["query"]["name"]) {
|
|
|
|
name = query["query"]["name"];
|
2020-05-28 11:35:57 +02:00
|
|
|
let parameters = (query["query"]["parameters"])?query["query"]["parameters"]:[];
|
|
|
|
if(name.split('.')[0] == "rcd" && parameters.length > 0 && stakeholder.type=="ri") {
|
|
|
|
//rcd.{{queryname}}
|
2020-06-02 14:45:08 +02:00
|
|
|
parameters[0] = ChartHelper.prefix + "index_id" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_id"] = stakeholder.index_id;
|
2020-05-28 11:35:57 +02:00
|
|
|
}else if(name.split('.')[0] == "monitor" && parameters.length == 0 && stakeholder.type=="funder"){
|
|
|
|
// old saved queries without params
|
|
|
|
//monitor.{{funder_shortName}}.{{type}}.{{queryname}}
|
|
|
|
let stakeholderSN = name.split('.')[1];
|
|
|
|
query["query"]["name"] = name.split('.' + stakeholderSN + ".")[0] + "." + ChartHelper.prefix + "index_shortName" + ChartHelper.suffix +"." + name.split('.' + stakeholderSN + ".")[1];
|
|
|
|
indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName.toLowerCase();
|
|
|
|
}else if(name.split('.')[0] == "monitor" && parameters.length > 0 && name.split('.')[1] == stakeholder.type) {
|
|
|
|
// new parameterized queries
|
2020-07-10 10:37:51 +02:00
|
|
|
//monitor.{{type}}.{{queryname}}.{{param1 - id }}.{{param2 result-type}}.{{fl0}} --> params [start year, end year, id, result type, fl0]
|
|
|
|
|
|
|
|
let index = (name.split('.').slice(3).length +2 == parameters.length)?[2]:((name.split('.').slice(3).length * 2 + 4 == parameters.length)?[2,name.split('.').slice(3).length+4]:[0]);
|
|
|
|
for(let i of index) {
|
|
|
|
if (name.split('.').length > 3 && name.split('.')[3] == "id") {
|
|
|
|
parameters[i] = ChartHelper.prefix + "index_id" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_id"] = stakeholder.index_id;
|
|
|
|
} else if (name.split('.').length > 3 && name.split('.')[3] == "shortname") {
|
|
|
|
parameters[i] = ChartHelper.prefix + "index_shortName" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_shortName"] = stakeholder.index_shortName.toLowerCase();
|
|
|
|
} else if (name.split('.').length > 3 && name.split('.')[3] == "name") {
|
|
|
|
parameters[i] = ChartHelper.prefix + "index_name" + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["index_name"] = stakeholder.index_name;
|
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
2019-12-23 14:54:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
private extractDataTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
let index = 0;
|
2020-06-16 09:30:45 +02:00
|
|
|
if(!obj[this.getDescriptionObjectName(obj)] || !obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]){
|
2020-06-12 19:32:41 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
2020-05-28 11:35:57 +02:00
|
|
|
if (query["name"]) {
|
|
|
|
let name = query["name"];
|
|
|
|
query["name"] = ChartHelper.prefix + "data_title_"+index + ChartHelper.suffix;
|
|
|
|
indicatorPath.parameters["data_title_"+index] = name;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
private extractTitle(obj, indicatorPath: IndicatorPath) {
|
2019-11-20 13:55:23 +01:00
|
|
|
let title = "";
|
2020-06-12 19:32:41 +02:00
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["title"]) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["title"]["text"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["options"] && obj[this.getDescriptionObjectName(obj)]["options"]["title"]) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["options"]["title"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["options"]["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
indicatorPath.parameters["title"] = title ? title : "";
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2019-12-23 14:54:37 +01:00
|
|
|
|
2019-12-05 17:10:00 +01:00
|
|
|
private extractSubTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
let subtitle = "";
|
2020-06-12 19:32:41 +02:00
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["subtitle"]) {
|
|
|
|
subtitle = obj[this.getDescriptionObjectName(obj)]["subtitle"]["text"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["subtitle"]["text"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
|
2019-12-23 14:54:37 +01:00
|
|
|
indicatorPath.parameters["subtitle"] = subtitle ? subtitle : "";
|
2020-06-12 19:32:41 +02:00
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["title"] && obj[this.getDescriptionObjectName(obj)]["title"] && obj[this.getDescriptionObjectName(obj)]["title"]["subtext"]) {
|
|
|
|
subtitle = obj[this.getDescriptionObjectName(obj)]["title"]["subtext"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["title"]["subtext"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
|
2020-06-02 14:45:08 +02:00
|
|
|
indicatorPath.parameters["subtitle"] = subtitle ? subtitle : "";
|
2019-12-05 17:10:00 +01:00
|
|
|
}
|
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
|
|
|
|
private extractXTitle(obj, indicatorPath: IndicatorPath) {
|
2019-11-20 13:55:23 +01:00
|
|
|
let title = "";
|
2020-06-12 19:32:41 +02:00
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["xAxis"] && obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]["text"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["options"] && obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"] && obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"]) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["xAxis"] && obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"]) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
indicatorPath.parameters["xAxisTitle"] = title ? title : "";
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2019-11-19 15:25:19 +01:00
|
|
|
|
|
|
|
private extractYTitle(obj, indicatorPath: IndicatorPath) {
|
2019-11-20 13:55:23 +01:00
|
|
|
let title = "";
|
2020-06-12 19:32:41 +02:00
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["yAxis"] && obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"] ) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"]["text"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["options"]&& obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"] && obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"]) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["yAxis"] && obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"]) {
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"];
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2020-05-28 11:35:57 +02:00
|
|
|
indicatorPath.parameters["yAxisTitle"] = title ? title : "";
|
2019-11-13 15:27:07 +01:00
|
|
|
}
|
2019-11-24 17:30:04 +01:00
|
|
|
|
2019-11-20 13:55:23 +01:00
|
|
|
private extractOldToolTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
let title = "";
|
|
|
|
if (obj["title"]) {
|
|
|
|
title = obj["title"];
|
|
|
|
obj["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
2019-11-24 17:30:04 +01:00
|
|
|
indicatorPath.parameters["title"] = title;
|
2019-11-20 13:55:23 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private extractOldToolXTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
let title = "";
|
|
|
|
if (obj["xaxistitle"]) {
|
|
|
|
title = obj["xaxistitle"];
|
|
|
|
obj["xaxistitle"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
2019-11-24 17:30:04 +01:00
|
|
|
indicatorPath.parameters["xAxisTitle"] = title;
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private extractOldToolYTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
let title = "";
|
2019-11-24 17:30:04 +01:00
|
|
|
if (obj["fieldsheaders"]) {
|
2019-12-23 14:54:37 +01:00
|
|
|
title = Array.isArray(obj["fieldsheaders"]) ? obj["fieldsheaders"][0] : obj["fieldsheaders"];
|
|
|
|
if (Array.isArray(obj["fieldsheaders"])) {
|
2019-11-29 15:58:52 +01:00
|
|
|
obj["fieldsheaders"][0] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
2019-12-23 14:54:37 +01:00
|
|
|
} else {
|
2019-11-29 15:58:52 +01:00
|
|
|
obj["fieldsheaders"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
|
|
|
}
|
2019-11-24 17:30:04 +01:00
|
|
|
indicatorPath.parameters["yAxisTitle"] = title;
|
2019-11-20 13:55:23 +01:00
|
|
|
}
|
|
|
|
}
|
2019-11-13 15:27:07 +01:00
|
|
|
|
2019-11-08 16:47:47 +01:00
|
|
|
}
|