diff --git a/landingPages/organization/organization.component.html b/landingPages/organization/organization.component.html index d529c785..4e68458b 100644 --- a/landingPages/organization/organization.component.html +++ b/landingPages/organization/organization.component.html @@ -231,7 +231,7 @@ - + Project list for {{funder.name}} (CSV) @@ -249,7 +249,7 @@ - + Publications of organization (CSV) - based on the affiliation information. diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index 8bee36d1..498bda57 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -314,7 +314,7 @@ export class OrganizationComponent { } } - public downloadFile(url:string){ + public downloadFile(url:string, filename: string){ console.log("Downloading file: "+ url); this.openLoading(); @@ -323,7 +323,18 @@ export class OrganizationComponent { this.downloadFileSub = this._reportsService.downloadCSVFile(url).subscribe( data => { this.closeLoading(); - window.open(window.URL.createObjectURL(data)); + + 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 + + //window.open(window.URL.createObjectURL(data)); if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url, this.piwikSiteId).subscribe(); } @@ -348,6 +359,8 @@ export class OrganizationComponent { let counter: number = count; let title: boolean = false; + let filename: string = 'funder-project-publications-report'; + this.countProjectsSub = this._searchProjectsService.getProjectsForOrganizations(this.organizationId,' and (funder exact "'+ funderId + '" ) ',1,count,[], this.properties).subscribe( data => { @@ -378,7 +391,18 @@ export class OrganizationComponent { } } this.closeLoading(); - window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }))); + + 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(); // } @@ -399,7 +423,18 @@ export class OrganizationComponent { } } this.closeLoading(); - window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' }))); + + 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(); // } diff --git a/landingPages/project/project.component.html b/landingPages/project/project.component.html index 6a26cb0f..458db180 100644 --- a/landingPages/project/project.component.html +++ b/landingPages/project/project.component.html @@ -449,7 +449,7 @@
  • - + Get {{projectInfo.funder}} report (CSV)
  • @@ -486,7 +486,7 @@
  • - + Get {{projectInfo.funder}} report (CSV)
  • diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index 9f42ae62..70bf8883 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -373,14 +373,25 @@ actionsAfterGettingProjectInfo(){ this.showLoading = false; } - public downloadfile(url:string){ + public downloadfile(url:string, filename: string){ this.openLoading(); this.setMessageLoading("Downloading CSV file"); this._reportsService.downloadCSVFile(url).subscribe( data => { this.closeLoading(); - window.open(window.URL.createObjectURL(data)); + + 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 + + //window.open(window.URL.createObjectURL(data)); if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe(); }