Deposit: Use Autocomplete in search Organization| add access mode icos| Add access mode in search results & in pubs/data Landing pages

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44862 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-12-07 14:54:31 +00:00
parent 04dae0c3f6
commit f1af290005
11 changed files with 97 additions and 44 deletions

View File

@ -34,7 +34,15 @@ import {SearchOrganizationsService} from '../services/searchOrganizations.servic
<h3>Locate data provider via your institution</h3>
<form>
<div class="form-group form-inline">
<div class="input-group">
<entities-autocomplete [entityType]="'organization'" [depositType]=compatibility [selectedValue]=selectedId [showSelected]=true
[placeHolderMessage] = "'Search for Organizations'" [title] = "Organizations" [multipleSelections]=false
(selectedValueChanged)="valueChanged($event)" ></entities-autocomplete>
</div>
<button class="btn btn-default" type="submit" (click)="organizationSelected(selectedId)" >Next</button>
</div>
<!--div class="input-group">
<span class="input-group-addon" id="sizing-addon2">Filter</span>
<span>
<input type="text" class="form-control" placeholder="Type keywords..." aria-describedby="sizing-addon2" [(ngModel)]="keyword" name="keyword" >
@ -42,7 +50,9 @@ import {SearchOrganizationsService} from '../services/searchOrganizations.servic
<span class="input-group-btn">
<button (click)="keywordChanged()" type="submit" class="btn btn-default">SELECT</button>
</span>
</div>
<div>
<ul class="list-group" >
<li class="list-group-item" *ngIf="status == errorCodes.LOADING">
@ -64,7 +74,7 @@ import {SearchOrganizationsService} from '../services/searchOrganizations.servic
<a style="cursor:pointer;" (click)="organizationSelected(item.id)">{{item.name}}</a>
</li>
</ul>
</div>
</div-->
</form>
</div>
</div>
@ -85,6 +95,7 @@ export class DepositComponent {
public status: number;
public errorCodes:ErrorCodes = new ErrorCodes();
public selectedId = "";
constructor (private _router: Router,
private _searchOrganizationsService: SearchOrganizationsService) {
@ -122,11 +133,19 @@ export class DepositComponent {
}
organizationSelected(id: string) {
if(this.requestFor == "Publications") {
this._router.navigate( ['deposit-publications-result'], { queryParams: { "organizationId": id } } );
} else if(this.requestFor == "Datasets") {
console.info("call deposit result for datasets")
this._router.navigate( ['deposit-datasets-result'], { queryParams: { "organizationId": id } } );
if(id && id.length > 0){
if(this.requestFor == "Publications") {
this._router.navigate( ['deposit-publications-result'], { queryParams: { "organizationId": id } } );
} else if(this.requestFor == "Datasets") {
console.info("call deposit result for datasets")
this._router.navigate( ['deposit-datasets-result'], { queryParams: { "organizationId": id } } );
}
}
}
valueChanged($event){
this.selectedId = $event.value;
}
}

View File

@ -4,7 +4,7 @@ import {Component, Input} from '@angular/core';
@Component({
selector: 'showTitle',
template: `
<h2 *ngIf="title != undefined">
<h2 *ngIf="title != undefined" [class] = "title['accessMode']" [title] = "title['accessMode']" >
<div *ngIf="title['url'] != undefined">
<a class="custom-external" href="{{title['url']}}" target="_blank">
<div [innerHTML]="title['name']"></div>
@ -15,7 +15,7 @@ import {Component, Input} from '@angular/core';
</div>
</h2>
`
})
export class ShowTitleComponent {

View File

@ -12,7 +12,7 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
<div *ngIf="status == errorCodes.NOT_AVAILABLE" class="alert alert-danger" role="alert">Service not available</div>
<li *ngFor="let result of results">
<h4>
<h4 [class] = result.title.accessMode [title] = result.title.accessMode >
<a href="{{result['title'].url}}">
<p *ngIf="result['title'].name != undefined && result['title'].name != ''"
[innerHTML]="result['title'].name">

View File

@ -66,9 +66,11 @@ export class DatasetService {
}
this.datasetInfo.embargoEndDate = data[0].embargoenddate;
}
this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""};
if(data[0]['bestlicense'].hasOwnProperty("classid")) {
this.datasetInfo.title.accessMode = data[0]['bestlicense'].classid;
}
if(data[1] != null) {
this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""};
if(Array.isArray(data[1])) {
this.datasetInfo.title['name'] = data[1][0].content;
} else {

View File

@ -22,6 +22,33 @@ export class EntitiesSearchService {
return this.parse(request,"oaf:project","project");
});
}
searchByDepositType(keyword:string, DepositType:string):any {
console.info("In searchOrganizationsforDeposit");
let link = OpenaireProperties.getSearchResourcesAPIURL();
let url = link+"?query=";
if(keyword!= null && keyword != '' ) {
url += "((oaftype exact organization and deletedbyinference=false and "+
"(reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=*))"+
" and ((organizationlegalname all "+'"'+keyword+'"'+") or (organizationlegalshortname all "+'"'+keyword+'"'+")) " +
// "and " + this.quote(params) + " " +
"and (collectedfromdatasourcename exact "+DepositType+")) "
}
url += "&page=0&size=10";
url += "&format=json";
// let url = OpenaireProperties. getSearchAPIURLLast()+"projects?"+((keyword && keyword.length > 0)?("q=" +keyword):"")+((funderId && funderId.length > 0 )?"&fq=funderid exact " + '"'+funderId+ '"':"")+"&size=10&page=0&format=json";
return this.http.get(url).toPromise()
.then(request =>
{
request = request.json().results;
console.log(request);
return this.parse(request,"oaf:organization","organization");
});
}
searchByType(keyword:string,type:string){
if (type == "project"){
return this.searchEntity(keyword,"projects","oaf:project","project");
@ -91,24 +118,7 @@ private fetch (link,id,oafEntityType,type){
}
// private search (link,keyword,oafEntityType,type){
// let url = link+"?";
// if(keyword!= null && keyword != '' ) {
// url += "q="+ keyword;
// }
//
// url += "&page=0&size="+10+"&format=json";
// return this.http.get(url)
// .map(res => <any> res.json().results)
// .map(res => <any> this.parse(res,oafEntityType,type));
// // .then(request =>
// // {
// // request = request.json().results;
// // return this.parse(request,oafEntityType,type);
// // });
//
//
// }
private parse(data: any,oafEntityType:string, type:string){
var array:any =[]
let length = Array.isArray(data) ? data.length : 1;
@ -130,13 +140,16 @@ private fetch (link,id,oafEntityType,type){
value.label = resData["fullname"];
}
}else if(resData["legalname"]){
if(Array.isArray(resData["legalname"])) {
value.label = resData["legalname"][0];
} else {
value.label = resData["legalname"];
}
}
value.id = length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
value.id = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(type=="project"){
value.projectAcronym = resData['acronym'];
value.projectName = value.label;
@ -152,6 +165,7 @@ private fetch (link,id,oafEntityType,type){
}
array.push(value);
}
console.info("Parsing results.... Size:"+array.length);
return array;
}

View File

@ -64,8 +64,11 @@ export class PublicationService {
this.publicationInfo.embargoEndDate = data[0].embargoenddate;
}
this.publicationInfo.title = {"name": "", "url": "", "accessMode": ""};
if(data[0]['bestlicense'].hasOwnProperty("classid")) {
this.publicationInfo.title.accessMode = data[0]['bestlicense'].classid;
}
if(data[1] != null) {
this.publicationInfo.title = {"name": "", "url": "", "accessMode": ""};
if(Array.isArray(data[1])) {
this.publicationInfo.title['name'] = data[1][0].content;

View File

@ -25,7 +25,7 @@ import {EntitiesSearchService} from '../services/entitySearch.service';
<div *ngIf = "keyword != null && keyword.length > 0 " class="suggestions" >
<div *ngIf="showLoading" class="alert alert-info row-fluid " role="alert">Loading... <span class="glyphicon glyphicon-repeat" aria-hidden="true"></span></div>
<ul class="list-group" >
<li *ngIf = "filtered.length > 0 " class="list-group-item" >
<li *ngIf = "numFilteredResults > 0 " class="list-group-item" >
Select:
</li>
<li class="list-group-item" *ngFor=" let item of filtered | async">
@ -35,7 +35,7 @@ import {EntitiesSearchService} from '../services/entitySearch.service';
</div>
<div class="messages">
<div *ngIf="warningMessage.length > 0" class="alert alert-warning row-fluid " role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>{{warningMessage}}</div>
<div *ngIf="filtered.length == 0 && keyword.length >=3 " class="alert alert-info row-fluid " role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>No results found</div>
<div *ngIf="numFilteredResults == 0 && keyword.length >=3 " class="alert alert-info row-fluid " role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>No results found</div>
</div>
</div>
@ -70,13 +70,17 @@ export class EntitiesAutocompleteComponent {
@Input() public funderId:string;
@Input() public entityType:string ;
@Input() public depositType:string ;
constructor (private _search:EntitiesSearchService, private myElement: ElementRef) {
}
ngOnInit () {
console.info("init deposit org" +this.entityType +" "+this.depositType);
if(this.entityType == "project" && this.funderId ){
this.filtered = this.searchTermStream
.debounceTime(300).distinctUntilChanged()
@ -86,6 +90,19 @@ export class EntitiesAutocompleteComponent {
this.numFilteredResults = results.length;
return results;
});
}else if(this.entityType == "organization" && this.depositType ){
console.info("init deposit org")
this.filtered = this.searchTermStream
.debounceTime(300).distinctUntilChanged()
.switchMap((term: string) => {
var results = this._search.searchByDepositType(term, this.depositType);
this.showLoading = false;
this.numFilteredResults = results.length;
console.info("deposit org::: Resuults"+results.length)
return results;
});
}else{
this.filtered = this.searchTermStream
@ -96,18 +113,7 @@ export class EntitiesAutocompleteComponent {
this.numFilteredResults = results.length;
return results;
});
// this.filtered =
// this.searchTermStream
// .debounceTime(300).distinctUntilChanged()
// .switchMap((term: string) => {
// var results = this._search.searchByType(term, this.entityType);
// this.showLoading = false;
// return results;
// });
//
// .subscribe(term => this.wikipediaService.search(term).then(items => this.items = items));
// // }
this.getSelectedNameFromGivenId();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -23,6 +23,15 @@
.search-form {margin:5px; }
.clickable { cursor:pointer; }
.OPEN {
background: rgba(0, 0, 0, 0) url("/assets/openAccess.png") no-repeat scroll right center;
padding-right: 18px;
}
.EMBARGO, .CLOSED, .RESTRICTED {
background: rgba(0, 0, 0, 0) url("/assets/closedAccess.png") no-repeat scroll right center;
padding-right: 18px;
}
</style>
<base href="/">