2019-07-22 11:16:50 +02:00
|
|
|
import {Component, ElementRef, Input, ViewChild} from '@angular/core';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Meta, Title} from '@angular/platform-browser';
|
|
|
|
import {OrganizationService} from '../../services/organization.service';
|
|
|
|
import {OrganizationInfo} from '../../utils/entities/organizationInfo';
|
|
|
|
import {ReportsService} from '../../services/reports.service';
|
|
|
|
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
2019-09-11 11:45:54 +02:00
|
|
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
2019-07-22 11:16:50 +02:00
|
|
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
|
|
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
2020-03-16 14:09:46 +01:00
|
|
|
import {ProjectsInModalComponent} from '../landing-utils/projects-in-modal.component';
|
2019-07-22 11:16:50 +02:00
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
|
|
|
|
|
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
|
|
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
|
|
|
import {StringUtils} from '../../utils/string-utils.class';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
2019-04-24 14:31:01 +02:00
|
|
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
2019-07-22 11:16:50 +02:00
|
|
|
import {HelperService} from "../../utils/helper/helper.service";
|
2019-11-07 10:51:09 +01:00
|
|
|
import {Location} from "@angular/common";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
interface Total {
|
|
|
|
publications: number;
|
|
|
|
datasets: number;
|
|
|
|
software: number;
|
|
|
|
other: number;
|
|
|
|
results: number;
|
|
|
|
dataproviders: number;
|
|
|
|
}
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
2019-07-22 11:16:50 +02:00
|
|
|
selector: 'organization',
|
|
|
|
templateUrl: 'organization.component.html',
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
|
|
|
export class OrganizationComponent {
|
2018-04-11 10:59:01 +02:00
|
|
|
@Input() piwikSiteId = null;
|
2019-07-22 11:16:50 +02:00
|
|
|
@Input() communityId = null;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
public organizationInfo: OrganizationInfo;
|
|
|
|
public organizationId: string;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
// Message variables
|
|
|
|
public warningMessage = "";
|
|
|
|
public errorMessage = "";
|
|
|
|
public showLoading: boolean = true;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
// CSV variables
|
|
|
|
public downloadURLAPI: string;
|
|
|
|
public csvProjectParamsHead: string;
|
|
|
|
public csvPublicationParamsHead: string;
|
|
|
|
public csvParamsTail: string;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
// Active tab variable for responsiveness
|
|
|
|
public activeTab: string = "Publications";
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
// Variables for publications, research data, projects, dataproviders tabs
|
2020-03-16 14:09:46 +01:00
|
|
|
public total: Total = {
|
|
|
|
publications: 0,
|
|
|
|
datasets: 0,
|
|
|
|
software: 0,
|
|
|
|
other: 0,
|
|
|
|
results: 0,
|
|
|
|
dataproviders: 0
|
|
|
|
};
|
2019-07-22 11:16:50 +02:00
|
|
|
public fetchProjects: FetchProjects;
|
|
|
|
// Variables for projects query (query results only if projects tab is clicked)
|
2020-03-16 14:09:46 +01:00
|
|
|
@ViewChild(ProjectsInModalComponent) projectsInModalComponent: ProjectsInModalComponent;
|
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
@ViewChild(ModalLoading) loading: ModalLoading;
|
|
|
|
// Alert box when CSV: Project Publications for a funder is requested
|
|
|
|
@ViewChild('AlertModalApplyAll') alertApplyAll;
|
|
|
|
// Alert box when something is wrong with CSV requests
|
|
|
|
@ViewChild('AlertModalCsvError') alertCsvError;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
public pageContents = null;
|
|
|
|
public divContents = null;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
// Helper variables to specify funder in downloadPublicationsFile function
|
2020-03-16 14:09:46 +01:00
|
|
|
public contentTypes: [string,string][] =[
|
|
|
|
['results', 'all research outcomes'],
|
|
|
|
['publications', 'publications'],
|
|
|
|
['datasets', 'research data'],
|
|
|
|
['software', 'software'],
|
|
|
|
['other', 'other research products'],
|
|
|
|
];
|
|
|
|
public funderContentType: string = '';
|
|
|
|
public funder: any = "";
|
2019-07-22 11:16:50 +02:00
|
|
|
private funderId: string;
|
2020-03-16 14:09:46 +01:00
|
|
|
private funderCount: number;
|
2019-07-22 11:16:50 +02:00
|
|
|
sub: any;
|
|
|
|
infoSub: any;
|
|
|
|
piwiksub: any;
|
|
|
|
downloadFileSub: any;
|
|
|
|
downloadFilePiwikSub: any;
|
|
|
|
countProjectsSub: any;
|
|
|
|
countPublSub: any;
|
|
|
|
downloadProjectPublSub: any;
|
|
|
|
properties: EnvProperties;
|
2020-03-16 14:09:46 +01:00
|
|
|
public indexUpdateDate: Date;
|
|
|
|
public showFeedback: boolean = false;
|
|
|
|
public feedbackFields: string [] = ['Name', 'Country', 'Other'];
|
|
|
|
|
2019-10-02 16:15:08 +02:00
|
|
|
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
|
2020-03-16 14:09:46 +01:00
|
|
|
@ViewChild('projectsModal') projectsModal;
|
2019-10-02 16:15:08 +02:00
|
|
|
public deleteByInferenceOpened: boolean = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
//private ngUnsubscribe: Subject<void> = new Subject<void>();
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
constructor(private element: ElementRef,
|
|
|
|
private _organizationService: OrganizationService,
|
|
|
|
private _piwikService: PiwikService,
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private _searchDataprovidersService: SearchDataprovidersService,
|
|
|
|
private _reportsService: ReportsService,
|
2019-09-11 11:45:54 +02:00
|
|
|
private _searchResearchResultsService: SearchResearchResultsService,
|
2019-07-22 11:16:50 +02:00
|
|
|
// private _searchDatasetsService: SearchDatasetsService,
|
|
|
|
private _searchProjectsService: SearchProjectsService,
|
|
|
|
private _meta: Meta,
|
|
|
|
private _title: Title,
|
|
|
|
private _router: Router,
|
|
|
|
private helper: HelperService,
|
2019-11-07 10:51:09 +01:00
|
|
|
private seoService: SEOService,
|
|
|
|
private _location: Location) {
|
2019-07-22 11:16:50 +02:00
|
|
|
this.fetchProjects = new FetchProjects(this._searchProjectsService);
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
ngOnInit() {
|
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
2020-03-16 14:09:46 +01:00
|
|
|
if(this.properties.lastIndexUpdate) {
|
|
|
|
this.indexUpdateDate = new Date(this.properties.lastIndexUpdate);
|
|
|
|
}
|
2019-07-22 11:16:50 +02:00
|
|
|
//this.getDivContents();
|
|
|
|
this.getPageContents();
|
|
|
|
this.updateUrl(data.envSpecific.baseLink + this._router.url);
|
|
|
|
});
|
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
|
|
this.organizationInfo = null;
|
|
|
|
this.updateTitle("Organization");
|
|
|
|
this.updateDescription("");
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.organizationId = params['organizationId'];
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
if (this.organizationId) {
|
|
|
|
this.getOrganizationInfo();
|
|
|
|
} else {
|
|
|
|
this.showLoading = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
this._router.navigate(['/error'], {
|
|
|
|
queryParams: {
|
|
|
|
"page": this._location.path(true),
|
|
|
|
"page_type": "organization"
|
|
|
|
}
|
|
|
|
});
|
2019-10-31 12:39:23 +01:00
|
|
|
//this.warningMessage = "No valid organization id";
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
HelperFunctions.scroll();
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.csvParamsTail = '" and relorganizationid exact "' + this.organizationId + '" ))';
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
});
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.downloadURLAPI = this.properties.csvAPIURL;
|
2020-03-16 14:09:46 +01:00
|
|
|
//this.csvAffiliatedPublications = this.downloadURLAPI + "?format=csv&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relorganizationid exact \"" + this.organizationId + "\"))";
|
|
|
|
this.csvProjectParamsHead = 'format=csv&type=projects&fq=((funder exact "';
|
2019-07-22 11:16:50 +02:00
|
|
|
//this.csvPublicationParamsHead = 'format=csv-special&type=publications&page=0&query=((((oaftype exact result) and (resulttypeid exact publication)) and (funderid exact ';
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private getPageContents() {
|
|
|
|
this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
|
|
|
|
this.pageContents = contents;
|
|
|
|
})
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private getDivContents() {
|
|
|
|
this.helper.getDivHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
|
|
|
|
this.divContents = contents;
|
|
|
|
})
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
ngOnDestroy() {
|
|
|
|
if (this.sub) {
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.piwiksub) {
|
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.infoSub) {
|
|
|
|
this.infoSub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.downloadFileSub) {
|
|
|
|
this.downloadFileSub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.downloadFilePiwikSub) {
|
|
|
|
this.downloadFilePiwikSub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.countProjectsSub) {
|
|
|
|
this.countProjectsSub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.countPublSub) {
|
|
|
|
this.countPublSub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.downloadProjectPublSub) {
|
|
|
|
this.downloadProjectPublSub.unsubscribe();
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
/*
|
|
|
|
this.ngUnsubscribe.next();
|
|
|
|
this.ngUnsubscribe.complete();
|
|
|
|
*/
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
private getTotalResearchResults() {
|
|
|
|
this._searchResearchResultsService.numOfEntityResults('publication',
|
|
|
|
this.organizationInfo.objIdentifier, 'organization', this.properties).subscribe(total => {
|
|
|
|
this.total.publications = total;
|
|
|
|
this.total.results += total;
|
|
|
|
});
|
|
|
|
this._searchResearchResultsService.numOfEntityResults('dataset',
|
|
|
|
this.organizationInfo.objIdentifier, 'organization', this.properties).subscribe(total => {
|
|
|
|
this.total.datasets = total;
|
|
|
|
this.total.results += total;
|
|
|
|
});
|
|
|
|
this._searchResearchResultsService.numOfEntityResults('software',
|
|
|
|
this.organizationInfo.objIdentifier, 'organization', this.properties).subscribe(total => {
|
|
|
|
this.total.software = total;
|
|
|
|
this.total.results += total;
|
|
|
|
});
|
|
|
|
this._searchResearchResultsService.numOfEntityResults('other',
|
|
|
|
this.organizationInfo.objIdentifier, 'organization', this.properties).subscribe(total => {
|
|
|
|
this.total.other = total;
|
|
|
|
this.total.results += total;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private getTotalDataproviders() {
|
|
|
|
this._searchDataprovidersService.numOfEntityDataproviders(
|
|
|
|
this.organizationInfo.objIdentifier,'organization', this.properties).subscribe(
|
|
|
|
total => {
|
|
|
|
this.total.dataproviders = total;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private getOrganizationInfo() {
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.warningMessage = '';
|
|
|
|
this.errorMessage = ""
|
|
|
|
this.showLoading = true;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.organizationInfo = null;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.infoSub = this._organizationService.getOrganizationInfo(this.organizationId, this.properties).subscribe(
|
|
|
|
data => {
|
|
|
|
if (data == null) {
|
|
|
|
this.showLoading = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
this._router.navigate(['/error'], {
|
|
|
|
queryParams: {
|
|
|
|
"page": this._location.path(true),
|
|
|
|
"page_type": "organization"
|
|
|
|
}
|
|
|
|
});
|
2019-07-22 11:16:50 +02:00
|
|
|
this.errorMessage = 'No organization found';
|
|
|
|
} else {
|
|
|
|
this.organizationInfo = data;
|
|
|
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrganization + this.organizationInfo.objIdentifier);
|
|
|
|
this.updateTitle(this.organizationInfo.title.name);
|
|
|
|
this.updateDescription("Organization, country, " + this.organizationInfo.title.name + ((this.organizationInfo.title.name && this.organizationInfo.title.name != this.organizationInfo.name) ? (", " + this.organizationInfo.name) : ""));
|
|
|
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
|
|
|
this.piwiksub = this._piwikService.trackView(this.properties, this.organizationInfo.title.name, this.piwikSiteId).subscribe();
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
console.log(this.organizationInfo);
|
2019-07-22 11:16:50 +02:00
|
|
|
var refineFields: string [] = ["funder"];
|
2020-03-16 14:09:46 +01:00
|
|
|
this.getTotalResearchResults();
|
|
|
|
this.getTotalDataproviders();
|
2019-07-22 11:16:50 +02:00
|
|
|
this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, 0, refineFields, this.properties);
|
|
|
|
this.showLoading = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log(err)
|
|
|
|
this.handleError("Error getting organization for id: " + this.organizationId, err);
|
2020-03-16 14:09:46 +01:00
|
|
|
if (err.status == 404) {
|
|
|
|
this._router.navigate(['/error'], {
|
|
|
|
queryParams: {
|
|
|
|
"page": this._location.path(true),
|
|
|
|
"page_type": "organization"
|
|
|
|
}
|
|
|
|
});
|
2019-10-31 12:39:23 +01:00
|
|
|
}
|
2019-07-22 11:16:50 +02:00
|
|
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrganizations);
|
2019-10-31 12:39:23 +01:00
|
|
|
//this.errorMessage = 'No organization found';
|
2019-07-22 11:16:50 +02:00
|
|
|
this.showLoading = false;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*public searchDataproviders(page: number = 1) {
|
|
|
|
this.fetchDataproviders.getResultsForEntity("organization", this.organizationId, page, 1, this.properties);
|
|
|
|
}*/
|
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
public downloadFile(url: string, filename: string) {
|
|
|
|
this.openLoading();
|
|
|
|
this.setMessageLoading("Downloading CSV file");
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.downloadFileSub = this._reportsService.downloadCSVFile(url).subscribe(
|
|
|
|
data => {
|
|
|
|
this.closeLoading();
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
var url = window.URL.createObjectURL(data);
|
|
|
|
var a = window.document.createElement('a');
|
|
|
|
window.document.body.appendChild(a);
|
|
|
|
a.setAttribute('style', 'display: none');
|
|
|
|
a.href = url;
|
|
|
|
a.download = filename + ".csv";
|
|
|
|
a.click();
|
|
|
|
window.URL.revokeObjectURL(url);
|
|
|
|
a.remove(); // remove the element
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
//window.open(window.URL.createObjectURL(data));
|
|
|
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
|
|
|
this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url, this.piwikSiteId).subscribe();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log("Error downloading the file.");
|
|
|
|
this.handleError("Error downloading file: " + filename + ".csv", err);
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.closeLoading();
|
|
|
|
this.confirmOpenCsvError();
|
|
|
|
}/*,
|
|
|
|
() => console.log('Completed file download.')*/
|
|
|
|
);
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
private downloadFileByFunder() {
|
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.openLoading();
|
|
|
|
this.setMessageLoading("Downloading CSV file");
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
let response: string[] = [];
|
|
|
|
let totalResponse: string = "";
|
|
|
|
let projects = [];
|
2020-03-16 14:09:46 +01:00
|
|
|
let counter: number = this.funderCount;
|
2019-07-22 11:16:50 +02:00
|
|
|
let title: boolean = false;
|
|
|
|
let title_index: number = 0;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
let filename: string = 'funder-project-' + this.funderContentType + '-report';
|
|
|
|
|
|
|
|
this.countProjectsSub = this._searchProjectsService.getProjectsForOrganizations(this.organizationId, ' and (funder exact "' + this.encodeURI(this.funderId) + '" ) ', 1, this.funderCount, [], this.properties).subscribe(
|
2019-07-22 11:16:50 +02:00
|
|
|
data => {
|
|
|
|
projects = data[1];
|
|
|
|
for (let index = 0; index < projects.length; index++) {
|
2020-03-16 14:09:46 +01:00
|
|
|
this.countPublSub = this._searchResearchResultsService.numOfEntityResults(this.funderContentType, projects[index].id, "project", this.properties).subscribe(
|
2019-07-22 11:16:50 +02:00
|
|
|
data => {
|
|
|
|
//if(data == 0 && title) { // if no publications for this project
|
|
|
|
if (data == 0 && (counter > 1 || title)) { // if no publications for this project
|
|
|
|
counter--;
|
|
|
|
response[index] = "";
|
|
|
|
//console.info("index: "+index, "counter: "+counter, "id:"+projects[index].id, response[index]);
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
if (counter == 0) {
|
|
|
|
//for(let i=count-1; i>=0; i--) {
|
|
|
|
for (let i = 0; i < projects.length; i++) {
|
|
|
|
if (response[i] != "") {
|
|
|
|
if (i == title_index) {
|
|
|
|
totalResponse = response[i] + totalResponse;
|
|
|
|
} else {
|
|
|
|
totalResponse += response[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.closeLoading();
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
var csvurl = window.URL.createObjectURL(new Blob([totalResponse], {type: 'text/csv'}));
|
|
|
|
var a = window.document.createElement('a');
|
|
|
|
window.document.body.appendChild(a);
|
|
|
|
a.setAttribute('style', 'display: none');
|
|
|
|
a.href = csvurl;
|
|
|
|
a.download = filename + ".csv";
|
|
|
|
a.click();
|
|
|
|
window.URL.revokeObjectURL(csvurl);
|
|
|
|
a.remove(); // remove the element
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let url: string;
|
|
|
|
if (!title) {
|
|
|
|
title_index = index;
|
|
|
|
//console.info(title_index);
|
2020-03-16 14:09:46 +01:00
|
|
|
url = this.downloadURLAPI + '?format=csv-special&' + this.getTypeParam(this.funderContentType)+ '&fq=((relprojectid exact "' + projects[index].id + '"))';
|
2019-07-22 11:16:50 +02:00
|
|
|
} else {
|
2020-03-16 14:09:46 +01:00
|
|
|
url = this.downloadURLAPI + '?format=csv-special-notitle&' + this.getTypeParam(this.funderContentType)+ '&fq=((relprojectid exact "' + projects[index].id + '"))';
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
|
|
|
title = true;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.downloadProjectPublSub = this._reportsService.getCSVResponse(url).subscribe(
|
|
|
|
data => {
|
|
|
|
counter--;
|
|
|
|
response[index] = data;
|
|
|
|
//console.info("index: "+index, "counter: "+counter, "id:"+projects[index].id, response[index]);
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
if (counter == 0) {
|
|
|
|
//for(let i=count-1; i>=0; i--) {
|
|
|
|
for (let i = 0; i < projects.length; i++) {
|
|
|
|
if (response[i] != "") {
|
|
|
|
if (i == title_index) {
|
|
|
|
totalResponse = response[i] + totalResponse;
|
|
|
|
} else {
|
|
|
|
totalResponse += response[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.closeLoading();
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
var csvurl = window.URL.createObjectURL(new Blob([totalResponse], {type: 'text/csv'}));
|
|
|
|
var a = window.document.createElement('a');
|
|
|
|
window.document.body.appendChild(a);
|
|
|
|
a.setAttribute('style', 'display: none');
|
|
|
|
a.href = csvurl;
|
|
|
|
a.download = filename + ".csv";
|
|
|
|
a.click();
|
|
|
|
window.URL.revokeObjectURL(csvurl);
|
|
|
|
a.remove(); // remove the element
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error downloading file: " + filename, err);
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.closeLoading();
|
|
|
|
this.confirmOpenCsvError();
|
|
|
|
}/*,
|
|
|
|
() => console.log('Completed file download.')*/
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting number of publications for project with id: " + projects[index].id, err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting projects for organization with id: " + this.organizationId, err);
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
this.closeLoading();
|
|
|
|
this.confirmOpenCsvError();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private updateDescription(description: string) {
|
2019-12-05 17:07:07 +01:00
|
|
|
this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
|
|
|
|
this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private updateTitle(title: string) {
|
2019-08-02 16:55:32 +02:00
|
|
|
var _prefix = "";
|
2019-12-05 17:07:07 +01:00
|
|
|
// if(!this.communityId) {
|
|
|
|
// _prefix = "OpenAIRE | ";
|
|
|
|
// }
|
|
|
|
// var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
|
|
|
this._title.setTitle(title);
|
|
|
|
this._meta.updateTag({content: title}, "property='og:title'");
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private updateUrl(url: string) {
|
|
|
|
this._meta.updateTag({content: url}, "property='og:url'");
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private openLoading() {
|
|
|
|
if (this.loading) {
|
|
|
|
this.loading.open();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private closeLoading() {
|
|
|
|
if (this.loading) {
|
|
|
|
this.loading.close();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private setMessageLoading(message: string) {
|
|
|
|
if (this.loading) {
|
|
|
|
this.loading.message = message;
|
2019-02-15 13:50:24 +01:00
|
|
|
}
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public confirmOpenApplyAll(contentType: string) {
|
2019-07-22 11:16:50 +02:00
|
|
|
this.alertApplyAll.cancelButton = true;
|
|
|
|
this.alertApplyAll.okButton = true;
|
|
|
|
this.alertApplyAll.alertTitle = "CSV FILE";
|
|
|
|
this.alertApplyAll.message = "Do you wish to download a CSV file? Note that this process may take a while.";
|
|
|
|
this.alertApplyAll.okButtonText = "Yes";
|
|
|
|
this.alertApplyAll.cancelButtonText = "No";
|
|
|
|
this.alertApplyAll.open();
|
2020-03-16 14:09:46 +01:00
|
|
|
this.funderId = this.funder.id;
|
|
|
|
this.funderCount = this.funder.number;
|
|
|
|
this.funderContentType = contentType;
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public confirmCloseApplyAll() {
|
|
|
|
this.downloadFileByFunder();
|
2019-07-22 11:16:50 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
public confirmOpenCsvError() {
|
|
|
|
this.alertCsvError.cancelButton = false;
|
|
|
|
this.alertCsvError.okButton = true;
|
|
|
|
this.alertCsvError.alertTitle = "ERROR DOWNLOADING CSV FILE";
|
|
|
|
this.alertCsvError.message = "There was an error in csv downloading. Please try again later.";
|
|
|
|
this.alertCsvError.okButtonText = "OK";
|
|
|
|
this.alertCsvError.open();
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
encodeURI(input: string): string {
|
|
|
|
return StringUtils.URIEncode(input);
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-07-22 11:16:50 +02:00
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error("Organizaton Landing Page: " + message, error);
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-10-02 16:15:08 +02:00
|
|
|
openDeletedByInference() {
|
|
|
|
this.deleteByInferenceOpened = true;
|
|
|
|
this.alertModalDeletedByInference.cancelButton = false;
|
|
|
|
this.alertModalDeletedByInference.okButton = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
this.alertModalDeletedByInference.alertTitle = "Other versions of";
|
2019-10-02 16:15:08 +02:00
|
|
|
this.alertModalDeletedByInference.open();
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
openProjectsModal() {
|
|
|
|
this.projectsInModalComponent.pageChange({value: 1});
|
|
|
|
this.projectsModal.cancelButton = false;
|
|
|
|
this.projectsModal.okButton = false;
|
|
|
|
this.projectsModal.alertTitle = "Projects of";
|
|
|
|
this.projectsModal.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
public getTypeParam(type: string): string {
|
|
|
|
if(type == 'results') {
|
|
|
|
type = 'publications&type=datasets&type=software&type=other';
|
|
|
|
}
|
|
|
|
return 'type='+type;
|
|
|
|
}
|
|
|
|
|
|
|
|
getCSVAffiliated(contentType: string): string {
|
|
|
|
return this.downloadURLAPI + '?format=csv&' + this.getTypeParam(contentType) + '&fq=(relorganizationid exact "' + this.organizationId + '")';
|
|
|
|
}
|
|
|
|
|
|
|
|
getFunderProjects(): string {
|
|
|
|
return this.downloadURLAPI + '?'+this.csvProjectParamsHead+encodeURI(this.funder.id)+this.csvParamsTail;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|