1
|
import {Component, ElementRef, Input, ViewChild} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from '@angular/router';
|
3
|
import {Meta, Title} from '@angular/platform-browser';
|
4
|
import {OrganizationService} from '../../services/organization.service';
|
5
|
import {OrganizationInfo} from '../../utils/entities/organizationInfo';
|
6
|
import {ReportsService} from '../../services/reports.service';
|
7
|
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
8
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
9
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
10
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
11
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
12
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
13
|
|
14
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
15
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
16
|
import {StringUtils} from '../../utils/string-utils.class';
|
17
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
18
|
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
19
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
20
|
import {HelperService} from "../../utils/helper/helper.service";
|
21
|
import {Location} from "@angular/common";
|
22
|
import {FetchResearchResults} from "../../utils/fetchEntitiesClasses/fetchResearchResults.class";
|
23
|
import {FetchDataproviders} from "../../utils/fetchEntitiesClasses/fetchDataproviders.class";
|
24
|
import {IndexInfoService} from "../../utils/indexInfo.service";
|
25
|
import {Subscriber} from "rxjs";
|
26
|
import {properties} from "../../../../environments/environment";
|
27
|
|
28
|
@Component({
|
29
|
selector: 'organization',
|
30
|
templateUrl: 'organization.component.html',
|
31
|
})
|
32
|
export class OrganizationComponent {
|
33
|
@Input() piwikSiteId = null;
|
34
|
@Input() communityId = null;
|
35
|
|
36
|
public organizationInfo: OrganizationInfo;
|
37
|
public organizationId: string;
|
38
|
|
39
|
// Message variables
|
40
|
public warningMessage = "";
|
41
|
public errorMessage = "";
|
42
|
public showLoading: boolean = true;
|
43
|
|
44
|
// CSV variables
|
45
|
public downloadURLAPI: string;
|
46
|
public csvProjectParamsHead: string;
|
47
|
public csvParamsTail: string;
|
48
|
|
49
|
// Variables for publications, research data, projects, dataproviders tabs
|
50
|
public fetchProjects: FetchProjects;
|
51
|
public fetchPublications: FetchResearchResults;
|
52
|
public fetchDatasets: FetchResearchResults;
|
53
|
public fetchSoftware: FetchResearchResults;
|
54
|
public fetchOrps: FetchResearchResults;
|
55
|
public fetchDataproviders: FetchDataproviders
|
56
|
public searchNumber: number = 5;
|
57
|
|
58
|
// Request results of each tab only the one time (first time tab is clicked)
|
59
|
private reloadPublications: boolean = true;
|
60
|
private reloadDatasets: boolean = true;
|
61
|
private reloadSoftware: boolean = true;
|
62
|
private reloadOrps: boolean = true;
|
63
|
private reloadDataproviders: boolean = true;
|
64
|
|
65
|
// Active tab variable for responsiveness
|
66
|
public activeTab: string = "";
|
67
|
|
68
|
@ViewChild('downloadReportModal') downloadReportModal;
|
69
|
@ViewChild('downloadFunderReportModal') downloadFunderReportModal;
|
70
|
|
71
|
@ViewChild(ModalLoading) loading: ModalLoading;
|
72
|
// Alert box when CSV: Project Publications for a funder is requested
|
73
|
@ViewChild('AlertModalApplyAll') alertApplyAll;
|
74
|
// Alert box when something is wrong with CSV requests
|
75
|
@ViewChild('AlertModalCsvError') alertCsvError;
|
76
|
|
77
|
public routerHelper: RouterHelper = new RouterHelper();
|
78
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
79
|
public pageContents = null;
|
80
|
public divContents = null;
|
81
|
|
82
|
// Helper variables to specify funder in downloadPublicationsFile function
|
83
|
public contentTypes: [string, string][] = [
|
84
|
['results', 'all research outcomes'],
|
85
|
['publications', 'publications'],
|
86
|
['datasets', 'research data'],
|
87
|
['software', 'software'],
|
88
|
['other', 'other research products'],
|
89
|
];
|
90
|
public funderContentType: string = '';
|
91
|
public funder: any = "";
|
92
|
private funderId: string;
|
93
|
private funderCount: number;
|
94
|
subscriptions = [];
|
95
|
innerReportSubscriptions = [];
|
96
|
properties: EnvProperties;
|
97
|
public indexUpdateDate: Date;
|
98
|
public showFeedback: boolean = false;
|
99
|
public feedbackFields: string [] = ['Name', 'Country', 'Other'];
|
100
|
|
101
|
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
|
102
|
@ViewChild('projectsModal') projectsModal;
|
103
|
public deleteByInferenceOpened: boolean = false;
|
104
|
|
105
|
|
106
|
constructor(private element: ElementRef,
|
107
|
private _organizationService: OrganizationService,
|
108
|
private _piwikService: PiwikService,
|
109
|
private route: ActivatedRoute,
|
110
|
private _searchDataprovidersService: SearchDataprovidersService,
|
111
|
private _reportsService: ReportsService,
|
112
|
private _searchResearchResultsService: SearchResearchResultsService,
|
113
|
private _searchProjectsService: SearchProjectsService,
|
114
|
private _meta: Meta,
|
115
|
private _title: Title,
|
116
|
private _router: Router,
|
117
|
private helper: HelperService,
|
118
|
private seoService: SEOService,
|
119
|
private _location: Location,
|
120
|
private indexInfoService: IndexInfoService) {
|
121
|
this.fetchProjects = new FetchProjects(this._searchProjectsService);
|
122
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
123
|
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
|
124
|
this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService);
|
125
|
this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService);
|
126
|
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
|
127
|
}
|
128
|
|
129
|
ngOnInit() {
|
130
|
|
131
|
this.properties = properties;
|
132
|
if (typeof document !== 'undefined') {
|
133
|
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
|
134
|
if (lastIndexUpdate) {
|
135
|
this.indexUpdateDate = new Date(lastIndexUpdate);
|
136
|
}
|
137
|
}));
|
138
|
}
|
139
|
//this.getDivContents();
|
140
|
this.getPageContents();
|
141
|
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url);
|
142
|
|
143
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
144
|
this.organizationInfo = null;
|
145
|
this.updateTitle("Organization");
|
146
|
this.updateDescription("");
|
147
|
|
148
|
this.organizationId = params['organizationId'];
|
149
|
|
150
|
if (this.organizationId && StringUtils.isOpenAIREID(this.organizationId)) {
|
151
|
this.getOrganizationInfo();
|
152
|
} else {
|
153
|
this.showLoading = false;
|
154
|
this._router.navigate(['/error'], {
|
155
|
queryParams: {
|
156
|
"page": this._location.path(true),
|
157
|
"page_type": "organization"
|
158
|
}
|
159
|
});
|
160
|
}
|
161
|
this.csvParamsTail = '" and relorganizationid exact "' + this.organizationId + '" ))';
|
162
|
}));
|
163
|
|
164
|
this.downloadURLAPI = this.properties.csvAPIURL;
|
165
|
//this.csvAffiliatedPublications = this.downloadURLAPI + "?format=csv&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relorganizationid exact \"" + this.organizationId + "\"))";
|
166
|
this.csvProjectParamsHead = 'format=csv&type=projects&fq=((funder exact "';
|
167
|
//this.csvPublicationParamsHead = 'format=csv-special&type=publications&page=0&query=((((oaftype exact result) and (resulttypeid exact publication)) and (funderid exact ';
|
168
|
}
|
169
|
|
170
|
private getPageContents() {
|
171
|
if(this.communityId) {
|
172
|
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
173
|
this.pageContents = contents;
|
174
|
}));
|
175
|
}
|
176
|
}
|
177
|
|
178
|
private getDivContents() {
|
179
|
if(this.communityId) {
|
180
|
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
181
|
this.divContents = contents;
|
182
|
}));
|
183
|
}
|
184
|
}
|
185
|
|
186
|
ngOnDestroy() {
|
187
|
this.subscriptions.forEach(subscription => {
|
188
|
if (subscription instanceof Subscriber) {
|
189
|
subscription.unsubscribe();
|
190
|
}
|
191
|
});
|
192
|
this.innerReportSubscriptions.forEach(subscription => {
|
193
|
if(subscription instanceof Subscriber) {
|
194
|
subscription.unsubscribe();
|
195
|
}
|
196
|
});
|
197
|
|
198
|
this.fetchDatasets.clearSubscriptions();
|
199
|
this.fetchPublications.clearSubscriptions();
|
200
|
this.fetchSoftware.clearSubscriptions();
|
201
|
this.fetchPublications.clearSubscriptions();
|
202
|
this.fetchDataproviders.clearSubscriptions();
|
203
|
this.fetchProjects.clearSubscriptions();
|
204
|
}
|
205
|
|
206
|
private getTotalResearchResults() {
|
207
|
this.fetchPublications.getNumForEntity('publication', 'organization', this.organizationId, this.properties);
|
208
|
this.fetchDatasets.getNumForEntity('dataset', 'organization', this.organizationId, this.properties);
|
209
|
this.fetchSoftware.getNumForEntity('software', 'organization', this.organizationId, this.properties);
|
210
|
this.fetchOrps.getNumForEntity('other', 'organization', this.organizationId, this.properties);
|
211
|
}
|
212
|
|
213
|
private getTotalDataproviders() {
|
214
|
this.fetchDataproviders.getNumForEntity('organization', this.organizationId, this.properties);
|
215
|
}
|
216
|
|
217
|
// private searchContentProviders() {
|
218
|
// this.fetchDataproviders.getResultsForEntity("organization", this.organizationId, 1, this.searchNumber, this.properties);
|
219
|
// }
|
220
|
private searchContentProviders(page: number, size: number) {
|
221
|
if (this.reloadDataproviders &&
|
222
|
(this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING ||
|
223
|
(this.fetchDataproviders.searchUtils.status == this.errorCodes.DONE && this.fetchDataproviders.searchUtils.totalResults > 0)
|
224
|
)
|
225
|
) {
|
226
|
this.fetchDataproviders.getResultsForEntity("organization", this.organizationId, page, size, this.properties);
|
227
|
}
|
228
|
this.reloadDataproviders = false;
|
229
|
}
|
230
|
|
231
|
// private searchPublications() {
|
232
|
// this.fetchPublications.getResultsForEntity("publication", "organization", this.organizationId, 1, size, this.properties);
|
233
|
// }
|
234
|
private searchPublications(page: number, size: number) {
|
235
|
if (this.reloadPublications &&
|
236
|
(this.fetchPublications.searchUtils.status == this.errorCodes.LOADING ||
|
237
|
(this.fetchPublications.searchUtils.status == this.errorCodes.DONE && this.fetchPublications.searchUtils.totalResults > 0)
|
238
|
)
|
239
|
) {
|
240
|
this.fetchPublications.getResultsForEntity("publication", "organization", this.organizationId, page, size, this.properties);
|
241
|
}
|
242
|
this.reloadPublications = false;
|
243
|
}
|
244
|
|
245
|
// private searchDatasets() {
|
246
|
// this.fetchDatasets.getResultsForEntity("dataset", "organization", this.organizationId, 1, this.searchNumber, this.properties);
|
247
|
// }
|
248
|
private searchDatasets(page: number, size: number) {
|
249
|
if (this.reloadDatasets &&
|
250
|
(this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING ||
|
251
|
(this.fetchDatasets.searchUtils.status == this.errorCodes.DONE && this.fetchDatasets.searchUtils.totalResults > 0)
|
252
|
)
|
253
|
) {
|
254
|
this.fetchDatasets.getResultsForEntity("dataset", "organization", this.organizationId, page, size, this.properties);
|
255
|
}
|
256
|
this.reloadDatasets = false;
|
257
|
}
|
258
|
|
259
|
// private searchSoftware() {
|
260
|
// this.fetchSoftware.getResultsForEntity("software", "organization", this.organizationId, 1, this.searchNumber, this.properties);
|
261
|
// }
|
262
|
private searchSoftware(page: number, size: number) {
|
263
|
if (this.reloadSoftware &&
|
264
|
(this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
|
265
|
(this.fetchSoftware.searchUtils.status == this.errorCodes.DONE && this.fetchSoftware.searchUtils.totalResults > 0)
|
266
|
)
|
267
|
) {
|
268
|
this.fetchSoftware.getResultsForEntity("software", "organization", this.organizationId, page, size, this.properties);
|
269
|
}
|
270
|
this.reloadSoftware = false;
|
271
|
}
|
272
|
|
273
|
// private searchOrps() {
|
274
|
// this.fetchOrps.getResultsForEntity("other", "organization", this.organizationId, 1, this.searchNumber, this.properties);
|
275
|
// }
|
276
|
private searchOrps(page: number, size: number) {
|
277
|
if (this.reloadOrps &&
|
278
|
(this.fetchOrps.searchUtils.status == this.errorCodes.LOADING ||
|
279
|
(this.fetchOrps.searchUtils.status == this.errorCodes.DONE && this.fetchOrps.searchUtils.totalResults > 0)
|
280
|
)
|
281
|
) {
|
282
|
this.fetchOrps.getResultsForEntity("other", "organization", this.organizationId, page, size, this.properties);
|
283
|
}
|
284
|
this.reloadOrps = false;
|
285
|
}
|
286
|
|
287
|
private getOrganizationInfo() {
|
288
|
|
289
|
this.warningMessage = '';
|
290
|
this.errorMessage = ""
|
291
|
this.showLoading = true;
|
292
|
|
293
|
this.organizationInfo = null;
|
294
|
|
295
|
this.subscriptions.push(this._organizationService.getOrganizationInfo(this.organizationId, this.properties).subscribe(
|
296
|
data => {
|
297
|
if (data == null) {
|
298
|
this.showLoading = false;
|
299
|
this._router.navigate(['/error'], {
|
300
|
queryParams: {
|
301
|
"page": this._location.path(true),
|
302
|
"page_type": "organization"
|
303
|
}
|
304
|
});
|
305
|
this.errorMessage = 'No organization found';
|
306
|
} else {
|
307
|
this.organizationInfo = data;
|
308
|
this.organizationId = this.organizationInfo.objIdentifier; // reset in case the parameter was a canonical url. The related queries and reports should have the dedup id
|
309
|
this.csvParamsTail = '" and relorganizationid exact "' + this.organizationId + '" ))';
|
310
|
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToOrganization + this.organizationInfo.relcanId);
|
311
|
this.updateTitle((this.organizationInfo.title.name?this.organizationInfo.title.name:(this.organizationInfo.name?this.organizationInfo.name:'No title available')));
|
312
|
this.updateDescription("Organization, country, " +
|
313
|
(this.organizationInfo.title.name?this.organizationInfo.title.name:'No title available') +
|
314
|
((this.organizationInfo.title.name && this.organizationInfo.title.name != this.organizationInfo.name) ? (', ') : '') +
|
315
|
(this.organizationInfo.name?this.organizationInfo.name:''));
|
316
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
317
|
this.subscriptions.push(this._piwikService.trackView(this.properties, this.organizationInfo.title.name, this.piwikSiteId).subscribe());
|
318
|
}
|
319
|
var refineFields: string [] = ["funder"];
|
320
|
|
321
|
if (typeof document !== 'undefined') {
|
322
|
this.getTotalResearchResults();
|
323
|
this.getTotalDataproviders();
|
324
|
}
|
325
|
|
326
|
this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, this.searchNumber, refineFields, this.properties);
|
327
|
this.showLoading = false;
|
328
|
}
|
329
|
},
|
330
|
err => {
|
331
|
//console.log(err)
|
332
|
this.handleError("Error getting organization for id: " + this.organizationId, err);
|
333
|
if (err.status == 404) {
|
334
|
this._router.navigate(['/error'], {
|
335
|
queryParams: {
|
336
|
"page": this._location.path(true),
|
337
|
"page_type": "organization"
|
338
|
}
|
339
|
});
|
340
|
}
|
341
|
this.seoService.createLinkForCanonicalURL(this.properties.domain+ this.properties.baseLink + this.properties.searchLinkToOrganizations);
|
342
|
this.errorMessage = 'No organization found';
|
343
|
this.showLoading = false;
|
344
|
}
|
345
|
));
|
346
|
}
|
347
|
|
348
|
public downloadFile(url: string, filename: string) {
|
349
|
this.openLoading();
|
350
|
this.setMessageLoading("Downloading CSV file");
|
351
|
|
352
|
this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe(
|
353
|
data => {
|
354
|
this.closeLoading();
|
355
|
|
356
|
var url = window.URL.createObjectURL(data);
|
357
|
var a = window.document.createElement('a');
|
358
|
window.document.body.appendChild(a);
|
359
|
a.setAttribute('style', 'display: none');
|
360
|
a.href = url;
|
361
|
a.download = filename + ".csv";
|
362
|
a.click();
|
363
|
window.URL.revokeObjectURL(url);
|
364
|
a.remove(); // remove the element
|
365
|
|
366
|
//window.open(window.URL.createObjectURL(data));
|
367
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
368
|
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename, this.piwikSiteId).subscribe());
|
369
|
}
|
370
|
},
|
371
|
err => {
|
372
|
//console.log("Error downloading the file.");
|
373
|
this.handleError("Error downloading file: " + filename + ".csv", err);
|
374
|
|
375
|
this.closeLoading();
|
376
|
this.confirmOpenCsvError();
|
377
|
}/*,
|
378
|
() => console.log('Completed file download.')*/
|
379
|
));
|
380
|
}
|
381
|
|
382
|
private downloadFileByFunder() {
|
383
|
|
384
|
this.openLoading();
|
385
|
this.setMessageLoading("Downloading CSV file");
|
386
|
|
387
|
let response: string[] = [];
|
388
|
let totalResponse: string = "";
|
389
|
let projects = [];
|
390
|
let counter: number = this.funderCount;
|
391
|
let title: boolean = false;
|
392
|
let title_index: number = 0;
|
393
|
|
394
|
let filename: string = 'funder-project-' + this.funderContentType + '-report';
|
395
|
|
396
|
this.subscriptions.push(this._searchProjectsService.getProjectsForOrganizations(this.organizationId, ' and (funder exact "' + this.encodeURI(this.funderId) + '" ) ', 1, this.funderCount, [], this.properties).subscribe(
|
397
|
data => {
|
398
|
projects = data[1];
|
399
|
for (let index = 0; index < projects.length; index++) {
|
400
|
this.innerReportSubscriptions.push(this._searchResearchResultsService.numOfEntityResults(this.funderContentType, projects[index].id, "project", this.properties).subscribe(
|
401
|
data => {
|
402
|
//if(data == 0 && title) { // if no publications for this project
|
403
|
if (data == 0 && (counter > 1 || title)) { // if no publications for this project
|
404
|
counter--;
|
405
|
response[index] = "";
|
406
|
//console.info("index: "+index, "counter: "+counter, "id:"+projects[index].id, response[index]);
|
407
|
|
408
|
if (counter == 0) {
|
409
|
//for(let i=count-1; i>=0; i--) {
|
410
|
for (let i = 0; i < projects.length; i++) {
|
411
|
if (response[i] != "") {
|
412
|
if (i == title_index) {
|
413
|
totalResponse = response[i] + totalResponse;
|
414
|
} else {
|
415
|
totalResponse += response[i];
|
416
|
}
|
417
|
}
|
418
|
}
|
419
|
this.closeLoading();
|
420
|
|
421
|
var csvurl = window.URL.createObjectURL(new Blob([totalResponse], {type: 'text/csv'}));
|
422
|
var a = window.document.createElement('a');
|
423
|
window.document.body.appendChild(a);
|
424
|
a.setAttribute('style', 'display: none');
|
425
|
a.href = csvurl;
|
426
|
a.download = filename + ".csv";
|
427
|
a.click();
|
428
|
window.URL.revokeObjectURL(csvurl);
|
429
|
a.remove(); // remove the element
|
430
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
431
|
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename, this.piwikSiteId).subscribe());
|
432
|
}
|
433
|
}
|
434
|
} else {
|
435
|
let url: string;
|
436
|
if (!title) {
|
437
|
title_index = index;
|
438
|
//console.info(title_index);
|
439
|
url = this.downloadURLAPI + '?format=csv-special&' + this.getTypeParam(this.funderContentType) + '&fq=((relprojectid exact "' + projects[index].id + '"))';
|
440
|
} else {
|
441
|
url = this.downloadURLAPI + '?format=csv-special-notitle&' + this.getTypeParam(this.funderContentType) + '&fq=((relprojectid exact "' + projects[index].id + '"))';
|
442
|
}
|
443
|
title = true;
|
444
|
|
445
|
this.innerReportSubscriptions.push(this._reportsService.getCSVResponse(url).subscribe(
|
446
|
data => {
|
447
|
counter--;
|
448
|
response[index] = data;
|
449
|
//console.info("index: "+index, "counter: "+counter, "id:"+projects[index].id, response[index]);
|
450
|
|
451
|
if (counter == 0) {
|
452
|
//for(let i=count-1; i>=0; i--) {
|
453
|
for (let i = 0; i < projects.length; i++) {
|
454
|
if (response[i] != "") {
|
455
|
if (i == title_index) {
|
456
|
totalResponse = response[i] + totalResponse;
|
457
|
} else {
|
458
|
totalResponse += response[i];
|
459
|
}
|
460
|
}
|
461
|
}
|
462
|
this.closeLoading();
|
463
|
|
464
|
var csvurl = window.URL.createObjectURL(new Blob([totalResponse], {type: 'text/csv'}));
|
465
|
var a = window.document.createElement('a');
|
466
|
window.document.body.appendChild(a);
|
467
|
a.setAttribute('style', 'display: none');
|
468
|
a.href = csvurl;
|
469
|
a.download = filename + ".csv";
|
470
|
a.click();
|
471
|
window.URL.revokeObjectURL(csvurl);
|
472
|
a.remove(); // remove the element
|
473
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
474
|
this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename, this.piwikSiteId).subscribe());
|
475
|
}
|
476
|
}
|
477
|
},
|
478
|
err => {
|
479
|
this.handleError("Error downloading file: " + filename, err);
|
480
|
|
481
|
this.closeLoading();
|
482
|
this.confirmOpenCsvError();
|
483
|
this.innerReportSubscriptions.forEach(subscription => subscription.unsubscribe());
|
484
|
}/*,
|
485
|
() => console.log('Completed file download.')*/
|
486
|
) );
|
487
|
}
|
488
|
},
|
489
|
err => {
|
490
|
this.handleError("Error getting number of publications for project with id: " + projects[index].id, err);
|
491
|
this.closeLoading();
|
492
|
this.confirmOpenCsvError();
|
493
|
this.innerReportSubscriptions.forEach(subscription => subscription.unsubscribe());
|
494
|
}));
|
495
|
}
|
496
|
},
|
497
|
err => {
|
498
|
this.handleError("Error getting projects for organization with id: " + this.organizationId, err);
|
499
|
|
500
|
this.closeLoading();
|
501
|
this.confirmOpenCsvError();
|
502
|
}
|
503
|
));
|
504
|
}
|
505
|
|
506
|
private updateDescription(description: string) {
|
507
|
this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
|
508
|
this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
|
509
|
}
|
510
|
|
511
|
private updateTitle(title: string) {
|
512
|
var _prefix = "";
|
513
|
// if(!this.communityId) {
|
514
|
// _prefix = "OpenAIRE | ";
|
515
|
// }
|
516
|
// var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
517
|
this._title.setTitle(title);
|
518
|
this._meta.updateTag({content: title}, "property='og:title'");
|
519
|
}
|
520
|
|
521
|
private updateUrl(url: string) {
|
522
|
this._meta.updateTag({content: url}, "property='og:url'");
|
523
|
}
|
524
|
|
525
|
private openLoading() {
|
526
|
this.closeDownloadReportModal();
|
527
|
this.closeDownloadFunderReportModal();
|
528
|
|
529
|
if (this.loading) {
|
530
|
this.loading.open();
|
531
|
}
|
532
|
}
|
533
|
|
534
|
private closeLoading() {
|
535
|
if (this.loading) {
|
536
|
this.loading.close();
|
537
|
}
|
538
|
}
|
539
|
|
540
|
private setMessageLoading(message: string) {
|
541
|
if (this.loading) {
|
542
|
this.loading.message = message;
|
543
|
}
|
544
|
}
|
545
|
|
546
|
public confirmOpenApplyAll(contentType: string) {
|
547
|
this.alertApplyAll.cancelButton = true;
|
548
|
this.alertApplyAll.okButton = true;
|
549
|
this.alertApplyAll.alertTitle = "CSV FILE";
|
550
|
this.alertApplyAll.message = "Do you wish to download a CSV file? Note that this process may take a while.";
|
551
|
this.alertApplyAll.okButtonText = "Yes";
|
552
|
this.alertApplyAll.cancelButtonText = "No";
|
553
|
this.alertApplyAll.open();
|
554
|
this.funderId = this.funder.id;
|
555
|
this.funderCount = this.funder.number;
|
556
|
this.funderContentType = contentType;
|
557
|
}
|
558
|
|
559
|
public confirmCloseApplyAll() {
|
560
|
this.downloadFileByFunder();
|
561
|
}
|
562
|
|
563
|
public confirmOpenCsvError() {
|
564
|
this.alertCsvError.cancelButton = false;
|
565
|
this.alertCsvError.okButton = true;
|
566
|
this.alertCsvError.alertTitle = "ERROR DOWNLOADING CSV FILE";
|
567
|
this.alertCsvError.message = "There was an error in csv downloading. Please try again later.";
|
568
|
this.alertCsvError.okButtonText = "OK";
|
569
|
this.alertCsvError.open();
|
570
|
}
|
571
|
|
572
|
encodeURI(input: string): string {
|
573
|
return StringUtils.URIEncode(input);
|
574
|
}
|
575
|
|
576
|
private handleError(message: string, error) {
|
577
|
console.error("Organizaton Landing Page: " + message, error);
|
578
|
}
|
579
|
|
580
|
openDeletedByInference() {
|
581
|
this.deleteByInferenceOpened = true;
|
582
|
this.alertModalDeletedByInference.cancelButton = false;
|
583
|
this.alertModalDeletedByInference.okButton = false;
|
584
|
this.alertModalDeletedByInference.alertTitle = "Other versions of";
|
585
|
this.alertModalDeletedByInference.open();
|
586
|
}
|
587
|
|
588
|
public getTypeParam(type: string): string {
|
589
|
if (type == 'results') {
|
590
|
type = 'publications&type=datasets&type=software&type=other';
|
591
|
}
|
592
|
return 'type=' + type;
|
593
|
}
|
594
|
|
595
|
getCSVAffiliated(contentType: string): string {
|
596
|
return this.downloadURLAPI + '?format=csv&' + this.getTypeParam(contentType) + '&fq=(relorganizationid exact "' + this.organizationId + '")';
|
597
|
}
|
598
|
|
599
|
getFunderProjects(): string {
|
600
|
return this.downloadURLAPI + '?' + this.csvProjectParamsHead + encodeURI(this.funder.id) + this.csvParamsTail;
|
601
|
}
|
602
|
|
603
|
open(value: any) {
|
604
|
console.log(value);
|
605
|
}
|
606
|
|
607
|
openDownloadReportModal() {
|
608
|
this.downloadReportModal.cancelButton = false;
|
609
|
this.downloadReportModal.okButton = false;
|
610
|
this.downloadReportModal.alertTitle = "Download content report";
|
611
|
this.downloadReportModal.open();
|
612
|
}
|
613
|
|
614
|
closeDownloadReportModal() {
|
615
|
this.downloadReportModal.cancel();
|
616
|
}
|
617
|
|
618
|
openDownloadFunderReportModal() {
|
619
|
this.funder = this.fetchProjects.funders[0];
|
620
|
this.downloadFunderReportModal.cancelButton = false;
|
621
|
this.downloadFunderReportModal.okButton = false;
|
622
|
this.downloadFunderReportModal.alertTitle = "Download funder report";
|
623
|
this.downloadFunderReportModal.open();
|
624
|
}
|
625
|
|
626
|
closeDownloadFunderReportModal() {
|
627
|
this.downloadFunderReportModal.cancel();
|
628
|
}
|
629
|
|
630
|
public getParamsForSearchLink(type: string = "") {
|
631
|
if(type) {
|
632
|
return this.routerHelper.createQueryParams(['f0', 'fv0', 'type', 'qf', 'sortBy'], ['relorganizationid', this.organizationId, type, 'false', 'resultdateofacceptance,descending']);
|
633
|
} else {
|
634
|
return this.routerHelper.createQueryParams(['f0', 'fv0'], ['relorganizationid', this.organizationId]);
|
635
|
}
|
636
|
}
|
637
|
|
638
|
public onSelectActiveTab(activeTabId) {
|
639
|
if (this.activeTab != activeTabId) { // tab really changed
|
640
|
if (activeTabId == 'projects') {
|
641
|
this.activeTab = 'projects';
|
642
|
} else if (activeTabId == 'dataProviders') {
|
643
|
this.activeTab = 'dataProviders';
|
644
|
this.searchContentProviders(1, this.searchNumber);
|
645
|
} else if (activeTabId == 'publications') {
|
646
|
this.activeTab = 'publications';
|
647
|
this.searchPublications(1, this.searchNumber);
|
648
|
} else if (activeTabId == 'datasets') {
|
649
|
this.activeTab = 'datasets';
|
650
|
this.searchDatasets(1, this.searchNumber);
|
651
|
} else if (activeTabId == 'software') {
|
652
|
this.activeTab = 'software';
|
653
|
this.searchSoftware(1, this.searchNumber);
|
654
|
} else if (activeTabId == 'other') {
|
655
|
this.activeTab = "other";
|
656
|
this.searchOrps(1, this.searchNumber);
|
657
|
}
|
658
|
}
|
659
|
}
|
660
|
|
661
|
public get total(): number {
|
662
|
let total = this.fetchPublications.searchUtils.totalResults;
|
663
|
total += this.fetchDatasets.searchUtils.totalResults;
|
664
|
total += this.fetchSoftware.searchUtils.totalResults;
|
665
|
total += this.fetchOrps.searchUtils.totalResults;
|
666
|
return total;
|
667
|
}
|
668
|
|
669
|
// public get numberOfTabs(): number {
|
670
|
// if (this.tabsAreInitialized) {
|
671
|
// return this._numberOfTabs;
|
672
|
// }
|
673
|
// if (!this.organizationInfo
|
674
|
// || this.fetchProjects.searchUtils.status === this.errorCodes.LOADING
|
675
|
// || this.fetchDataproviders.searchUtils.status === this.errorCodes.LOADING
|
676
|
// || this.fetchPublications.searchUtils.status == this.errorCodes.LOADING
|
677
|
// || this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING
|
678
|
// || this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING
|
679
|
// || this.fetchOrps.searchUtils.status == this.errorCodes.LOADING) {
|
680
|
// return 0;
|
681
|
// }
|
682
|
// if (this.fetchProjects.searchUtils.totalResults > 0) {
|
683
|
// if (this._numberOfTabs == 0) {
|
684
|
// this.firstTab = 'projects';
|
685
|
// }
|
686
|
// this._numberOfTabs++;
|
687
|
// }
|
688
|
// if (this.fetchDataproviders.searchUtils.totalResults > 0) {
|
689
|
// if (this._numberOfTabs == 0) {
|
690
|
// this.firstTab = 'dataProviders';
|
691
|
// this.searchContentProviders(1, this.searchNumber);
|
692
|
// }
|
693
|
// this._numberOfTabs++;
|
694
|
// }
|
695
|
// if (this.fetchPublications.searchUtils.totalResults > 0) {
|
696
|
// if (this._numberOfTabs == 0) {
|
697
|
// this.firstTab = 'publications';
|
698
|
// this.searchPublications(1, this.searchNumber);
|
699
|
// }
|
700
|
// this._numberOfTabs++;
|
701
|
// }
|
702
|
// if (this.fetchDatasets.searchUtils.totalResults > 0) {
|
703
|
// if (this._numberOfTabs == 0) {
|
704
|
// this.firstTab = 'datasets';
|
705
|
// this.searchDatasets(1, this.searchNumber);
|
706
|
// }
|
707
|
// this._numberOfTabs++;
|
708
|
// }
|
709
|
// if (this.fetchSoftware.searchUtils.totalResults > 0) {
|
710
|
// if (this._numberOfTabs == 0) {
|
711
|
// this.firstTab = 'software';
|
712
|
// this.searchSoftware(1, this.searchNumber);
|
713
|
// }
|
714
|
// this._numberOfTabs++;
|
715
|
// }
|
716
|
// if (this.fetchOrps.searchUtils.totalResults > 0) {
|
717
|
// if (this._numberOfTabs == 0) {
|
718
|
// this.firstTab = 'other';
|
719
|
// this.searchOrps(1, this.searchNumber);
|
720
|
// }
|
721
|
// this._numberOfTabs++;
|
722
|
// }
|
723
|
// this.activeTab = this.firstTab;
|
724
|
// this.tabsAreInitialized = true;
|
725
|
// return this._numberOfTabs;
|
726
|
// }
|
727
|
|
728
|
private getEntityName(entityType: string, plural: boolean, full: boolean): string {
|
729
|
if (entityType == "publication") {
|
730
|
return "publication" + (plural ? "s" : "");
|
731
|
} else if (entityType == "dataset") {
|
732
|
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
733
|
} else if (entityType == "software") {
|
734
|
return "software";
|
735
|
} else if (entityType == "other") {
|
736
|
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
737
|
} else if (entityType == "dataprovider") {
|
738
|
return (full ? ("content provider" + (plural ? "s" : "")) : "dataprovider" + (plural ? "s" : ""));
|
739
|
} else {
|
740
|
return entityType + (plural ? "s" : "");
|
741
|
}
|
742
|
}
|
743
|
|
744
|
public scroll() {
|
745
|
HelperFunctions.scroll();
|
746
|
}
|
747
|
}
|