Search Datasets and Organizations completed | bug fixed in searchPaging (totalPages has to be integer)
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43990 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
165220fdf4
commit
1f3e97cb96
|
@ -16,6 +16,8 @@ import { SearchComponent } from './searchPages/find/search.component';
|
|||
import { SearchPublicationsComponent } from './searchPages/searchPublications.component';
|
||||
import { SearchDataprovidersComponent } from './searchPages/searchDataproviders.component';
|
||||
import { SearchProjectsComponent } from './searchPages/searchProjects.component';
|
||||
import { SearchDatasetsComponent } from './searchPages/searchDatasets.component';
|
||||
import { SearchOrganizationsComponent } from './searchPages/searchOrganizations.component';
|
||||
import { AdvancedSearchPublicationsComponent } from './searchPages/advancedSearchPublications.component';
|
||||
import { DepositComponent } from './deposit/deposit.component';
|
||||
import { DepositResultComponent } from './deposit/depositResult.component';
|
||||
|
@ -28,9 +30,9 @@ import { SearchCompatibleDataprovidersComponent } from './searchPages/dataProvid
|
|||
const appRoutes: Routes = [
|
||||
{ path: '', component: SearchComponent, pathMatch: 'full' },
|
||||
{ path: 'claims', component: ClaimsAdminComponent },
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'claim', component: ClaimComponent },
|
||||
{ path: 'myclaims', component: MyClaimsComponent },
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'claim', component: ClaimComponent },
|
||||
{ path: 'myclaims', component: MyClaimsComponent },
|
||||
{ path: 'search/person', component: PersonComponent },
|
||||
{ path: 'search/project', component: ProjectComponent },
|
||||
{ path: 'search/organization', component: OrganizationComponent },
|
||||
|
@ -44,13 +46,15 @@ const appRoutes: Routes = [
|
|||
{ path: 'search/find/publications', component: SearchPublicationsComponent },
|
||||
{ path: 'search/find/dataproviders', component: SearchDataprovidersComponent },
|
||||
{ path: 'search/find/projects', component: SearchProjectsComponent },
|
||||
{ path: 'search/find/datasets', component: SearchDatasetsComponent },
|
||||
{ path: 'search/find/organizations', component: SearchOrganizationsComponent },
|
||||
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
|
||||
{ path: 'deposit', component: DepositComponent},
|
||||
{ path: 'deposit-results', component: DepositResultComponent},
|
||||
{ path: 'deposit-results', component: DepositResultComponent},
|
||||
{ path: 'test', component: TestComponent},
|
||||
{ path: 'search', component: SearchAllComponent },
|
||||
{ path: 'error', component: ErrorPageComponent},
|
||||
{ path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
|
||||
{ path: 'error', component: ErrorPageComponent},
|
||||
{ path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
|
||||
|
||||
];
|
||||
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
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 { SearchDataprovidersComponent } from '../searchDataproviders.component';
|
||||
import { SearchProjectsComponent } from '../searchProjects.component';
|
||||
import { SearchDatasetsComponent } from '../searchDatasets.component';
|
||||
import { SearchOrganizationsComponent } from '../searchOrganizations.component';
|
||||
|
||||
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
||||
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
||||
|
||||
import {SearchProjectsService} from '../../services/searchProjects.service';
|
||||
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
|
||||
|
||||
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
||||
|
||||
@Component({
|
||||
|
@ -35,7 +40,7 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
|||
</li>
|
||||
<li [class]="activeTab=='datasets'?'active':''" >
|
||||
<a data-toggle="tab" href="#dataTab">
|
||||
Datasets (-)
|
||||
Datasets ({{searchDatasetsComponent.totalResults}})
|
||||
</a>
|
||||
</li>
|
||||
<li >
|
||||
|
@ -50,7 +55,7 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
|||
</li>
|
||||
<li>
|
||||
<a data-toggle="tab" href="#organizationsTab" >
|
||||
Organizations (-)
|
||||
Organizations ({{searchOrganizationsComponent.totalResults}})
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -65,8 +70,8 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
|||
<search-result [(results)]="searchPublicationsComponent.results" [(status)]= "searchPublicationsComponent.status"></search-result>
|
||||
</div>
|
||||
<div id="dataTab" class="tab-pane fade in active panel-body" >
|
||||
<!--div class = "text-right" *ngIf = "searchPublicationsComponent.totalResults > 10" ><a [href] = "linkToSearchPublications" >View all {{searchPublicationsComponent.totalResults}} results</a></div>
|
||||
<search-result [(results)]="searchPublicationsComponent.results" [(status)]= "searchPublicationsComponent.status"></search-result-->
|
||||
<div class = "text-right" *ngIf = "searchDatasetsComponent.totalResults > 10" ><a [href] = "linkToSearchDatasets" >View all {{searchDatasetsComponent.totalResults}} results</a></div>
|
||||
<search-result [(results)]="searchDatasetsComponent.results" [(status)]= "searchDatasetsComponent.status"></search-result>
|
||||
</div>
|
||||
<div id="projectsTab" class="tab-pane fade in active panel-body" >
|
||||
<div class = "text-right" *ngIf = "searchProjectsComponent.totalResults > 10" ><a [href] = "linkToSearchProjects" >View all {{searchProjectsComponent.totalResults}} results</a></div>
|
||||
|
@ -77,8 +82,8 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
|||
<search-result [(results)]="searchDataProvidersComponent.results" [(status)]= "searchDataProvidersComponent.status"></search-result>
|
||||
</div>
|
||||
<div id="organizationsTab" class="tab-pane fade in active panel-body" >
|
||||
<!--<div class = "text-right" *ngIf = "searchPublicationsComponent.totalResults > 10" ><a [href] = "linkToSearchPublications" >View all {{searchPublicationsComponent.totalResults}} results</a></div>
|
||||
<search-result [(results)]="searchPublicationsComponent.results" [(status)]= "searchPublicationsComponent.status"></search-result>-->
|
||||
<div class = "text-right" *ngIf = "searchOrganizationsComponent.totalResults > 10" ><a [href] = "linkToSearchOrganizations" >View all {{searchOrganizationsComponent.totalResults}} results</a></div>
|
||||
<search-result [(results)]="searchOrganizationsComponent.results" [(status)]= "searchOrganizationsComponent.status"></search-result>
|
||||
</div>
|
||||
<div id="peopleTab" class="tab-pane fade in active panel-body" >
|
||||
<!--<div class = "text-right" *ngIf = "searchPublicationsComponent.totalResults > 10" ><a [href] = "linkToSearchPublications" >View all {{searchPublicationsComponent.totalResults}} results</a></div>
|
||||
|
@ -104,18 +109,28 @@ export class SearchComponent {
|
|||
private linkToSearchPublications = "";
|
||||
private linkToSearchProjects = "";
|
||||
private linkToSearchDataproviders = "";
|
||||
private linkToSearchDatasets = "";
|
||||
private linkToSearchOrganizations = "";
|
||||
|
||||
private searchPublicationsComponent : SearchPublicationsComponent;
|
||||
private searchDataProvidersComponent : SearchDataprovidersComponent;
|
||||
private searchProjectsComponent : SearchProjectsComponent;
|
||||
private searchDatasetsComponent: SearchDatasetsComponent;
|
||||
private searchOrganizationsComponent: SearchOrganizationsComponent;
|
||||
|
||||
//TODO add more viewchild for other entities
|
||||
|
||||
constructor ( private route: ActivatedRoute,private _searchPublicationsService: SearchPublicationsService,private _searchDataprovidersService: SearchDataprovidersService,private _searchProjectsService: SearchProjectsService) {
|
||||
constructor ( private route: ActivatedRoute,
|
||||
private _searchPublicationsService: SearchPublicationsService,
|
||||
private _searchDataprovidersService: SearchDataprovidersService,
|
||||
private _searchProjectsService: SearchProjectsService,
|
||||
private _searchDatasetsService: SearchDatasetsService,
|
||||
private _searchOrganizationsService: SearchOrganizationsService) {
|
||||
this.searchPublicationsComponent = new SearchPublicationsComponent(this.route, this._searchPublicationsService);
|
||||
this.searchDataProvidersComponent = new SearchDataprovidersComponent(this.route,this._searchDataprovidersService);
|
||||
this.searchProjectsComponent = new SearchProjectsComponent(this.route, this._searchProjectsService);;
|
||||
|
||||
this.searchProjectsComponent = new SearchProjectsComponent(this.route, this._searchProjectsService);
|
||||
this.searchDatasetsComponent = new SearchDatasetsComponent(this.route, this._searchDatasetsService);;
|
||||
this.searchOrganizationsComponent = new SearchOrganizationsComponent(this.route, this._searchOrganizationsService);;
|
||||
}
|
||||
|
||||
private ngOnInit() {
|
||||
|
@ -136,7 +151,9 @@ export class SearchComponent {
|
|||
this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications() + this.keyword;
|
||||
}
|
||||
private searchDatasets() {
|
||||
this.activeTab = "publications";
|
||||
this.activeTab = "datasets";
|
||||
this.searchDatasetsComponent.getResults(this.keyword, 1, 10);
|
||||
this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets() + this.keyword;
|
||||
}
|
||||
private searchProjects() {
|
||||
this.activeTab = "projects";
|
||||
|
@ -149,7 +166,9 @@ export class SearchComponent {
|
|||
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders() + this.keyword;
|
||||
}
|
||||
private searchOrganizations() {
|
||||
this.activeTab = "publications";
|
||||
this.activeTab = "organizations";
|
||||
this.searchOrganizationsComponent.getResults(this.keyword, 1, 10);
|
||||
this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations() + this.keyword;
|
||||
}
|
||||
private searchPeople() {
|
||||
this.activeTab = "publications";
|
||||
|
@ -160,6 +179,8 @@ export class SearchComponent {
|
|||
this.searchPublications();
|
||||
this.searchProjects();
|
||||
this.searchDataProviders();
|
||||
this.searchDatasets();
|
||||
this.searchOrganizations();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import { SearchPublicationsComponent } from './searchPublications.component';
|
|||
import { AdvancedSearchPublicationsComponent } from './advancedSearchPublications.component';
|
||||
import { SearchDataprovidersComponent } from './searchDataproviders.component';
|
||||
import { SearchProjectsComponent } from './searchProjects.component';
|
||||
import {SearchDatasetsComponent} from './searchDatasets.component';
|
||||
import {SearchOrganizationsComponent} from './searchOrganizations.component';
|
||||
|
||||
import {SearchComponent} from './find/search.component';
|
||||
import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatibleDataProviders.component';
|
||||
|
@ -50,9 +52,11 @@ import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatible
|
|||
SearchDataprovidersComponent,
|
||||
SearchComponent,
|
||||
SearchProjectsComponent,
|
||||
SearchCompatibleDataprovidersComponent
|
||||
SearchCompatibleDataprovidersComponent,
|
||||
SearchDatasetsComponent,
|
||||
SearchOrganizationsComponent
|
||||
],
|
||||
|
||||
],
|
||||
providers:[
|
||||
// SearchPublicationsService
|
||||
],
|
||||
|
@ -62,6 +66,8 @@ import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatible
|
|||
SearchPublicationsComponent,
|
||||
SearchProjectsComponent,
|
||||
SearchDataprovidersComponent,
|
||||
SearchDatasetsComponent,
|
||||
SearchOrganizationsComponent,
|
||||
SearchComponent,
|
||||
SearchCompatibleDataprovidersComponent
|
||||
]
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import { ActivatedRoute} from '@angular/router';
|
||||
|
||||
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
|
||||
|
||||
import {SearchDatasetsService} from '../services/searchDatasets.service';
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-datasets',
|
||||
template: `
|
||||
|
||||
<search-page pageTitle="Search Datasets" type="datasource" [(filters)] = "filters"
|
||||
[(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
|
||||
[(page)] = "page" [(size)] = "size" [(status)] = "status" [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" >
|
||||
</search-page>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
export class SearchDatasetsComponent {
|
||||
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 _searchDatasetsService: SearchDatasetsService ) {
|
||||
//this.results =[];
|
||||
//this.filters =[];
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status =errorCodes.LOADING;
|
||||
this.baseUrl = OpenaireProperties.getLinkToSearchDatasets();
|
||||
}
|
||||
|
||||
private ngOnInit() {
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.keyword = (params['keyword']?params['keyword']:'');
|
||||
this.page = (params['page']=== undefined)?1:+params['page'];
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
public getResults(parameters:string, page: number, size: number){
|
||||
console.info("getResults: Execute search query "+parameters);
|
||||
|
||||
this._searchDatasetsService.searchDatasets(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");
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status = errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import { ActivatedRoute} from '@angular/router';
|
||||
|
||||
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
|
||||
|
||||
import {SearchOrganizationsService} from '../services/searchOrganizations.service';
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
|
||||
|
||||
@Component({
|
||||
selector: 'search-organizations',
|
||||
template: `
|
||||
|
||||
<search-page pageTitle="Search Organizations" type="datasource" [(filters)] = "filters"
|
||||
[(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
|
||||
[(page)] = "page" [(size)] = "size" [(status)] = "status" [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" >
|
||||
</search-page>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
export class SearchOrganizationsComponent {
|
||||
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 _searchOrganizationsService: SearchOrganizationsService ) {
|
||||
//this.results =[];
|
||||
//this.filters =[];
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status =errorCodes.LOADING;
|
||||
this.baseUrl = OpenaireProperties.getLinkToSearchOrganizations();
|
||||
}
|
||||
|
||||
private ngOnInit() {
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.keyword = (params['keyword']?params['keyword']:'');
|
||||
this.page = (params['page']=== undefined)?1:+params['page'];
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
public getResults(parameters:string, page: number, size: number){
|
||||
console.info("getResults: Execute search query "+parameters);
|
||||
|
||||
this._searchOrganizationsService.searchOrganizations(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");
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.status = errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import {Observable} from 'rxjs/Observable';
|
|||
<paging [currentPage]="page" [totalResults]="totalResults" [baseUrl]="baseUrl" [size]="size"> </paging>
|
||||
</div>
|
||||
<div class="text-left" *ngIf="results && results.length> 0">
|
||||
{{totalResults}} documents, page {{page}} of {{(totalResults/size)}}
|
||||
{{totalResults}} documents, page {{page}} of {{(currentPage())}}
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
@ -25,7 +25,15 @@ export class SearchPagingComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
currentPage(): number {
|
||||
let curPage: any = this.totalResults/this.size;
|
||||
if(!(Number.isInteger(curPage))) {
|
||||
curPage = (parseInt(curPage, 10) + 1);
|
||||
}
|
||||
return curPage;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,9 +37,13 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="result.publisher != undefined && result.publisher != ''">Publisher: {{result.publisher}}</div>
|
||||
|
||||
<div *ngIf="result.country != undefined && result.country != ''">Country: {{result.country}}</div>
|
||||
|
||||
<div *ngIf="result['projects'] != undefined">
|
||||
<span> Projects: </span>
|
||||
<span *ngFor="let project of result['projects'] let i=index">
|
||||
<span *ngFor="let project of result['projects'].slice(0,15) let i=index">
|
||||
<a *ngIf="project.url != undefined" href="{{project.url}}">
|
||||
{{project['funderShortname']?project['funderShortname']:project['funderName']}}
|
||||
| {{ project['acronym']?project['acronym']:project['title']}} ({{project.code}})
|
||||
|
@ -50,6 +54,7 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
|||
</p>
|
||||
<span *ngIf="i < result['projects'].length-1"> ,</span>
|
||||
</span>
|
||||
<span *ngIf="result['projects'].length > 15">...</span>
|
||||
</div>
|
||||
|
||||
<blockquote *ngIf="result.description != undefined && result.description != ''">
|
||||
|
|
|
@ -41,23 +41,17 @@ export class OrganizationService {
|
|||
|
||||
if(data[0] != null) {
|
||||
mydata = data[0];
|
||||
if(mydata.hasOwnProperty("legalshortname")) {
|
||||
if(mydata.hasOwnProperty("websiteurl")) {
|
||||
this.organizationInfo.title = {"name": mydata.legalshortname, "url": mydata.websiteurl};
|
||||
} else {
|
||||
this.organizationInfo.title = {"name": mydata.legalshortname, "url": ''};
|
||||
}
|
||||
|
||||
if(mydata.hasOwnProperty("websiteurl")) {
|
||||
this.organizationInfo.title = {"name": mydata.legalshortname, "url": mydata.websiteurl};
|
||||
} else {
|
||||
this.organizationInfo.title = {"name": mydata.legalshortname, "url": ''};
|
||||
}
|
||||
|
||||
if(mydata.hasOwnProperty("legalname")) {
|
||||
this.organizationInfo.name = mydata.legalname;
|
||||
if(this.organizationInfo.title == undefined) {
|
||||
if(mydata.hasOwnProperty("websiteurl")) {
|
||||
this.organizationInfo.title = {"name": mydata.legalname, "url": mydata.websiteurl};
|
||||
} else {
|
||||
this.organizationInfo.title = {"name": mydata.legalname, "url": ''};
|
||||
}
|
||||
}
|
||||
this.organizationInfo.name = mydata.legalname;
|
||||
|
||||
if(this.organizationInfo.title.name == '') {
|
||||
this.organizationInfo.title.name = this.organizationInfo.name;
|
||||
}
|
||||
|
||||
if(mydata.hasOwnProperty("country")) {
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {OpenaireProperties} from '../utils/properties/openaireProperties';
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
|
||||
@Injectable()
|
||||
export class SearchDatasetsService {
|
||||
private sizeOfDescription: number = 497;
|
||||
|
||||
constructor(private http: Http) {}
|
||||
|
||||
searchDatasets (params: string, page: number, size: number):any {
|
||||
|
||||
console.info("In searchDatasets");
|
||||
|
||||
let link = OpenaireProperties.getSearchAPIURL()+"datasets";
|
||||
|
||||
let url = link+"?";
|
||||
if(params != '') {
|
||||
url += "q="+params+"&page="+page+"&size="+size;
|
||||
} else {
|
||||
url += "page="+page+"&size="+size;
|
||||
}
|
||||
|
||||
return this.http.get(url)
|
||||
.map(res => <any> res.json())
|
||||
.do(res => console.info(res))
|
||||
//.map(res => []);
|
||||
.map(res => [res['meta'].total, this.parseResults(res['results'])])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = length > 1 ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
|
||||
result['title'] = {"name": '', "url": '', "accessMode": ''};
|
||||
|
||||
if(Array.isArray(resData['title'])) {
|
||||
result['title'].name = resData['title'][0].content;
|
||||
} else {
|
||||
result['title'].name = resData['title'].content;
|
||||
}
|
||||
|
||||
result['title'].url = OpenaireProperties.getsearchLinkToDataset();
|
||||
result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(resData['bestlicense'].hasOwnProperty("classid")) {
|
||||
result['title'].accessMode = resData['bestlicense'].classid;
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = relLength > 1 ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
if(relation['to'].class == "hasAuthor") {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"name": string, "url": string}>();
|
||||
}
|
||||
|
||||
result['authors'].push({"name": relation.fullname, "url": OpenaireProperties.getsearchLinkToPerson()+relation['to'].content});
|
||||
} else if(relation['to'].class == "isProducedBy") {
|
||||
if(result['projects'] == undefined) {
|
||||
result['projects'] = new Array<
|
||||
{ "url": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = result['projects'].length;
|
||||
|
||||
result['projects'][countProjects] = {
|
||||
"url": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
result['projects'][countProjects]['url'] =
|
||||
OpenaireProperties.getsearchLinkToProject() + relation['to'].content;
|
||||
result['projects'][countProjects]['acronym'] = relation.acronym;
|
||||
result['projects'][countProjects]['title'] = relation.title;
|
||||
result['projects'][countProjects]['code'] = relation.code;
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = fundingLength > 1 ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
result['projects'][countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
result['projects'][countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.year = resData.dateofacceptance.split('-')[0];
|
||||
|
||||
if(!Array.isArray(resData.description)) {
|
||||
result.description = resData.description;
|
||||
} else {
|
||||
result.description = resData.description[0];
|
||||
}
|
||||
if(result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription)+"...";
|
||||
}
|
||||
|
||||
result.embargoEndDate = resData.embargoenddate;
|
||||
|
||||
if(!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
} else {
|
||||
for(let i=0; i<resData.publisher.length; i++) {
|
||||
if(result.publisher != undefined){
|
||||
result.publisher += ', '+resData['publisher'][i];
|
||||
} else {
|
||||
result.publisher = resData['publisher'][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {OpenaireProperties} from '../utils/properties/openaireProperties';
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
|
||||
@Injectable()
|
||||
export class SearchOrganizationsService {
|
||||
|
||||
constructor(private http: Http) {}
|
||||
|
||||
searchOrganizations (params: string, page: number, size: number):any {
|
||||
|
||||
console.info("In searchOrganizations");
|
||||
|
||||
let link = OpenaireProperties.getSearchAPIURL()+"organizations";
|
||||
|
||||
let url = link+"?";
|
||||
if(params != '') {
|
||||
url += "q="+params+"&page="+page+"&size="+size;
|
||||
} else {
|
||||
url += "page="+page+"&size="+size;
|
||||
}
|
||||
|
||||
return this.http.get(url)
|
||||
.map(res => <any> res.json())
|
||||
.do(res => console.info(res))
|
||||
//.map(res => []);
|
||||
.map(res => [res['meta'].total, this.parseResults(res['results'])])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = length > 1 ? data[i]['result']['metadata']['oaf:entity']['oaf:organization'] : data['result']['metadata']['oaf:entity']['oaf:organization'];
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
|
||||
result['title'] = {"name": '', "url": '', "accessMode": ''};
|
||||
|
||||
result['title'].name = resData.legalshortname;
|
||||
if(result['title'].name == '') {
|
||||
result['title'].name = resData.legalname;
|
||||
}
|
||||
|
||||
result['title'].url = OpenaireProperties.getsearchLinkToOrganization();
|
||||
result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = relLength > 1 ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
if(relation['to'].class == "isParticipant") {
|
||||
if(result['projects'] == undefined) {
|
||||
result['projects'] = new Array<
|
||||
{ "url": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = result['projects'].length;
|
||||
|
||||
result['projects'][countProjects] = {
|
||||
"url": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
result['projects'][countProjects]['url'] =
|
||||
OpenaireProperties.getsearchLinkToProject() + relation['to'].content;
|
||||
result['projects'][countProjects]['acronym'] = relation.acronym;
|
||||
result['projects'][countProjects]['title'] = relation.title;
|
||||
result['projects'][countProjects]['code'] = relation.code;
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = fundingLength > 1 ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
result['projects'][countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
result['projects'][countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.country.hasOwnProperty("classname")) {
|
||||
result.country = resData.country.classname;
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
|
@ -115,7 +115,11 @@ export class SearchPublicationsService {
|
|||
|
||||
result.year = resData.dateofacceptance.split('-')[0];
|
||||
|
||||
result.description = resData.description;
|
||||
if(!Array.isArray(resData.description)) {
|
||||
result.description = resData.description;
|
||||
} else {
|
||||
result.description = resData.description[0];
|
||||
}
|
||||
if(result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription)+"...";
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ import { SearchOrcidService } from './searchOrcid.service';
|
|||
import {SearchPublicationsService} from './searchPublications.service';
|
||||
import {DataProviderService} from './dataProvider.service';
|
||||
import {SearchDataprovidersService} from './searchDataproviders.service';
|
||||
import {SearchDatasetsService} from './searchDatasets.service';
|
||||
import {SearchOrganizationsService} from './searchOrganizations.service';
|
||||
|
||||
import {SearchProjectsService} from './searchProjects.service';
|
||||
|
||||
|
@ -32,9 +34,8 @@ import {SearchProjectsService} from './searchProjects.service';
|
|||
PersonService, ProjectService, PublicationService, SearchCrossrefService,
|
||||
SearchCrossrefService, SearchDataciteService, SearchOrcidService,
|
||||
SearchPublicationsService, SearchDataprovidersService, DataProviderService,
|
||||
SearchProjectsService
|
||||
|
||||
],
|
||||
SearchProjectsService, SearchDatasetsService, SearchOrganizationsService
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
|
|
|
@ -25,10 +25,10 @@ import 'rxjs/Rx';
|
|||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Search <span class=""></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/search/find/publications">Publications</a></li>
|
||||
<li><a href="/search/find/">Datasets</a></li>
|
||||
<li><a href="/search/find/datasets">Datasets</a></li>
|
||||
<li><a href="/search/find/projects">Projects</a></li>
|
||||
<li><a href="/search/find/dataproviders">Data Providers</a></li>
|
||||
<li><a href="/search/find/">Organizations</a></li>
|
||||
<li><a href="/search/find/organizations">Organizations</a></li>
|
||||
<li><a href="/search/find/">People</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#">Separated link</a></li>
|
||||
|
|
|
@ -11,8 +11,9 @@ export class OpenaireProperties {
|
|||
private static searchLinkToPublications = "search/find/publications?keyword=";
|
||||
private static searchLinkToDataProviders = "search/find/dataproviders?keyword=";
|
||||
private static searchLinkToProjects = "search/find/projects?keyword=";
|
||||
private static searchLinkToDatasets = "search/find/datasets?keyword=";
|
||||
private static searchLinkToOrganizations = "search/find/organizations?keyword=";
|
||||
|
||||
getLinkToSearchProjects
|
||||
// Services - APIs
|
||||
|
||||
// public claimsAPIURL = "http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/"
|
||||
|
@ -82,6 +83,12 @@ getLinkToSearchProjects
|
|||
public static getLinkToSearchDataProviders():string{
|
||||
return this.baseSearchLink + this.searchLinkToDataProviders;
|
||||
}
|
||||
public static getLinkToSearchDatasets():string{
|
||||
return this.baseSearchLink + this.searchLinkToDatasets;
|
||||
}
|
||||
public static getLinkToSearchOrganizations():string{
|
||||
return this.baseSearchLink + this.searchLinkToOrganizations;
|
||||
}
|
||||
|
||||
// Services - APIs' getters
|
||||
public static getSearchAPIURL():string{
|
||||
|
|
|
@ -71,6 +71,8 @@ app.get('/search/find/publications', ngApp);
|
|||
app.get('/search/advanced/publications', ngApp);
|
||||
app.get('/search/find/dataproviders', ngApp);
|
||||
app.get('/search/find/projects', ngApp);
|
||||
app.get('/search/find/datasets', ngApp);
|
||||
app.get('/search/find/organizations', ngApp);
|
||||
app.get('/deposit', ngApp);
|
||||
app.get('/deposit-result', ngApp);
|
||||
app.get('/error', ngApp);
|
||||
|
|
Loading…
Reference in New Issue