Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
htmlProjectReport.component.ts | ||
---|---|---|
9 | 9 |
import {PiwikService} from '../../utils/piwik/piwik.service'; |
10 | 10 |
import {SEOService} from '../../sharedComponents/SEO/SEO.service'; |
11 | 11 |
import {HelperService} from "../../utils/helper/helper.service"; |
12 |
import {Subscriber} from "rxjs"; |
|
12 | 13 |
|
13 | 14 |
declare var UIkit: any; |
14 | 15 |
|
... | ... | |
62 | 63 |
public header2: string = ""; |
63 | 64 |
public htmlResult: string = ""; |
64 | 65 |
|
65 |
public sub: any; |
|
66 |
piwiksub: any; |
|
67 |
public subHTML: any; |
|
68 |
public subHTMLInfo: any; |
|
66 |
subscriptions = []; |
|
69 | 67 |
|
70 | 68 |
public warningMessage: string = ""; |
71 | 69 |
public errorMessage: string = ""; |
... | ... | |
86 | 84 |
} |
87 | 85 |
|
88 | 86 |
ngOnInit() { |
89 |
this.route.data |
|
87 |
this.subscriptions.push(this.route.data
|
|
90 | 88 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
91 | 89 |
this.properties = data.envSpecific; |
92 | 90 |
//this.getDivContents(); |
... | ... | |
94 | 92 |
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); |
95 | 93 |
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this._router.url); |
96 | 94 |
|
97 |
}); |
|
98 |
this.sub = this.route.queryParams.subscribe(params => {
|
|
95 |
}));
|
|
96 |
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
|
99 | 97 |
this.projectId = params['projectId']; |
100 | 98 |
|
101 | 99 |
if (params['size'] == parseInt(params['size'], 10)) { |
... | ... | |
136 | 134 |
this.warningMessage = "No valid project id"; |
137 | 135 |
} |
138 | 136 |
} |
139 |
}); |
|
137 |
}));
|
|
140 | 138 |
} |
141 | 139 |
|
142 | 140 |
private getPageContents() { |
143 | 141 |
if(this.communityId) { |
144 |
this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { |
|
142 |
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
|
145 | 143 |
this.pageContents = contents; |
146 |
}); |
|
144 |
}));
|
|
147 | 145 |
} |
148 | 146 |
} |
149 | 147 |
|
150 | 148 |
private getDivContents() { |
151 | 149 |
if(this.communityId) { |
152 |
this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { |
|
150 |
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
|
153 | 151 |
this.divContents = contents; |
154 |
}); |
|
152 |
}));
|
|
155 | 153 |
} |
156 | 154 |
} |
157 | 155 |
|
158 | 156 |
ngOnDestroy() { |
159 |
this.sub.unsubscribe(); |
|
160 |
if (this.piwiksub) { |
|
161 |
this.piwiksub.unsubscribe(); |
|
162 |
} |
|
163 |
if (this.subHTML) { |
|
164 |
this.subHTML.unsubscribe(); |
|
165 |
} |
|
166 |
if (this.subHTMLInfo) { |
|
167 |
this.subHTMLInfo.unsubscribe(); |
|
168 |
} |
|
157 |
this.subscriptions.forEach(subscription => { |
|
158 |
if (subscription instanceof Subscriber) { |
|
159 |
subscription.unsubscribe(); |
|
160 |
} |
|
161 |
}); |
|
169 | 162 |
} |
170 | 163 |
|
171 | 164 |
private createHeaders() { |
172 |
this.subHTMLInfo = this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe(
|
|
165 |
this.subscriptions.push(this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe(
|
|
173 | 166 |
data => { |
174 | 167 |
this.createHeader1(data); |
175 | 168 |
if (data.acronym) { |
... | ... | |
178 | 171 |
this.updateTitle(data.title + " " + this.resultsType + " report"); |
179 | 172 |
} |
180 | 173 |
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { |
181 |
this.piwiksub = this._piwikService.trackView(this.properties, ((data.acronym) ? data.acronym : data.title) + " " + this.resultsType + " report", this.piwikSiteId).subscribe();
|
|
174 |
this.subscriptions.push(this._piwikService.trackView(this.properties, ((data.acronym) ? data.acronym : data.title) + " " + this.resultsType + " report", this.piwikSiteId).subscribe());
|
|
182 | 175 |
} |
183 | 176 |
}, |
184 | 177 |
err => { |
... | ... | |
186 | 179 |
//console.log(err); |
187 | 180 |
this.createClipboard(); |
188 | 181 |
} |
189 |
); |
|
182 |
));
|
|
190 | 183 |
|
191 | 184 |
if (this.resultsType == "publication") { |
192 | 185 |
this.header2 += this.totalResults.toLocaleString('en-US') + " publications"; |
... | ... | |
207 | 200 |
intro += '</head>'; |
208 | 201 |
|
209 | 202 |
if (typeof window !== 'undefined') { |
210 |
this.subHTML = this.htmlService.getHTML(this.projectId, this.resultsType, this.properties.csvAPIURL).subscribe(
|
|
203 |
this.subscriptions.push(this.htmlService.getHTML(this.projectId, this.resultsType, this.properties.csvAPIURL).subscribe(
|
|
211 | 204 |
data => { |
212 | 205 |
//let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>'+data+'</body></html>'; |
213 | 206 |
let body: string = intro + '<body><h1>' + this.header1 + '</h1><h2>' + this.header2 + '</h2>'; |
... | ... | |
238 | 231 |
this.errorMessage = 'Service not available'; |
239 | 232 |
this.showLoading = false; |
240 | 233 |
} |
241 |
); |
|
234 |
));
|
|
242 | 235 |
} |
243 | 236 |
} |
244 | 237 |
|
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())