Adding a general search page
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43953 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
9d5a8b810d
commit
f643e4a18c
|
@ -12,7 +12,7 @@ import { OrganizationComponent } from './landingPages/organization/organization.
|
|||
import { DatasetComponent } from './landingPages/dataset/dataset.component';
|
||||
import { PublicationComponent } from './landingPages/publication/publication.component';
|
||||
import { DataProviderComponent } from './landingPages/dataProvider/dataProvider.component'
|
||||
import { SearchAllComponent } from './searchAll/searchAll.component';
|
||||
import { SearchComponent } from './searchPages/find/search.component';
|
||||
import { SearchPublicationsComponent } from './searchPages/searchPublications.component';
|
||||
import { AdvancedSearchPublicationsComponent } from './searchPages/advancedSearchPublications.component';
|
||||
import { DepositComponent } from './deposit/deposit.component';
|
||||
|
@ -22,8 +22,7 @@ import { TestComponent } from './test/test.component';
|
|||
|
||||
|
||||
const appRoutes: Routes = [
|
||||
|
||||
{ path: '', component: HomeComponent, pathMatch: 'full' },
|
||||
{ path: '', component: SearchComponent, pathMatch: 'full' },
|
||||
{ path: 'claims', component: ClaimsAdminComponent },
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'claim', component: ClaimComponent },
|
||||
|
@ -34,11 +33,11 @@ const appRoutes: Routes = [
|
|||
{ path: 'search/dataset', component: DatasetComponent },
|
||||
{ path: 'search/publication', component: PublicationComponent },
|
||||
{ path: 'search/dataprovider', component: DataProviderComponent},
|
||||
{ path: 'search', component: SearchAllComponent },
|
||||
{ path: 'search/find', component: SearchComponent },
|
||||
{ path: 'linking', component: LinkingComponent },
|
||||
{ path: 'bulk-linking', component: BulkLinkingComponent},
|
||||
{ path: 'search-publications', component: SearchPublicationsComponent },
|
||||
{ path: 'advanced-search-publications', component: AdvancedSearchPublicationsComponent },
|
||||
{ path: 'search/find/publications', component: SearchPublicationsComponent },
|
||||
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
|
||||
{ path: 'deposit', component: DepositComponent},
|
||||
{ path: 'deposit-results', component: DepositResultComponent},
|
||||
{ path: 'test', component: TestComponent},
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import { SearchPublicationsComponent } from '../searchPublications.component';
|
||||
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
||||
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-find',
|
||||
template: `
|
||||
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>{{pageTitle}}</h1>
|
||||
</div>
|
||||
<div >
|
||||
|
||||
<search-form [(keyword)]=keyword (keywordChange)="keywordChanged($event)"></search-form>
|
||||
|
||||
|
||||
<div *ngIf = "keyword.length > 0" class="container">
|
||||
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li [class]="activeTab=='publications'?'active':''" >
|
||||
<a data-toggle="tab" href="#pubsTab">
|
||||
Publications
|
||||
</a>
|
||||
</li>
|
||||
<li [class]="activeTab=='datasets'?'active':''" >
|
||||
<a data-toggle="tab" href="#dataTab">
|
||||
Datasets
|
||||
</a>
|
||||
</li>
|
||||
<li >
|
||||
<a data-toggle="tab" href="#projectsTab">
|
||||
Projects
|
||||
</a>
|
||||
</li >
|
||||
<li>
|
||||
<a data-toggle="tab" href="#dataProviderTab">
|
||||
Data Providers
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-toggle="tab" href="#organizationsTab" >
|
||||
Organizations
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-toggle="tab" href="#peopleTab" >
|
||||
People
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="pubsTab" class="tab-pane fade in active panel-body">
|
||||
<div class = "text-right" *ngIf = "searchPublicationsComponent.totalResults > 10" ><a [href] = "linkToSearchPublications" >Show all</a></div>
|
||||
<search-result [(results)]="searchPublicationsComponent.results" [(status)]= "searchPublicationsComponent.status"></search-result>
|
||||
</div>
|
||||
<div id="dataTab" class="tab-pane fade in active panel-body" >
|
||||
<!--search-result [results]="results" [page]="page"></search-result-->
|
||||
</div>
|
||||
<div id="projectsTab" class="tab-pane fade in active panel-body" >
|
||||
<!--search-result [results]="results" [page]="page"></search-result-->
|
||||
</div>
|
||||
<div id="dataProviderTab" class="tab-pane fade in active panel-body" >
|
||||
<!--search-result [results]="results" [page]="page"></search-result-->
|
||||
</div>
|
||||
<div id="organizationsTab" class="tab-pane fade in active panel-body" >
|
||||
<!--search-result [results]="results" [page]="page"></search-result-->
|
||||
</div>
|
||||
<div id="peopleTab" class="tab-pane fade in active panel-body" >
|
||||
<!--search-result [results]="results" [page]="page"></search-result-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class SearchComponent {
|
||||
private sub: any;
|
||||
private pageTitle = "Search in OpenAIRE"
|
||||
private keyword:string = "";
|
||||
private publications:string[];
|
||||
private datasets:string[];
|
||||
private projectsTab:string[];
|
||||
private dataproviders:string[];
|
||||
private organizations:string[];
|
||||
private people:string[];
|
||||
|
||||
private activeTab = "datasets";
|
||||
private linkToSearchPublications = "";
|
||||
|
||||
private searchPublicationsComponent : SearchPublicationsComponent;
|
||||
//TODO add more viewchild for other entities
|
||||
|
||||
constructor ( private route: ActivatedRoute,private _searchPublicationsService: SearchPublicationsService) {
|
||||
this.searchPublicationsComponent = new SearchPublicationsComponent(this.route, this._searchPublicationsService);;
|
||||
}
|
||||
|
||||
private ngOnInit() {
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.keyword = (params['keyword'])?params['keyword']:"";
|
||||
if(this.keyword !=null && this.keyword.length > 0){
|
||||
this.searchPublications();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
private ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
private searchPublications() {
|
||||
this.activeTab = "publications";
|
||||
this.searchPublicationsComponent.getResults(this.keyword, 1, 10);
|
||||
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications() + this.keyword;
|
||||
}
|
||||
private searchDatasets() {
|
||||
this.activeTab = "publications";
|
||||
}
|
||||
private searchProjects() {
|
||||
this.activeTab = "publications";
|
||||
}
|
||||
private searchDataProviders() {
|
||||
this.activeTab = "publications";
|
||||
}
|
||||
private searchOrganizations() {
|
||||
this.activeTab = "publications";
|
||||
}
|
||||
private searchPeople() {
|
||||
this.activeTab = "publications";
|
||||
}
|
||||
|
||||
private keywordChanged($event){
|
||||
this.keyword = $event.value;
|
||||
this.activeTab = "datasets";
|
||||
this.searchPublications();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ import {AdvancedSearchFormComponent} from './searchUtils/advancedSearchForm.comp
|
|||
import { SearchPublicationsComponent } from './searchPublications.component';
|
||||
import { AdvancedSearchPublicationsComponent } from './advancedSearchPublications.component';
|
||||
|
||||
|
||||
import {SearchComponent} from './find/search.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -40,7 +40,8 @@ import { AdvancedSearchPublicationsComponent } from './advancedSearchPublication
|
|||
SearchFilterComponent,
|
||||
AdvancedSearchFormComponent,
|
||||
SearchPublicationsComponent,
|
||||
AdvancedSearchPublicationsComponent
|
||||
AdvancedSearchPublicationsComponent,
|
||||
SearchComponent
|
||||
|
||||
|
||||
],
|
||||
|
@ -50,9 +51,8 @@ import { AdvancedSearchPublicationsComponent } from './advancedSearchPublication
|
|||
exports: [
|
||||
SearchAllComponent,
|
||||
AdvancedSearchPublicationsComponent,
|
||||
SearchPublicationsComponent
|
||||
|
||||
|
||||
SearchPublicationsComponent,
|
||||
SearchComponent
|
||||
]
|
||||
})
|
||||
export class SearchModule { }
|
||||
|
|
|
@ -5,111 +5,107 @@ import { Filter, Value} from './searchUtils/searchHelperClasses.class';
|
|||
|
||||
import {SearchPublicationsService} from '../services/searchPublications.service';
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {OpenaireProperties} from '../utils/properties/openaireProperties';
|
||||
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-publications',
|
||||
template: `
|
||||
|
||||
<search-page pageTitle="Search Publications" type="publication" [(filters)] = "filters"
|
||||
[(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
|
||||
[(page)] = "page" [(size)] = "size" (queryChange)="queryChanged($event)" >
|
||||
[(page)] = "page" [(size)] = "size" [(status)] = "status" (queryChange)="queryChanged($event)" >
|
||||
</search-page>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
export class SearchPublicationsComponent {
|
||||
private results =[];
|
||||
public results =[];
|
||||
private filters =[];
|
||||
private totalResults:number = 0 ;
|
||||
public totalResults:number = 0 ;
|
||||
public status:number;
|
||||
private keyword = '';
|
||||
private page :number = 1;
|
||||
private size :number = 10;
|
||||
private sub: any;
|
||||
|
||||
constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) {
|
||||
this.results =[];
|
||||
this.filters =[];
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status =errorCodes.LOADING;
|
||||
|
||||
this.getResults(this.keyword, this.page, this.size);
|
||||
|
||||
for(var i=0; i<5 ; i++){
|
||||
var values = [];
|
||||
for(var j=0; j<10 ; j++){
|
||||
var value:Value = {name: "name"+j, id: "filter_"+i+ "_id_"+j, number:j, selected:false}
|
||||
values.push(value);
|
||||
}
|
||||
values.sort((n2,n1) => {
|
||||
if (n1.number > n2.number) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (n1.number < n2.number) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
var filter:Filter = {title: "title"+i, filterId: "filter_"+i, originalFilterId: "filter_"+i, values : values, countSelectedValues:0, "filterOperator": 'and'}
|
||||
if(i==0) {
|
||||
var values = [];
|
||||
for(var j=0; j<10 ; j++){
|
||||
var value:Value = {name: "MYname"+j, id: "MYfilter_"+i+ "_id_"+j, number:j, selected:false}
|
||||
values.push(value);
|
||||
}
|
||||
values.sort((n2,n1) => {
|
||||
if (n1.number > n2.number) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (n1.number < n2.number) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'}
|
||||
this.filters.push(filter1);
|
||||
}
|
||||
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
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.filters.push(filter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
private ngOnInit() {
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
let page = (params['page']=== undefined)?1:+params['page'];
|
||||
let size = (params['size']=== undefined)?10:+params['size'];
|
||||
this.page = ( page <= 0 ) ? 1 : page;
|
||||
this.size = ( size <= 0 ) ? 10 : size;
|
||||
this.keyword = (params['keyword']?params['keyword']:'');
|
||||
this.keyword = (params['keyword']?params['keyword']:'');
|
||||
for(var i=0; i<5 ; i++){
|
||||
var values = [];
|
||||
for(var j=0; j<10 ; j++){
|
||||
var value:Value = {name: "name"+j, id: "filter_"+i+ "_id_"+j, number:j, selected:false}
|
||||
values.push(value);
|
||||
}
|
||||
values.sort((n2,n1) => {
|
||||
if (n1.number > n2.number) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (n1.number < n2.number) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
var filter:Filter = {title: "title"+i, filterId: "filter_"+i, originalFilterId: "filter_"+i, values : values, countSelectedValues:0, "filterOperator": 'and'}
|
||||
if(i==0) {
|
||||
var values = [];
|
||||
for(var j=0; j<10 ; j++){
|
||||
var value:Value = {name: "MYname"+j, id: "MYfilter_"+i+ "_id_"+j, number:j, selected:false}
|
||||
values.push(value);
|
||||
}
|
||||
values.sort((n2,n1) => {
|
||||
if (n1.number > n2.number) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (n1.number < n2.number) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'}
|
||||
this.filters.push(filter1);
|
||||
this.getResults(this.keyword, this.page, this.size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
private ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
sub: any;
|
||||
getResults(parameters:string, page: number, size: number){
|
||||
public getResults(parameters:string, page: number, size: number){
|
||||
console.info("getResults: Execute search query "+parameters);
|
||||
|
||||
this._searchPublicationsService.searchPublications(parameters, page, size).subscribe(
|
||||
|
@ -117,10 +113,21 @@ export class SearchPublicationsComponent {
|
|||
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");
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status = errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import {SearchResult} from '../../utils/entities/searchResult';
|
|||
<!--p *ngFor="let result of results">
|
||||
<search-result [id]="result.id" [title]="result.title" [page]="page"></search-result>
|
||||
</p-->
|
||||
<search-result [results]="results" [totalResults]="totalResults" [page]="page"></search-result>
|
||||
<search-result [results]="results" [totalResults]="totalResults" [status]=status [page]="page"></search-result>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -59,6 +59,7 @@ export class SearchPageComponent {
|
|||
@Input() type;
|
||||
@Input() page:number = 1;
|
||||
@Input() size: number = 10;
|
||||
@Input() status: number;
|
||||
@Input() totalResults: number = 0;
|
||||
@Input() keyword:string = '';
|
||||
|
||||
|
@ -71,6 +72,7 @@ export class SearchPageComponent {
|
|||
|
||||
ngOnInit() {
|
||||
console.info(" page - value: "+this.page);
|
||||
console.log(" search page st: "+this.status);
|
||||
//this.totalResults = this.totalResults;
|
||||
console.info("searchPage total="+this.totalResults);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {SearchResult} from '../../utils/entities/searchResult';
|
||||
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-result',
|
||||
template: `
|
||||
<ul class="list-unstyled">
|
||||
Status:{{status}}
|
||||
<div *ngIf="status == errorCodes.LOADING" class="alert alert-info" role="alert">Loading...</div>
|
||||
<div *ngIf="status == errorCodes.NONE" class="alert alert-info" role="alert">No Results found</div>
|
||||
<div *ngIf="status == errorCodes.ERROR" class="alert alert-warning" role="alert">An Error Occured</div>
|
||||
<div *ngIf="status == errorCodes.NOT_AVAILABLE" class="alert alert-danger" role="alert">Service not available</div>
|
||||
|
||||
<li *ngFor="let result of results">
|
||||
<h4>
|
||||
|
@ -64,6 +70,8 @@ export class SearchResultComponent {
|
|||
@Input() page: number;
|
||||
@Input() totalResults: number;
|
||||
@Input() results: SearchResult[];
|
||||
@Input() status: number;
|
||||
errorCodes:ErrorCodes = new ErrorCodes();
|
||||
|
||||
private errorMessage: string = "";
|
||||
/*
|
||||
|
@ -93,5 +101,6 @@ export class SearchResultComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.log(" search page st: "+this.status);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import 'rxjs/Rx';
|
|||
<li><a routerLink="/linking">Linking</a></li>
|
||||
<li><a routerLink="/bulk-linking">Bulk Linking</a></li>
|
||||
<li><a routerLink="/deposit">Deposit</a></li>
|
||||
<li><a routerLink="/search-publications">Search Publications</a></li>
|
||||
<li><a routerLink="/advanced-search-publications">Advanced Search Publications</a></li>
|
||||
<li><a routerLink="/search/find/publications">Search Publications</a></li>
|
||||
<li><a routerLink="/search/advanced/publications">Advanced Search Publications</a></li>
|
||||
<li><a routerLink="/deposit">Deposit</a></li>
|
||||
<li><a [queryParams]="{articleId: 'od_______908::3a5b2885656a91307156325644e73b92'}" routerLink="search/publication" >Publication </a></li>
|
||||
<li><a [queryParams]="{datasetId: 'datacite____::430ac1c41b7f99b7b543ef737dc41a74'}" routerLink="search/dataset" >Dataset </a></li>
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
export class OpenaireProperties {
|
||||
//landing Pages
|
||||
private static baseSearchLink="/"
|
||||
private static baseSearchLink="/";
|
||||
private static searchLinkToPublication = "search/publication?articleId=";
|
||||
private static searchLinkToProject = "search/project?projectId=";
|
||||
private static searchLinkToPerson = "search/person?personId=";
|
||||
private static searchLinkToDataProvider = "search/dataprovider?datasourceId=";
|
||||
private static searchLinkToDataset = "search/dataset?datasetId=";
|
||||
private static searchLinkToOrganization = "search/organization?organizationId=";
|
||||
private static searchLinkToPublications = "search-publications?keyword=";
|
||||
|
||||
// Services - APIs
|
||||
|
||||
|
@ -67,6 +68,10 @@ export class OpenaireProperties {
|
|||
public static getsearchLinkToDataProvider():string{
|
||||
return this.searchLinkToDataProvider;
|
||||
}
|
||||
//searchPages
|
||||
public static getLinkToSearchPublications():string{
|
||||
return this.baseSearchLink + this.searchLinkToPublications;
|
||||
}
|
||||
|
||||
// Services - APIs' getters
|
||||
public static getSearchAPIURL():string{
|
||||
|
@ -131,3 +136,10 @@ export class OpenaireProperties {
|
|||
return this.helpdesk;
|
||||
}
|
||||
}
|
||||
export class ErrorCodes {
|
||||
public LOADING = 0;
|
||||
public DONE = 1;
|
||||
public NONE = 2;
|
||||
public ERROR = 3;
|
||||
public NOT_AVAILABLE = 4;
|
||||
}
|
||||
|
|
|
@ -66,8 +66,8 @@ app.get('/search/dataset', ngApp);
|
|||
app.get('/search/dataprovider', ngApp);
|
||||
app.get('/search/publication', ngApp);
|
||||
app.get('/search', ngApp);
|
||||
app.get('/search-publications', ngApp);
|
||||
app.get('/advanced-search-publications', ngApp);
|
||||
app.get('/search/find/publications', ngApp);
|
||||
app.get('/search/advanced/publications', ngApp);
|
||||
app.get('/deposit', ngApp);
|
||||
app.get('/deposit-result', ngApp);
|
||||
app.get('/error', ngApp);
|
||||
|
|
Loading…
Reference in New Issue