0">
{{searchUtils.totalResults}} {{type}}, page {{searchUtils.page}} of {{(totalPages())}}
@@ -20,6 +20,8 @@ export class SearchPagingComponent {
@Input() results;
@Input() baseUrl;
@Input() type;
+ @Input() parameterNames:string[];
+ @Input() parameterValues:string[];
// @Input() totalResults:number = 0;
constructor () {
diff --git a/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts b/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts
index 9500efb0..9c85670c 100644
--- a/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts
+++ b/portal-2/src/app/searchPages/searchUtils/searchResults.module.ts
@@ -3,29 +3,23 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {SearchResult} from '../../utils/entities/searchResult';
-// import {SearchPagingComponent} from './searchPaging.component';
-// import {SearchDownloadComponent} from './searchDownload.component';
import {SearchResultComponent} from './searchResult.component';
-// import{PagingModule} from '../../utils/paging.module';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
CommonModule, FormsModule,
RouterModule
- // ,PagingModule
- ],
+ ],
declarations: [
SearchResultComponent,
- // SearchPagingComponent,
- // SearchDownloadComponent,
+
],
providers:[
],
exports: [
- // SearchPagingComponent,
- // SearchDownloadComponent,
+
SearchResultComponent
]
diff --git a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts
index 38342979..33e82484 100644
--- a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts
+++ b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts
@@ -45,19 +45,27 @@ export class SearchDataprovidersComponent {
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status =errorCodes.LOADING;
+ this.searchUtils.page =1;
this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders();
}
public ngOnInit() {
this.searchPage.refineFields = this.refineFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
+ var firstLoad =true;
this.sub = this.route.queryParams.subscribe(params => {
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
+ var refine = true;
+ if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
+ refine = false;
+
+ }
+ firstLoad = false;
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
- this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size);
+ this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});
}
@@ -230,7 +238,9 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number)
this.searchUtils.totalResults = data[0];
console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
- this.filters = data[2];
+ if(refine){
+ this.filters = data[2];
+ }
this.searchPage.checkSelectedFilters(this.filters);
// this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
diff --git a/portal-2/src/app/searchPages/simple/searchDatasets.component.ts b/portal-2/src/app/searchPages/simple/searchDatasets.component.ts
index 866d7096..09eda275 100644
--- a/portal-2/src/app/searchPages/simple/searchDatasets.component.ts
+++ b/portal-2/src/app/searchPages/simple/searchDatasets.component.ts
@@ -45,6 +45,7 @@ export class SearchDatasetsComponent {
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status =errorCodes.LOADING;
+ this.searchUtils.page =1;
this.baseUrl = OpenaireProperties.getLinkToSearchDatasets();
}
@@ -52,14 +53,18 @@ export class SearchDatasetsComponent {
public ngOnInit() {
this.searchPage.refineFields = this.refineFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
-
+ var firstLoad =true;
this.sub = this.route.queryParams.subscribe(params => {
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
+ var refine = true;
+ if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
+ refine = false;
+ }
+ firstLoad = false;
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
- // this.getRefineResults();
- //this.getResults(this.searchUtils.keyword, this.searchUtils.page, this.searchUtils.size, "searchPage");
+
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
- this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size);
+ this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});
}
@@ -177,7 +182,9 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number
this.searchUtils.totalResults = data[0];
console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
- this.filters = data[2];
+ if(refine){
+ this.filters = data[2];
+ }
this.searchPage.checkSelectedFilters(this.filters);
this.searchPage.updateBaseUrlWithParameters(this.filters);
var errorCodes:ErrorCodes = new ErrorCodes();
diff --git a/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts b/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts
index a19213ea..055f2c7b 100644
--- a/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts
+++ b/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts
@@ -43,6 +43,7 @@ export class SearchOrganizationsComponent {
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status =errorCodes.LOADING;
+ this.searchUtils.page =1;
this.baseUrl = OpenaireProperties.getLinkToSearchOrganizations();
}
@@ -50,13 +51,19 @@ export class SearchOrganizationsComponent {
public ngOnInit() {
this.searchPage.refineFields = this.refineFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
-
+ var firstLoad = true;
this.sub = this.route.queryParams.subscribe(params => {
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
+ var refine = true;
+ if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
+ refine = false;
+
+ }
+ firstLoad = false;
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
- this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size);
+ this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});
}
@@ -92,7 +99,9 @@ export class SearchOrganizationsComponent {
this.searchUtils.totalResults = data[0];
console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
- this.filters = data[2];
+ if(refine){
+ this.filters = data[2];
+ }
this.searchPage.checkSelectedFilters(this.filters);
this.searchPage.updateBaseUrlWithParameters(this.filters);
var errorCodes:ErrorCodes = new ErrorCodes();
diff --git a/portal-2/src/app/searchPages/simple/searchPeople.component.ts b/portal-2/src/app/searchPages/simple/searchPeople.component.ts
index 98387214..65468b85 100644
--- a/portal-2/src/app/searchPages/simple/searchPeople.component.ts
+++ b/portal-2/src/app/searchPages/simple/searchPeople.component.ts
@@ -55,97 +55,16 @@ export class SearchPeopleComponent {
this.sub = this.route.queryParams.subscribe(params => {
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
this.searchUtils.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;
- }
+ this.getResults(this.searchUtils.keyword, false, this.searchUtils.page, this.searchUtils.size);
- 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.searchUtils.keyword, true, this.searchUtils.page, this.searchUtils.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++;
- }
- }
- }
- }
- }
});
}
public ngOnDestroy() {
this.sub.unsubscribe();
- }
-/*
- public getResults(parameters:string, page: number, searchUtils.size: number){
- console.info("getResults: Execute search query "+parameters);
-
- this._searchPeopleService.searchPeople(parameters, page, searchUtils.size).subscribe(
- data => {
- this.searchUtils.totalResults = data[0];
- console.info("search People total="+this.searchUtils.totalResults);
- this.results = data[1];
- var errorCodes:ErrorCodes = new ErrorCodes();
- this.searchUtils.status = errorCodes.DONE;
- if(this.searchUtils.totalResults == 0 ){
- this.searchUtils.status = errorCodes.NONE;
- }
- },
- err => {
- console.log(err);
- console.info("error");
- //TODO check erros (service not available, bad request)
- // if( ){
- // this.searchUtils.status = ErrorCodes.ERROR;
- // }
- var errorCodes:ErrorCodes = new ErrorCodes();
- this.searchUtils.status = errorCodes.NOT_AVAILABLE;
- }
- );
- }
-*/
+ }
public getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
diff --git a/portal-2/src/app/searchPages/simple/searchProjects.component.ts b/portal-2/src/app/searchPages/simple/searchProjects.component.ts
index cb62aa61..bc70b0d8 100644
--- a/portal-2/src/app/searchPages/simple/searchProjects.component.ts
+++ b/portal-2/src/app/searchPages/simple/searchProjects.component.ts
@@ -43,6 +43,7 @@ export class SearchProjectsComponent {
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status =errorCodes.LOADING;
+ this.searchUtils.page =1;
this.baseUrl = OpenaireProperties.getLinkToSearchProjects();
}
@@ -52,17 +53,22 @@ export class SearchProjectsComponent {
this.searchPage.fieldIdsMap = this.fieldIdsMap;
console.info(" ngOnInit SearchProjectsComponent "+this.refineFields.length);
//get refine field filters from url parameters
-
+ var firstLoad = true;
this.sub = this.route.queryParams.subscribe(params => {
//get keyword from url parameters
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
+ var refine = true;
+ if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
+ refine = false;
+ }
+ firstLoad = false;
//get page from url parameters
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
- this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size);
+ this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});
}
@@ -98,7 +104,9 @@ export class SearchProjectsComponent {
this.searchUtils.totalResults = data[0];
console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
- this.filters = data[2];
+ if(refine){
+ this.filters = data[2];
+ }
this.searchPage.checkSelectedFilters(this.filters);
// this.filters = this.searchPage.checkSelectedFilters(data[2]);
this.searchPage.updateBaseUrlWithParameters(this.filters);
diff --git a/portal-2/src/app/searchPages/simple/searchPublications.component.ts b/portal-2/src/app/searchPages/simple/searchPublications.component.ts
index 1bfffae1..72661d67 100644
--- a/portal-2/src/app/searchPages/simple/searchPublications.component.ts
+++ b/portal-2/src/app/searchPages/simple/searchPublications.component.ts
@@ -54,6 +54,7 @@ export class SearchPublicationsComponent {
constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) {
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status =errorCodes.LOADING;
+ this.searchUtils.page =1;
this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
}
@@ -62,13 +63,20 @@ export class SearchPublicationsComponent {
this.searchPage.refineFields = this.refineFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
this.searchPage.type = "publication";
-
+ var firstLoad =true;
this.sub = this.route.queryParams.subscribe(params => {
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
+ var refine = true;
+ if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
+ refine = false;
+
+ }
+ firstLoad = false;
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
- this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size);
+
+ this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});
}
@@ -209,7 +217,9 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number
this.searchUtils.totalResults = data[0];
console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
- this.filters = data[2];
+ if(refine){
+ this.filters = data[2];
+ }
this.searchPage.checkSelectedFilters(this.filters);
this.searchPage.updateBaseUrlWithParameters(this.filters);
var errorCodes:ErrorCodes = new ErrorCodes();
diff --git a/portal-2/src/app/utils/entities/searchResult.ts b/portal-2/src/app/utils/entities/searchResult.ts
index 3d760303..7eda80df 100644
--- a/portal-2/src/app/utils/entities/searchResult.ts
+++ b/portal-2/src/app/utils/entities/searchResult.ts
@@ -25,4 +25,6 @@ export class SearchResult {
OAIPMHURL: string;
compatibility: string;
countries: string[];
+ constructor(){}
+
}
diff --git a/portal-2/src/app/utils/paging.module.ts b/portal-2/src/app/utils/paging.module.ts
index 846867c2..dbf53c87 100644
--- a/portal-2/src/app/utils/paging.module.ts
+++ b/portal-2/src/app/utils/paging.module.ts
@@ -1,15 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
+import { RouterModule } from '@angular/router';
import {pagingFormatterNoLoad} from './pagingFormatterNoLoad.component';
-
+
import {PagingFormatter} from './pagingFormatter.component';
@NgModule({
imports: [
- CommonModule, FormsModule
+ CommonModule, FormsModule, RouterModule
],
declarations: [
pagingFormatterNoLoad,
diff --git a/portal-2/src/app/utils/pagingFormatter.component.ts b/portal-2/src/app/utils/pagingFormatter.component.ts
index 8cefd4bc..b7594c47 100644
--- a/portal-2/src/app/utils/pagingFormatter.component.ts
+++ b/portal-2/src/app/utils/pagingFormatter.component.ts
@@ -2,6 +2,7 @@ import {Component, Input} from '@angular/core';
import {Router} from '@angular/router';
import {DomSanitizer} from '@angular/platform-browser';
//Usage Example
+import {RouterHelper} from './routerHelper.class';
@Component({
selector: 'paging',
@@ -10,21 +11,21 @@ import {DomSanitizer} from '@angular/platform-browser';
0 ) && (getTotalPages() > 1) && ( 0 < currentPage && currentPage <= getTotalPages() ) " class="uk-pagination">
- - 1" >
+
- 1" >
- - 1" >
+
- 1" >
- - 0">{{currentPage -2}}
- - 0 ">{{currentPage -1}}
+ - 0">{{currentPage -2}}
+ - 0 ">{{currentPage -1}}
- {{currentPage}}
- - {{currentPage +1}}
- - {{currentPage +2}}
- - {{currentPage +3}}
- - {{currentPage +4}}
+ - {{currentPage +1}}
+ - {{currentPage +2}}
+ - {{currentPage +3}}
+ - {{currentPage +4}}
- - currentPage">
+
- currentPage">
@@ -38,6 +39,10 @@ export class PagingFormatter {
@Input() size: number=10;
@Input() totalResults: number = 10;
@Input() baseUrl:string="";
+ @Input() parameterNames:string[];
+ @Input() parameterValues:string[];
+
+ public routerHelper:RouterHelper = new RouterHelper();
constructor ( private _router: Router, private sanitizer:DomSanitizer) {
}
@@ -50,8 +55,8 @@ export class PagingFormatter {
return (((this.totalResults/this.size) == i )? i :(i+1)) ;
}
- onPage(pageNum: number){
- return this.sanitizer.bypassSecurityTrustUrl( this.baseUrl+((this.baseUrl.indexOf("?") > -1 )?'&':'?')+ "page=" + (pageNum));
-
- }
+ // onPage(pageNum: number){
+ // return this.sanitizer.bypassSecurityTrustUrl( this.baseUrl+((this.baseUrl.indexOf("?") > -1 )?'&':'?')+ "page=" + (pageNum));
+ //
+ // }
}
diff --git a/portal-2/src/app/utils/routerHelper.class.ts b/portal-2/src/app/utils/routerHelper.class.ts
index 0fd3ce92..dc0ee61b 100644
--- a/portal-2/src/app/utils/routerHelper.class.ts
+++ b/portal-2/src/app/utils/routerHelper.class.ts
@@ -9,6 +9,12 @@ export class RouterHelper {
obj[key]=value;
return obj;
+ }
+ public createQueryParamsPaging(keys:string[],values:string[],key:string,value:number){
+ var obj = this.createQueryParams(keys, values);
+ obj[key] = ""+value;
+ return obj;
+
}
public createQueryParams(keys:string[],values:string[]){
var obj ={};