Compare commits

..

3 Commits

4 changed files with 25 additions and 24 deletions

View File

@ -10,21 +10,20 @@
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" <helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
[texts]="pageContents['top']"></helper> [texts]="pageContents['top']"></helper>
<form class=""> <form *ngIf="filterForm" class="">
<div class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid> <div class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid>
<div #searchInputComponent search-input [control]="filterForm.controls.keyword" [showSearch]="false" placeholder="Search links" <div #searchInputComponent search-input [searchControl]="filterForm.controls.keyword" placeholder="Search links"
[selected]="inputkeyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()" (searchEmitter)="changekeyword()" [expandable]="true"></div>
[bordered]="true" colorClass="uk-text-secondary"></div>
</div> </div>
<div class=" uk-grid uk-flex-middle"> <div class=" uk-grid uk-flex-middle">
<div class="">Filter by: </div> <div class="">Filter by: </div>
<div class="uk-width-medium uk-padding-remove uk-margin-small-left" dashboard-input <div class="uk-width-medium uk-padding-remove uk-margin-small-left" input
[formInput]="filterForm.get('entities')" [formInput]="filterForm.get('entities')"
placeholder="Search by entities" placeholder="Search by entities"
type="chips" [options]="allOptions" chipLabel="label"> type="chips" [options]="allOptions" chipLabel="label">
</div> </div>
<div class="">Sort by: </div> <div class="">Sort by: </div>
<div class="uk-width-medium uk-padding-remove uk-margin-small-left" dashboard-input <div class="uk-width-medium uk-padding-remove uk-margin-small-left" input
[formInput]="filterForm.get('sort')" [formInput]="filterForm.get('sort')"
type="select" type="select"
[options]="sortOptions"> [options]="sortOptions">

View File

@ -17,9 +17,10 @@ import {HelperService} from '../../../utils/helper/helper.service';
import {Meta, Title} from '@angular/platform-browser'; import {Meta, Title} from '@angular/platform-browser';
import {PiwikService} from '../../../utils/piwik/piwik.service'; import {PiwikService} from '../../../utils/piwik/piwik.service';
import {properties} from '../../../../../environments/environment'; import {properties} from '../../../../../environments/environment';
import {FormArray, FormBuilder, FormGroup} from '@angular/forms'; import {FormArray, FormBuilder, FormControl, FormGroup} from '@angular/forms';
import {Option} from '../../../sharedComponents/input/input.component'; import {Option} from '../../../sharedComponents/input/input.component';
import {SearchInputComponent} from '../../../sharedComponents/search-input/search-input.component'; import {SearchInputComponent} from '../../../sharedComponents/search-input/search-input.component';
import {OpenaireEntities} from "../../../utils/properties/searchFields";
declare var UIkit; declare var UIkit;
@Component({ @Component({
@ -62,9 +63,8 @@ export class DisplayClaimsComponent {
public filterForm: FormGroup; public filterForm: FormGroup;
public entitiesCtrl: FormArray; public entitiesCtrl: FormArray;
allOptions: Option[] = [{label: "Projects", value: {id:"project", label: "Projects"}},{label: "Publications", value:{id:"publication", label: "Publications"}},{label: "Research data", value: {id:"dataset", label: "Research data"}}, allOptions: Option[] = [{label: OpenaireEntities.PROJECTS, value: "project"},{label: OpenaireEntities.PUBLICATIONS, value:"publication"},{label: OpenaireEntities.DATASETS, value: "dataset"},
{label: "Software", value: {id:"software", label: "Software"}},{label: "Other reserch products", value: {id:"other", label: "Other reserch products"}},{label: "Communities", value: {id:"context", label: "Communities"}}]; {label: OpenaireEntities.SOFTWARE, value: "software"},{label: OpenaireEntities.OTHER, value: "other"},{label: OpenaireEntities.COMMUNITIES, value: "context"}];
sortOptions: Option[] = [ sortOptions: Option[] = [
{label:"Date (recent) ", value:{ sort: "date", descending: true }}, {label:"Date (oldest) ", value:{ sort: "date",descending:false }}, {label:"Date (recent) ", value:{ sort: "date", descending: true }}, {label:"Date (oldest) ", value:{ sort: "date",descending:false }},
// {label:"User (desc) ", value:{ sort: "user",descending: true }}, {label:"User (asc) ", value:{ sort: "user",descending:false }}, // {label:"User (desc) ", value:{ sort: "user",descending: true }}, {label:"User (asc) ", value:{ sort: "user",descending:false }},
@ -148,7 +148,7 @@ export class DisplayClaimsComponent {
this.page = (page <= 0) ? 1 : page; this.page = (page <= 0) ? 1 : page;
this.size = (size <= 0) ? this.defaultSize : size; this.size = (size <= 0) ? this.defaultSize : size;
this.entityTypes = [];//(params['types']?params['types']:[]); this.entityTypes = [];//(params['types']?params['types']:[]);
// this.setTypes(params['types']); // check the appropriate checkboxes this.setTypes(params['types']); // check the appropriate checkboxes
this.setSortby(params['sort']); this.setSortby(params['sort']);
this.getClaims(); this.getClaims();
this.subscriptions.push(this.searchTermStream this.subscriptions.push(this.searchTermStream
@ -161,9 +161,6 @@ export class DisplayClaimsComponent {
this.subscriptions.push(this.filterForm.get('entities').valueChanges.subscribe(value => { this.subscriptions.push(this.filterForm.get('entities').valueChanges.subscribe(value => {
this.goTo(); this.goTo();
})); }));
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.changekeyword();
}));
this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => { this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => {
this.goTo(); this.goTo();
})); }));
@ -196,7 +193,7 @@ export class DisplayClaimsComponent {
this.showErrorMessage = false; this.showErrorMessage = false;
this.showForbiddenMessage = false; this.showForbiddenMessage = false;
for (let type of this.entitiesCtrl.getRawValue()) { for (let type of this.entitiesCtrl.getRawValue()) {
types += (this.entitiesCtrl.getRawValue().length > 0 ? '&' : '') + "types=" + type.id; types += (types.length > 0 ? '&' : '') + "types=" + type;
} }
this.pageLoading = true; this.pageLoading = true;
if(this.subResults){ if(this.subResults){
@ -305,7 +302,7 @@ export class DisplayClaimsComponent {
params += (this.size == 10 ? "" : (params.length > 0 ? '&' : '') + "size=" + this.size); params += (this.size == 10 ? "" : (params.length > 0 ? '&' : '') + "size=" + this.size);
let types = ""; let types = "";
for (let type of this.entitiesCtrl.getRawValue()) { for (let type of this.entitiesCtrl.getRawValue()) {
types += (this.entitiesCtrl.getRawValue().length > 0 ? ',' : '') + type.id; types += (types.length > 0 ? ',' : '') + type;
} }
params += (this.entitiesCtrl.getRawValue().length > 0) ? (params.length > 0 ? '&' : '') + "types=" + types : ""; params += (this.entitiesCtrl.getRawValue().length > 0) ? (params.length > 0 ? '&' : '') + "types=" + types : "";
if (this.isAdmin) { if (this.isAdmin) {
@ -332,9 +329,14 @@ export class DisplayClaimsComponent {
this.filterForm.get("sort").setValue(option?option.value:this.sortOptions[0].value); this.filterForm.get("sort").setValue(option?option.value:this.sortOptions[0].value);
} }
changekeyword() { setTypes(typesParam: string) {
for(let type of typesParam?typesParam.split(','):[]){
this.entitiesCtrl.push(new FormControl(type));
}
}
if (this.filterForm.get("keyword").value.length >= 3 || this.filterForm.get("keyword").value.length == 0) { changekeyword() {
if (this.filterForm.get("keyword") && (this.filterForm.get("keyword").value.length >= 3 || this.filterForm.get("keyword").value.length == 0)) {
this.searchTermStream.next(this.filterForm.get("keyword").value); this.searchTermStream.next(this.filterForm.get("keyword").value);
} }
} }

View File

@ -13,31 +13,31 @@ export class ClaimsService {
return this.http.get(url, CustomOptions.getAuthOptions()); return this.http.get(url, CustomOptions.getAuthOptions());
} }
getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any { getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any {
let url = apiUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; let url = apiUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types);
return this.getClaimRequest(size,page,url,true); return this.getClaimRequest(size,page,url,true);
} }
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any { getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any {
//console.info('ClaimsService: getClaims for user : '+user); //console.info('ClaimsService: getClaims for user : '+user);
let url = apiUrl +"users/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; let url = apiUrl +"users/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types);
return this.getClaimRequest(size,page,url,false); return this.getClaimRequest(size,page,url,false);
} }
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string , apiUrl:string):any { getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string , apiUrl:string):any {
//console.info('ClaimsService: getClaims for context : '+contextId); //console.info('ClaimsService: getClaims for context : '+contextId);
let url = apiUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; let url = apiUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types);
return this.getClaimRequest(size,page,url,true); return this.getClaimRequest(size,page,url,true);
} }
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string ):any { getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string ):any {
//console.info('ClaimsService: getClaims for entity : '+resultId); //console.info('ClaimsService: getClaims for entity : '+resultId);
let url = apiUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; let url = apiUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types);
return this.getClaimRequest(size,page,url,true); return this.getClaimRequest(size,page,url,true);
} }
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string ):any { getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string ):any {
//console.info('ClaimsService: getClaims for project : '+projectId); //console.info('ClaimsService: getClaims for project : '+projectId);
let url = apiUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; let url = apiUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+(types.length>0?"&"+types:types);
return this.getClaimRequest(size,page,url,true); return this.getClaimRequest(size,page,url,true);
} }

View File

@ -463,7 +463,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
} }
getLabel(value: any) { getLabel(value: any) {
let option = this.filteredOptions.find(option => HelperFunctions.equals(option.value, value)); let option = this.optionsArray.find(option => HelperFunctions.equals(option.value, value));
return (option) ? option.label : (value); return (option) ? option.label : (value);
} }