Organization landing page: added Publications tab (+count for Projects tab since now it is the second one) & CSV download for the Publications based on affiliations

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@47540 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2017-06-16 14:15:17 +00:00
parent 25e2f5727e
commit ff7fc02161
11 changed files with 148 additions and 93 deletions

View File

@ -31,10 +31,21 @@
</dl>
<ul class="uk-tab" data-uk-switcher="{connect:'#tab-content'}">
<li class="uk-active">
<li class="uk-active">
<a>
Publications
<span class="uk-badge uk-badge-notification">
{{fetchPublications.searchUtils.totalResults}}
</span>
</a>
</li>
<li (click)="projectsClicked=true;">
<a>
Projects
<span class="uk-badge uk-badge-notification">{{(searchingProjectsTabComponent)?searchingProjectsTabComponent.fetchProjects.totalResults:0}}</span>
<span class="uk-badge uk-badge-notification">
<!--{{(searchingProjectsTabComponent)?searchingProjectsTabComponent.fetchProjects.totalResults:0}}-->
{{fetchProjects.searchUtils.totalResults}}
</span>
</a>
</li>
<li (click)="searchDataprovidersInit()">
@ -58,57 +69,26 @@
<ul id="tab-content" class="uk-switcher uk-margin custom-tab-content">
<li class="uk-animation-fade">
<searchingProjectsTab></searchingProjectsTab>
<!--div *ngIf="organizationInfo.projects == undefined" class = "uk-alert">
There are no projects
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.NONE" class="uk-alert uk-alert-primary uk-animation-fade" role="alert">There are no publications</div>
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.ERROR" class="uk-alert uk-alert-warning uk-animation-fade" role="alert">An Error Occured</div>
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger uk-animation-fade" role="alert">Service not available</div>
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.LOADING" class="uk-alert uk-alert-primary uk-animation-fade" role="alert">Loading...</div>
<div *ngIf="fetchPublications.searchUtils.totalResults > 0">
<div class = "uk-text-right" *ngIf = "fetchPublications.searchUtils.totalResults > 10">
<a [queryParams]="routerHelper.createQueryParams(['organizationId', 'or'], [organizationId, 'and'])"
routerLinkActive="router-link-active" [routerLink]="linkToSearchPublications">
View all {{fetchPublications.searchUtils.totalResults}} results
</a>
</div>
<tab-result [(results)]="fetchPublications.results"
[(status)]= "fetchPublications.status"
type="publication" urlParam="articleId">
</tab-result>
</div>
<div *ngIf="organizationInfo.projects != undefined">
<div *ngIf="organizationInfo.projects.size == 1">
<div *ngFor="let key of organizationInfo.projects.keys()">
<strong>Projects funded by {{key}}</strong>
</div>
</div>
<div *ngIf="organizationInfo.projects.size > 1">
<strong>Filter by Funder</strong>
<span *ngFor="let key of organizationInfo.projects.keys()" class="checkbox">
<label>
<!--input type="checkbox" (ngModelChange)="changeType(key)"-->
<!--input type="checkbox" (click)='handleClick(key)'>
{{key}}
</label>
</span>
</div>
<table class="uk-table uk-table-striped" *ngIf="organizationInfo.projects.size > 0">
<thead>
<tr>
<th class="uk-text-center">Funder</th>
<th class="uk-text-center">Project Name</th>
</tr>
</thead>
<tbody *ngFor="let key of organizationInfo.projects.keys()">
<tr *ngFor="let item of organizationInfo.projects.get(key)">
<td *ngIf="fundersSet.has(key)">
{{key}}
</td>
<td *ngIf="fundersSet.has(key)">
<!--a *ngIf="item['url'] != '' && item['name'] != ''" href="{{item['url']}}"-->
<!--a *ngIf="item['id'] != '' && item['name'] != ''"
[queryParams]="{projectId: item.id}" routerLinkActive="router-link-active" routerLink="/search/project">
{{item['name']}}
</a>
<p *ngIf="item['id'] == '' && item['name'] != ''">{{item['name']}}</p>
<span *ngIf="item['code'] != null && item['code'] != ''"> ({{item['code']}}) </span>
</td>
</tr>
</tbody>
</table>
</div-->
</li>
<li class="uk-animation-fade">
<searchingProjectsTab *ngIf="projectsClicked" [fetchProjects]="fetchProjects"></searchingProjectsTab>
</li>
<li class="uk-animation-fade">
@ -162,33 +142,35 @@
</dl>
</li>
<ng-container *ngIf="searchingProjectsTabComponent && searchingProjectsTabComponent.fetchProjects.funders.length > 0">
<li *ngFor="let funder of searchingProjectsTabComponent.fetchProjects.funders">
<ng-container *ngIf="fetchProjects && fetchProjects.funders.length > 0">
<li *ngFor="let funder of fetchProjects.funders">
<!--a href="{{downloadURLAPI}}resources?size={{organizationInfo.projects.get(key).length}}&{{csvProjectParamsHead}}{{organizationInfo.projects.get(key)[0]['funderId']}}{{csvParamsTail}}">
Download projects report (CSV) for {{key}}
</a-->
<span class="clickable" (click)="downloadfile(downloadURLAPI+'resources?size='+funder.number+'&'+csvProjectParamsHead+funder.id+csvParamsTail)">
<span class="clickable" (click)="downloadFile(downloadURLAPI+'resources?size='+funder.number+'&'+csvProjectParamsHead+funder.id+csvParamsTail)">
<!--span class="clickable" (click)="downloadProjectsFile(downloadURLAPI+'organizations/'+organizationId+'/projects?fq=(funderid exact '+funder.id+')&size='+funder.number)"-->
<span aria-hidden="true" class="glyphicon glyphicon-download"></span>
<span class="uk-icon-download"> Project list for {{funder.name}} (CSV)</span>
</span>
</li>
<li *ngFor="let funder of searchingProjectsTabComponent.fetchProjects.funders">
<span class="clickable" (click)="confirmOpen(funder.name,funder.id, funder.number)">
<li *ngFor="let funder of fetchProjects.funders">
<span class="clickable" (click)="confirmOpenApplyAll(funder.name,funder.id, funder.number)">
<span aria-hidden="true" class="glyphicon glyphicon-download"></span>
<span class="uk-icon-download"> Project Publications for {{funder.name}} (CSV)</span>
</span>
</li>
<!--li>
<span class="clickable">
<span aria-hidden="true" class="glyphicon glyphicon-download"></span>
<span class="uk-icon-download"> Publications of organization (CSV) - based on the affiliation information.</span>
</span>
</li-->
</ng-container>
<li>
<span class="clickable" (click)="downloadFile(downloadURLAPI+'organizations/'+organizationId+'/publications?format=csv')">
<span aria-hidden="true" class="glyphicon glyphicon-download"></span>
<span class="uk-icon-download"> Publications of organization (CSV) - based on the affiliation information.</span>
</span>
</li>
</ul>
</div>
</div>
<modal-loading></modal-loading>
<modal-alert (alertOutput)="confirmClose($event)"></modal-alert>
<modal-alert #AlertModalApplyAll (alertOutput)="confirmCloseApplyAll($event)"></modal-alert>
<modal-alert #AlertModalCsvError></modal-alert>
</div>

View File

@ -5,6 +5,8 @@ import {ActivatedRoute, Router} from '@angular/router';
import {OrganizationService} from '../../services/organization.service';
import {OrganizationInfo} from '../../utils/entities/organizationInfo';
import {ReportsService} from '../../services/reports.service';
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class';
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
import {SearchPublicationsService} from '../../services/searchPublications.service';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
@ -42,19 +44,25 @@ export class OrganizationComponent {
subDataproviders: any;
subDataprovidersCount: any;
private fetchDataproviders : FetchDataproviders;
private linkToSearchDataproviders:string = "";
public projectsClicked: boolean = false;
public fetchPublications: FetchPublications;
public linkToSearchPublications: string = "";
public fetchProjects: FetchProjects;
public fetchDataproviders : FetchDataproviders;
public linkToSearchDataproviders:string = "";
@ViewChild (SearchingProjectsTabComponent) searchingProjectsTabComponent : SearchingProjectsTabComponent ;
private projectFunders:string[] = [];
public projectFunders:string[] = [];
public routerHelper:RouterHelper = new RouterHelper();
@ViewChild (ModalLoading) loading : ModalLoading ;
@ViewChild(AlertModal) alertApplyAll;
@ViewChild('AlertModalApplyAll') alertApplyAll;
@ViewChild('AlertModalCsvError') alertCsvError;
private funder: string;
private funderId: string;
private count: number;
public funder: string;
public funderId: string;
public count: number;
public errorCodes:ErrorCodes = new ErrorCodes();
@ -67,6 +75,8 @@ export class OrganizationComponent {
private _searchProjectsService: SearchProjectsService, private _meta: Meta,
private _router: Router) {
this.fetchPublications = new FetchPublications(this._searchPublicationsService);
this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url);
}
@ -136,6 +146,11 @@ export class OrganizationComponent {
this.updateTitle(this.organizationInfo.title.name);
this.updateDescription("Organization, country, projects, search, repositories, open access"+this.organizationInfo.title.name);
this.fetchPublications.getResultsForEntity("organization", this.organizationId, 1, 10);
this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications();
//this.fetchProjects.getNumForEntity("organization", this.organizationId);
var refineFields:string [] = ["funderid"];
this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, 0,refineFields);
this.fetchDataproviders.getNumForEntity("organization", this.organizationId);
/*let projectsNum = 0;
@ -210,7 +225,7 @@ export class OrganizationComponent {
}
}
downloadfile(url:string){
downloadFile(url:string){
console.log("Downloading file: "+ url);
this.openLoading();
@ -221,7 +236,11 @@ export class OrganizationComponent {
this.closeLoading();
window.open(window.URL.createObjectURL(data));
},
error => console.log("Error downloading the file."),
error => {
console.log("Error downloading the file.");
this.closeLoading();
this.confirmOpenCsvError();
},
() => console.log('Completed file download.'));
}
@ -253,7 +272,7 @@ export class OrganizationComponent {
url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle&size="+data;
}
if(data == 0) {
if(data == 0) { // if no publications for this project
counter--;
response[index] = "";
if(counter == 0) {
@ -261,8 +280,6 @@ export class OrganizationComponent {
if(response[i] != "") {
totalResponse += response[i];
}
console.info("1response "+i+": "+response[i]);
}
this.closeLoading();
window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
@ -289,7 +306,11 @@ export class OrganizationComponent {
window.open(window.URL.createObjectURL(new Blob([totalResponse], { type: 'text/csv' })));
}
},
error => console.log("Error downloading the file."),
error => {
console.log("Error downloading the file.");
this.closeLoading();
this.confirmOpenCsvError();
},
() => console.log('Completed file download.')
);
}
@ -298,7 +319,12 @@ export class OrganizationComponent {
}//);
},
error => console.log("Error getting projects project."));
error => {
console.log("Error getting projects project.");
this.closeLoading();
this.confirmOpenCsvError();
}
);
// let counter: number = this.organizationInfo.projects.get(funder).length;
//
@ -365,11 +391,11 @@ export class OrganizationComponent {
}
}
confirmOpen(funder: string, funderId:string, count:number){
confirmOpenApplyAll(funder: string, funderId:string, count:number){
this.alertApplyAll.cancelButton = true;
this.alertApplyAll.okButton = true;
this.alertApplyAll.alertTitle = "CSV FILE";
this.alertApplyAll.message = "Do you wish to download a CSV file?\nNote that this process may take a while.";
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();
@ -378,7 +404,16 @@ export class OrganizationComponent {
this.funderId = funderId;
this.count = count;
}
confirmClose(data){
confirmCloseApplyAll(data){
this.downloadPublicationsFile(this.funder, this.funderId, this.count);
}
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();
}
}

View File

@ -131,7 +131,7 @@ export class PersonComponent {
console.log(err);
}
);*/
this.fetchDatasets.getNumResultsForEntity("people", this.personId);
this.fetchDatasets.getNumForEntity("people", this.personId);
},
err => {

View File

@ -119,7 +119,7 @@ export class ProjectComponent{
// console.log(err);
// }
//);
this.fetchDatasets.getNumResultsForEntity("project", this.projectId);
this.fetchDatasets.getNumForEntity("project", this.projectId);
}else{
this.warningMessage="No valid project id";

View File

@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, Input} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import { FetchProjects } from '../utils/fetchEntitiesClasses/fetchProjects.class';
@ -54,7 +54,7 @@ import {RouterHelper} from '../utils/routerHelper.class';
})
export class SearchingProjectsTabComponent {
public fetchProjects : FetchProjects;
@Input() fetchProjects : FetchProjects;
public organizationId:string = "";
public page :number = 1;
public size :number = 10;
@ -75,10 +75,12 @@ export class SearchingProjectsTabComponent {
this.organizationId = params['organizationId'];
if(this.organizationId) {
this.fetchProjects = new FetchProjects(this._searchProjectsService);
//this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.linkToSearchProjects = OpenaireProperties.getLinkToAdvancedSearchProjects();//+"?organization="+this.organizationId+"or=and";;
this.search(true,"");
if(this.fetchProjects.searchUtils.totalResults > 0) {
this.search(false,"");
}
}
});
}

View File

@ -450,8 +450,6 @@ export class SearchDataprovidersService {
}
numOfDataproviders(params: string):any {
console.info("getOfDataproviders : Dataproviders Service + params="+params);
let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
let key = url;
if (this._cache.has(key)) {

View File

@ -243,11 +243,11 @@ export class SearchProjectsService {
return results;
}
numOfEntityProjects(id: string, entity: string):any {
numOfProjects(params: string):any {
//OpenaireProperties.getSearchAPIURLLast()
//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"
let url = OpenaireProperties.getSearchAPIURLLast()+entity+id+"/projects/count"+ "?format=json";
let url = OpenaireProperties.getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));

View File

@ -143,6 +143,7 @@ export class SearchPublicationsService {
searchPublicationsForEntity (params: string, page: number, size: number):any {
let link = OpenaireProperties.getSearchAPIURLLast();
let url = link+params+"/publications"+ "?format=json";
url += "&page="+(page-1)+"&size="+size;
let key = url;
if (this._cache.has(key)) {

View File

@ -74,7 +74,7 @@ export class FetchDatasets{
);
}
public getNumResultsForEntity(entity:string, id:string){
public getNumForEntity(entity:string, id:string){
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;

View File

@ -90,10 +90,45 @@ export class FetchProjects{
);
}
public getNumForEntity(entity: string, id:string) {
var parameters="";
if(entity == "organization") {
parameters = "organizations/"+id+"/projects/count";
}
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
if(parameters != "") {
this._searchProjectsService.numOfProjects(parameters).subscribe(
data => {
this.searchUtils.totalResults = data;
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
// if( ){
// this.searchUtils.status = ErrorCodes.ERROR;
// }
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.ERROR;
}
);
}
}
public getResultsForOrganizations(organizationId:string, filterquery:string, page: number, size: number, refineFields:string[]){
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
this._searchProjectsService.getProjectsForOrganizations(organizationId,filterquery, page, size,refineFields).subscribe(
data => {
this.searchUtils.totalResults = data[0]; // the results can be filtered so this number can be no total results

View File

@ -97,6 +97,8 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number)
parameters = "projects/"+id;
} else if(entity == "person") {
parameters = "people/"+id;
} else if(entity == "organization") {
parameters = "organizations/"+id;
}
if(parameters != "") {