Revision 47540
Added by Konstantina Galouni almost 7 years ago
organization.component.ts | ||
---|---|---|
5 | 5 |
import {OrganizationService} from '../../services/organization.service'; |
6 | 6 |
import {OrganizationInfo} from '../../utils/entities/organizationInfo'; |
7 | 7 |
import {ReportsService} from '../../services/reports.service'; |
8 |
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class'; |
|
9 |
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class'; |
|
8 | 10 |
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class'; |
9 | 11 |
import {SearchPublicationsService} from '../../services/searchPublications.service'; |
10 | 12 |
import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; |
... | ... | |
42 | 44 |
subDataproviders: any; |
43 | 45 |
subDataprovidersCount: any; |
44 | 46 |
|
45 |
private fetchDataproviders : FetchDataproviders; |
|
46 |
private linkToSearchDataproviders:string = ""; |
|
47 |
public projectsClicked: boolean = false; |
|
48 |
|
|
49 |
public fetchPublications: FetchPublications; |
|
50 |
public linkToSearchPublications: string = ""; |
|
51 |
public fetchProjects: FetchProjects; |
|
52 |
public fetchDataproviders : FetchDataproviders; |
|
53 |
public linkToSearchDataproviders:string = ""; |
|
47 | 54 |
@ViewChild (SearchingProjectsTabComponent) searchingProjectsTabComponent : SearchingProjectsTabComponent ; |
48 |
private projectFunders:string[] = [];
|
|
55 |
public projectFunders:string[] = [];
|
|
49 | 56 |
|
50 | 57 |
public routerHelper:RouterHelper = new RouterHelper(); |
51 | 58 |
|
52 | 59 |
@ViewChild (ModalLoading) loading : ModalLoading ; |
53 |
@ViewChild(AlertModal) alertApplyAll; |
|
60 |
@ViewChild('AlertModalApplyAll') alertApplyAll; |
|
61 |
@ViewChild('AlertModalCsvError') alertCsvError; |
|
54 | 62 |
|
55 |
private funder: string;
|
|
56 |
private funderId: string;
|
|
57 |
private count: number;
|
|
63 |
public funder: string;
|
|
64 |
public funderId: string;
|
|
65 |
public count: number;
|
|
58 | 66 |
|
59 | 67 |
public errorCodes:ErrorCodes = new ErrorCodes(); |
60 | 68 |
|
... | ... | |
67 | 75 |
private _searchProjectsService: SearchProjectsService, private _meta: Meta, |
68 | 76 |
private _router: Router) { |
69 | 77 |
|
78 |
this.fetchPublications = new FetchPublications(this._searchPublicationsService); |
|
79 |
this.fetchProjects = new FetchProjects(this._searchProjectsService); |
|
70 | 80 |
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); |
71 | 81 |
this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url); |
72 | 82 |
} |
... | ... | |
136 | 146 |
this.updateTitle(this.organizationInfo.title.name); |
137 | 147 |
this.updateDescription("Organization, country, projects, search, repositories, open access"+this.organizationInfo.title.name); |
138 | 148 |
|
149 |
this.fetchPublications.getResultsForEntity("organization", this.organizationId, 1, 10); |
|
150 |
this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications(); |
|
151 |
//this.fetchProjects.getNumForEntity("organization", this.organizationId); |
|
152 |
var refineFields:string [] = ["funderid"]; |
|
153 |
this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, 0,refineFields); |
|
139 | 154 |
this.fetchDataproviders.getNumForEntity("organization", this.organizationId); |
140 | 155 |
|
141 | 156 |
/*let projectsNum = 0; |
... | ... | |
210 | 225 |
} |
211 | 226 |
} |
212 | 227 |
|
213 |
downloadfile(url:string){
|
|
228 |
downloadFile(url:string){
|
|
214 | 229 |
console.log("Downloading file: "+ url); |
215 | 230 |
|
216 | 231 |
this.openLoading(); |
... | ... | |
221 | 236 |
this.closeLoading(); |
222 | 237 |
window.open(window.URL.createObjectURL(data)); |
223 | 238 |
}, |
224 |
error => console.log("Error downloading the file."), |
|
239 |
error => { |
|
240 |
console.log("Error downloading the file."); |
|
241 |
this.closeLoading(); |
|
242 |
this.confirmOpenCsvError(); |
|
243 |
}, |
|
225 | 244 |
() => console.log('Completed file download.')); |
226 | 245 |
} |
227 | 246 |
|
... | ... | |
253 | 272 |
url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle&size="+data; |
254 | 273 |
} |
255 | 274 |
|
256 |
if(data == 0) { |
|
275 |
if(data == 0) { // if no publications for this project
|
|
257 | 276 |
counter--; |
258 | 277 |
response[index] = ""; |
259 | 278 |
if(counter == 0) { |
... | ... | |
261 | 280 |
if(response[i] != "") { |
262 | 281 |
totalResponse += response[i]; |
263 | 282 |
} |
264 |
|
|
265 |
console.info("1response "+i+": "+response[i]); |
|
266 | 283 |
} |
267 | 284 |
this.closeLoading(); |
268 | 285 |
window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }))); |
... | ... | |
289 | 306 |
window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }))); |
290 | 307 |
} |
291 | 308 |
}, |
292 |
error => console.log("Error downloading the file."), |
|
309 |
error => { |
|
310 |
console.log("Error downloading the file."); |
|
311 |
this.closeLoading(); |
|
312 |
this.confirmOpenCsvError(); |
|
313 |
}, |
|
293 | 314 |
() => console.log('Completed file download.') |
294 | 315 |
); |
295 | 316 |
} |
... | ... | |
298 | 319 |
}//); |
299 | 320 |
|
300 | 321 |
}, |
301 |
error => console.log("Error getting projects project.")); |
|
322 |
error => { |
|
323 |
console.log("Error getting projects project."); |
|
324 |
this.closeLoading(); |
|
325 |
this.confirmOpenCsvError(); |
|
326 |
} |
|
327 |
); |
|
302 | 328 |
|
303 | 329 |
// let counter: number = this.organizationInfo.projects.get(funder).length; |
304 | 330 |
// |
... | ... | |
365 | 391 |
} |
366 | 392 |
} |
367 | 393 |
|
368 |
confirmOpen(funder: string, funderId:string, count:number){ |
|
394 |
confirmOpenApplyAll(funder: string, funderId:string, count:number){
|
|
369 | 395 |
this.alertApplyAll.cancelButton = true; |
370 | 396 |
this.alertApplyAll.okButton = true; |
371 | 397 |
this.alertApplyAll.alertTitle = "CSV FILE"; |
372 |
this.alertApplyAll.message = "Do you wish to download a CSV file?\nNote that this process may take a while.";
|
|
398 |
this.alertApplyAll.message = "Do you wish to download a CSV file? Note that this process may take a while.";
|
|
373 | 399 |
this.alertApplyAll.okButtonText = "Yes"; |
374 | 400 |
this.alertApplyAll.cancelButtonText = "No"; |
375 | 401 |
this.alertApplyAll.open(); |
... | ... | |
378 | 404 |
this.funderId = funderId; |
379 | 405 |
this.count = count; |
380 | 406 |
} |
381 |
confirmClose(data){
|
|
407 |
confirmCloseApplyAll(data){
|
|
382 | 408 |
this.downloadPublicationsFile(this.funder, this.funderId, this.count); |
383 | 409 |
} |
410 |
|
|
411 |
confirmOpenCsvError(){ |
|
412 |
this.alertCsvError.cancelButton = false; |
|
413 |
this.alertCsvError.okButton = true; |
|
414 |
this.alertCsvError.alertTitle = "ERROR DOWNLOADING CSV FILE"; |
|
415 |
this.alertCsvError.message = "There was an error in csv downloading. Please try again later."; |
|
416 |
this.alertCsvError.okButtonText = "OK"; |
|
417 |
this.alertCsvError.open(); |
|
418 |
} |
|
384 | 419 |
} |
Also available in: Unified diff
Organization landing page: added Publications tab (+count for Projects tab since now it is the second one) & CSV download for the Publications based on affiliations