add a first draft of compatible data Providers page, in search clean url from parameters when click clear filters, minor changes in filters format
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43967 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
2c62cfe94d
commit
165220fdf4
|
@ -23,6 +23,7 @@ import { ErrorPageComponent } from './error/errorPage.component';
|
|||
import { TestComponent } from './test/test.component';
|
||||
|
||||
import { SearchAllComponent } from './searchAll/searchAll.component';
|
||||
import { SearchCompatibleDataprovidersComponent } from './searchPages/dataProviders/compatibleDataProviders.component';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{ path: '', component: SearchComponent, pathMatch: 'full' },
|
||||
|
@ -36,6 +37,7 @@ const appRoutes: Routes = [
|
|||
{ path: 'search/dataset', component: DatasetComponent },
|
||||
{ path: 'search/publication', component: PublicationComponent },
|
||||
{ path: 'search/dataprovider', component: DataProviderComponent},
|
||||
{ path: 'search/data-providers', component: SearchCompatibleDataprovidersComponent},
|
||||
{ path: 'search/find', component: SearchComponent },
|
||||
{ path: 'linking', component: LinkingComponent },
|
||||
{ path: 'bulk-linking', component: BulkLinkingComponent},
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import { ActivatedRoute} from '@angular/router';
|
||||
|
||||
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
|
||||
|
||||
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
||||
import {SearchResult} from '../../utils/entities/searchResult';
|
||||
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-dataproviders',
|
||||
template: `
|
||||
|
||||
<search-page pageTitle="Compatible Dataproviders" type="datasource" [(filters)] = "filters"
|
||||
[(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
|
||||
[(page)] = "page" [(size)] = "size" [(status)] = "status" [baseUrl] = "baseUrl" [showResultCount]=false (queryChange)="queryChanged($event)" >
|
||||
</search-page>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
export class SearchCompatibleDataprovidersComponent {
|
||||
public results =[];
|
||||
private filters =[];
|
||||
public totalResults:number = 0 ;
|
||||
private baseUrl:string;
|
||||
public status:number;
|
||||
private keyword = '';
|
||||
private page :number = 1;
|
||||
private size :number = 10;
|
||||
private sub: any;
|
||||
|
||||
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status =errorCodes.LOADING;
|
||||
this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders();
|
||||
}
|
||||
|
||||
private ngOnInit() {
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.keyword = (params['keyword']?params['keyword']:'');
|
||||
this.page = (params['page']=== undefined)?1:+params['page'];
|
||||
this.filters = this.createFilters();
|
||||
for(var i=0; i< this.filters.length ; i++){
|
||||
var filter = this.filters[i];
|
||||
console.info(params);
|
||||
if(params[filter.filterId] != undefined) {
|
||||
let values = params[filter.filterId].split(",");
|
||||
for(let value of values) {
|
||||
for(let filterValue of filter.values) {
|
||||
if(filterValue.id == value) {
|
||||
filterValue.selected = true;
|
||||
filter.countSelectedValues++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getResults(this.keyword, this.page, this.size);
|
||||
});
|
||||
}
|
||||
|
||||
private ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
public getResults(parameters:string, page: number, size: number){
|
||||
console.info("getResults: Execute search query "+parameters);
|
||||
//q=(not datasourcecompatibilityid exact 'UNKNOWN' )and (not datasourcecompatibilityid exact 'hostedBy' ) and (not datasourcecompatibilityid exact 'notCompatible' )
|
||||
// (datasourcecompatibilityid <> "UNKNOWN") and (datasourcecompatibilityid <> "hostedBy") and (datasourcecompatibilityid <> "notCompatible")
|
||||
this._searchDataprovidersService.searchDataproviders(parameters, page, size).subscribe(
|
||||
data => {
|
||||
this.totalResults = data[0];
|
||||
console.info("searchPubl total="+this.totalResults);
|
||||
this.results = data[1];
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status = errorCodes.DONE;
|
||||
if(this.totalResults == 0 ){
|
||||
this.status = errorCodes.NONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.error(err);
|
||||
console.info("error");
|
||||
this.totalResults = 0;
|
||||
this.results = [];
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status = errorCodes.ERROR;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private setFilters(){
|
||||
//TODO set filters from
|
||||
}
|
||||
|
||||
private queryChanged($event) {
|
||||
var parameters = $event.value;
|
||||
console.info("queryChanged: Execute search query "+parameters);
|
||||
this.getResults(parameters, this.page, this.size);
|
||||
}
|
||||
private createFilters():Filter[] {
|
||||
var filter_names=["Type","Compatibility Level"];
|
||||
var filter_ids=["type","compatibility"];
|
||||
var filter_original_ids=["datasourcetypeid","openairecompatibilityid"];
|
||||
|
||||
var value_names=[
|
||||
["Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", "Publication Repositories Aggregators",
|
||||
"Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"],
|
||||
["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]];
|
||||
var value_ids=[
|
||||
["instRepo","thematicRepo", "otherRepo", "pubRepoAggr",
|
||||
"dataRepo", "dataRepoAggr", "jRepo", "jRepoAggr", "cris", "pubCat"],
|
||||
["compBasic","comp2", "comp2plus", "comp3","comp2data"]];
|
||||
var value_original_ids=[
|
||||
["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic or aggregator::pubsrepository::institutional or aggregator::pubsrepository::unknown",
|
||||
"datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"],
|
||||
["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]];
|
||||
var filters: Filter[] =[];
|
||||
for(var i =0 ; i < filter_names.length;i++){
|
||||
var values:Value[] = [];
|
||||
for(var j =0 ; j < value_names[i].length;j++){
|
||||
var value:Value = {name: value_names[i][j], id: value_ids[i][j], number:j, selected:false}
|
||||
values.push(value);
|
||||
}
|
||||
var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or'}
|
||||
filters.push(filter);
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,7 @@ import { SearchDataprovidersComponent } from './searchDataproviders.component';
|
|||
import { SearchProjectsComponent } from './searchProjects.component';
|
||||
|
||||
import {SearchComponent} from './find/search.component';
|
||||
import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatibleDataProviders.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
@ -48,7 +49,8 @@ import {SearchComponent} from './find/search.component';
|
|||
AdvancedSearchPublicationsComponent,
|
||||
SearchDataprovidersComponent,
|
||||
SearchComponent,
|
||||
SearchProjectsComponent
|
||||
SearchProjectsComponent,
|
||||
SearchCompatibleDataprovidersComponent
|
||||
|
||||
],
|
||||
providers:[
|
||||
|
@ -60,7 +62,8 @@ import {SearchComponent} from './find/search.component';
|
|||
SearchPublicationsComponent,
|
||||
SearchProjectsComponent,
|
||||
SearchDataprovidersComponent,
|
||||
SearchComponent
|
||||
SearchComponent,
|
||||
SearchCompatibleDataprovidersComponent
|
||||
]
|
||||
})
|
||||
export class SearchModule { }
|
||||
|
|
|
@ -6,17 +6,17 @@ import { Filter, Value} from './searchHelperClasses.class';
|
|||
@Component({
|
||||
selector: 'search-filter',
|
||||
template: `
|
||||
<p>{{filter.title}} </p>
|
||||
<h4>{{filter.title}} </h4>
|
||||
<p *ngFor = "let value of filter.values.slice(0,5)" >
|
||||
<input [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" />
|
||||
<span> {{value.name}} ({{value.number}}) </span>
|
||||
<span> {{value.name}}</span><span *ngIf = "showResultCount === true" > ({{value.number}}) </span>
|
||||
</p>
|
||||
|
||||
<a *ngIf = "!showAll && filter.values.length > 5" (click)="toggleShowAll()" > More</a>
|
||||
<span *ngIf = "filter.values.length > 5 && showAll" >
|
||||
<p *ngFor = "let value of filter.values.slice(5)" >
|
||||
<input [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" />
|
||||
<span> {{value.name}} ({{value.number}}) </span>
|
||||
<span> {{value.name}}</span><span *ngIf = "showResultCount === true" > ({{value.number}}) </span>
|
||||
</p>
|
||||
<a (click)="toggleShowAll()" > Less</a>
|
||||
</span>
|
||||
|
@ -32,6 +32,7 @@ export class SearchFilterComponent {
|
|||
//@Output() change = new EventEmitter();
|
||||
@Input() test:{value:number} ;
|
||||
@Input() filter:Filter;
|
||||
@Input() showResultCount:boolean = true;
|
||||
private showAll:boolean = false;
|
||||
|
||||
constructor () {
|
||||
|
@ -39,6 +40,7 @@ export class SearchFilterComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.info(" showResultCount "+this.showResultCount + " (this.showResultCount == true): " + (this.showResultCount == true)+ " (this.showResultCount == false): "+(this.showResultCount == false));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import {SearchResult} from '../../utils/entities/searchResult';
|
|||
<div class="col-xs-12 col-sm-3">
|
||||
<a *ngIf="isFiltered()" (click)="clearFilters()" > Clear Filters</a>
|
||||
<p *ngFor="let filter of filters " >
|
||||
<search-filter [filter]="filter" (change)="filterChanged($event)"></search-filter>
|
||||
<search-filter [filter]="filter" [showResultCount]=showResultCount (change)="filterChanged($event)"></search-filter>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
@ -45,13 +45,13 @@ export class SearchPageComponent {
|
|||
@Input() keyword: string = '';
|
||||
@Output() queryChange = new EventEmitter();
|
||||
@Input() baseUrl:string = '';
|
||||
@Input() showResultCount:boolean = true;
|
||||
|
||||
constructor (private location: Location) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.info(" page - value: "+this.page);
|
||||
console.info("searchPage total="+this.totalResults);
|
||||
console.info("searchPage: results.length = "+this.results.length);
|
||||
}
|
||||
|
@ -131,6 +131,8 @@ export class SearchPageComponent {
|
|||
if(this.keyword.length > 0 ){
|
||||
this.keyword ='';
|
||||
}
|
||||
this.location.go(location.pathname);
|
||||
this.goTo(1);
|
||||
}
|
||||
|
||||
goTo(page:number = 1){
|
||||
|
|
|
@ -64,6 +64,7 @@ app.get('/search/project', ngApp);
|
|||
app.get('/search/organization', ngApp);
|
||||
app.get('/search/dataset', ngApp);
|
||||
app.get('/search/dataprovider', ngApp);
|
||||
app.get('search/data-providers', ngApp);
|
||||
app.get('/search/publication', ngApp);
|
||||
app.get('/search', ngApp);
|
||||
app.get('/search/find/publications', ngApp);
|
||||
|
|
Loading…
Reference in New Issue