Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
searchDownload.component.ts | ||
---|---|---|
8 | 8 |
import {ErrorCodes} from '../../utils/properties/errorCodes'; |
9 | 9 |
|
10 | 10 |
import 'rxjs'; |
11 |
import {Subscriber} from "rxjs"; |
|
11 | 12 |
|
12 | 13 |
@Component({ |
13 | 14 |
selector: 'search-download', |
... | ... | |
38 | 39 |
@Input() type: string; |
39 | 40 |
@ViewChild(AlertModal) alertApplyAll: AlertModal; |
40 | 41 |
downloadURLAPI: string; |
41 |
|
|
42 |
sub: any; |
|
43 |
downloadFilePiwikSub: any; |
|
44 |
|
|
42 |
|
|
45 | 43 |
public csvLimit: number = 0; |
46 | 44 |
|
47 | 45 |
@ViewChild(ModalLoading) loading: ModalLoading; |
... | ... | |
50 | 48 |
public isPiwikEnabled; |
51 | 49 |
public properties: EnvProperties; |
52 | 50 |
public errorCodes: ErrorCodes = new ErrorCodes(); |
53 |
|
|
51 |
subscriptions = []; |
|
54 | 52 |
constructor(private route: ActivatedRoute, private _reportsService: ReportsService, private _piwikService: PiwikService) { |
55 | 53 |
} |
56 | 54 |
|
57 | 55 |
ngOnInit() { |
58 |
this.route.data |
|
56 |
this.subscriptions.push(this.route.data
|
|
59 | 57 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
60 | 58 |
this.properties = data.envSpecific; |
61 | 59 |
this.csvLimit = data.envSpecific.csvLimit; |
62 | 60 |
this.downloadURLAPI = data.envSpecific.csvAPIURL; |
63 | 61 |
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; |
64 |
}); |
|
62 |
}));
|
|
65 | 63 |
} |
66 |
|
|
64 |
|
|
67 | 65 |
ngOnDestroy() { |
68 |
if (this.sub) { |
|
69 |
this.sub.unsubscribe(); |
|
70 |
} |
|
71 |
if (this.downloadFilePiwikSub) { |
|
72 |
this.downloadFilePiwikSub.unsubscribe(); |
|
73 |
} |
|
66 |
this.subscriptions.forEach(subscription => { |
|
67 |
if (subscription instanceof Subscriber) { |
|
68 |
subscription.unsubscribe(); |
|
69 |
} |
|
70 |
}); |
|
74 | 71 |
} |
75 | 72 |
|
76 | 73 |
denialOfDownload() { |
... | ... | |
91 | 88 |
//console.log("Downloading file: "+ url); |
92 | 89 |
this.openLoading(); |
93 | 90 |
this.setMessageLoading("Downloading CSV file"); |
94 |
|
|
95 |
this._reportsService.downloadCSVFile(url).subscribe( |
|
91 |
|
|
92 |
this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe(
|
|
96 | 93 |
data => { |
97 | 94 |
this.closeLoading(); |
98 | 95 |
//window.open(window.URL.createObjectURL(data),filename+".csv"); |
... | ... | |
113 | 110 |
//window.location.href = window.URL.createObjectURL(data); |
114 | 111 |
|
115 | 112 |
if (this.isPiwikEnabled && (typeof document !== 'undefined')) { |
116 |
this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe();
|
|
113 |
this.subscriptions.push(this._piwikService.trackDownload(this.properties, url).subscribe());
|
|
117 | 114 |
} |
118 | 115 |
}, |
119 | 116 |
error => { |
... | ... | |
128 | 125 |
console.log('Completed file download.'); |
129 | 126 |
//setTimeout(function(){ newWindow.close(); }, 500); |
130 | 127 |
}*/ |
131 |
); |
|
128 |
));
|
|
132 | 129 |
} |
133 | 130 |
|
134 | 131 |
|
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())