Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
searchBar.component.ts | ||
---|---|---|
1 | 1 |
import {Component, Input} from '@angular/core'; |
2 |
import {ActivatedRoute, NavigationEnd, NavigationStart, Router} from '@angular/router';
|
|
2 |
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; |
|
3 | 3 |
import {EnvProperties} from "../../utils/properties/env-properties"; |
4 | 4 |
import {SearchCustomFilter} from "../../searchPages/searchUtils/searchUtils.class"; |
5 |
import {Subscriber} from "rxjs"; |
|
5 | 6 |
|
6 | 7 |
@Component({ |
7 | 8 |
selector: 'search-bar', |
... | ... | |
22 | 23 |
@Input() onlyresults:boolean=false; |
23 | 24 |
parameters = {}; |
24 | 25 |
advancedSearchLink = null; |
26 |
subscriptions = []; |
|
25 | 27 |
constructor(private router: Router, |
26 | 28 |
private route: ActivatedRoute ) { |
27 |
this.router.events.subscribe((e) => { |
|
29 |
this.subscriptions.push(this.router.events.subscribe((e) => {
|
|
28 | 30 |
if(e instanceof NavigationEnd){ |
29 | 31 |
// console.log(e) |
30 | 32 |
this.initialize(); |
31 | 33 |
} |
34 |
})); |
|
35 |
} |
|
36 |
ngOnDestroy() { |
|
37 |
this.subscriptions.forEach(subscription => { |
|
38 |
if (subscription instanceof Subscriber) { |
|
39 |
subscription.unsubscribe(); |
|
40 |
} |
|
32 | 41 |
}); |
33 | 42 |
} |
34 |
|
|
35 | 43 |
ngOnInit() { |
36 | 44 |
|
37 | 45 |
// this.activeRouteEnabled = false; |
... | ... | |
39 | 47 |
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); |
40 | 48 |
} |
41 | 49 |
this.entityType = "all"; |
42 |
this.route.queryParams.subscribe(params => { |
|
50 |
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
|
43 | 51 |
this.parameters = Object.assign({}, params); |
44 | 52 |
if(params["fv0"] && params["f0"] && params["f0"] == "q"){ |
45 | 53 |
this.keyword =params["fv0"]; |
... | ... | |
60 | 68 |
} |
61 | 69 |
} |
62 | 70 |
} |
63 |
}); |
|
71 |
}));
|
|
64 | 72 |
this.initialize() |
65 | 73 |
} |
66 | 74 |
initialize(){ |
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())