20 |
20 |
import {FormBuilder, FormControl} from "@angular/forms";
|
21 |
21 |
|
22 |
22 |
@Component({
|
23 |
|
selector: 'monitor',
|
24 |
|
templateUrl: 'monitor.component.html',
|
|
23 |
selector: 'monitor',
|
|
24 |
templateUrl: 'monitor.component.html',
|
25 |
25 |
})
|
26 |
26 |
export class MonitorComponent implements OnInit, OnDestroy {
|
27 |
|
public piwiksub: any;
|
28 |
|
public pageContents = null;
|
29 |
|
public divContents = null;
|
30 |
|
public status: number;
|
31 |
|
public loading: boolean = true;
|
32 |
|
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
33 |
|
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
34 |
|
public activeTopic: Topic = null;
|
35 |
|
public activeCategory: Category = null;
|
36 |
|
public activeSubCategory: SubCategory = null;
|
37 |
|
public sideBar: Sidebar = null;
|
38 |
|
public errorCodes: ErrorCodes;
|
39 |
|
public stakeholder: Stakeholder;
|
40 |
|
public numberResults: Map<number, number> = new Map<number, number>();
|
41 |
|
public chartsActiveType: Map<number, IndicatorPath> = new Map<number, IndicatorPath>();
|
42 |
|
private errorMessages: ErrorMessagesComponent;
|
43 |
|
properties: EnvProperties;
|
44 |
|
fundingL0;
|
45 |
|
startYear;
|
46 |
|
endYear;
|
|
27 |
public piwiksub: any;
|
|
28 |
public pageContents = null;
|
|
29 |
public divContents = null;
|
|
30 |
public status: number;
|
|
31 |
public loading: boolean = true;
|
|
32 |
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
|
33 |
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
|
34 |
public activeTopic: Topic = null;
|
|
35 |
public activeCategory: Category = null;
|
|
36 |
public activeSubCategory: SubCategory = null;
|
|
37 |
public sideBar: Sidebar = null;
|
|
38 |
public errorCodes: ErrorCodes;
|
|
39 |
public stakeholder: Stakeholder;
|
|
40 |
public numberResults: Map<number, number> = new Map<number, number>();
|
|
41 |
public chartsActiveType: Map<number, IndicatorPath> = new Map<number, IndicatorPath>();
|
|
42 |
private errorMessages: ErrorMessagesComponent;
|
|
43 |
properties: EnvProperties;
|
|
44 |
fundingL0;
|
|
45 |
startYear;
|
|
46 |
endYear;
|
47 |
47 |
|
48 |
|
public keyword:FormControl;
|
|
48 |
public keyword: FormControl;
|
49 |
49 |
|
50 |
|
constructor(
|
51 |
|
private route: ActivatedRoute,
|
52 |
|
private _router: Router,
|
53 |
|
private _meta: Meta,
|
54 |
|
private _title: Title,
|
55 |
|
private _piwikService: PiwikService,
|
56 |
|
private helper: HelperService,
|
57 |
|
private stakeholderService: StakeholderService,
|
58 |
|
private statisticsService: StatisticsService,
|
59 |
|
private layoutService: LayoutService,
|
60 |
|
private seoService: SEOService,
|
61 |
|
private cdr: ChangeDetectorRef,
|
62 |
|
private sanitizer: DomSanitizer, private _fb: FormBuilder) {
|
63 |
|
this.errorCodes = new ErrorCodes();
|
64 |
|
this.errorMessages = new ErrorMessagesComponent();
|
65 |
|
this.status = this.errorCodes.LOADING;
|
66 |
|
}
|
|
50 |
constructor(
|
|
51 |
private route: ActivatedRoute,
|
|
52 |
private _router: Router,
|
|
53 |
private _meta: Meta,
|
|
54 |
private _title: Title,
|
|
55 |
private _piwikService: PiwikService,
|
|
56 |
private helper: HelperService,
|
|
57 |
private stakeholderService: StakeholderService,
|
|
58 |
private statisticsService: StatisticsService,
|
|
59 |
private layoutService: LayoutService,
|
|
60 |
private seoService: SEOService,
|
|
61 |
private cdr: ChangeDetectorRef,
|
|
62 |
private sanitizer: DomSanitizer, private _fb: FormBuilder) {
|
|
63 |
this.errorCodes = new ErrorCodes();
|
|
64 |
this.errorMessages = new ErrorMessagesComponent();
|
|
65 |
this.status = this.errorCodes.LOADING;
|
|
66 |
}
|
67 |
67 |
|
68 |
|
public ngOnInit() {
|
69 |
|
this.keyword = this._fb.control('');
|
70 |
|
this.keyword.valueChanges.subscribe(value=>{
|
71 |
|
console.log("KEyword Changed!");
|
72 |
|
//TODO do a real action
|
73 |
|
});
|
74 |
|
this.layoutService.setHasSidebar(false);
|
75 |
|
this.layoutService.setHasHeader(false);
|
76 |
|
this.route.data
|
77 |
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
78 |
|
this.route.params.subscribe(params => {
|
79 |
|
this.properties = data.envSpecific;
|
80 |
|
var url = data.envSpecific.baseLink + this._router.url;
|
81 |
|
if (!this.stakeholder || this.stakeholder.index_id !== params['stakeholder']) {
|
82 |
|
this.status = this.errorCodes.LOADING;
|
83 |
|
this.numberResults = new Map<number, number>();
|
84 |
|
this.chartsActiveType = new Map<number, IndicatorPath>();
|
85 |
|
// this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
86 |
|
let stakeholder:Stakeholder = null;
|
87 |
|
if(params['stakeholder']=="fwf"){
|
88 |
|
stakeholder = new Stakeholder("fwf", "funder", "fwf_________::FWF","Austrian Science Fund (FWF)","FWF",
|
89 |
|
false,"fwf",true,true, null);
|
90 |
|
stakeholder = this.stakeholderUtils.
|
91 |
|
createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
92 |
|
stakeholder.logoUrl = "./assets/fwf.png";
|
93 |
|
}else if(params['stakeholder']=="arc"){
|
94 |
|
stakeholder = new Stakeholder("arc","funder","arc_________::ARC",
|
95 |
|
"Australian Research Council (ARC)","ARC",
|
96 |
|
false,"arc",true,true, null);
|
97 |
|
stakeholder = this.stakeholderUtils.
|
98 |
|
createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
99 |
|
stakeholder.logoUrl = "./assets/arc1.gif";
|
100 |
|
}else{
|
101 |
|
stakeholder = new Stakeholder("ec","funder","ec__________::EC",
|
102 |
|
"European Commission","EC",
|
103 |
|
false,"ec",true,true, null);
|
104 |
|
stakeholder = this.stakeholderUtils.
|
105 |
|
createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
106 |
|
stakeholder.logoUrl = "./assets/ec.png";
|
107 |
|
}
|
108 |
|
|
109 |
|
if(stakeholder) {
|
110 |
|
this.stakeholder = stakeholder;
|
111 |
|
this.seoService.createLinkForCanonicalURL(url, false);
|
112 |
|
this._meta.updateTag({content: url}, "property='og:url'");
|
113 |
|
var description = "Monitor Dashboard | " + this.stakeholder.index_name;
|
114 |
|
var title = "Monitor Dashboard | " + this.stakeholder.index_shortName;
|
115 |
|
this._meta.updateTag({content: description}, "name='description'");
|
116 |
|
this._meta.updateTag({content: description}, "property='og:description'");
|
117 |
|
this._meta.updateTag({content: title}, "property='og:title'");
|
118 |
|
this._title.setTitle(title);
|
119 |
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
120 |
|
this.piwiksub = this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe();
|
121 |
|
}
|
122 |
|
//this.getDivContents();
|
123 |
|
this.getPageContents();
|
124 |
|
this.status = this.errorCodes.DONE;
|
125 |
|
this.setView(params);
|
126 |
|
}
|
127 |
|
// }, error => {
|
128 |
|
// this.navigateToError();
|
129 |
|
// })
|
130 |
|
} else {
|
131 |
|
this.setView(params);
|
132 |
|
}
|
|
68 |
public ngOnInit() {
|
|
69 |
this.keyword = this._fb.control('');
|
|
70 |
this.keyword.valueChanges.subscribe(value => {
|
|
71 |
console.log("KEyword Changed!");
|
|
72 |
//TODO do a real action
|
133 |
73 |
});
|
134 |
|
});
|
135 |
|
}
|
|
74 |
this.layoutService.setHasSidebar(false);
|
|
75 |
this.layoutService.setHasHeader(false);
|
|
76 |
this.route.data
|
|
77 |
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
78 |
this.route.params.subscribe(params => {
|
|
79 |
this.properties = data.envSpecific;
|
|
80 |
var url = data.envSpecific.baseLink + this._router.url;
|
|
81 |
if (!this.stakeholder || this.stakeholder.index_id !== params['stakeholder']) {
|
|
82 |
this.status = this.errorCodes.LOADING;
|
|
83 |
this.numberResults = new Map<number, number>();
|
|
84 |
this.chartsActiveType = new Map<number, IndicatorPath>();
|
|
85 |
// this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
|
86 |
let stakeholder: Stakeholder = null;
|
|
87 |
if (params['stakeholder'] == "fwf") {
|
|
88 |
stakeholder = new Stakeholder("fwf", "funder", "fwf_________::FWF", "Austrian Science Fund (FWF)", "FWF",
|
|
89 |
false, "fwf", true, true, null);
|
|
90 |
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
|
91 |
stakeholder.logoUrl = "./assets/fwf.png";
|
|
92 |
} else if (params['stakeholder'] == "arc") {
|
|
93 |
stakeholder = new Stakeholder("arc", "funder", "arc_________::ARC",
|
|
94 |
"Australian Research Council (ARC)", "ARC",
|
|
95 |
false, "arc", true, true, null);
|
|
96 |
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
|
97 |
stakeholder.logoUrl = "./assets/arc1.gif";
|
|
98 |
} else {
|
|
99 |
stakeholder = new Stakeholder("ec", "funder", "ec__________::EC",
|
|
100 |
"European Commission", "EC",
|
|
101 |
false, "ec", true, true, null);
|
|
102 |
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
|
|
103 |
stakeholder.logoUrl = "./assets/ec.png";
|
|
104 |
}
|
|
105 |
if (stakeholder) {
|
|
106 |
this.stakeholder = stakeholder;
|
|
107 |
this.seoService.createLinkForCanonicalURL(url, false);
|
|
108 |
this._meta.updateTag({content: url}, "property='og:url'");
|
|
109 |
var description = "Monitor Dashboard | " + this.stakeholder.index_name;
|
|
110 |
var title = "Monitor Dashboard | " + this.stakeholder.index_shortName;
|
|
111 |
this._meta.updateTag({content: description}, "name='description'");
|
|
112 |
this._meta.updateTag({content: description}, "property='og:description'");
|
|
113 |
this._meta.updateTag({content: title}, "property='og:title'");
|
|
114 |
this._title.setTitle(title);
|
|
115 |
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
|
116 |
this.piwiksub = this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe();
|
|
117 |
}
|
|
118 |
//this.getDivContents();
|
|
119 |
this.getPageContents();
|
|
120 |
this.status = this.errorCodes.DONE;
|
|
121 |
this.setView(params);
|
|
122 |
}
|
|
123 |
// }, error => {
|
|
124 |
// this.navigateToError();
|
|
125 |
// })
|
|
126 |
} else {
|
|
127 |
this.setView(params);
|
|
128 |
}
|
|
129 |
});
|
|
130 |
});
|
|
131 |
}
|
136 |
132 |
|
137 |
|
public get open() {
|
138 |
|
return this.layoutService.open;
|
139 |
|
}
|
|
133 |
public get open() {
|
|
134 |
return this.layoutService.open;
|
|
135 |
}
|
140 |
136 |
|
141 |
|
public toggleOpen(event = null) {
|
142 |
|
if(!event) {
|
143 |
|
this.layoutService.setOpen(!this.open);
|
144 |
|
} else if(event && event['value'] === true) {
|
145 |
|
this.layoutService.setOpen(false);
|
|
137 |
public toggleOpen(event = null) {
|
|
138 |
if (!event) {
|
|
139 |
this.layoutService.setOpen(!this.open);
|
|
140 |
} else if (event && event['value'] === true) {
|
|
141 |
this.layoutService.setOpen(false);
|
|
142 |
}
|
146 |
143 |
}
|
147 |
|
}
|
148 |
144 |
|
149 |
|
private getPageContents() {
|
150 |
|
this.helper.getPageHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
151 |
|
this.pageContents = contents;
|
152 |
|
})
|
153 |
|
}
|
|
145 |
private getPageContents() {
|
|
146 |
this.helper.getPageHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
|
147 |
this.pageContents = contents;
|
|
148 |
})
|
|
149 |
}
|
154 |
150 |
|
155 |
|
private getDivContents() {
|
156 |
|
this.helper.getDivHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
157 |
|
this.divContents = contents;
|
158 |
|
})
|
159 |
|
}
|
|
151 |
private getDivContents() {
|
|
152 |
this.helper.getDivHelpContents(this._router.url, this.properties, 'monitor').subscribe(contents => {
|
|
153 |
this.divContents = contents;
|
|
154 |
})
|
|
155 |
}
|
160 |
156 |
|
161 |
|
private setView(params: Params) {
|
162 |
|
if (params && params['topic']) {
|
163 |
|
this.activeTopic = this.stakeholder.topics.filter(topic => topic.alias === decodeURIComponent(params['topic']))[0];
|
164 |
|
if (this.activeTopic) {
|
165 |
|
if (params['category']) {
|
166 |
|
this.activeCategory = this.activeTopic.categories.filter(category =>
|
167 |
|
(category.alias === params['category']) && category.isPublic && category.isActive)[0];
|
|
157 |
private setView(params: Params) {
|
|
158 |
if (params && params['topic']) {
|
|
159 |
this.activeTopic = this.stakeholder.topics.
|
|
160 |
find(topic => topic.alias === decodeURIComponent(params['topic']) && topic.isPublic && topic.isActive);
|
|
161 |
if (this.activeTopic) {
|
|
162 |
if (params['category']) {
|
|
163 |
this.activeCategory = this.activeTopic.categories.find(category =>
|
|
164 |
(category.alias === params['category']) && category.isPublic && category.isActive);
|
|
165 |
} else {
|
|
166 |
this.activeCategory = this.activeTopic.categories.
|
|
167 |
find(category => category.isPublic && category.isActive);
|
|
168 |
if (this.activeCategory) {
|
|
169 |
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
|
170 |
subCategory.isPublic && subCategory.isActive);
|
|
171 |
if (this.activeSubCategory) {
|
|
172 |
this.setSideBar();
|
|
173 |
this.setIndicators();
|
|
174 |
} else {
|
|
175 |
this.navigateToError();
|
|
176 |
}
|
|
177 |
} else {
|
|
178 |
this.navigateToError();
|
|
179 |
}
|
|
180 |
return;
|
|
181 |
}
|
|
182 |
if (this.activeCategory) {
|
|
183 |
if (params['subCategory']) {
|
|
184 |
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
|
185 |
(subCategory.alias === params['subCategory'] && subCategory.isPublic && subCategory.isActive));
|
|
186 |
} else {
|
|
187 |
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
|
188 |
subCategory.isPublic && subCategory.isActive);
|
|
189 |
}
|
|
190 |
if (this.activeSubCategory) {
|
|
191 |
this.setSideBar();
|
|
192 |
this.setIndicators();
|
|
193 |
} else {
|
|
194 |
this.navigateToError();
|
|
195 |
}
|
|
196 |
return;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
this.navigateToError();
|
168 |
200 |
} else {
|
169 |
|
let category: Category = this.activeTopic.categories[0];
|
170 |
|
if(category) {
|
171 |
|
this.navigateTo(this.stakeholder.alias, this.activeTopic.alias, category.alias);
|
172 |
|
} else {
|
173 |
|
this.navigateToError();
|
174 |
|
}
|
175 |
|
return;
|
|
201 |
this.activeTopic = this.stakeholder.topics.find(topic => topic.isPublic && topic.isActive);
|
|
202 |
if(this.activeTopic) {
|
|
203 |
this.activeCategory = this.activeTopic.categories.find(category => category.isPublic && category.isActive);
|
|
204 |
if (this.activeCategory) {
|
|
205 |
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => subCategory.isPublic && subCategory.isActive);
|
|
206 |
if (this.activeSubCategory) {
|
|
207 |
this.setSideBar();
|
|
208 |
this.setIndicators();
|
|
209 |
} else {
|
|
210 |
this.navigateToError();
|
|
211 |
}
|
|
212 |
} else {
|
|
213 |
this.navigateToError();
|
|
214 |
}
|
|
215 |
} else {
|
|
216 |
this.navigateToError();
|
|
217 |
}
|
176 |
218 |
}
|
177 |
|
if (this.activeCategory) {
|
178 |
|
if (params['subCategory']) {
|
179 |
|
this.activeSubCategory = this.activeCategory.subCategories.filter(subCategory =>
|
180 |
|
(subCategory.alias === params['subCategory'] && subCategory.isPublic && subCategory.isActive))[0];
|
181 |
|
} else {
|
182 |
|
this.activeSubCategory = this.activeCategory.subCategories.filter(subCategory =>
|
183 |
|
!subCategory.alias && subCategory.isPublic && subCategory.isActive)[0];
|
184 |
|
}
|
185 |
|
if (this.activeSubCategory) {
|
186 |
|
this.setSideBar();
|
187 |
|
this.setIndicators();
|
188 |
|
return;
|
189 |
|
} else {
|
190 |
|
let subCategory: SubCategory = this.activeCategory.subCategories.filter(subCategory =>
|
191 |
|
subCategory.isPublic && subCategory.isActive)[0];
|
192 |
|
this.navigateTo(this.stakeholder.alias, this.activeTopic.alias, this.activeCategory.alias, subCategory.alias);
|
193 |
|
return;
|
194 |
|
}
|
195 |
|
}
|
196 |
|
}
|
197 |
|
this.navigateToError();
|
198 |
|
} else {
|
199 |
|
let topic: Topic = this.stakeholder.topics[0];
|
200 |
|
let category: Category = topic.categories.filter(category => category.isPublic && category.isActive)[0];
|
201 |
|
if(topic && category) {
|
202 |
|
this.navigateTo(this.stakeholder.alias, topic.alias, category.alias);
|
203 |
|
} else {
|
204 |
|
this.navigateToError();
|
205 |
|
}
|
206 |
219 |
}
|
207 |
|
}
|
208 |
220 |
|
209 |
|
private setSideBar() {
|
210 |
|
let items: Item[] = [];
|
211 |
|
this.activeTopic.categories.forEach(category => {
|
212 |
|
if (category.isPublic && category.isActive) {
|
213 |
|
let subItems: Item[] = [];
|
214 |
|
category.subCategories.forEach(subCategory => {
|
215 |
|
if (subCategory.alias != null && subCategory.isPublic && subCategory.isActive) {
|
216 |
|
subItems.push(new Item(subCategory.name, (
|
217 |
|
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias + '/' + subCategory.alias),
|
218 |
|
null, null, false));
|
219 |
|
}
|
|
221 |
private setSideBar() {
|
|
222 |
let items: Item[] = [];
|
|
223 |
this.activeTopic.categories.forEach(category => {
|
|
224 |
if (category.isPublic && category.isActive) {
|
|
225 |
let subItems: Item[] = [];
|
|
226 |
category.subCategories.forEach(subCategory => {
|
|
227 |
if (subCategory.isPublic && subCategory.isActive) {
|
|
228 |
subItems.push(new Item(subCategory.alias, subCategory.name, (
|
|
229 |
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias + '/' + subCategory.alias),
|
|
230 |
null, null, false));
|
|
231 |
}
|
|
232 |
});
|
|
233 |
const open = this.activeCategory.alias === category.alias;
|
|
234 |
items.push(new Item(category.alias, category.name, (
|
|
235 |
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias),
|
|
236 |
subItems, null, open));
|
|
237 |
}
|
220 |
238 |
});
|
221 |
|
const open = this.activeCategory.alias === category.alias;
|
222 |
|
items.push(new Item(category.name, (
|
223 |
|
'/' + this.stakeholder.alias + '/' + this.activeTopic.alias + '/' + category.alias),
|
224 |
|
subItems, null, open));
|
225 |
|
}
|
226 |
|
});
|
227 |
|
this.sideBar = new Sidebar(items, null);
|
228 |
|
}
|
|
239 |
this.sideBar = new Sidebar(items, null);
|
|
240 |
}
|
229 |
241 |
|
230 |
|
private setIndicators() {
|
231 |
|
let urls: Map<string, number[]> = new Map<string, number[]>();
|
232 |
|
this.activeSubCategory.numbers.forEach((number, index) => {
|
233 |
|
if (number.isActive && number.isPublic) {
|
234 |
|
let url = number.indicatorPaths[0].url;
|
235 |
|
//add fundingLevel0 filter in the query
|
236 |
|
if(this.fundingL0 && number.indicatorPaths[0].filters.get("fundingL0")){
|
237 |
|
url = url + number.indicatorPaths[0].filters.get("fundingL0").replace(ChartHelper.prefix+'fundingL0'+ChartHelper.suffix,encodeURIComponent(this.fundingL0));
|
238 |
|
}
|
239 |
|
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
|
240 |
|
const indexes = urls.get(pair) ? urls.get(pair) : [];
|
241 |
|
indexes.push(index);
|
242 |
|
urls.set(pair, indexes);
|
243 |
|
}
|
244 |
|
});
|
245 |
|
urls.forEach((indexes, pair) => {
|
246 |
|
pair = JSON.parse(pair);
|
247 |
|
this.statisticsService.getNumbers(pair[0], pair[1]).subscribe(response => {
|
248 |
|
indexes.forEach(index => {
|
249 |
|
let result = JSON.parse(JSON.stringify(response));
|
250 |
|
this.activeSubCategory.numbers[index].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
251 |
|
if (result) {
|
252 |
|
result = result[jsonPath];
|
|
242 |
private setIndicators() {
|
|
243 |
let urls: Map<string, number[]> = new Map<string, number[]>();
|
|
244 |
this.activeSubCategory.numbers.forEach((number, index) => {
|
|
245 |
if (number.isActive && number.isPublic) {
|
|
246 |
let url = number.indicatorPaths[0].url;
|
|
247 |
//add fundingLevel0 filter in the query
|
|
248 |
if (this.fundingL0 && number.indicatorPaths[0].filters.get("fundingL0")) {
|
|
249 |
url = url + number.indicatorPaths[0].filters.get("fundingL0").replace(ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix, encodeURIComponent(this.fundingL0));
|
|
250 |
}
|
|
251 |
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
|
|
252 |
const indexes = urls.get(pair) ? urls.get(pair) : [];
|
|
253 |
indexes.push(index);
|
|
254 |
urls.set(pair, indexes);
|
253 |
255 |
}
|
254 |
|
});
|
255 |
|
this.numberResults.set(index, result);
|
256 |
256 |
});
|
257 |
|
})
|
258 |
|
});
|
259 |
|
this.activeSubCategory.charts.forEach((chart, index) => {
|
260 |
|
if (chart.indicatorPaths.length > 0) {
|
261 |
|
chart.indicatorPaths[0].safeResourceUrl = this.getUrlByStakeHolder(chart.indicatorPaths[0]);
|
262 |
|
this.chartsActiveType.set(index, chart.indicatorPaths[0]);
|
263 |
|
}
|
264 |
|
});
|
265 |
|
this.cdr.detectChanges();
|
266 |
|
}
|
|
257 |
urls.forEach((indexes, pair) => {
|
|
258 |
pair = JSON.parse(pair);
|
|
259 |
this.statisticsService.getNumbers(pair[0], pair[1]).subscribe(response => {
|
|
260 |
indexes.forEach(index => {
|
|
261 |
let result = JSON.parse(JSON.stringify(response));
|
|
262 |
this.activeSubCategory.numbers[index].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
|
263 |
if (result) {
|
|
264 |
result = result[jsonPath];
|
|
265 |
}
|
|
266 |
});
|
|
267 |
this.numberResults.set(index, result);
|
|
268 |
});
|
|
269 |
})
|
|
270 |
});
|
|
271 |
this.activeSubCategory.charts.forEach((chart, index) => {
|
|
272 |
if (chart.indicatorPaths.length > 0) {
|
|
273 |
chart.indicatorPaths[0].safeResourceUrl = this.getUrlByStakeHolder(chart.indicatorPaths[0]);
|
|
274 |
this.chartsActiveType.set(index, chart.indicatorPaths[0]);
|
|
275 |
}
|
|
276 |
});
|
|
277 |
this.cdr.detectChanges();
|
|
278 |
}
|
267 |
279 |
|
268 |
|
public getUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
269 |
|
return this.sanitizer.bypassSecurityTrustResourceUrl(
|
270 |
|
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath, this.fundingL0, this.startYear, this.endYear)));
|
271 |
|
}
|
|
280 |
public getUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
|
281 |
return this.sanitizer.bypassSecurityTrustResourceUrl(
|
|
282 |
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath, this.fundingL0, this.startYear, this.endYear)));
|
|
283 |
}
|
272 |
284 |
|
273 |
|
public setActiveChart(index, type: string) {
|
274 |
|
let activeChart = this.activeSubCategory.charts[index].indicatorPaths.filter(indicatorPath => indicatorPath.type === type)[0];
|
275 |
|
activeChart.safeResourceUrl = this.getUrlByStakeHolder(activeChart);
|
276 |
|
this.chartsActiveType.set(index, activeChart);
|
277 |
|
}
|
|
285 |
public setActiveChart(index, type: string) {
|
|
286 |
let activeChart = this.activeSubCategory.charts[index].indicatorPaths.filter(indicatorPath => indicatorPath.type === type)[0];
|
|
287 |
activeChart.safeResourceUrl = this.getUrlByStakeHolder(activeChart);
|
|
288 |
this.chartsActiveType.set(index, activeChart);
|
|
289 |
}
|
278 |
290 |
|
279 |
|
private navigateToError() {
|
280 |
|
this._router.navigate(['/error'], {queryParams: {'page': this._router.url}});
|
281 |
|
}
|
|
291 |
private navigateToError() {
|
|
292 |
this._router.navigate(['/error'], {queryParams: {'page': this._router.url}});
|
|
293 |
}
|
282 |
294 |
|
283 |
|
public navigateTo(stakeholder: string, topic: string, category: string = null, subcategory: string = null) {
|
284 |
|
let url = stakeholder + '/' + topic + ((category) ? ('/'
|
285 |
|
+ category) : '') + ((subcategory) ? ('/' + subcategory) : '');
|
286 |
|
return this._router.navigate([url]);
|
287 |
|
}
|
|
295 |
public navigateTo(stakeholder: string, topic: string, category: string = null, subcategory: string = null) {
|
|
296 |
let url = stakeholder + '/' + topic + ((category) ? ('/'
|
|
297 |
+ category) : '') + ((subcategory) ? ('/' + subcategory) : '');
|
|
298 |
return this._router.navigate([url]);
|
|
299 |
}
|
288 |
300 |
|
289 |
|
public quote(param: string): string {
|
290 |
|
return StringUtils.quote(param);
|
291 |
|
}
|
|
301 |
public quote(param: string): string {
|
|
302 |
return StringUtils.quote(param);
|
|
303 |
}
|
292 |
304 |
|
293 |
|
public ngOnDestroy() {
|
294 |
|
if (this.piwiksub) {
|
295 |
|
this.piwiksub.unsubscribe();
|
|
305 |
public ngOnDestroy() {
|
|
306 |
if (this.piwiksub) {
|
|
307 |
this.piwiksub.unsubscribe();
|
|
308 |
}
|
296 |
309 |
}
|
297 |
|
}
|
298 |
310 |
}
|
[MonitorDashboard]: Sidebar: add activeItem and subItem to check which element is active