Project

General

Profile

« Previous | Next » 

Revision 46271

comment claim functionalities | tidy up navbar links | extra query for projects of an organization when requiring pubs report | remove href from home page tabs

View differences:

organization.component.ts
8 8
import {SearchPublicationsService} from '../../services/searchPublications.service';
9 9

  
10 10
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
11
import {SearchProjectsService} from '../../services/searchProjects.service';
11 12

  
12 13
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
13 14
import {SearchingProjectsTabComponent} from '../searchingProjectsInTab.component';
......
39 40
    private fetchDataproviders : FetchDataproviders;
40 41
    private linkToSearchDataproviders = "";
41 42
    @ViewChild (SearchingProjectsTabComponent) searchingProjectsTabComponent : SearchingProjectsTabComponent ;
43
    private projectFunders:string[] = [];
42 44

  
43 45
    constructor (private _organizationService: OrganizationService,
44 46
                 private  route: ActivatedRoute,
45 47
                 private _searchDataprovidersService: SearchDataprovidersService,
46 48
                 private _reportsService: ReportsService,
47
                 private _searchPublicationsService: SearchPublicationsService) {
49
                 private _searchPublicationsService: SearchPublicationsService,
50
                 private _searchProjectsService: SearchProjectsService) {
48 51

  
49 52
            console.info('organization constructor');
50 53
            this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
......
181 184
                       () => console.log('Completed file download.'));
182 185
     }
183 186

  
184
     downloadPublicationsFile(funder: string){
187
     downloadPublicationsFile(funder: string, funderId:string, count:number){
185 188
       console.log("Downloading publications file");
186 189
       let response: string[] = [];
187 190
       let totalResponse: string = "";
188
       let counter: number = this.organizationInfo.projects.get(funder).length;
191
       let projects = [];
192
       let counter: number = count;
193
       this._searchProjectsService.getProjectsForOrganizations(this.organizationId,' and (funderid exact '+ funderId + ' ) ',1,count,[]).subscribe(
194
           data =>
195
               {
196
                 projects = data[1];
197
                  for(let index=0; index < projects.length; index++) {
198
                      this._searchPublicationsService.numOfEntityPublications(projects[index].id, "projects/").subscribe(
199
                          data =>
200
                              {
201
                                  // let index: number = this.organizationInfo.projects.get(funder).indexOf(project);
189 202

  
190
       for(let project of this.organizationInfo.projects.get(funder)) {
191
            this._searchPublicationsService.numOfEntityPublications(project.id, "projects/").subscribe(
192
                data =>
193
                    {
194
                        let index: number = this.organizationInfo.projects.get(funder).indexOf(project);
203
                                  let url: string;
204
                                  if(index == 0) {
205
                                      url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special&size="+data;
206
                                  } else {
207
                                      url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle&size="+data;
208
                                  }
195 209

  
196
                        let url: string;
197
                        if(index == 0) {
198
                            url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special&size="+data;
199
                        } else {
200
                            url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special-notitle&size="+data;
201
                        }
210
                                  this._reportsService.getCSVResponse(url).subscribe(
211
                                      data =>
212
                                          {
213
                                              counter--;
202 214

  
203
                        this._reportsService.getCSVResponse(url).subscribe(
204
                            data =>
205
                                {
206
                                    counter--;
215
                                              response[index] = data;
207 216

  
208
                                    response[index] = data;
217
                                              if(counter == 0) {
218
                                                  for(let i=0; i<count; i++) {
219
                                                      totalResponse += response[i]+"\n";
220
                                                  }
221
                                                  window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
222
                                              }
223
                                          },
224
                                      error => console.log("Error downloading the file."),
225
                                      () => console.log('Completed file download.'));
226
                              },
227
                          error => console.log("Error getting number of publications for project."));
228
                  }//);
209 229

  
210
                                    if(counter == 0) {
211
                                        for(let i=0; i<this.organizationInfo.projects.get(funder).length; i++) {
212
                                            totalResponse += response[i]+"\n";
213
                                        }
214
                                        window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
215
                                    }
216
                                },
217
                            error => console.log("Error downloading the file."),
218
                            () => console.log('Completed file download.'));
219
                    },
220
                error => console.log("Error getting number of publications for project."));
221
        }//);
230
               },
231
           error => console.log("Error getting projects project."));
232

  
233
      //  let counter: number = this.organizationInfo.projects.get(funder).length;
234
       //
235
      //  for(let project of this.organizationInfo.projects.get(funder)) {
236
      //       this._searchPublicationsService.numOfEntityPublications(project.id, "projects/").subscribe(
237
      //           data =>
238
      //               {
239
      //                   let index: number = this.organizationInfo.projects.get(funder).indexOf(project);
240
       //
241
      //                   let url: string;
242
      //                   if(index == 0) {
243
      //                       url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special&size="+data;
244
      //                   } else {
245
      //                       url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special-notitle&size="+data;
246
      //                   }
247
       //
248
      //                   this._reportsService.getCSVResponse(url).subscribe(
249
      //                       data =>
250
      //                           {
251
      //                               counter--;
252
       //
253
      //                               response[index] = data;
254
       //
255
      //                               if(counter == 0) {
256
      //                                   for(let i=0; i<this.organizationInfo.projects.get(funder).length; i++) {
257
      //                                       totalResponse += response[i]+"\n";
258
      //                                   }
259
      //                                   window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
260
      //                               }
261
      //                           },
262
      //                       error => console.log("Error downloading the file."),
263
      //                       () => console.log('Completed file download.'));
264
      //               },
265
      //           error => console.log("Error getting number of publications for project."));
266
        // }//);
222 267
    }
223 268
}

Also available in: Unified diff