Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
searchPageTableView.component.ts | ||
---|---|---|
5 | 5 |
import {Location} from '@angular/common'; |
6 | 6 |
import {ActivatedRoute, Router} from '@angular/router'; |
7 | 7 |
import {Title, Meta} from '@angular/platform-browser'; |
8 |
import {Subject} from 'rxjs';
|
|
8 |
import {Subject, Subscriber} from 'rxjs';
|
|
9 | 9 |
import {DataTableDirective } from 'angular-datatables'; |
10 | 10 |
import {EnvProperties} from '../../utils/properties/env-properties'; |
11 | 11 |
import {Filter, Value} from './searchHelperClasses.class'; |
... | ... | |
68 | 68 |
@ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ; |
69 | 69 |
public currentFilter: Filter; |
70 | 70 |
public errorCodes:ErrorCodes = new ErrorCodes(); |
71 |
piwiksub: any;
|
|
71 |
subscriptions = [];
|
|
72 | 72 |
dtOptions: DataTables.Settings = {}; |
73 | 73 |
showTable = false; filteringAdded = false; |
74 | 74 |
@ViewChild(DataTableDirective) datatableElement: DataTableDirective; |
... | ... | |
92 | 92 |
private helper: HelperService) { } |
93 | 93 |
|
94 | 94 |
ngOnInit() { |
95 |
this.route.data |
|
95 |
this.subscriptions.push(this.route.data
|
|
96 | 96 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
97 | 97 |
this.properties = data.envSpecific; |
98 | 98 |
this.getPageContents(); |
... | ... | |
102 | 102 |
this.url =this.properties.domain+this.properties.baseLink+location.pathname; |
103 | 103 |
} |
104 | 104 |
if(typeof document !== 'undefined' && this.isPiwikEnabled){ |
105 |
this.piwiksub = this._piwikService.trackView(data.envSpecific, this.pageTitle, this.piwikSiteId).subscribe();
|
|
105 |
this.subscriptions.push(this._piwikService.trackView(data.envSpecific, this.pageTitle, this.piwikSiteId).subscribe());
|
|
106 | 106 |
} |
107 |
}); |
|
107 |
}));
|
|
108 | 108 |
this.dtOptions = { |
109 | 109 |
"paging": true, |
110 | 110 |
"searching": false, |
... | ... | |
120 | 120 |
|
121 | 121 |
} |
122 | 122 |
ngOnDestroy() { |
123 |
if(this.piwiksub){ |
|
124 |
this.piwiksub.unsubscribe(); |
|
123 |
this.subscriptions.forEach(subscription => { |
|
124 |
if (subscription instanceof Subscriber) { |
|
125 |
subscription.unsubscribe(); |
|
125 | 126 |
} |
127 |
}); |
|
128 |
|
|
126 | 129 |
try{ |
127 | 130 |
$.fn['dataTable'].ext.search.pop(); |
128 | 131 |
}catch(e){ |
... | ... | |
577 | 580 |
return filters; |
578 | 581 |
} |
579 | 582 |
private getPageContents() { |
580 |
this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : null, this.router.url).subscribe(contents => { |
|
583 |
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : null, this.router.url).subscribe(contents => {
|
|
581 | 584 |
|
582 | 585 |
this.pageContents = contents; |
583 |
}) |
|
586 |
}));
|
|
584 | 587 |
} |
585 | 588 |
} |
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())