1
|
import {ChangeDetectorRef, Component, OnDestroy, OnInit, ViewRef} from '@angular/core';
|
2
|
import {ActivatedRoute, Params, Router} from '@angular/router';
|
3
|
import {DomSanitizer, Meta, Title} from '@angular/platform-browser';
|
4
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
5
|
|
6
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
7
|
import {Dates, StringUtils} from '../openaireLibrary/utils/string-utils.class';
|
8
|
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
9
|
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
|
10
|
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
11
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
12
|
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
|
13
|
import {
|
14
|
Category, Indicator,
|
15
|
IndicatorPath, IndicatorSize,
|
16
|
Stakeholder,
|
17
|
SubCategory,
|
18
|
Topic,
|
19
|
Visibility
|
20
|
} from "../openaireLibrary/monitor/entities/stakeholder";
|
21
|
import {StatisticsService} from "../utils/services/statistics.service";
|
22
|
import {IndicatorUtils, StakeholderUtils} from "../utils/indicator-utils";
|
23
|
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
|
24
|
import {FormBuilder, FormControl} from "@angular/forms";
|
25
|
import {Subscriber, Subscription} from "rxjs";
|
26
|
import {User} from "../openaireLibrary/login/utils/helper.class";
|
27
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
28
|
import {RangeFilter} from "../openaireLibrary/utils/rangeFilter/rangeFilterHelperClasses.class";
|
29
|
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
30
|
import {Location} from "@angular/common";
|
31
|
import {RouterHelper} from "../openaireLibrary/utils/routerHelper.class";
|
32
|
import {properties} from "../../environments/environment";
|
33
|
import {IndexInfoService} from "../openaireLibrary/utils/indexInfo.service";
|
34
|
import {ConfigurationService} from "../openaireLibrary/utils/configuration/configuration.service";
|
35
|
|
36
|
@Component({
|
37
|
selector: 'monitor',
|
38
|
templateUrl: 'monitor.component.html',
|
39
|
styleUrls: ['monitor.component.css']
|
40
|
})
|
41
|
export class MonitorComponent implements OnInit, OnDestroy {
|
42
|
public user: User;
|
43
|
public subscriptions: any[] = [];
|
44
|
piwikSiteId;
|
45
|
title;
|
46
|
description;
|
47
|
public pageContents = null;
|
48
|
public divContents = null;
|
49
|
public status: number;
|
50
|
public loading: boolean = true;
|
51
|
public isViewPublic: boolean = false;
|
52
|
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
53
|
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
54
|
public activeTopic: Topic = null;
|
55
|
public activeCategory: Category = null;
|
56
|
public activeSubCategory: SubCategory = null;
|
57
|
public errorCodes: ErrorCodes;
|
58
|
public stakeholder: Stakeholder;
|
59
|
public numberResults: Map<string, number> = new Map<string, number>();
|
60
|
public chartsActiveType: Map<string, IndicatorPath> = new Map<string, IndicatorPath>();
|
61
|
private errorMessages: ErrorMessagesComponent;
|
62
|
properties: EnvProperties = properties;
|
63
|
filterToggle = false;
|
64
|
public routerHelper: RouterHelper = new RouterHelper();
|
65
|
filters: Filter[] = [];
|
66
|
queryParams = {};
|
67
|
periodFilter: RangeFilter = {
|
68
|
title: "Time range",
|
69
|
filterId: "year",
|
70
|
originalFilterIdFrom: null,
|
71
|
originalFilterIdTo: null,
|
72
|
selectedFromValue: null,
|
73
|
selectedToValue: null,
|
74
|
selectedFromAndToValues: ""
|
75
|
};
|
76
|
privateStakeholder = false;
|
77
|
public keyword: FormControl;
|
78
|
public statsUpdateDate: Date;
|
79
|
constructor(
|
80
|
private route: ActivatedRoute,
|
81
|
private _router: Router,
|
82
|
private _meta: Meta,
|
83
|
private _title: Title,
|
84
|
private _piwikService: PiwikService,
|
85
|
private helper: HelperService,
|
86
|
private stakeholderService: StakeholderService,
|
87
|
private userManagementService: UserManagementService,
|
88
|
private statisticsService: StatisticsService,
|
89
|
private layoutService: LayoutService,
|
90
|
private seoService: SEOService,
|
91
|
private cdr: ChangeDetectorRef,
|
92
|
private indexInfoService: IndexInfoService,
|
93
|
private sanitizer: DomSanitizer, private _fb: FormBuilder, private router: Router,
|
94
|
private configurationService: ConfigurationService) {
|
95
|
this.errorCodes = new ErrorCodes();
|
96
|
this.errorMessages = new ErrorMessagesComponent();
|
97
|
this.status = this.errorCodes.LOADING;
|
98
|
}
|
99
|
|
100
|
public ngOnInit() {
|
101
|
if (typeof document !== 'undefined') {
|
102
|
this.subscriptions.push(this.indexInfoService.getStatsLastDate(this.properties).subscribe(lastIndexUpdate => {
|
103
|
if (lastIndexUpdate) {
|
104
|
this.statsUpdateDate = new Date(lastIndexUpdate);
|
105
|
}
|
106
|
}));
|
107
|
}
|
108
|
this.keyword = this._fb.control('');
|
109
|
this.subscriptions.push(this.keyword.valueChanges.subscribe(value => {
|
110
|
console.log("Keyword Changed!");
|
111
|
//TODO do a real action
|
112
|
}));
|
113
|
let subscription: Subscription;
|
114
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
115
|
this.user = user;
|
116
|
|
117
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
118
|
this.loading = true;
|
119
|
this.activeTopic = null;
|
120
|
this.activeCategory = null;
|
121
|
this.activeSubCategory = null;
|
122
|
this.filterToggle = false;
|
123
|
if (subscription) {
|
124
|
subscription.unsubscribe();
|
125
|
}
|
126
|
var url = properties.domain + properties.baseLink + this._router.url;
|
127
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
128
|
this.queryParams = Object.assign({}, params);
|
129
|
this.isViewPublic = (params['view'] == 'public');
|
130
|
}));
|
131
|
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
|
132
|
this.status = this.errorCodes.LOADING;
|
133
|
this.numberResults = new Map<string, number>();
|
134
|
this.chartsActiveType = new Map<string, IndicatorPath>();
|
135
|
subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
136
|
if (stakeholder) {
|
137
|
this.stakeholder = stakeholder;
|
138
|
// add fl0 filter only for EC
|
139
|
if (this.stakeholder.index_id == "ec__________::EC") {
|
140
|
this.filters.push({
|
141
|
title: "Funding Stream",
|
142
|
filterId: "relfundinglevel0_id",
|
143
|
originalFilterId: "relfundinglevel0_id",
|
144
|
countSelectedValues: 0,
|
145
|
values: [{name: "EC|FP7", id: "ec__________::EC::FP7", selected: false, number: 0}, {
|
146
|
name: "EC|H2020",
|
147
|
id: "ec__________::EC::H2020",
|
148
|
selected: false,
|
149
|
number: 0
|
150
|
}]
|
151
|
,
|
152
|
filterOperator: "or",
|
153
|
valueIsExact: true,
|
154
|
filterType: "radio",
|
155
|
radioValue: ""
|
156
|
});
|
157
|
}
|
158
|
if (this.stakeholder.type == "funder") {
|
159
|
// this.filters.push({title: "Co-funded research outcomes",filterId: "co-funded",originalFilterId: "co-funded", countSelectedValues: 0,
|
160
|
// values:[{name: "true", id: "co-funded", selected: false, number: 0}, {name: "false", id: "no-co-funded", selected: false, number: 0}]
|
161
|
// ,filterOperator: "or", valueIsExact: true, filterType: "radio", radioValue:""});
|
162
|
this.filters.push({
|
163
|
title: "Co-funded", filterId: "co-funded", originalFilterId: "co-funded", countSelectedValues: 0,
|
164
|
values: [{name: "Co-funded research output", id: "co-funded-results", selected: false, number: 0}]
|
165
|
, filterOperator: "or", valueIsExact: true, filterType: "checkbox", radioValue: ""
|
166
|
});
|
167
|
}
|
168
|
this.initializeFilters();
|
169
|
this.seoService.createLinkForCanonicalURL(url, false);
|
170
|
this._meta.updateTag({content: url}, "property='og:url'");
|
171
|
this.description = "Monitor Dashboard | " + this.stakeholder.name;
|
172
|
this.title = "Monitor Dashboard | " + this.stakeholder.name;
|
173
|
this._meta.updateTag({content: this.description}, "name='description'");
|
174
|
this._meta.updateTag({content: this.description}, "property='og:description'");
|
175
|
this._meta.updateTag({content: this.title}, "property='og:title'");
|
176
|
this._title.setTitle(this.title);
|
177
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
178
|
this.subscriptions.push(this.configurationService.communityInformationState.subscribe(portal => {
|
179
|
if (portal && portal.piwik) {
|
180
|
console.debug(portal)
|
181
|
this.piwikSiteId = portal.piwik;
|
182
|
console.debug(this.piwikSiteId)
|
183
|
this.subscriptions.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe());
|
184
|
}
|
185
|
}));
|
186
|
|
187
|
}
|
188
|
if (this.isPublicOrIsMember(stakeholder.visibility)) {
|
189
|
//this.getDivContents();
|
190
|
// this.getPageContents();
|
191
|
this.status = this.errorCodes.DONE;
|
192
|
this.setView(params);
|
193
|
} else {
|
194
|
this.privateStakeholder = true;
|
195
|
// this.navigateToError();
|
196
|
if (subscription) {
|
197
|
subscription.unsubscribe();
|
198
|
}
|
199
|
}
|
200
|
}else{
|
201
|
this.navigateToError();
|
202
|
if (subscription) {
|
203
|
subscription.unsubscribe();
|
204
|
}
|
205
|
}
|
206
|
});
|
207
|
this.subscriptions.push(subscription);
|
208
|
} else {
|
209
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
210
|
if (this.piwikSiteId) {
|
211
|
console.debug(this.piwikSiteId)
|
212
|
this.subscriptions.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe());
|
213
|
}
|
214
|
}
|
215
|
this.initializeFilters();
|
216
|
this.setView(params);
|
217
|
}
|
218
|
}));
|
219
|
}));
|
220
|
|
221
|
}
|
222
|
|
223
|
private initializeFilters() {
|
224
|
this.periodFilter.selectedFromValue = (this.queryParams['year'] && this.queryParams['year'].indexOf("range") == 0) ? this.queryParams['year'].split("range")[1].split(":")[0] : "";
|
225
|
this.periodFilter.selectedToValue = (this.queryParams['year'] && this.queryParams['year'].indexOf("range") == 0) ? this.queryParams['year'].split("range")[1].split(":")[1] : "";
|
226
|
this.validateYearRange(false);
|
227
|
|
228
|
for (let filter of this.filters) {
|
229
|
if (this.queryParams[filter.filterId]) {
|
230
|
for (let value of filter.values) {
|
231
|
if (value.id == StringUtils.URIDecode(StringUtils.unquote(this.queryParams[filter.filterId]))) {
|
232
|
value.selected = true;
|
233
|
filter.countSelectedValues = 1;
|
234
|
break;
|
235
|
}
|
236
|
}
|
237
|
} else {
|
238
|
this.clearfFilter(filter);
|
239
|
}
|
240
|
}
|
241
|
|
242
|
}
|
243
|
|
244
|
private validateYearRange(navigateTo: boolean = false) {
|
245
|
let validYears = true;
|
246
|
|
247
|
if (this.periodFilter.selectedToValue && (this.periodFilter.selectedToValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedToValue, Dates.currentYear - 20, Dates.currentYear))) {
|
248
|
this.periodFilter.selectedToValue = Dates.currentYear + "";
|
249
|
validYears = false;
|
250
|
}
|
251
|
if (this.periodFilter.selectedFromValue && (this.periodFilter.selectedFromValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedFromValue, Dates.currentYear - 20, Dates.currentYear))) {
|
252
|
this.periodFilter.selectedFromValue = Dates.currentYear - 20 + "";
|
253
|
validYears = false;
|
254
|
}
|
255
|
if (this.periodFilter.selectedFromValue && this.periodFilter.selectedFromValue.length && this.periodFilter.selectedToValue && this.periodFilter.selectedToValue.length > 0 && parseInt(this.periodFilter.selectedFromValue, 10) > parseInt(this.periodFilter.selectedToValue, 10)) {
|
256
|
this.periodFilter.selectedFromValue = this.periodFilter.selectedToValue;
|
257
|
validYears = false;
|
258
|
}
|
259
|
if (!validYears || navigateTo) {
|
260
|
if (this.periodFilter.selectedFromValue || this.periodFilter.selectedToValue) {
|
261
|
this.queryParams["year"] = 'range' + (this.periodFilter.selectedFromValue ? this.periodFilter.selectedFromValue : '') + ":" + (this.periodFilter.selectedToValue ? this.periodFilter.selectedToValue : "");
|
262
|
} else {
|
263
|
delete this.queryParams["year"];
|
264
|
}
|
265
|
// this.location.go(location.pathname, this.routerHelper.createQueryParamsString( Object.keys(this.queryParams), Object.values(this.queryParams)));
|
266
|
this.router.navigate([], {queryParams: this.queryParams});
|
267
|
this.setIndicators();
|
268
|
}
|
269
|
}
|
270
|
|
271
|
clearAll() {
|
272
|
for (let filter of this.filters) {
|
273
|
this.clearfFilter(filter);
|
274
|
}
|
275
|
this.periodFilter.selectedFromValue = "";
|
276
|
this.periodFilter.selectedToValue = "";
|
277
|
this.validateYearRange(true)
|
278
|
}
|
279
|
|
280
|
clearfFilter(filter: Filter) {
|
281
|
filter.countSelectedValues = 0;
|
282
|
filter.radioValue = "";
|
283
|
for (let value of filter.values) {
|
284
|
if (value.selected) {
|
285
|
value.selected = false;
|
286
|
}
|
287
|
}
|
288
|
if (this.queryParams[filter.filterId]) {
|
289
|
delete this.queryParams[filter.filterId];
|
290
|
}
|
291
|
}
|
292
|
|
293
|
countSelectedFilters(): number {
|
294
|
let count = 0;
|
295
|
if (this.periodFilter.selectedFromAndToValues.length > 0) {
|
296
|
count += 2;
|
297
|
}
|
298
|
for (let filter of this.filters) {
|
299
|
count += filter.countSelectedValues;
|
300
|
}
|
301
|
return count;
|
302
|
}
|
303
|
|
304
|
public get isSmallScreen() {
|
305
|
return this.layoutService.isSmallScreen;
|
306
|
}
|
307
|
|
308
|
public get open() {
|
309
|
return this.layoutService.open;
|
310
|
}
|
311
|
|
312
|
private getPageContents() {
|
313
|
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.properties.adminToolsCommunity, this._router.url).subscribe(contents => {
|
314
|
this.pageContents = contents;
|
315
|
}));
|
316
|
}
|
317
|
|
318
|
private getDivContents() {
|
319
|
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.properties.adminToolsCommunity, this._router.url).subscribe(contents => {
|
320
|
this.divContents = contents;
|
321
|
}));
|
322
|
}
|
323
|
|
324
|
private setView(params: Params) {
|
325
|
this.loading = false;
|
326
|
if (params['topic']) {
|
327
|
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility));
|
328
|
if (this.activeTopic) {
|
329
|
if (params['category']) {
|
330
|
this.activeCategory = this.activeTopic.categories.find(category =>
|
331
|
(category.alias === params['category']) && this.isPublicOrIsMember(category.visibility));
|
332
|
if (!this.activeCategory) {
|
333
|
this.navigateToError();
|
334
|
return;
|
335
|
}
|
336
|
} else {
|
337
|
this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility));
|
338
|
if (this.activeCategory) {
|
339
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
340
|
this.isPublicOrIsMember(subCategory.visibility));
|
341
|
if (this.activeSubCategory) {
|
342
|
this.setIndicators();
|
343
|
}
|
344
|
}
|
345
|
return;
|
346
|
}
|
347
|
if (this.activeCategory) {
|
348
|
if (params['subCategory']) {
|
349
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
350
|
(subCategory.alias === params['subCategory'] && this.isPublicOrIsMember(subCategory.visibility)));
|
351
|
if (!this.activeSubCategory) {
|
352
|
this.navigateToError();
|
353
|
return;
|
354
|
}
|
355
|
} else {
|
356
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
357
|
this.isPublicOrIsMember(subCategory.visibility));
|
358
|
}
|
359
|
if (this.activeSubCategory) {
|
360
|
this.setIndicators();
|
361
|
} else {
|
362
|
this.navigateToError();
|
363
|
}
|
364
|
return;
|
365
|
} else {
|
366
|
this.activeSubCategory = null;
|
367
|
}
|
368
|
} else {
|
369
|
this.navigateToError();
|
370
|
return;
|
371
|
}
|
372
|
} else {
|
373
|
this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility));
|
374
|
if (this.activeTopic) {
|
375
|
this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility));
|
376
|
if (this.activeCategory) {
|
377
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => this.isPublicOrIsMember(subCategory.visibility));
|
378
|
if (this.activeSubCategory) {
|
379
|
this.setIndicators();
|
380
|
}
|
381
|
}
|
382
|
}
|
383
|
}
|
384
|
}
|
385
|
|
386
|
filter() {
|
387
|
this.validateYearRange(true);
|
388
|
}
|
389
|
|
390
|
filterChanged($event, navigate: boolean = true) {
|
391
|
let selected = "";
|
392
|
for (let value of $event.value.values) {
|
393
|
if (value.selected) {
|
394
|
selected = value.id;
|
395
|
break;
|
396
|
}
|
397
|
}
|
398
|
if (selected) {
|
399
|
this.queryParams[$event.value.filterId] = StringUtils.quote(StringUtils.URIEncode(selected));
|
400
|
} else {
|
401
|
delete this.queryParams[$event.value.filterId];
|
402
|
}
|
403
|
if (navigate) {
|
404
|
this.router.navigate([], {queryParams: this.queryParams});
|
405
|
this.setIndicators();
|
406
|
}
|
407
|
|
408
|
}
|
409
|
|
410
|
private getfl0() {
|
411
|
if (this.queryParams["relfundinglevel0_id"] && this.filters.length > 0) {
|
412
|
let value = StringUtils.URIDecode(StringUtils.unquote(this.queryParams["relfundinglevel0_id"] ));
|
413
|
return value.split("::")[value.split("::").length - 1];
|
414
|
}
|
415
|
return null;
|
416
|
}
|
417
|
|
418
|
private getCoFunded() {
|
419
|
if (this.queryParams["co-funded"] && this.filters.length > 0) {
|
420
|
return this.queryParams["co-funded"] && this.queryParams["co-funded"] == "co-funded-results";
|
421
|
}
|
422
|
return false;
|
423
|
}
|
424
|
|
425
|
clearPeriodFilter() {
|
426
|
if (this.periodFilter.selectedFromValue || this.periodFilter.selectedToValue) {
|
427
|
this.periodFilter.selectedFromValue = "";
|
428
|
this.periodFilter.selectedToValue = "";
|
429
|
this.filter();
|
430
|
}
|
431
|
|
432
|
}
|
433
|
|
434
|
private setIndicators() {
|
435
|
this.periodFilter.selectedFromAndToValues = (this.periodFilter.selectedFromValue || this.periodFilter.selectedToValue ? ((this.periodFilter.selectedFromValue && !this.periodFilter.selectedToValue ? "From " : "") + (!this.periodFilter.selectedFromValue && this.periodFilter.selectedToValue ? "Until " : "") + (this.periodFilter.selectedFromValue ? this.periodFilter.selectedFromValue : "") +
|
436
|
(this.periodFilter.selectedFromValue && this.periodFilter.selectedToValue ? " - " : "") + (this.periodFilter.selectedToValue ? this.periodFilter.selectedToValue : "")) : "");
|
437
|
//clear numbers when filters change
|
438
|
this.numberResults.clear();
|
439
|
let urls: Map<string, [number, number][]> = new Map<string, [number, number][]>();
|
440
|
this.activeSubCategory.numbers.forEach((section, i) => {
|
441
|
section.indicators.forEach((number, j) => {
|
442
|
if (this.isPublicOrIsMember(number.visibility)) {
|
443
|
let url = this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, number.indicatorPaths[0], this.getfl0(), this.periodFilter.selectedFromValue, this.periodFilter.selectedToValue, this.getCoFunded());
|
444
|
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
|
445
|
const indexes = urls.get(pair) ? urls.get(pair) : [];
|
446
|
indexes.push([i, j]);
|
447
|
urls.set(pair, indexes);
|
448
|
}
|
449
|
});
|
450
|
});
|
451
|
urls.forEach((indexes, pair) => {
|
452
|
pair = JSON.parse(pair);
|
453
|
this.subscriptions.push(this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => {
|
454
|
indexes.forEach(([i, j]) => {
|
455
|
let result = JSON.parse(JSON.stringify(response));
|
456
|
this.activeSubCategory.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
457
|
if (result) {
|
458
|
result = result[jsonPath];
|
459
|
}
|
460
|
});
|
461
|
if (typeof result === 'string' || typeof result === 'number') {
|
462
|
result = Number(result);
|
463
|
if (result === Number.NaN) {
|
464
|
result = 0;
|
465
|
}
|
466
|
} else {
|
467
|
result = 0;
|
468
|
}
|
469
|
this.numberResults.set(i + '-' + j, result);
|
470
|
});
|
471
|
}));
|
472
|
});
|
473
|
this.activeSubCategory.charts.forEach((section, i) => {
|
474
|
section.indicators.forEach((indicator, j) => {
|
475
|
if (indicator.indicatorPaths.length > 0) {
|
476
|
indicator.indicatorPaths[0].safeResourceUrl = this.getUrlByStakeHolder(indicator.indicatorPaths[0]);
|
477
|
this.chartsActiveType.set(i + '-' + j, indicator.indicatorPaths[0]);
|
478
|
}
|
479
|
});
|
480
|
});
|
481
|
if (this.cdr && !(this.cdr as ViewRef).destroyed) {
|
482
|
this.cdr.detectChanges();
|
483
|
}
|
484
|
}
|
485
|
|
486
|
public getUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
487
|
return this.sanitizer.bypassSecurityTrustResourceUrl(
|
488
|
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, indicatorPath, this.getfl0(), this.periodFilter.selectedFromValue, this.periodFilter.selectedToValue, this.getCoFunded())));
|
489
|
}
|
490
|
|
491
|
public setActiveChart(i: number, j: number, type: string) {
|
492
|
let activeChart = this.activeSubCategory.charts[i].indicators[j].indicatorPaths.filter(indicatorPath => indicatorPath.type === type)[0];
|
493
|
activeChart.safeResourceUrl = this.getUrlByStakeHolder(activeChart);
|
494
|
this.chartsActiveType.set(i + '-' + j, activeChart);
|
495
|
}
|
496
|
|
497
|
private navigateToError() {
|
498
|
this._router.navigate(['/error'], {queryParams: {'page': this._router.url}});
|
499
|
}
|
500
|
|
501
|
public navigateTo(stakeholder: string, topic: string, category: string = null, subcategory: string = null) {
|
502
|
let url = stakeholder + '/' + topic + ((category) ? ('/'
|
503
|
+ category) : '') + ((subcategory) ? ('/' + subcategory) : '');
|
504
|
return this._router.navigate([url], {queryParams: this.queryParams});
|
505
|
}
|
506
|
|
507
|
public quote(param: string): string {
|
508
|
return StringUtils.quote(param);
|
509
|
}
|
510
|
|
511
|
public ngOnDestroy() {
|
512
|
this.subscriptions.forEach(subscription => {
|
513
|
if (subscription instanceof Subscriber) {
|
514
|
subscription.unsubscribe();
|
515
|
}
|
516
|
});
|
517
|
}
|
518
|
|
519
|
public isPublicOrIsMember(visibility: Visibility): boolean {
|
520
|
if (visibility == "PRIVATE" || (this.isViewPublic && visibility != "PUBLIC")) {
|
521
|
return false;
|
522
|
}
|
523
|
return true;
|
524
|
}
|
525
|
|
526
|
public countSubCategoriesToShow(category: Category): number {
|
527
|
let counter = 0;
|
528
|
for (let sub of category.subCategories) {
|
529
|
if (this.isPublicOrIsMember(sub.visibility)) {
|
530
|
counter++;
|
531
|
}
|
532
|
}
|
533
|
return counter;
|
534
|
}
|
535
|
|
536
|
public countIndicatorsToShow(indicators: Indicator[]): number {
|
537
|
let counter = 0;
|
538
|
for (let i of indicators) {
|
539
|
if (this.isPublicOrIsMember(i.visibility)) {
|
540
|
counter++;
|
541
|
}
|
542
|
}
|
543
|
return counter;
|
544
|
}
|
545
|
|
546
|
/*
|
547
|
Feedback mail
|
548
|
*/
|
549
|
public get mailText() {
|
550
|
return "mailto:" + this.properties.feedbackmail + "?subject=%5BOpenAIRE%20Monitor%5D%20" + (this.stakeholder ? this.stakeholder.name : "") + "%20dashboard%20feedback"
|
551
|
}
|
552
|
|
553
|
mailMe() {
|
554
|
window.location.href = this.mailText;
|
555
|
}
|
556
|
|
557
|
public getNumberClassBySize(size: IndicatorSize) {
|
558
|
if(size === 'small') {
|
559
|
return 'uk-width-1-4@xl uk-width-1-3@l uk-width-1-2@m uk-width-1-1';
|
560
|
} else if(size === 'medium') {
|
561
|
return 'uk-width-1-3@l uk-width-1-2@m uk-width-1-1';
|
562
|
} else {
|
563
|
return 'uk-width-1-2@l uk-width-1-1@m uk-width-1-1';
|
564
|
}
|
565
|
}
|
566
|
|
567
|
public getChartClassBySize(size: IndicatorSize) {
|
568
|
if(size === 'small') {
|
569
|
return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1';
|
570
|
} else if(size === 'medium') {
|
571
|
return 'uk-width-1-2@l uk-width-1-1';
|
572
|
} else {
|
573
|
return 'uk-width-1-1';
|
574
|
}
|
575
|
}
|
576
|
}
|