1
|
import {SafeResourceUrl} from "@angular/platform-browser";
|
2
|
|
3
|
export const ChartHelper = {
|
4
|
prefix: "((__",
|
5
|
suffix: "__))"
|
6
|
};
|
7
|
|
8
|
export type StakeholderType = 'funder' | 'ri' | 'project' | 'organization';
|
9
|
export type IndicatorType = 'number' | 'chart';
|
10
|
export type IndicatorWidth = 'small' | 'medium' | 'large';
|
11
|
export type IndicatorPathType = 'table' | 'bar' | 'column' | 'pie' | 'line' | 'other';
|
12
|
export type SourceType = 'statistics' | 'search' | 'metrics' | 'stats-tool' | 'old' | 'image';
|
13
|
|
14
|
export class Stakeholder {
|
15
|
_id: string;
|
16
|
type: StakeholderType;
|
17
|
name: string;
|
18
|
index_id;
|
19
|
index_name: string;
|
20
|
index_shortName: string;
|
21
|
alias: string;
|
22
|
defaultId: string;
|
23
|
isActive: boolean;
|
24
|
isPublic: boolean;
|
25
|
creationDate: Date = null;
|
26
|
updateDate: Date;
|
27
|
managers: string[];
|
28
|
logoUrl: string;
|
29
|
topics: Topic[];
|
30
|
description: string;
|
31
|
|
32
|
constructor(id: string, type: StakeholderType, index_id, index_name: string, index_shortName: string, alias: string, isActive: boolean,
|
33
|
isPublic: boolean, logoUrl: string, defaultId: string = null, description: string = null) {
|
34
|
this.initializeFunder(id, type, index_id, index_name, index_shortName, defaultId, alias, isActive, isPublic, logoUrl, description);
|
35
|
this.topics = [];
|
36
|
this.managers = [];
|
37
|
}
|
38
|
|
39
|
initializeFunder(id: string, type: StakeholderType, index_id, index_name: string, index_shortName: string, defaultId: string,
|
40
|
alias: string, isActive: boolean, isPublic: boolean, logoUrl: string, description: string = null) {
|
41
|
this._id = id;
|
42
|
this.type = type;
|
43
|
this.index_id = index_id;
|
44
|
this.index_name = index_name;
|
45
|
this.index_shortName = index_shortName;
|
46
|
this.defaultId = defaultId;
|
47
|
this.alias = alias;
|
48
|
this.isActive = isActive;
|
49
|
this.isPublic = isPublic;
|
50
|
this.logoUrl = logoUrl;
|
51
|
}
|
52
|
}
|
53
|
|
54
|
export class StakeholderInfo extends Stakeholder {
|
55
|
isManager: boolean = false;
|
56
|
}
|
57
|
|
58
|
export class Topic {
|
59
|
_id: string;
|
60
|
name: string;
|
61
|
alias: string;
|
62
|
description: string;
|
63
|
isActive: boolean;
|
64
|
isPublic: boolean;
|
65
|
defaultId: string;
|
66
|
categories: Category[];
|
67
|
|
68
|
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean, defaultId: string = null) {
|
69
|
this._id = null;
|
70
|
this.name = name;
|
71
|
this.description = description;
|
72
|
this.alias = alias;
|
73
|
this.isActive = isActive;
|
74
|
this.isPublic = isPublic;
|
75
|
this.defaultId = defaultId;
|
76
|
this.categories = [];
|
77
|
}
|
78
|
}
|
79
|
|
80
|
export class Category {
|
81
|
_id: string;
|
82
|
name: string;
|
83
|
alias: string;
|
84
|
description: string;
|
85
|
isActive: boolean;
|
86
|
isPublic: boolean;
|
87
|
defaultId: string;
|
88
|
subCategories: SubCategory[];
|
89
|
|
90
|
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean, defaultId: string = null) {
|
91
|
this._id = null;
|
92
|
this.name = name;
|
93
|
this.description = description;
|
94
|
this.alias = alias;
|
95
|
this.isActive = isActive;
|
96
|
this.isPublic = isPublic;
|
97
|
this.defaultId = defaultId;
|
98
|
this.subCategories = [];
|
99
|
}
|
100
|
}
|
101
|
|
102
|
export class SubCategory {
|
103
|
_id: string;
|
104
|
name: string;
|
105
|
alias: string;
|
106
|
description: string;
|
107
|
isActive: boolean;
|
108
|
isPublic: boolean;
|
109
|
defaultId: string;
|
110
|
charts: Section[];
|
111
|
numbers: Section[];
|
112
|
recommendedFor: string[];
|
113
|
|
114
|
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean, defaultId: string = null) {
|
115
|
this._id = null;
|
116
|
this.name = name;
|
117
|
this.description = description;
|
118
|
this.alias = alias;
|
119
|
this.isActive = isActive;
|
120
|
this.isPublic = isPublic;
|
121
|
this.defaultId = defaultId;
|
122
|
this.charts = [];
|
123
|
this.numbers = [];
|
124
|
this.recommendedFor = [];
|
125
|
}
|
126
|
|
127
|
}
|
128
|
|
129
|
export class Section {
|
130
|
_id: string;
|
131
|
title: string;
|
132
|
defaultId: string;
|
133
|
stakeholderAlias: string;
|
134
|
type: IndicatorType;
|
135
|
indicators: Indicator[];
|
136
|
|
137
|
constructor(type: IndicatorType, title: string = null, defaultId: string = null, stakeholderAlias: string = null) {
|
138
|
this._id = null;
|
139
|
this.title = title;
|
140
|
this.type = type;
|
141
|
this.defaultId = defaultId;
|
142
|
this.stakeholderAlias = stakeholderAlias;
|
143
|
this.indicators = [];
|
144
|
}
|
145
|
}
|
146
|
|
147
|
export class Indicator {
|
148
|
_id: string;
|
149
|
name: string;
|
150
|
description: string;
|
151
|
type: IndicatorType;
|
152
|
width: IndicatorWidth;
|
153
|
tags: string[];
|
154
|
isActive: boolean;
|
155
|
isPublic: boolean;
|
156
|
defaultId: string;
|
157
|
indicatorPaths: IndicatorPath[];
|
158
|
recommendedFor: string[];
|
159
|
|
160
|
constructor(name: string, description: string, type: IndicatorType, width: IndicatorWidth, isActive: boolean, isPublic: boolean, indicatorPaths: IndicatorPath[], defaultId: string = null) {
|
161
|
this._id = null;
|
162
|
this.name = name;
|
163
|
this.description = description;
|
164
|
this.type = type;
|
165
|
this.width = width;
|
166
|
this.isActive = isActive;
|
167
|
this.isPublic = isPublic;
|
168
|
this.defaultId = defaultId;
|
169
|
this.indicatorPaths = indicatorPaths;
|
170
|
this.recommendedFor = [];
|
171
|
}
|
172
|
|
173
|
}
|
174
|
|
175
|
export class IndicatorPath {
|
176
|
type: IndicatorPathType;
|
177
|
source: SourceType;
|
178
|
url: string;
|
179
|
safeResourceUrl: SafeResourceUrl; // initialize on front end
|
180
|
jsonPath: string[];
|
181
|
chartObject: string;
|
182
|
parameters: any;
|
183
|
filters: any;
|
184
|
|
185
|
constructor(type: IndicatorPathType, source: SourceType, url: string, chartObject: string, jsonPath: string[]) {
|
186
|
this.type = type;
|
187
|
this.url = url;
|
188
|
this.source = source;
|
189
|
this.jsonPath = jsonPath;
|
190
|
this.chartObject = chartObject;
|
191
|
this.parameters = {};
|
192
|
this.filters = {};
|
193
|
}
|
194
|
|
195
|
static createParameters(funderName: string = null, title: string = null, chartType: string = null): any {
|
196
|
return {
|
197
|
index_name: funderName,
|
198
|
title: title,
|
199
|
type: chartType
|
200
|
};
|
201
|
}
|
202
|
|
203
|
static createResultFilters(dbType: string = null): any {
|
204
|
return {
|
205
|
fundingL0: '{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}',
|
206
|
start_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}',
|
207
|
end_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}'
|
208
|
};
|
209
|
}
|
210
|
}
|