1. 'Search Content Providers' page gets its content by Community API - 'searchDataproviders' service added.

2. In 'Search Content Providers' page. datatable is used to show results - no filters exist.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@51012 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-03-02 12:52:12 +00:00
parent 77b8803d6e
commit c0e4df0714
5 changed files with 206 additions and 7 deletions

View File

@ -7,10 +7,16 @@ import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
import {SearchDataProvidersModule} from '../../openaireLibrary/searchPages/simple/searchDataProviders.module'; import {SearchDataProvidersModule} from '../../openaireLibrary/searchPages/simple/searchDataProviders.module';
import {SearchPageTableViewModule} from '../../openaireLibrary/searchPages/searchUtils/searchPageTableView.module';
//import {DataProvidersServiceModule} from '../../openaireLibrary/services/dataProvidersService.module';
import {SearchFormModule} from '../../openaireLibrary/searchPages/searchUtils/searchForm.module';
import {SearchDataprovidersServiceModule} from '../../services/searchDataprovidersService.module';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
SearchDataProvidersModule, SearchDataProvidersRoutingModule SearchDataProvidersModule, SearchDataProvidersRoutingModule,
SearchPageTableViewModule, /*DataProvidersServiceModule,*/ SearchFormModule, SearchDataprovidersServiceModule
], ],
declarations: [ declarations: [

View File

@ -1,14 +1,167 @@
import {Component, Input, ViewChild} from '@angular/core'; import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import { Filter, Value} from '../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class';
import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult';
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
import {SearchFields, FieldDetails} from '../../openaireLibrary/utils/properties/searchFields';
import {SearchPageTableViewComponent } from '../../openaireLibrary/searchPages/searchUtils/searchPageTableView.component';
import {SearchUtilsClass } from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {SearchCommunityDataprovidersService} from '../../services/searchDataproviders.service';
@Component({ @Component({
selector: 'openaire-search-dataproviders', selector: 'openaire-search-dataproviders',
template: ` template: `
<search-dataproviders> <search-page-table pageTitle="OpenAIRE Content Providers Table"
</search-dataproviders> type="content providers" entityType="dataprovider"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[columnNames]="columnNames"
[showResultCount]=false
[disableForms]="disableForms"
searchFormClass="datasourcesTableSearchForm"
formPlaceholderText="Search for Content Providers">
</search-page-table>
` `
}) })
export class OpenaireSearchDataprovidersComponent { export class OpenaireSearchDataprovidersComponent {
private errorCodes: ErrorCodes;
public columnNames = ['Name', 'Official Name'];
public results =[];
public filters =[];
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
public sub: any; public subResults: any;
public _location:Location;
public searchFields:SearchFields = new SearchFields();
public refineFields: string[] = [];// = this.searchFields.JOURNAL_FIELDS;
properties:EnvProperties;
public disableForms: boolean = false;
@ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ;
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchCommunityDataprovidersService) {
this.errorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
});
//this.searchPage.refineFields = this.refineFields;
this.sub = this.route.queryParams.subscribe(params => {
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
//this.filters = this.createFilters();
//this.searchPage.getParametersFromUrl(params);
this._getResults(params);
});
}
public ngOnDestroy() {
if(this.sub){
this.sub.unsubscribe();
}
if(this.subResults){
this.subResults.unsubscribe();
}
}
private _getResults(params){
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = [];
this.searchUtils.totalResults = 0;
let size: number = 0;
this.subResults = this._searchDataprovidersService.searchDataproviders(this.properties).subscribe(
data => {
//this.filters = this.createFilters(data, params);
console.info(data);
this.searchUtils.totalResults = data.length;
console.info("search Content Providers [total results:"+this.searchUtils.totalResults+"]");
this.results = data;
//this.searchPage.checkSelectedFilters(this.filters);
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
this.disableForms = false;
this.searchPage.triggerInitialLoad();
this.searchPage.transform(this.results);
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
this.disableForms = false;
}
);
}
private setFilters(){
//TODO set filters from
}
/*
private createFilters(data, params):Filter[] {
let length = Array.isArray(data) ? data.length : 1;
var filter_names=[];
var filter_ids=[];
var searchFields = new SearchFields();
var filter_original_ids = [];//searchFields.JOURNAL_FIELDS;
this.refineFields = ["relfunder"];
this.searchPage.refineFields = this.refineFields;
this.searchPage.getParametersFromUrl(params);
var value_names=[];
var value_original_ids=[];
var funders = new Set<String>();
var value_name = [];
var value_original_id = [];
let i;
for(i=0; i<length; i++) {
let resData = Array.isArray(data) ? data[i] : data;
if(resData.funder && !funders.has(resData.funder)) {
funders.add(resData.funder);
value_name.push(resData.funder);
value_original_id.push(resData.funder.trim());
}
}
value_names.push(value_name);
value_original_ids.push(value_original_id);
var filters: Filter[] =[];
for(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_original_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);
}
console.info(filters);
return filters;
}
*/
} }

View File

@ -3,7 +3,6 @@ import { ActivatedRoute} from '@angular/router';
import { Filter, Value} from '../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class'; import { Filter, Value} from '../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class';
import {SearchDataprovidersService} from '../../openaireLibrary/services/searchDataproviders.service';
import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult'; import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult';
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
import {SearchFields, FieldDetails} from '../../openaireLibrary/utils/properties/searchFields'; import {SearchFields, FieldDetails} from '../../openaireLibrary/utils/properties/searchFields';
@ -22,7 +21,7 @@ import {SearchCommunityProjectsService} from '../../services/searchProjects.serv
[columnNames]="columnNames" [columnNames]="columnNames"
[showResultCount]=false [showResultCount]=false
[disableForms]="disableForms" [disableForms]="disableForms"
searchFormClass="journalsTableSearchForm" searchFormClass="projectsTableSearchForm"
formPlaceholderText="Search for Projects"> formPlaceholderText="Search for Projects">
</search-page-table> </search-page-table>
` `
@ -45,7 +44,7 @@ export class OpenaireSearchProjectsComponent {
@ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ;
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService, private _searchProjectsService: SearchCommunityProjectsService) { constructor (private route: ActivatedRoute, private _searchProjectsService: SearchCommunityProjectsService) {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING; this.searchUtils.status = this.errorCodes.LOADING;
} }

View File

@ -0,0 +1,21 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {SearchResult} from '../openaireLibrary/utils/entities/searchResult';
import {RefineResultsUtils} from '../openaireLibrary/services/servicesUtils/refineResults.class';
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
@Injectable()
export class SearchCommunityDataprovidersService {
constructor(private http: Http ) {}
searchDataproviders (properties:EnvProperties ):any {
let url = properties.communityAPI+"egi/contentproviders";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
}
}

View File

@ -0,0 +1,20 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {SearchCommunityDataprovidersService} from './searchDataproviders.service';
@NgModule({
imports: [
CommonModule, FormsModule
],
declarations: [
],
providers:[
SearchCommunityDataprovidersService
],
exports: [
]
})
export class SearchDataprovidersServiceModule { }