Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
resultLanding.component.ts | ||
---|---|---|
19 | 19 |
import {StringUtils} from "../../utils/string-utils.class"; |
20 | 20 |
import {properties} from "../../../../environments/environment"; |
21 | 21 |
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service"; |
22 |
import {Subscriber} from "rxjs"; |
|
22 | 23 |
|
23 | 24 |
|
24 | 25 |
@Component({ |
... | ... | |
37 | 38 |
public deleteByInferenceOpened: boolean = false; |
38 | 39 |
|
39 | 40 |
public resultLandingInfo: ResultLandingInfo; |
40 |
public relatedResults: RelationResult[]; |
|
41 | 41 |
public supplementaryResults: RelationResult[]; |
42 | 42 |
public relation: string = 'trust'; |
43 | 43 |
public id: string; |
... | ... | |
78 | 78 |
// Map counting variables |
79 | 79 |
public bioentitiesNum: number = 0; |
80 | 80 |
public relatedResultsNum: number = 0; |
81 |
public supplementaryResultsNum: number = 0; |
|
82 |
|
|
81 |
|
|
83 | 82 |
// Message variables |
84 | 83 |
public warningMessage = ""; |
85 | 84 |
public errorMessage = ""; |
... | ... | |
89 | 88 |
public routerHelper: RouterHelper = new RouterHelper(); |
90 | 89 |
public activeTab: string = null; |
91 | 90 |
private doi: string; |
92 |
sub: any; |
|
93 |
piwiksub: any; |
|
94 |
infoSub: any; |
|
91 |
subscriptions = []; |
|
95 | 92 |
properties: EnvProperties = properties; |
96 | 93 |
public indexUpdateDate: Date; |
97 | 94 |
public pageContents = null; |
... | ... | |
121 | 118 |
|
122 | 119 |
ngOnInit() { |
123 | 120 |
if (typeof document !== 'undefined') { |
124 |
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { |
|
121 |
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
|
|
125 | 122 |
if (lastIndexUpdate) { |
126 | 123 |
this.indexUpdateDate = new Date(lastIndexUpdate); |
127 | 124 |
} |
128 |
}); |
|
125 |
}));
|
|
129 | 126 |
} |
130 | 127 |
//this.getDivContents(); |
131 | 128 |
this.getPageContents(); |
132 | 129 |
this.updateUrl(this.properties.domain +this.properties.baseLink + this._router.url); |
133 |
this.sub = this.route.queryParams.subscribe(data => {
|
|
130 |
this.subscriptions.push(this.route.queryParams.subscribe(data => {
|
|
134 | 131 |
this.resultLandingInfo = null; |
135 | 132 |
if (data['articleId']) { |
136 | 133 |
this.type = "publication"; |
... | ... | |
189 | 186 |
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; |
190 | 187 |
|
191 | 188 |
this.scroll(); |
192 |
}); |
|
189 |
}));
|
|
193 | 190 |
} |
194 | 191 |
|
195 | 192 |
private getPageContents() { |
196 | 193 |
if (this.communityId) { |
197 |
this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { |
|
194 |
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
|
198 | 195 |
this.pageContents = contents; |
199 |
}); |
|
196 |
}));
|
|
200 | 197 |
} |
201 | 198 |
} |
202 | 199 |
|
203 | 200 |
private getDivContents() { |
204 | 201 |
if (this.communityId) { |
205 |
this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { |
|
202 |
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
|
206 | 203 |
this.divContents = contents; |
207 |
}); |
|
204 |
}));
|
|
208 | 205 |
} |
209 | 206 |
} |
210 |
|
|
207 |
|
|
211 | 208 |
ngOnDestroy() { |
212 |
if (this.sub) { |
|
213 |
this.sub.unsubscribe(); |
|
214 |
} |
|
215 |
if (this.piwiksub) { |
|
216 |
this.piwiksub.unsubscribe(); |
|
217 |
} |
|
218 |
if (this.infoSub) { |
|
219 |
this.infoSub.unsubscribe(); |
|
220 |
} |
|
209 |
this.subscriptions.forEach(subscription => { |
|
210 |
if (subscription instanceof Subscriber) { |
|
211 |
subscription.unsubscribe(); |
|
212 |
} |
|
213 |
}); |
|
214 |
this._vocabulariesService.clearSubscriptions(); |
|
221 | 215 |
} |
222 | 216 |
|
223 | 217 |
public getTypeName(): string { |
... | ... | |
244 | 238 |
} |
245 | 239 |
|
246 | 240 |
private getOpenCitations() { |
247 |
this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe( |
|
241 |
this.subscriptions.push(this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe(
|
|
248 | 242 |
data => { |
249 | 243 |
this.resultLandingInfo.openCitations = data[1]; |
250 | 244 |
}, |
251 | 245 |
err => { |
252 | 246 |
this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err); |
253 | 247 |
} |
254 |
); |
|
248 |
));
|
|
255 | 249 |
} |
256 | 250 |
|
257 | 251 |
private getProvenanceVocabularyAndResultLandingInfo() { |
... | ... | |
262 | 256 |
this.resultLandingInfo = null; |
263 | 257 |
|
264 | 258 |
if (typeof document !== 'undefined') { |
265 |
this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe( |
|
259 |
this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe(
|
|
266 | 260 |
provenanceActionVocabulary => { |
267 | 261 |
this.getResultLandingInfo(provenanceActionVocabulary); |
268 | 262 |
}, err => { |
269 | 263 |
this.getResultLandingInfo(null); |
270 | 264 |
this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err); |
271 | 265 |
} |
272 |
); |
|
266 |
));
|
|
273 | 267 |
} else { |
274 | 268 |
this.getResultLandingInfo(null); |
275 | 269 |
} |
... | ... | |
315 | 309 |
// } |
316 | 310 |
|
317 | 311 |
private getResultLandingInfo(provenanceActionVocabulary: any) { |
318 |
this.infoSub = this._resultLaningService.getResultLandingInfo(this.id, this.type, provenanceActionVocabulary, this.properties).subscribe(
|
|
312 |
this.subscriptions.push(this._resultLaningService.getResultLandingInfo(this.id, this.type, provenanceActionVocabulary, this.properties).subscribe(
|
|
319 | 313 |
data => { |
320 | 314 |
this.resultLandingInfo = data; |
321 | 315 |
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType |
... | ... | |
331 | 325 |
this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description) : ("," + this.resultLandingInfo.title))); |
332 | 326 |
} |
333 | 327 |
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { |
334 |
this.piwiksub = this._piwikService.trackView(this.properties, this.resultLandingInfo.title/*.name*/, this.piwikSiteId).subscribe();
|
|
328 |
this.subscriptions.push(this._piwikService.trackView(this.properties, this.resultLandingInfo.title/*.name*/, this.piwikSiteId).subscribe());
|
|
335 | 329 |
} |
336 | 330 |
|
337 | 331 |
let bioentitiesNum = 0; |
... | ... | |
344 | 338 |
if (typeof document !== 'undefined') { |
345 | 339 |
if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) { |
346 | 340 |
this.doi = this.resultLandingInfo.identifiers.get('doi')[0]; |
347 |
this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => { |
|
341 |
this.subscriptions.push(this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => {
|
|
348 | 342 |
this.hasAltMetrics = hasAltMetrics; |
349 | 343 |
}, error => { |
350 | 344 |
this.hasAltMetrics = false; |
351 |
}); |
|
345 |
}));
|
|
352 | 346 |
} |
353 | 347 |
} |
354 | 348 |
this.showLoading = false; |
... | ... | |
371 | 365 |
this.showLoading = false; |
372 | 366 |
this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage); |
373 | 367 |
} |
374 |
); |
|
368 |
));
|
|
375 | 369 |
} |
376 | 370 |
|
377 | 371 |
public metricsResults($event) { |
Also available in: Unified diff
[Library|Trunk]
code clean up:
-remove app.* files from library
-remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc)
-remove Freeguard from modules
-unsubscribe all subscriptions
-Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions())
-Fetchers: unsubscribe from the component that uses them (clearSubscriptions())