home and search all page is the same page now | search/find show browse results when there is no keyword

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@45417 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-01-17 10:56:37 +00:00
parent 026c64900f
commit d4e1832d9a
10 changed files with 242 additions and 33 deletions

View File

@ -4,7 +4,7 @@ import { RouterModule } from '@angular/router';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', redirectTo: '/home', pathMatch: 'full' }
{ path: '', redirectTo: '/search/find', pathMatch: 'full' }
])
],
})

View File

@ -7,7 +7,7 @@ import {Location} from '@angular/common';
selector: 'home',
template:`
<div class="uk-margin">
<div class="uk-margin-top">
<div class="page-header">
<h1>Openaire Search</h1>
</div>

View File

@ -18,50 +18,52 @@ import {SearchPeopleService} from '../../services/searchPeople.service';
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
@Component({
selector: 'search-find',
template: `
<div class="uk-margin">
<div class="uk-margin-top">
<div class="page-header">
<h1>{{pageTitle}}</h1>
</div>
<div >
<div class="uk-grid">
<div class="uk-width-1-1 uk-margin uk-panel uk-panel-box uk-panel-box-default">
<search-form [(keyword)]=keyword (keywordChange)="keywordChanged($event)"></search-form>
<div *ngIf = "keyword.length > 0" class="uk-grid uk-margin-top">
</div>
<div class=" uk-grid uk-margin-top uk-width-1-1">
<ul class="uk-tab uk-tab-left uk-width-large-1-5 uk-width-small-1-1 " data-uk-tab="{connect:'#searchtabs'}">
<li (click)="searchPublications()" >
<a href="#pubsTab">
Publications ({{searchPublicationsComponent.searchUtils.totalResults}})
Publications {{((keyword.length > 0)?'('+searchPublicationsComponent.searchUtils.totalResults+')':'')}}
</a>
</li>
<li (click)="searchDatasets()">
<a href="#dataTab" (click)="searchDatasets()">
Datasets ({{searchDatasetsComponent.searchUtils.totalResults}})
Datasets {{((keyword.length > 0)?'('+searchDatasetsComponent.searchUtils.totalResults+')':'')}}
</a>
</li>
<li (click)="searchProjects()" >
<a href="#projectsTab">
Projects ({{searchProjectsComponent.searchUtils.totalResults}})
Projects {{((keyword.length > 0)?'('+searchProjectsComponent.searchUtils.totalResults+')':'')}}
</a>
</li>
<li (click)="searchDataProviders()" >
<a href="#dataProviderTab">
Data Providers ({{searchDataProvidersComponent.searchUtils.totalResults}})
Data Providers {{((keyword.length > 0)?'('+searchDataProvidersComponent.searchUtils.totalResults+')':'')}}
</a>
</li>
<li (click)="searchOrganizations()" >
<a href="#organizationsTab" >
Organizations ({{searchOrganizationsComponent.searchUtils.totalResults}})
Organizations {{((keyword.length > 0)?'('+searchOrganizationsComponent.searchUtils.totalResults+')':'')}}
</a>
</li>
<li (click)="searchPeople()" >
<a href="#peopleTab" >
People ({{searchPeopleComponent.searchUtils.totalResults}})
People {{((keyword.length > 0)?'('+searchPeopleComponent.searchUtils.totalResults+')':'')}}
</a>
</li>
@ -71,31 +73,64 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
<ul id="searchtabs" class="uk-switcher uk-margin-left uk-width-large-3-4 uk-width-small-1-1">
<li id="pubsTab" class="uk-active">
<div *ngIf = "keyword.length > 0">
<div class = "uk-text-right" *ngIf = "searchPublicationsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchPublications" >View all {{searchPublicationsComponent.searchUtils.totalResults}} results</a></div>
<search-result [(results)]="searchPublicationsComponent.results" [(status)]= "searchPublicationsComponent.status"></search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='publications'" >
<browse-entities entityName="publication" baseUrl="/search/find/publications" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
</div>
</li>
<li id="dataTab">
<div *ngIf = "keyword.length > 0">
<div class = "uk-text-right" *ngIf = "searchDatasetsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchDatasets" >View all {{searchDatasetsComponent.searchUtils.totalResults}} results</a></div>
<search-result [(results)]="searchDatasetsComponent.results" [(status)]= "searchDatasetsComponent.status"></search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='datasets'" >
<browse-entities entityName="dataset" baseUrl="/search/find/datasets" [refineFields]=searchFields.RESULT_REFINE_FIELDS></browse-entities>
</div>
</li>
<li id="projectsTab" >
<div *ngIf = "keyword.length > 0">
<div class = "uk-text-right" *ngIf = "searchProjectsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchProjects" >View all {{searchProjectsComponent.searchUtils.totalResults}} results</a></div>
<search-result [(results)]="searchProjectsComponent.results" [(status)]= "searchProjectsComponent.status"></search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='projects'" >
<browse-entities entityName="project" baseUrl="/search/find/projects" [refineFields]=searchFields.PROJECT_REFINE_FIELDS></browse-entities>
</div>
</li>
<li id="dataProviderTab">
<div *ngIf = "keyword.length > 0">
<div class = "uk-text-right" *ngIf = "searchDataProvidersComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchDataproviders" >View all {{searchDataProvidersComponent.searchUtils.totalResults}} results</a></div>
<search-result [(results)]="searchDataProvidersComponent.results" [(status)]= "searchDataProvidersComponent.status"></search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='dataproviders'" >
<browse-entities entityName="dataprovider" baseUrl="/search/find/dataproviders" [refineFields]=searchFields.DATASOURCE_REFINE_FIELDS></browse-entities>
</div>
</li>
<li id="organizationsTab" >
<div *ngIf = "keyword.length > 0">
<div class = "uk-text-right" *ngIf = "searchOrganizationsComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchOrganizations" >View all {{searchOrganizationsComponent.searchUtils.totalResults}} results</a></div>
<search-result [(results)]="searchOrganizationsComponent.results" [(status)]= "searchOrganizationsComponent.status"></search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='organizations'" >
<browse-entities entityName="organization" baseUrl="/search/find/organizations" [refineFields]=searchFields.ORGANIZATION_REFINE_FIELDS></browse-entities>
</div>
</li>
<li id="peopleTab">
<div *ngIf = "keyword.length > 0">
<div class = "uk-text-right" *ngIf = "searchPeopleComponent.searchUtils.totalResults> 10" ><a [href] = "linkToSearchPeople" >View all {{searchPeopleComponent.searchUtils.totalResults}} results</a></div>
<search-result [(results)]="searchPeopleComponent.results" [(status)]= "searchPeopleComponent.status"></search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='people'" >
<div class="uk-alert uk-alert-info" role="alert">No person statistics found</div>
</div>
</li>
</ul>
</div>
</div>
`
})
@ -139,6 +174,7 @@ export class SearchComponent {
public searchDatasetsComponent: SearchDatasetsComponent;
public searchOrganizationsComponent: SearchOrganizationsComponent;
public searchPeopleComponent: SearchPeopleComponent;
public searchFields:SearchFields = new SearchFields();
public subPub;public subData;public subProjects;public subOrg;public subPeople; public subDataPr;
constructor ( private route: ActivatedRoute,
@ -213,7 +249,6 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
}
}
private searchProjects() {
console.info("Here!!!");
this.activeTab = "projects";
if(this.reloadProjects) {
this.reloadProjects = false;
@ -222,7 +257,7 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
}
}
private searchDataProviders() {
this.activeTab = "datproviders";
this.activeTab = "dataproviders";
if(this.reloadDataproviders) {
this.reloadDataproviders = false;
this.searchDataProvidersComponent.getResults(this.keyword, false, 1, 10);
@ -264,7 +299,7 @@ public subPub;public subData;public subProjects;public subOrg;public subPeople;
if(this.activeTab == "projects") {
this.searchProjects();
}
if(this.activeTab == "datasources") {
if(this.activeTab == "dataproviders") {
this.searchDataProviders();
}
if(this.activeTab == "datasets") {

View File

@ -17,6 +17,9 @@ import {SearchFormComponent} from './searchUtils/searchForm.component';
import {SearchPagingComponent} from './searchUtils/searchPaging.component';
import {SearchDownloadComponent} from './searchUtils/searchDownload.component';
import {BrowseEntitiesComponent} from './searchUtils/browseEntities.component';
import {BrowseStatisticComponent} from './searchUtils/browseStatistic.component';
import {SearchResultComponent} from './searchUtils/searchResult.component';
import {SearchFilterComponent} from './searchUtils/searchFilter.component';
import {AdvancedSearchFormComponent} from './searchUtils/advancedSearchForm.component';
@ -71,7 +74,9 @@ import { SearchRoutingModule } from './search-routing.module';
DatasourceTableViewComponent,
SearchDatasetsComponent,
SearchOrganizationsComponent,
SearchPeopleComponent
SearchPeopleComponent,
BrowseEntitiesComponent,
BrowseStatisticComponent
],
providers:[
@ -91,7 +96,9 @@ import { SearchRoutingModule } from './search-routing.module';
SearchComponent,
SearchCompatibleDataprovidersComponent,
SearchEntityRegistriesComponent,
SearchResultComponent
SearchResultComponent,
BrowseEntitiesComponent,
BrowseStatisticComponent
]
})
export class SearchModule { }

View File

@ -0,0 +1,92 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass} from '../searchUtils/searchUtils.class';
@Component({
selector: 'browse-entities',
template: `
<div>
<div *ngIf="status == errorCodes.LOADING" class="uk-alert uk-alert-primary" role="alert">Loading...</div>
<div *ngIf="status == errorCodes.NONE" class="uk-alert uk-alert-primary" role="alert">No Results found</div>
<div *ngIf="status == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
<div *ngIf="status == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
<div class ="uk-grid">
<div *ngFor= "let filter of filters" class = "uk-margin-top uk-width-large-1-5 uk-width-medium-1-4 uk-width-small-1-2">
<browse-statistic [baseUrl]=baseUrl [filter]=filter ></browse-statistic>
</div>
</div>
</div>
`
})
export class BrowseEntitiesComponent {
public searchFields:SearchFields = new SearchFields();
public filters =[];
@Input() public baseUrl:string = "";
@Input() public entityName:string = "";
@Input() public refineFields: string[] ;//= this.searchFields.RESULT_REFINE_FIELDS;
public sub: any;
public errorCodes:ErrorCodes = new ErrorCodes();
public status = this.errorCodes.LOADING;
public fieldIdsMap=this.searchFields.RESULT_REFINE_FIELDS;
constructor ( private _refineFieldsService: RefineFieldResultsService ) {
// this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
}
public ngOnInit() {
console.log(this.searchFields.HIDDEN_FIELDS);
for(var i=0; i < this.searchFields.HIDDEN_FIELDS.length; i++){
console.log("hidden"+this.searchFields.HIDDEN_FIELDS[i]);
var index = this.refineFields.indexOf(this.searchFields.HIDDEN_FIELDS[i]) ;
if(index > -1){
console.log("remove"+this.searchFields.HIDDEN_FIELDS[i]);
this.refineFields.splice(index,1);
}
}
this.getStats();
}
public ngOnDestroy() {
if(this.sub){
this.sub.unsubscribe();
}
}
private getStats(){
this.status = this.errorCodes.LOADING;
this.sub = this._refineFieldsService.getRefineFieldsResultsByEntityName(this.refineFields,this.entityName).subscribe(
data => {
console.info("Get Stats for "+this.entityName+ ": [Total:"+data[0]+" ] [fields: "+data[1].length+"]");
this.filters = data[1];
this.status = this.errorCodes.DONE;
if(data[0] == 0 ){
this.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
// if( ){
// this.searchUtils.status = ErrorCodes.ERROR;
// }
this.status = this.errorCodes.ERROR;
}
);
}
}

View File

@ -0,0 +1,58 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass} from '../searchUtils/searchUtils.class';
@Component({
selector: 'browse-statistic',
template: `
<h4 class="tm-article-subtitle">{{filter.title}}</h4>
<div *ngIf="filter.values.length == 0" class="uk-alert uk-alert-info" role="alert">No {{filter.title}} statistics found</div>
<ul *ngIf="filter.values.length > 0 && !viewAll" class="uk-list uk-list-line ">
<li *ngFor= "let value of filter.values.slice(0,5)"><a [href]="baseUrl+'?'+filter.filterId+'='+value.id">{{_formatName(value)}} ({{value.number}})</a></li>
<li *ngIf= " filter.values.length > 5 && !viewAll " (click)="viewAll=true;">
<span ><span class="uk-text-muted clickable">View more </span><a><i class="uk-icon-toggle-right"></i></a></span>
</li>
</ul>
<ul *ngIf="filter.values.length > 0 && viewAll" class="uk-list uk-list-line searchFilterBoxValues">
<li *ngFor= "let value of filter.values"><a [href]="baseUrl+'?'+filter.filterId+'='+value.id">{{_formatName(value)}} ({{value.number}})</a></li>
<li *ngIf= " filter.values.length > 5 && viewAll " (click)="viewAll=false;">
<span ><span class="uk-text-muted clickable">View more </span><a><i class="uk-icon-toggle-up"></i></a></span>
</li>
</ul>
`
})
export class BrowseStatisticComponent {
@Input() public baseUrl:string = "";
@Input() public filter:string = "";
private _maxCharacters = 30;
private showAll = false;
constructor () {
}
public ngOnInit() {
}
private _formatName(value){
return (((value.name+" ("+value.number+")").length >this._maxCharacters)?(value.name.substring(0,(this._maxCharacters - (" ("+value.number+")").length - ('...').length))+"..."):value.name)
}
}

View File

@ -109,7 +109,7 @@ export class SearchPageComponent {
for(let value of values) {
countvalues++;
var paramId = this.fieldIdsMap[filterId].param;
parameters+='&' + paramId+ '='+ value+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or");
parameters+='&' + paramId+ '='+ value;//+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or");
fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId +" exact " + this.quote(value) ;
}
if(countvalues > 0){

View File

@ -7,11 +7,29 @@ import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from '../shared/cache.service';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
@Injectable()
export class RefineFieldResultsService {
// scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/projects?refine=true&fields=funderid&page=1&size=0
constructor(private http: Http, public _cache: CacheService) {}
getRefineFieldsResultsByEntityName(fields:string[], entityName:string):any{
let link = OpenaireProperties.getSearchAPIURLForEntity(entityName)+"?format=json&refine=true&page=1&size=0";
for(var i=0; i < fields.length; i++){
link += "&fields="+fields[i];
}
let key = link;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key)).do(res => console.log(res['meta'])).map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]).do(res => console.log(res));
}
return this.http.get(link)
.map(res => <any> res.json())
.do(res => {
this._cache.set(key, res);
})
.map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]);
}
getRefineFieldResultsByFieldName(fieldName:string, entityName:string):any{
let link = OpenaireProperties.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName + "&format=json";
return this.getField(link,fieldName)

View File

@ -131,7 +131,7 @@ export class SearchFields {
public HIDDEN_FIELDS:string[] = ["fundinglevel0_id","fundinglevel1_id","fundinglevel2_id",
"relfundinglevel0_id","relfundinglevel1_id,relfundinglevel2_id"];
"relfundinglevel0_id","relfundinglevel1_id","relfundinglevel2_id"];
public DEPENDENT_FIELDS: { [key:string]:string } = {["fundinglevel0_id"]:"funderid",
["fundinglevel1_id"]:"fundinglevel0_id", ["fundinglevel2_id"]:"fundinglevel1_id", ["relfundinglevel0_id"]:"relfunderid",

View File

@ -10,7 +10,6 @@
* ];
**/
export const routes: string[] = [
'home',
'claims','claim','myclaims','linking','bulk-linking',
'search/person','search/publication','search/project','search/dataset','search/dataprovider','search/organization',
'search/find/people','search/find/publications','search/find/projects','search/find/datasets','search/find/dataproviders','search/find/organizations',