[Trunk | Library] : Bug Fix: title of Project Publications csv, now always on top.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56268 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
3405681ac7
commit
5fbcd7bf7d
|
@ -360,6 +360,7 @@ export class OrganizationComponent {
|
||||||
let projects = [];
|
let projects = [];
|
||||||
let counter: number = count;
|
let counter: number = count;
|
||||||
let title: boolean = false;
|
let title: boolean = false;
|
||||||
|
let title_index: number = 0;
|
||||||
|
|
||||||
let filename: string = 'funder-project-publications-report';
|
let filename: string = 'funder-project-publications-report';
|
||||||
|
|
||||||
|
@ -368,140 +369,102 @@ export class OrganizationComponent {
|
||||||
{
|
{
|
||||||
projects = data[1];
|
projects = data[1];
|
||||||
for(let index=0; index < projects.length; index++) {
|
for(let index=0; index < projects.length; index++) {
|
||||||
this.countPublSub = this._searchPublicationsService.numOfEntityPublications(projects[index].id, "project", this.properties).subscribe(
|
this.countPublSub = this._searchPublicationsService.numOfEntityPublications(projects[index].id, "project", this.properties).subscribe(
|
||||||
data =>
|
data =>
|
||||||
{
|
{
|
||||||
// let index: number = this.organizationInfo.projects.get(funder).indexOf(project);
|
//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]);
|
||||||
|
|
||||||
let url: string;
|
if(counter == 0) {
|
||||||
if(!title) {
|
//for(let i=count-1; i>=0; i--) {
|
||||||
//url = this.downloadURLAPI+"projects/"+projects[index].id+"?type=publications&format=csv-special";//&size="+data;
|
for(let i=0; i < projects.length; i++) {
|
||||||
url = this.downloadURLAPI+"?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact \""+projects[index].id+"\"))"
|
if(response[i] != "") {
|
||||||
} else {
|
if(i == title_index) {
|
||||||
//url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle";//&size="+data;
|
totalResponse = response[i]+totalResponse;
|
||||||
url = this.downloadURLAPI+"?format=csv-special-notitle&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact \""+projects[index].id+"\"))"
|
} else {
|
||||||
|
totalResponse += response[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.closeLoading();
|
||||||
|
|
||||||
|
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);
|
||||||
|
url = this.downloadURLAPI+"?format=csv-special&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact \""+projects[index].id+"\"))"
|
||||||
|
} else {
|
||||||
|
url = this.downloadURLAPI+"?format=csv-special-notitle&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact \""+projects[index].id+"\"))"
|
||||||
|
}
|
||||||
|
title = true;
|
||||||
|
|
||||||
|
this.downloadProjectPublSub = this._reportsService.getCSVResponse(url).subscribe(
|
||||||
|
data =>
|
||||||
|
{
|
||||||
|
counter--;
|
||||||
|
response[index] = data;
|
||||||
|
//console.info("index: "+index, "counter: "+counter, "id:"+projects[index].id, response[index]);
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
if(data == 0 && (counter > 1 || title)) { // if no publications for this project
|
var csvurl = window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }));
|
||||||
counter--;
|
var a = window.document.createElement('a');
|
||||||
response[index] = "";
|
window.document.body.appendChild(a);
|
||||||
if(counter == 0) {
|
a.setAttribute('style', 'display: none');
|
||||||
for(let i=0; i<count; i++) {
|
a.href = csvurl;
|
||||||
if(response[i] != "") {
|
a.download = filename+".csv";
|
||||||
totalResponse += response[i];
|
a.click();
|
||||||
}
|
window.URL.revokeObjectURL(csvurl);
|
||||||
}
|
a.remove(); // remove the element
|
||||||
this.closeLoading();
|
}
|
||||||
|
},
|
||||||
var csvurl = window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }));
|
err => {
|
||||||
var a = window.document.createElement('a');
|
this.handleError("Error downloading file: "+filename, err);
|
||||||
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
|
|
||||||
|
|
||||||
//window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
|
|
||||||
// if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
|
||||||
// this._piwikService.trackDownload(this.properties, url).subscribe();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
title = true;
|
|
||||||
|
|
||||||
this.downloadProjectPublSub = this._reportsService.getCSVResponse(url).subscribe(
|
|
||||||
data =>
|
|
||||||
{
|
|
||||||
counter--;
|
|
||||||
response[index] = data;
|
|
||||||
|
|
||||||
if(counter == 0) {
|
|
||||||
for(let i=0; i<count; i++) {
|
|
||||||
if(response[i] != "") {
|
|
||||||
totalResponse += response[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.closeLoading();
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
//window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
|
|
||||||
// if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
|
||||||
// this._piwikService.trackDownload(this.properties, url).subscribe();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
//console.log("Error downloading the file.");
|
|
||||||
this.handleError("Error downloading file: "+filename, err);
|
|
||||||
|
|
||||||
this.closeLoading();
|
|
||||||
this.confirmOpenCsvError();
|
|
||||||
}/*,
|
|
||||||
() => console.log('Completed file download.')*/
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
//console.log("Error getting number of publications for project.")
|
|
||||||
this.handleError("Error getting number of publications for project with id: "+projects[index].id, err);
|
|
||||||
});
|
|
||||||
}//);
|
|
||||||
|
|
||||||
|
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 => {
|
err => {
|
||||||
//console.log("Error getting projects project.");
|
|
||||||
this.handleError("Error getting projects for organization with id: "+this.organizationId, err);
|
this.handleError("Error getting projects for organization with id: "+this.organizationId, err);
|
||||||
|
|
||||||
this.closeLoading();
|
this.closeLoading();
|
||||||
this.confirmOpenCsvError();
|
this.confirmOpenCsvError();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// let counter: number = this.organizationInfo.projects.get(funder).length;
|
|
||||||
//
|
|
||||||
// for(let project of this.organizationInfo.projects.get(funder)) {
|
|
||||||
// this._searchPublicationsService.numOfEntityPublications(project.id, "projects/").subscribe(
|
|
||||||
// data =>
|
|
||||||
// {
|
|
||||||
// let index: number = this.organizationInfo.projects.get(funder).indexOf(project);
|
|
||||||
//
|
|
||||||
// let url: string;
|
|
||||||
// if(index == 0) {
|
|
||||||
// url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special&size="+data;
|
|
||||||
// } else {
|
|
||||||
// url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special-notitle&size="+data;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this._reportsService.getCSVResponse(url).subscribe(
|
|
||||||
// data =>
|
|
||||||
// {
|
|
||||||
// counter--;
|
|
||||||
//
|
|
||||||
// response[index] = data;
|
|
||||||
//
|
|
||||||
// if(counter == 0) {
|
|
||||||
// for(let i=0; i<this.organizationInfo.projects.get(funder).length; i++) {
|
|
||||||
// totalResponse += response[i]+"\n";
|
|
||||||
// }
|
|
||||||
// window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// error => console.log("Error downloading the file."),
|
|
||||||
// () => console.log('Completed file download.'));
|
|
||||||
// },
|
|
||||||
// error => console.log("Error getting number of publications for project."));
|
|
||||||
// }//);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateDescription(description:string) {
|
private updateDescription(description:string) {
|
||||||
|
|
Loading…
Reference in New Issue