Add stasProfile input in edit-stakeholder and replace its value in all indicators URL.
This commit is contained in:
parent
9a5de31d58
commit
be7fd26f7b
|
@ -15,6 +15,7 @@ import {NotifyFormComponent} from "../../openaireLibrary/notifications/notify-fo
|
|||
import {NotificationUtils} from "../../openaireLibrary/notifications/notification-utils";
|
||||
import {Notification} from "../../openaireLibrary/notifications/notifications";
|
||||
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
|
||||
import {StatsProfilesService} from "../../stats-profiles/stats-profiles.service";
|
||||
|
||||
@Component({
|
||||
selector: 'edit-stakeholder',
|
||||
|
@ -29,18 +30,23 @@ import {NotificationHandler} from "../../openaireLibrary/utils/notification-hand
|
|||
<div input [formInput]="stakeholderFb.get('alias')"
|
||||
placeholder="URL Alias"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-3@m">
|
||||
<div class="uk-width-1-2@m">
|
||||
<div input [formInput]="stakeholderFb.get('index_id')"
|
||||
placeholder="Index ID"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-3@m">
|
||||
<div class="uk-width-1-2@m">
|
||||
<div input [formInput]="stakeholderFb.get('index_name')"
|
||||
placeholder="Index Name"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-3@m">
|
||||
<div class="uk-width-1-2@m">
|
||||
<div input [formInput]="stakeholderFb.get('index_shortName')"
|
||||
placeholder="Index Short Name"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-2@m">
|
||||
<div *ngIf="statsProfiles" input [formInput]="stakeholderFb.get('statsProfile')" [type]="'autocomplete_soft'"
|
||||
[options]="statsProfiles" [showOptionsOnEmpty]="true"
|
||||
placeholder="Stats Profile"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-1">
|
||||
<div input [type]="'textarea'" placeholder="Description"
|
||||
[rows]="4" [formInput]="stakeholderFb.get('description')"></div>
|
||||
|
@ -119,8 +125,9 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
public stakeholder: Stakeholder;
|
||||
public isDefault: boolean;
|
||||
public isNew: boolean;
|
||||
public loading: boolean = false;
|
||||
public loading: boolean = false;
|
||||
public types: Option[];
|
||||
public statsProfiles: string[];
|
||||
public properties: EnvProperties = properties;
|
||||
private subscriptions: any[] = [];
|
||||
/**
|
||||
|
@ -137,6 +144,7 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
|
||||
constructor(private fb: UntypedFormBuilder,
|
||||
private stakeholderService: StakeholderService,
|
||||
private statsProfileService: StatsProfilesService,
|
||||
private utilsService: UtilitiesService, private userManagementService: UserManagementService,) {
|
||||
}
|
||||
|
||||
|
@ -154,6 +162,14 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
this.isNew = isNew;
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
if(this.isCurator) {
|
||||
this.subscriptions.push(this.statsProfileService.getStatsProfile().subscribe(statsProfiles => {
|
||||
this.statsProfiles = statsProfiles.map(statsProfile => statsProfile.name);
|
||||
console.log()
|
||||
}));
|
||||
} else {
|
||||
this.statsProfiles = [];
|
||||
}
|
||||
this.types = this.stakeholderUtils.getTypesByUserRoles(this.user, this.stakeholder.alias);
|
||||
this.stakeholderFb = this.fb.group({
|
||||
_id: this.fb.control(this.stakeholder._id),
|
||||
|
@ -163,6 +179,7 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
index_name: this.fb.control(this.stakeholder.index_name, Validators.required),
|
||||
index_id: this.fb.control(this.stakeholder.index_id, Validators.required),
|
||||
index_shortName: this.fb.control(this.stakeholder.index_shortName, Validators.required),
|
||||
statsProfile: this.fb.control(this.stakeholder.statsProfile, Validators.required),
|
||||
creationDate: this.fb.control(this.stakeholder.creationDate),
|
||||
alias: this.fb.control(this.stakeholder.alias,
|
||||
[
|
||||
|
@ -215,6 +232,11 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
}, 0);
|
||||
}
|
||||
} else {
|
||||
if(!this.isCurator) {
|
||||
setTimeout(() => {
|
||||
this.stakeholderFb.get('statsProfile').disable();
|
||||
}, 0);
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.stakeholderFb.get('alias').disable();
|
||||
this.stakeholderFb.get('index_id').disable();
|
||||
|
@ -238,6 +260,10 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
public get isAdmin() {
|
||||
return Session.isPortalAdministrator(this.user);
|
||||
}
|
||||
|
||||
public get isCurator() {
|
||||
return this.stakeholder && (this.isAdmin || Session.isCurator(this.stakeholder.type, this.user));
|
||||
}
|
||||
|
||||
public get disabled(): boolean {
|
||||
return (this.stakeholderFb && this.stakeholderFb.invalid) ||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6a2ac8cc4e1a77c10f632eccfd73b91082fe4a4a
|
||||
Subproject commit e88bb206dcfbe6da62542c45794d4fe6e552fb09
|
|
@ -1,46 +1,51 @@
|
|||
import {
|
||||
ChartHelper, FilterType,
|
||||
Indicator, IndicatorFilterUtils,
|
||||
IndicatorPath, IndicatorPathType, IndicatorType,
|
||||
ChartHelper,
|
||||
FilterType,
|
||||
Indicator,
|
||||
IndicatorFilterUtils,
|
||||
IndicatorPath,
|
||||
IndicatorPathType,
|
||||
IndicatorType,
|
||||
SourceType,
|
||||
Stakeholder,
|
||||
StakeholderEntities,
|
||||
SubCategory,
|
||||
Topic, Visibility,
|
||||
StakeholderEntities
|
||||
Topic,
|
||||
Visibility
|
||||
} from "../openaireLibrary/monitor/entities/stakeholder";
|
||||
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
||||
import {Option} from "../openaireLibrary/sharedComponents/input/input.component";
|
||||
import {Session} from "../openaireLibrary/login/utils/helper.class";
|
||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||
import {properties} from "../../environments/environment";
|
||||
|
||||
export class StakeholderUtils {
|
||||
|
||||
statuses: Option[] = [
|
||||
{value: 'PUBLIC', label: 'Public'},
|
||||
{value: 'RESTRICTED', label: 'Restricted'},
|
||||
{value: 'PRIVATE', label: 'Private'}
|
||||
];
|
||||
|
||||
|
||||
types: Option[] = [
|
||||
{value: 'funder', label: StakeholderEntities.FUNDER},
|
||||
{value: 'ri', label: StakeholderEntities.RI},
|
||||
{value: 'project', label: StakeholderEntities.PROJECT},
|
||||
{value: 'organization', label: StakeholderEntities.ORGANIZATION}
|
||||
];
|
||||
|
||||
|
||||
visibility: Option[] = [
|
||||
{icon: 'earth', value: "PUBLIC", label: 'Public'},
|
||||
{icon: 'restricted', value: "RESTRICTED", label: 'Restricted'},
|
||||
{icon: 'incognito', value: "PRIVATE", label: 'Private'},
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
visibilityIcon: Map<Visibility, string> = new Map<Visibility, string>([
|
||||
["PUBLIC", 'earth'],
|
||||
["PRIVATE", 'incognito'],
|
||||
["RESTRICTED", 'restricted']
|
||||
]);
|
||||
|
||||
|
||||
getTypesByUserRoles(user, id: string = null): Option[] {
|
||||
let types = [];
|
||||
for (let type of this.types) {
|
||||
|
@ -50,7 +55,7 @@ export class StakeholderUtils {
|
|||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
public createFunderFromDefaultProfile(funder: Stakeholder, defaultTopics: Topic[]): Stakeholder {
|
||||
funder.topics = HelperFunctions.copy(defaultTopics);
|
||||
for (let topic of funder.topics) {
|
||||
|
@ -122,7 +127,7 @@ export class StakeholderUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
category.subCategories = subTokeep;
|
||||
}
|
||||
|
@ -130,7 +135,7 @@ export class StakeholderUtils {
|
|||
//console.log (funder);
|
||||
return funder;
|
||||
}
|
||||
|
||||
|
||||
aliasValidatorString(elements: string[]): ValidatorFn {
|
||||
return (control: AbstractControl): { [key: string]: string } | null => {
|
||||
if (control.value && elements.find(element =>
|
||||
|
@ -141,7 +146,7 @@ export class StakeholderUtils {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
aliasValidator(elements: any[]): ValidatorFn {
|
||||
return (control: AbstractControl): { [key: string]: string } | null => {
|
||||
if (control.value && elements.find(element =>
|
||||
|
@ -152,7 +157,7 @@ export class StakeholderUtils {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
generateAlias(name: string): string {
|
||||
let alias = name.toLowerCase();
|
||||
while (alias.includes('/') || alias.includes(' ')) {
|
||||
|
@ -165,7 +170,7 @@ export class StakeholderUtils {
|
|||
}
|
||||
|
||||
export class IndicatorUtils {
|
||||
|
||||
|
||||
allChartTypes: Option[] = [
|
||||
{value: 'pie', label: 'Pie'},
|
||||
{value: 'table', label: 'Table'},
|
||||
|
@ -181,7 +186,7 @@ export class IndicatorUtils {
|
|||
{value: 'medium', label: 'Medium'},
|
||||
{value: 'large', label: 'Large'}
|
||||
];
|
||||
|
||||
|
||||
allSourceTypes: Option[] = [
|
||||
{value: 'search', label: 'Search'},
|
||||
{value: 'statistics', label: 'Statistics'},
|
||||
|
@ -190,25 +195,12 @@ export class IndicatorUtils {
|
|||
sourceTypes: Option[] = [
|
||||
{value: 'stats-tool', label: 'Statistics tool'}
|
||||
];
|
||||
isPublic: Option[] = [
|
||||
{icon: 'public', value: true, label: 'Public'},
|
||||
{icon: 'lock', value: false, label: 'Private'},
|
||||
];
|
||||
|
||||
|
||||
isActive: Option[] = [
|
||||
{icon: 'brightness_1', iconClass: '', value: true, label: 'Active'},
|
||||
{icon: 'brightness_1', value: false, label: 'Inactive'},
|
||||
];
|
||||
|
||||
chartTypesIcons: Map<string, string> = new Map([
|
||||
['pie', 'pie_chart'],
|
||||
['table', 'table_chart'],
|
||||
['line', 'show_chart'],
|
||||
['column', 'bar_chart'],
|
||||
['bar', 'notes'],
|
||||
['other', 'perm_media']
|
||||
]);
|
||||
|
||||
|
||||
getChartTypes(initialType) {
|
||||
let types: Option[] = [];
|
||||
if (this.basicChartTypes.indexOf(initialType) != -1) {
|
||||
|
@ -229,23 +221,20 @@ export class IndicatorUtils {
|
|||
return this.allChartTypes;
|
||||
}
|
||||
}
|
||||
|
||||
isPublicIcon: Map<boolean, string> = new Map([
|
||||
[true, 'public'],
|
||||
[false, 'lock']
|
||||
]);
|
||||
|
||||
isActiveIcon: string = 'brightness_1';
|
||||
|
||||
|
||||
ignoredParameters = ['index_name', 'index_id', 'index_shortName'];
|
||||
|
||||
statsProfileParameter = 'profile';
|
||||
|
||||
parametersValidators: Map<string, any> = new Map<string, any>([
|
||||
['start_year', [Validators.required, Validators.pattern('^\\d+$')]],
|
||||
['end_year', [Validators.required, Validators.pattern('^\\d+$')]]
|
||||
]);
|
||||
|
||||
|
||||
public getFullUrl(stakeholder: Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null): string {
|
||||
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
||||
if (stakeholder.statsProfile) {
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix).join(stakeholder.statsProfile)
|
||||
}
|
||||
if (indicatorPath.parameters) {
|
||||
Object.keys(indicatorPath.parameters).forEach(key => {
|
||||
let replacedValue = indicatorPath.parameters[key];
|
||||
|
@ -264,7 +253,7 @@ export class IndicatorUtils {
|
|||
if (key == "index_shortName") {
|
||||
replacedValue = stakeholder.index_shortName.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + key + ChartHelper.suffix).join(replacedValue)
|
||||
});
|
||||
}
|
||||
|
@ -282,7 +271,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
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"] = [];
|
||||
|
@ -303,9 +292,9 @@ export class IndicatorUtils {
|
|||
}
|
||||
replacedUrl = JSON.stringify(newJsonObject);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//For numbers (e.g from stats-api , search service, etc)
|
||||
//For numbers (e.g. from stats-api , search service, etc)
|
||||
if (indicatorPath.url.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) != -1) {
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
|
||||
}
|
||||
|
@ -317,10 +306,13 @@ 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 {
|
||||
indicatorPath.filtersApplied = 0;
|
||||
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
||||
if (stakeholder.statsProfile) {
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix).join(stakeholder.statsProfile)
|
||||
}
|
||||
if (indicatorPath.parameters) {
|
||||
Object.keys(indicatorPath.parameters).forEach(key => {
|
||||
let replacedValue = indicatorPath.parameters[key];
|
||||
|
@ -343,7 +335,7 @@ export class IndicatorUtils {
|
|||
if (key == "index_shortName") {
|
||||
replacedValue = stakeholder.index_shortName.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + key + ChartHelper.suffix).join(replacedValue)
|
||||
});
|
||||
}
|
||||
|
@ -375,7 +367,7 @@ export class IndicatorUtils {
|
|||
indicatorPath.filtersApplied += filterResults.filtersApplied;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//For numbers
|
||||
if (replacedUrl.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) != -1) {
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
|
||||
|
@ -387,10 +379,11 @@ export class IndicatorUtils {
|
|||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
|
||||
}
|
||||
//Check apply enhancements return this.applySchemaEnhancements( ..);
|
||||
console.log(replacedUrl);
|
||||
return (indicatorPath.chartObject ? indicatorPath.url + encodeURIComponent(replacedUrl) : replacedUrl);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private addFilter(replacedUrl, filterType: FilterType, filterValue) {
|
||||
let newJsonObject = JSON.parse(replacedUrl);
|
||||
let filterApplied: boolean = false;
|
||||
|
@ -398,7 +391,7 @@ export class IndicatorUtils {
|
|||
for (let queries of this.getQueryObjectName(newJsonObject) ? newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)] : newJsonObject[this.getDescriptionObjectName(newJsonObject)]) {
|
||||
/*Chart with Named Queries*/
|
||||
if (queries["query"]["name"] && !queries["query"]["select"]) {
|
||||
|
||||
|
||||
if (queries["query"]["name"].indexOf("monitor.") == -1 || !queries["query"]["parameters"]) {
|
||||
continue;
|
||||
}
|
||||
|
@ -442,7 +435,7 @@ export class IndicatorUtils {
|
|||
// console.debug("Field Params length:" + paramFields.length)
|
||||
// console.debug(paramFields)
|
||||
// console.debug("Parameters length:" + queries["query"]["parameters"].length)
|
||||
|
||||
|
||||
if ((paramFields.length + 2) == queries["query"]["parameters"].length || (paramFields.length * 2 + 4) == queries["query"]["parameters"].length) {
|
||||
filterApplied = true;
|
||||
if (filterType == "start_year") {
|
||||
|
@ -514,7 +507,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
return {"url": JSON.stringify(newJsonObject), "filtersApplied": (filterApplied) ? 1 : 0};
|
||||
}
|
||||
|
||||
|
||||
isComparingChart(newJsonObject, filter,) {
|
||||
let queriesCount = this.getQueryObjectName(newJsonObject) ? newJsonObject[this.getDescriptionObjectName(newJsonObject)][this.getQueryObjectName(newJsonObject)].length : newJsonObject[this.getDescriptionObjectName(newJsonObject)].length;
|
||||
let values = [];
|
||||
|
@ -532,7 +525,7 @@ export class IndicatorUtils {
|
|||
// console.debug(values);
|
||||
return values.length > 1;
|
||||
}
|
||||
|
||||
|
||||
generateIndicatorByForm(form: any, indicatorPaths: IndicatorPath[], type: IndicatorType, addParameters: boolean = true): Indicator {
|
||||
let indicator: Indicator = new Indicator(form.name, form.description, form.additionalDescription, type,
|
||||
form.width, form.height, form.visibility, indicatorPaths, form.defaultId);
|
||||
|
@ -550,7 +543,7 @@ export class IndicatorUtils {
|
|||
});
|
||||
return indicator;
|
||||
}
|
||||
|
||||
|
||||
generateIndicatorByNumberUrl(source: SourceType, url: string, stakeholder: Stakeholder, jsonPath = [], sourceServices: string[] = []): IndicatorPath {
|
||||
let indicatorPath = new IndicatorPath(null, source, url, null, jsonPath);
|
||||
if (source === 'stats-tool') {
|
||||
|
@ -588,7 +581,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
return indicatorPath;
|
||||
}
|
||||
|
||||
|
||||
generateIndicatorByChartUrl(source: SourceType, url: string, type: IndicatorPathType = null, stakeholder: Stakeholder): IndicatorPath {
|
||||
let indicatorPath = new IndicatorPath(type, source, null, null, []);
|
||||
try {
|
||||
|
@ -599,13 +592,13 @@ export class IndicatorUtils {
|
|||
let chart = JSON.parse(indicatorPath.chartObject);
|
||||
// console.debug(indicatorPath);
|
||||
if (indicatorPath.url == "chart?json=") {
|
||||
|
||||
|
||||
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" || chart["library"] == "HighMaps")) {
|
||||
indicatorPath.type = this.extractType(chart, indicatorPath);
|
||||
} else {
|
||||
indicatorPath.type = this.defaultChartType;
|
||||
}
|
||||
|
||||
|
||||
this.extractTitle(chart, indicatorPath);
|
||||
this.extractSubTitle(chart, indicatorPath);
|
||||
this.extractXTitle(chart, indicatorPath);
|
||||
|
@ -621,6 +614,7 @@ export class IndicatorUtils {
|
|||
this.extractStartYear(chart, indicatorPath);
|
||||
this.extractEndYear(chart, indicatorPath);
|
||||
indicatorPath.chartObject = JSON.stringify(chart);
|
||||
console.log(indicatorPath);
|
||||
}
|
||||
} else if (source === 'old') {
|
||||
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
|
||||
|
@ -647,7 +641,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
return indicatorPath;
|
||||
}
|
||||
|
||||
|
||||
private getQueryObjectName(obj) {
|
||||
if ((obj[this.getDescriptionObjectName(obj)]).hasOwnProperty("queriesInfo")) {
|
||||
return "queriesInfo";
|
||||
|
@ -655,7 +649,7 @@ export class IndicatorUtils {
|
|||
return "queries";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private getDescriptionObjectName(obj) {
|
||||
if (obj.hasOwnProperty("mapDescription")) {
|
||||
return "mapDescription";
|
||||
|
@ -667,7 +661,7 @@ export class IndicatorUtils {
|
|||
return "series";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractType(obj, indicatorPath: IndicatorPath): IndicatorPathType {
|
||||
let type = (obj[this.getDescriptionObjectName(obj)] && obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"]) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"] : "";
|
||||
if (this.basicChartTypes.indexOf(type) == -1) {
|
||||
|
@ -678,18 +672,21 @@ export class IndicatorUtils {
|
|||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
private extractStakeHolders(obj, indicatorPath: IndicatorPath, stakeholder: Stakeholder) {
|
||||
this.extractFunder(obj, indicatorPath, stakeholder);
|
||||
this.extractRI(obj, indicatorPath, stakeholder);
|
||||
this.extractOrganization(obj, indicatorPath, stakeholder);
|
||||
}
|
||||
|
||||
|
||||
private extractFunder(obj, indicatorPath: IndicatorPath, stakeholder: Stakeholder) {
|
||||
if (stakeholder.type != "funder") {
|
||||
return;
|
||||
}
|
||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||
if(query["query"]["profile"]) {
|
||||
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
||||
}
|
||||
if (!query["query"]["filters"]) {
|
||||
return;
|
||||
}
|
||||
|
@ -710,12 +707,15 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractRI(obj, indicatorPath: IndicatorPath, stakeholder: Stakeholder) {
|
||||
if (stakeholder.type != "ri") {
|
||||
return;
|
||||
}
|
||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||
if(query["query"]["profile"]) {
|
||||
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
||||
}
|
||||
if (!query["query"]["filters"]) {
|
||||
return;
|
||||
}
|
||||
|
@ -732,7 +732,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractOrganization(obj, indicatorPath: IndicatorPath, stakeholder: Stakeholder) {
|
||||
// works for publication.project.organization.name
|
||||
// and publication.organization.name
|
||||
|
@ -740,6 +740,9 @@ export class IndicatorUtils {
|
|||
return;
|
||||
}
|
||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||
if(query["query"]["profile"]) {
|
||||
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
||||
}
|
||||
if (!query["query"]["filters"]) {
|
||||
return;
|
||||
}
|
||||
|
@ -756,7 +759,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractStartYear(obj, indicatorPath: IndicatorPath) {
|
||||
let start_year;
|
||||
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
||||
|
@ -774,7 +777,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractEndYear(obj, indicatorPath: IndicatorPath) {
|
||||
let end_year;
|
||||
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
||||
|
@ -792,7 +795,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private parameterizeDefaultQuery(obj, indicatorPath: IndicatorPath, stakeholder: Stakeholder) {
|
||||
let name = "";
|
||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||
|
@ -814,7 +817,7 @@ export class IndicatorUtils {
|
|||
} else if (name.split('.')[0] == "monitor" && parameters.length > 0 && name.split('.')[1] == stakeholder.type) {
|
||||
// new parameterized queries
|
||||
//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") {
|
||||
|
@ -832,7 +835,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractDataTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let index = 0;
|
||||
if (!obj[this.getDescriptionObjectName(obj)] || !obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
||||
|
@ -847,7 +850,7 @@ export class IndicatorUtils {
|
|||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let title = "";
|
||||
if (obj[this.getDescriptionObjectName(obj)]["title"]) {
|
||||
|
@ -859,7 +862,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
indicatorPath.parameters["title"] = title ? title : "";
|
||||
}
|
||||
|
||||
|
||||
private extractSubTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let subtitle = "";
|
||||
if (obj[this.getDescriptionObjectName(obj)]["subtitle"]) {
|
||||
|
@ -872,7 +875,7 @@ export class IndicatorUtils {
|
|||
indicatorPath.parameters["subtitle"] = subtitle ? subtitle : "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractXTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let title = "";
|
||||
if (obj[this.getDescriptionObjectName(obj)]["xAxis"] && obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]) {
|
||||
|
@ -887,7 +890,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
indicatorPath.parameters["xAxisTitle"] = title ? title : "";
|
||||
}
|
||||
|
||||
|
||||
private extractYTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let title = "";
|
||||
if (obj[this.getDescriptionObjectName(obj)]["yAxis"] && obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"]) {
|
||||
|
@ -902,17 +905,17 @@ export class IndicatorUtils {
|
|||
}
|
||||
indicatorPath.parameters["yAxisTitle"] = title ? title : "";
|
||||
}
|
||||
|
||||
|
||||
private extractOldToolTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let title = "";
|
||||
if (obj["title"]) {
|
||||
title = obj["title"];
|
||||
obj["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
||||
indicatorPath.parameters["title"] = title;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractOldToolXTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let title = "";
|
||||
if (obj["xaxistitle"]) {
|
||||
|
@ -921,7 +924,7 @@ export class IndicatorUtils {
|
|||
indicatorPath.parameters["xAxisTitle"] = title;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extractOldToolYTitle(obj, indicatorPath: IndicatorPath) {
|
||||
let title = "";
|
||||
if (obj["fieldsheaders"]) {
|
||||
|
@ -934,11 +937,11 @@ export class IndicatorUtils {
|
|||
indicatorPath.parameters["yAxisTitle"] = title;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public checkForSchemaEnhancements(url: string): boolean {
|
||||
return url != this.applySchemaEnhancements(url);
|
||||
}
|
||||
|
||||
|
||||
public applySchemaEnhancements(url: string): string {
|
||||
let resultEnhancements = [
|
||||
[".project.acronym", ".project acronym"],
|
||||
|
@ -957,7 +960,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (url.split('json=').length > 1) {
|
||||
let obj = JSON.parse(decodeURIComponent(url.split('json=')[1]));
|
||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||
|
|
Loading…
Reference in New Issue