2020-06-03 15:43:14 +02:00
|
|
|
import {SafeResourceUrl} from "@angular/platform-browser";
|
|
|
|
|
|
|
|
export const ChartHelper = {
|
|
|
|
prefix: "((__",
|
|
|
|
suffix: "__))"
|
|
|
|
};
|
|
|
|
|
|
|
|
export type StakeholderType = 'funder' | 'ri' | 'project' | 'organization';
|
|
|
|
export type IndicatorType = 'number' | 'chart';
|
|
|
|
export type IndicatorWidth = 'small' | 'medium' | 'large';
|
|
|
|
export type IndicatorPathType = 'table' | 'bar' | 'column' | 'pie' | 'line' | 'other';
|
|
|
|
export type SourceType = 'statistics' | 'search' | 'metrics' | 'stats-tool' | 'old' | 'image';
|
|
|
|
|
|
|
|
export class Stakeholder {
|
|
|
|
_id: string;
|
|
|
|
type: StakeholderType;
|
|
|
|
name: string;
|
|
|
|
index_id;
|
|
|
|
index_name: string;
|
|
|
|
index_shortName: string;
|
|
|
|
alias: string;
|
|
|
|
defaultId: string;
|
|
|
|
isActive: boolean;
|
|
|
|
isPublic: boolean;
|
|
|
|
creationDate: Date = null;
|
|
|
|
updateDate: Date;
|
|
|
|
managers: string[];
|
2020-06-05 14:56:28 +02:00
|
|
|
logoUrl: string;
|
2020-06-03 15:43:14 +02:00
|
|
|
topics: Topic[];
|
2020-06-05 14:56:28 +02:00
|
|
|
description: string;
|
|
|
|
|
|
|
|
constructor(id: string, type: StakeholderType, index_id, index_name: string, index_shortName: string, alias: string, isActive: boolean,
|
|
|
|
isPublic: boolean, logoUrl: string, defaultId: string = null, description: string = null) {
|
|
|
|
this.initializeFunder(id, type, index_id, index_name, index_shortName, defaultId, alias, isActive, isPublic, logoUrl, description);
|
2020-06-03 15:43:14 +02:00
|
|
|
this.topics = [];
|
|
|
|
this.managers = [];
|
|
|
|
}
|
2020-06-05 14:56:28 +02:00
|
|
|
|
|
|
|
initializeFunder(id: string, type: StakeholderType, index_id, index_name: string, index_shortName: string, defaultId: string,
|
|
|
|
alias: string, isActive: boolean, isPublic: boolean, logoUrl: string, description: string = null) {
|
2020-06-03 15:43:14 +02:00
|
|
|
this._id = id;
|
|
|
|
this.type = type;
|
|
|
|
this.index_id = index_id;
|
|
|
|
this.index_name = index_name;
|
|
|
|
this.index_shortName = index_shortName;
|
|
|
|
this.defaultId = defaultId;
|
|
|
|
this.alias = alias;
|
|
|
|
this.isActive = isActive;
|
|
|
|
this.isPublic = isPublic;
|
|
|
|
this.logoUrl = logoUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-05 14:56:28 +02:00
|
|
|
export class StakeholderInfo extends Stakeholder {
|
|
|
|
isManager: boolean = false;
|
|
|
|
}
|
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
export class Topic {
|
|
|
|
_id: string;
|
|
|
|
name: string;
|
|
|
|
alias: string;
|
|
|
|
description: string;
|
|
|
|
isActive: boolean;
|
|
|
|
isPublic: boolean;
|
|
|
|
defaultId: string;
|
|
|
|
categories: Category[];
|
2020-06-11 12:11:05 +02:00
|
|
|
iconUrl: string;
|
2020-06-05 14:56:28 +02:00
|
|
|
|
2020-06-11 12:11:05 +02:00
|
|
|
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean, defaultId: string = null, iconUrl: string = null) {
|
2020-06-03 15:43:14 +02:00
|
|
|
this._id = null;
|
|
|
|
this.name = name;
|
|
|
|
this.description = description;
|
|
|
|
this.alias = alias;
|
|
|
|
this.isActive = isActive;
|
|
|
|
this.isPublic = isPublic;
|
|
|
|
this.defaultId = defaultId;
|
|
|
|
this.categories = [];
|
2020-06-11 12:11:05 +02:00
|
|
|
this.iconUrl = iconUrl;
|
2020-06-03 15:43:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Category {
|
|
|
|
_id: string;
|
|
|
|
name: string;
|
|
|
|
alias: string;
|
|
|
|
description: string;
|
|
|
|
isActive: boolean;
|
|
|
|
isPublic: boolean;
|
|
|
|
defaultId: string;
|
|
|
|
subCategories: SubCategory[];
|
2020-06-05 14:56:28 +02:00
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean, defaultId: string = null) {
|
|
|
|
this._id = null;
|
|
|
|
this.name = name;
|
|
|
|
this.description = description;
|
|
|
|
this.alias = alias;
|
|
|
|
this.isActive = isActive;
|
|
|
|
this.isPublic = isPublic;
|
|
|
|
this.defaultId = defaultId;
|
|
|
|
this.subCategories = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class SubCategory {
|
|
|
|
_id: string;
|
|
|
|
name: string;
|
|
|
|
alias: string;
|
|
|
|
description: string;
|
|
|
|
isActive: boolean;
|
|
|
|
isPublic: boolean;
|
|
|
|
defaultId: string;
|
|
|
|
charts: Section[];
|
|
|
|
numbers: Section[];
|
2020-06-05 14:56:28 +02:00
|
|
|
recommendedFor: string[];
|
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean, defaultId: string = null) {
|
|
|
|
this._id = null;
|
|
|
|
this.name = name;
|
|
|
|
this.description = description;
|
|
|
|
this.alias = alias;
|
|
|
|
this.isActive = isActive;
|
|
|
|
this.isPublic = isPublic;
|
|
|
|
this.defaultId = defaultId;
|
|
|
|
this.charts = [];
|
|
|
|
this.numbers = [];
|
2020-06-05 14:56:28 +02:00
|
|
|
this.recommendedFor = [];
|
2020-06-03 15:43:14 +02:00
|
|
|
}
|
2020-06-05 14:56:28 +02:00
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Section {
|
|
|
|
_id: string;
|
|
|
|
title: string;
|
|
|
|
defaultId: string;
|
|
|
|
stakeholderAlias: string;
|
|
|
|
type: IndicatorType;
|
|
|
|
indicators: Indicator[];
|
|
|
|
|
|
|
|
constructor(type: IndicatorType, title: string = null, defaultId: string = null, stakeholderAlias: string = null) {
|
|
|
|
this._id = null;
|
|
|
|
this.title = title;
|
|
|
|
this.type = type;
|
|
|
|
this.defaultId = defaultId;
|
|
|
|
this.stakeholderAlias = stakeholderAlias;
|
|
|
|
this.indicators = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Indicator {
|
|
|
|
_id: string;
|
|
|
|
name: string;
|
|
|
|
description: string;
|
|
|
|
type: IndicatorType;
|
|
|
|
width: IndicatorWidth;
|
|
|
|
tags: string[];
|
|
|
|
isActive: boolean;
|
|
|
|
isPublic: boolean;
|
|
|
|
defaultId: string;
|
|
|
|
indicatorPaths: IndicatorPath[];
|
2020-06-05 14:56:28 +02:00
|
|
|
recommendedFor: string[];
|
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
constructor(name: string, description: string, type: IndicatorType, width: IndicatorWidth, isActive: boolean, isPublic: boolean, indicatorPaths: IndicatorPath[], defaultId: string = null) {
|
|
|
|
this._id = null;
|
|
|
|
this.name = name;
|
|
|
|
this.description = description;
|
|
|
|
this.type = type;
|
|
|
|
this.width = width;
|
|
|
|
this.isActive = isActive;
|
|
|
|
this.isPublic = isPublic;
|
|
|
|
this.defaultId = defaultId;
|
|
|
|
this.indicatorPaths = indicatorPaths;
|
|
|
|
this.recommendedFor = [];
|
|
|
|
}
|
2020-06-05 14:56:28 +02:00
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export class IndicatorPath {
|
|
|
|
type: IndicatorPathType;
|
|
|
|
source: SourceType;
|
|
|
|
url: string;
|
|
|
|
safeResourceUrl: SafeResourceUrl; // initialize on front end
|
|
|
|
jsonPath: string[];
|
|
|
|
chartObject: string;
|
|
|
|
parameters: any;
|
|
|
|
filters: any;
|
2020-06-05 14:56:28 +02:00
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
constructor(type: IndicatorPathType, source: SourceType, url: string, chartObject: string, jsonPath: string[]) {
|
|
|
|
this.type = type;
|
|
|
|
this.url = url;
|
|
|
|
this.source = source;
|
|
|
|
this.jsonPath = jsonPath;
|
|
|
|
this.chartObject = chartObject;
|
|
|
|
this.parameters = {};
|
|
|
|
this.filters = {};
|
|
|
|
}
|
2020-06-05 14:56:28 +02:00
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
static createParameters(funderName: string = null, title: string = null, chartType: string = null): any {
|
|
|
|
return {
|
|
|
|
index_name: funderName,
|
|
|
|
title: title,
|
|
|
|
type: chartType
|
|
|
|
};
|
|
|
|
}
|
2020-06-05 14:56:28 +02:00
|
|
|
|
2020-06-03 15:43:14 +02:00
|
|
|
static createResultFilters(dbType: string = null): any {
|
|
|
|
return {
|
|
|
|
fundingL0: '{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}',
|
|
|
|
start_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}',
|
|
|
|
end_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|