diff --git a/searchPages/searchDataProviders.component.ts b/searchPages/searchDataProviders.component.ts
new file mode 100644
index 00000000..53fccf28
--- /dev/null
+++ b/searchPages/searchDataProviders.component.ts
@@ -0,0 +1,206 @@
+import {Component, Input, ViewChild} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
+import {AdvancedField} from './searchUtils/searchHelperClasses.class';
+import {SearchDataprovidersService} from '../services/searchDataproviders.service';
+import {ErrorCodes} from '../utils/properties/errorCodes';
+import {ErrorMessagesComponent} from '../utils/errorMessages.component';
+import {SearchFields} from '../utils/properties/searchFields';
+import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
+
+import {EnvProperties} from '../utils/properties/env-properties';
+import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component";
+
+
+@Component({
+ selector: 'search-dataproviders',
+ template: `
+
+
+
+
+ `
+ })
+
+export class SearchDataProvidersComponent {
+ private errorCodes: ErrorCodes;
+ private errorMessages: ErrorMessagesComponent;
+@Input() piwikSiteId = null;
+@Input() customFilter:SearchCustomFilter= null;
+ public results =[];
+ public filters =[];
+ public searchUtils:SearchUtilsClass = new SearchUtilsClass();
+ public searchFields:SearchFields = new SearchFields();
+
+ public fieldIds: string[] = this.searchFields.DATASOURCE_ADVANCED_FIELDS;
+ public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS;
+ public selectedFields:AdvancedField[] = [];
+
+ public resourcesQuery = "(oaftype exact datasource)";
+ public csvParams: string;
+ public disableForms: boolean = false;
+ public loadPaging: boolean = true;
+ public oldTotalResults: number = 0;
+ public pagingLimit: number = 0;
+ public isPiwikEnabled;
+ properties:EnvProperties;
+
+ public refineFields: string[] = this.searchFields.DATASOURCE_REFINE_FIELDS;
+ @ViewChild(NewSearchPageComponent) searchPage: NewSearchPageComponent;
+ @Input() simpleView: boolean = true;
+ simpleSearchLink: string = "";
+ advancedSearchLink: string = "";
+ @Input() hasPrefix: boolean = true;
+ @Input() openaireLink: string;
+ constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService ) {
+ this.results =[];
+ this.errorCodes = new ErrorCodes();
+ this.errorMessages = new ErrorMessagesComponent();
+ this.searchUtils.status = this.errorCodes.LOADING;
+
+ //console.info("Con -base url:"+this.searchUtils.baseUrl );
+
+ }
+ ngOnInit() {
+ this.route.data
+ .subscribe((data: { envSpecific: EnvProperties }) => {
+ this.properties= data.envSpecific;
+ this.simpleSearchLink = this.properties.searchLinkToDataProviders;
+ this.advancedSearchLink = this.properties.searchLinkToAdvancedDataProviders;
+ this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink;
+ this.pagingLimit = data.envSpecific.pagingLimit;
+ this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
+
+ });
+
+ var firstLoad = true;
+ this.sub = this.route.queryParams.subscribe(params => {
+ this.loadPaging = true;
+ if(params['page'] && this.searchUtils.page != params['page']) {
+ this.loadPaging = false;
+ this.oldTotalResults = this.searchUtils.totalResults;
+ }
+ var refine = true;
+ if (this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) && this.filters && !firstLoad) {
+ refine = false;
+
+ }
+ let page = (params['page']=== undefined)?0:+params['page'];
+ this.searchUtils.page = ( page < 1 ) ? 1 : page;
+
+ this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
+ if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
+ this.searchUtils.size = 10;
+ }
+
+ this.searchPage.fieldIds = this.fieldIds;
+ this.selectedFields =[];
+ this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, "datasource");
+
+ // this.searchPage.selectedFields = this.selectedFields;
+ // this.searchPage.fieldIdsMap = this.fieldIdsMap;
+ // this.searchPage.customFilter = this.customFilter;
+ // this.searchPage.getSelectedFiltersFromUrl(params);
+ this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
+ });
+ }
+ ngOnDestroy() {
+ this.sub.unsubscribe();
+ }
+ sub: any;
+ public getResults(parameters:string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null){
+ if(page > this.pagingLimit ) {
+ size=0;
+ }
+ if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
+ if(parameters!= null && parameters != '' ) {
+ this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))";
+ }else{
+ this.csvParams ="&fq="+this.resourcesQuery;
+ }
+ this.csvParams += (refineFieldsFilterQuery?refineFieldsFilterQuery:'');
+
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.LOADING;
+ //this.searchPage.openLoading();
+ this.disableForms = true;
+ this.results = [];
+ this.searchUtils.totalResults = 0;
+
+ //console.info("Advanced Search for Content Providers: Execute search query "+parameters);
+ this._searchDataProvidersService.advancedSearchDataproviders(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery).subscribe(
+ data => {
+ this.searchUtils.totalResults = data[0];
+ this.results = data[1];
+ if (refine) {
+ this.filters = this.searchPage.prepareFiltersToShow(data[2]);
+ }else{
+ this.searchPage.buildPageURLParameters(this.filters, false);
+ }
+ // this.searchPage.updateBaseUrlWithParameters();
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.DONE;
+ if(this.searchUtils.totalResults == 0 ){
+ this.searchUtils.status = this.errorCodes.NONE;
+ }
+ //this.searchPage.closeLoading();
+ this.disableForms = false;
+
+ if(this.searchUtils.status == this.errorCodes.DONE) {
+ // Page out of limit
+ let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
+ if(!(Number.isInteger(totalPages))) {
+ totalPages = (parseInt(totalPages, 10) + 1);
+ }
+ if(totalPages < page) {
+ this.searchUtils.totalResults = 0;
+ this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
+ }
+ }
+ },
+ err => {
+ //console.log(err);
+ this.handleError("Error getting content providers", err);
+ this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
+
+ //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;
+ /*if(err.status == '404') {
+ this.searchUtils.status = this.errorCodes.NOT_FOUND;
+ } else if(err.status == '500') {
+ this.searchUtils.status = this.errorCodes.ERROR;
+ } else {
+ this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
+ }*/
+ //this.searchPage.closeLoading();
+ this.disableForms = false;
+ }
+ );
+ }
+ }
+
+ private handleError(message: string, error) {
+ console.error("Content Providers advanced Search Page: "+message, error);
+ }
+}
diff --git a/searchPages/searchDataProviders.module.ts b/searchPages/searchDataProviders.module.ts
new file mode 100644
index 00000000..f129fffa
--- /dev/null
+++ b/searchPages/searchDataProviders.module.ts
@@ -0,0 +1,26 @@
+import {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {FormsModule} from '@angular/forms';
+import {FreeGuard} from '../login/freeGuard.guard';
+import {IsRouteEnabled} from '../error/isRouteEnabled.guard';
+import {NewSearchPageModule} from "./searchUtils/newSearchPage.module";
+import {DataProvidersServiceModule} from "../services/dataProvidersService.module";
+import {SearchDataProvidersComponent} from "./searchDataProviders.component";
+
+@NgModule({
+ imports: [
+ CommonModule, FormsModule,
+ DataProvidersServiceModule,
+ NewSearchPageModule
+
+ ],
+ declarations: [
+ SearchDataProvidersComponent
+ ],
+ providers: [FreeGuard, IsRouteEnabled],
+ exports: [
+ SearchDataProvidersComponent
+ ]
+})
+
+export class SearchDataProvidersModule { }
diff --git a/searchPages/searchOrganizations.component.ts b/searchPages/searchOrganizations.component.ts
new file mode 100644
index 00000000..2e26a619
--- /dev/null
+++ b/searchPages/searchOrganizations.component.ts
@@ -0,0 +1,208 @@
+import {Component, Input, ViewChild} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
+import {AdvancedField} from './searchUtils/searchHelperClasses.class';
+import {SearchOrganizationsService} from '../services/searchOrganizations.service';
+import {ErrorCodes} from '../utils/properties/errorCodes';
+import {ErrorMessagesComponent} from '../utils/errorMessages.component';
+import {SearchFields} from '../utils/properties/searchFields';
+import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
+import {EnvProperties} from '../utils/properties/env-properties';
+import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component";
+
+
+@Component({
+ selector: 'search-organizations',
+ template: `
+
+
+ `
+ })
+
+export class SearchOrganizationsComponent {
+ private errorCodes: ErrorCodes;
+ private errorMessages: ErrorMessagesComponent;
+ properties:EnvProperties;
+@Input() piwikSiteId = null;
+ public results =[];
+ public filters =[];
+ public searchUtils:SearchUtilsClass = new SearchUtilsClass();
+ public searchFields:SearchFields = new SearchFields();
+
+ public fieldIds: string[] = this.searchFields.ORGANIZATION_ADVANCED_FIELDS;
+ public fieldIdsMap = this.searchFields.ORGANIZATION_FIELDS;
+ public selectedFields:AdvancedField[] = [];
+ public csvParams: string;
+ public disableForms: boolean = false;
+ public loadPaging: boolean = true;
+ public oldTotalResults: number = 0;
+ public pagingLimit: number = 0;
+ public isPiwikEnabled;
+
+ @Input() customFilter:SearchCustomFilter= null;
+ public refineFields: string[] = this.searchFields.ORGANIZATION_REFINE_FIELDS;
+ @ViewChild(NewSearchPageComponent) searchPage: NewSearchPageComponent;
+ @Input() simpleView: boolean = true;
+ simpleSearchLink: string = "";
+ advancedSearchLink: string = "";
+ @Input() hasPrefix: boolean = true;
+ @Input() openaireLink: string;
+
+public resourcesQuery = "(oaftype exact organization)";
+ constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) {
+ this.results =[];
+ this.errorCodes = new ErrorCodes();
+ this.errorMessages = new ErrorMessagesComponent();
+ this.searchUtils.status = this.errorCodes.LOADING;
+
+
+
+ }
+ ngOnInit() {
+ this.route.data
+ .subscribe((data: { envSpecific: EnvProperties }) => {
+ this.properties= data.envSpecific;
+ this.simpleSearchLink = this.properties.searchLinkToProjects;
+ this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects;
+ this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink;
+ this.pagingLimit = data.envSpecific.pagingLimit;
+ this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
+
+ });
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.LOADING;
+ var firstLoad = true;
+
+ this.sub = this.route.queryParams.subscribe(params => {
+ this.loadPaging = true;
+ if(params['page'] && this.searchUtils.page != params['page']) {
+ this.loadPaging = false;
+ this.oldTotalResults = this.searchUtils.totalResults;
+ }
+ var refine = true;
+ if (this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) && this.filters && !firstLoad) {
+ refine = false;
+
+ }
+ let page = (params['page']=== undefined)?1:+params['page'];
+ this.searchUtils.page = ( page <= 0 ) ? 1 : page;
+
+ this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
+ if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
+ this.searchUtils.size = 10;
+ }
+
+ this.searchPage.fieldIds = this.fieldIds;
+ this.selectedFields =[];
+ // this.searchPage.selectedFields = this.selectedFields;
+ // this.searchPage.fieldIdsMap = this.fieldIdsMap;
+ // this.searchPage.customFilter = this.customFilter;
+ // this.searchPage.getSelectedFiltersFromUrl(params);
+ this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, "organization");
+
+ this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
+
+ });
+ }
+ ngOnDestroy() {
+ this.sub.unsubscribe();
+ }
+ sub: any;
+ public getResults(parameters:string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null){
+ if(page > this.pagingLimit) {
+ size=0;
+ }
+ if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
+ if(parameters!= null && parameters != '' ) {
+ this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))";
+ }else{
+ this.csvParams ="&fq="+this.resourcesQuery;
+ }
+
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.LOADING;
+ //this.searchPage.openLoading();
+ this.disableForms = true;
+ this.results = [];
+ this.searchUtils.totalResults = 0;
+
+ //console.info("Advanced Search for Organizations: Execute search query "+parameters);
+ this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size, this.properties,(refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery).subscribe(
+ data => {
+ this.searchUtils.totalResults = data[0];
+ this.results = data[1];
+ if (refine) {
+ this.filters = this.searchPage.prepareFiltersToShow(data[2]);
+ }else{
+ this.searchPage.buildPageURLParameters(this.filters, false);
+ }
+ // this.searchPage.updateBaseUrlWithParameters();
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.DONE;
+ if(this.searchUtils.totalResults == 0 ){
+ this.searchUtils.status = this.errorCodes.NONE;
+ }
+ //this.searchPage.closeLoading();
+ this.disableForms = false;
+
+ if(this.searchUtils.status == this.errorCodes.DONE) {
+ // Page out of limit!!!
+ let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
+ if(!(Number.isInteger(totalPages))) {
+ totalPages = (parseInt(totalPages, 10) + 1);
+ }
+ if(totalPages < page) {
+ this.searchUtils.totalResults = 0;
+ this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
+ }
+ }
+ },
+ err => {
+ //console.log(err);
+ this.handleError("Error getting organizations", err);
+ this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
+
+ //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;
+ /*if(err.status == '404') {
+ this.searchUtils.status = this.errorCodes.NOT_FOUND;
+ } else if(err.status == '500') {
+ this.searchUtils.status = this.errorCodes.ERROR;
+ } else {
+ this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
+ }*/
+
+ //this.searchPage.closeLoading();
+ this.disableForms = false;
+ }
+ );
+ }
+ }
+ private setFilters(){
+ //TODO set filters from
+ }
+
+ private handleError(message: string, error) {
+ console.error("Organizations advanced Search Page: "+message, error);
+ }
+}
diff --git a/searchPages/searchOrganizations.module.ts b/searchPages/searchOrganizations.module.ts
new file mode 100644
index 00000000..3cec0145
--- /dev/null
+++ b/searchPages/searchOrganizations.module.ts
@@ -0,0 +1,26 @@
+import {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {FormsModule} from '@angular/forms';
+import {FreeGuard} from '../login/freeGuard.guard';
+import {IsRouteEnabled} from '../error/isRouteEnabled.guard';
+import {NewSearchPageModule} from "./searchUtils/newSearchPage.module";
+import {OrganizationsServiceModule} from "../services/organizationsService.module";
+import {SearchOrganizationsComponent} from "./searchOrganizations.component";
+
+@NgModule({
+ imports: [
+ CommonModule, FormsModule,
+ OrganizationsServiceModule,
+ NewSearchPageModule
+
+ ],
+ declarations: [
+ SearchOrganizationsComponent
+ ],
+ providers: [FreeGuard, IsRouteEnabled],
+ exports: [
+ SearchOrganizationsComponent
+ ]
+})
+
+export class SearchOrganizationsModule { }
diff --git a/searchPages/searchProjects.component.ts b/searchPages/searchProjects.component.ts
new file mode 100644
index 00000000..eb0085c7
--- /dev/null
+++ b/searchPages/searchProjects.component.ts
@@ -0,0 +1,211 @@
+import {Component, Input, ViewChild} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
+import {AdvancedField} from './searchUtils/searchHelperClasses.class';
+import {SearchProjectsService} from '../services/searchProjects.service';
+import {ErrorCodes} from '../utils/properties/errorCodes';
+import {ErrorMessagesComponent} from '../utils/errorMessages.component';
+import {SearchFields} from '../utils/properties/searchFields';
+import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
+import {EnvProperties} from '../utils/properties/env-properties';
+import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component";
+
+@Component({
+ selector: 'search-projects',
+ template: `
+
+
+
+ `
+ })
+
+export class SearchProjectsComponent {
+ private errorCodes: ErrorCodes;
+ private errorMessages: ErrorMessagesComponent;
+@Input() piwikSiteId = null;
+@Input() customFilter:SearchCustomFilter= null;
+ public results =[];
+ public filters =[];
+
+ public searchUtils:SearchUtilsClass = new SearchUtilsClass();
+ public searchFields:SearchFields = new SearchFields();
+
+ public fieldIds: string[] = this.searchFields.PROJECT_ADVANCED_FIELDS;
+ public fieldIdsMap = this.searchFields.PROJECT_FIELDS;
+ public selectedFields:AdvancedField[] = [];
+ properties:EnvProperties;
+
+ public resourcesQuery = "(oaftype exact project)";
+ public csvParams: string;
+ public disableForms: boolean = false;
+ public loadPaging: boolean = true;
+ public oldTotalResults: number = 0;
+ public pagingLimit: number = 0;
+ public isPiwikEnabled;
+ public refineFields: string[] = this.searchFields.PROJECT_REFINE_FIELDS;
+ @ViewChild(NewSearchPageComponent) searchPage: NewSearchPageComponent;
+ @Input() simpleView: boolean = true;
+ simpleSearchLink: string = "";
+ advancedSearchLink: string = "";
+ @Input() hasPrefix: boolean = true;
+ @Input() openaireLink: string;
+
+ constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService ) {
+
+ this.results =[];
+ this.errorCodes = new ErrorCodes();
+ this.errorMessages = new ErrorMessagesComponent();
+ this.searchUtils.status = this.errorCodes.LOADING;
+
+
+
+
+ }
+ ngOnInit() {
+ this.route.data
+ .subscribe((data: { envSpecific: EnvProperties }) => {
+ this.properties= data.envSpecific;
+ this.simpleSearchLink = this.properties.searchLinkToProjects;
+ this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects;
+ this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink;
+ this.pagingLimit = data.envSpecific.pagingLimit;
+ this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
+
+ });
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.LOADING;
+ var firstLoad = true;
+
+ this.sub = this.route.queryParams.subscribe(params => {
+ this.loadPaging = true;
+ if(params['page'] && this.searchUtils.page != params['page']) {
+ this.loadPaging = false;
+ this.oldTotalResults = this.searchUtils.totalResults;
+ }
+ var refine = true;
+ if (this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) && this.filters && !firstLoad) {
+ refine = false;
+
+ }
+ let page = (params['page']=== undefined)?1:+params['page'];
+ this.searchUtils.page = ( page <= 0 ) ? 1 : page;
+
+ this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
+ if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
+ this.searchUtils.size = 10;
+ }
+
+ this.searchPage.fieldIds = this.fieldIds;
+ this.selectedFields = [];
+ this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.fieldIdsMap,this.customFilter,params, "project");
+ // this.selectedFields =[];
+ // this.searchPage.selectedFields = this.selectedFields;
+ // this.searchPage.fieldIdsMap = this.fieldIdsMap;
+ // this.searchPage.customFilter = this.customFilter;
+ // this.searchPage.getSelectedFiltersFromUrl(params);
+ this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
+ firstLoad = false;
+ });
+ }
+ ngOnDestroy() {
+ this.sub.unsubscribe();
+ }
+ sub: any;
+ public getResults(parameters:string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null){
+ if(page > this.pagingLimit) {
+ size=0;
+ }
+ if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
+ if(parameters!= null && parameters != '' ) {
+ this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))";
+ }else{
+ this.csvParams ="&fq="+this.resourcesQuery;
+ }
+ this.csvParams += (refineFieldsFilterQuery?refineFieldsFilterQuery:'');
+
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.LOADING;
+ //this.searchPage.openLoading();
+ this.disableForms = true;
+ this.results = [];
+ this.searchUtils.totalResults = 0;
+
+ //console.info("Advanced Search for Publications: Execute search query "+parameters);
+ this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties,(refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery).subscribe(
+ data => {
+ this.searchUtils.totalResults = data[0];
+ this.results = data[1];
+ // this.searchPage.updateBaseUrlWithParameters();
+ if (refine) {
+ this.filters = this.searchPage.prepareFiltersToShow(data[2]);
+ }else{
+ this.searchPage.buildPageURLParameters(this.filters, false);
+ }
+ //var errorCodes:ErrorCodes = new ErrorCodes();
+ this.searchUtils.status = this.errorCodes.DONE;
+ if(this.searchUtils.totalResults == 0 ){
+ this.searchUtils.status = this.errorCodes.NONE;
+ }
+ //this.searchPage.closeLoading();
+ this.disableForms = false;
+
+ if(this.searchUtils.status == this.errorCodes.DONE) {
+ // Page out of limit!!!
+ let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
+ if(!(Number.isInteger(totalPages))) {
+ totalPages = (parseInt(totalPages, 10) + 1);
+ }
+ if(totalPages < page) {
+ this.searchUtils.totalResults = 0;
+ this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
+ }
+ }
+ },
+ err => {
+ //console.log(err);
+ this.handleError("Error getting projects", err);
+ this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
+
+ //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;
+ /*if(err.status == '404') {
+ this.searchUtils.status = this.errorCodes.NOT_FOUND;
+ } else if(err.status == '500') {
+ this.searchUtils.status = this.errorCodes.ERROR;
+ } else {
+ this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
+ }*/
+
+ //this.searchPage.closeLoading();
+ this.disableForms = false;
+
+ }
+ );
+ }
+ }
+
+ private handleError(message: string, error) {
+ console.error("Projects advanced Search Page: "+message, error);
+ }
+}
diff --git a/searchPages/searchProjects.module.ts b/searchPages/searchProjects.module.ts
new file mode 100644
index 00000000..8e791ec0
--- /dev/null
+++ b/searchPages/searchProjects.module.ts
@@ -0,0 +1,26 @@
+import {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {FormsModule} from '@angular/forms';
+import {FreeGuard} from '../login/freeGuard.guard';
+import {IsRouteEnabled} from '../error/isRouteEnabled.guard';
+import {NewSearchPageModule} from "./searchUtils/newSearchPage.module";
+import {SearchProjectsComponent} from "./searchProjects.component";
+import {ProjectsServiceModule} from "../services/projectsService.module";
+
+@NgModule({
+ imports: [
+ CommonModule, FormsModule,
+ ProjectsServiceModule,
+ NewSearchPageModule
+
+ ],
+ declarations: [
+ SearchProjectsComponent
+ ],
+ providers: [FreeGuard, IsRouteEnabled],
+ exports: [
+ SearchProjectsComponent
+ ]
+})
+export class SearchProjectsModule {
+}
diff --git a/searchPages/searchResearchResults.component.ts b/searchPages/searchResearchResults.component.ts
index a0b28c98..4b626ff1 100644
--- a/searchPages/searchResearchResults.component.ts
+++ b/searchPages/searchResearchResults.component.ts
@@ -1,6 +1,6 @@
import {Component, Input, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
-import {AdvancedField} from './searchUtils/searchHelperClasses.class';
+import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
import {SearchResearchResultsService} from '../services/searchResearchResults.service';
import {ErrorCodes} from '../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../utils/errorMessages.component';
@@ -13,7 +13,6 @@ import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component";
@Component({
selector: 'search-research-results',
template: `
- {{resultType}}
@@ -71,7 +70,12 @@ export class SearchResearchResultsComponent {
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
@ViewChild(NewSearchPageComponent) searchPage: NewSearchPageComponent;
@Input() simpleView: boolean = true;
-
+ quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
+ filter: null,
+ selected: true,
+ filterId: "resultbestaccessright",
+ value: "Open Access"
+ };
constructor(private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService) {
this.results = [];
this.errorCodes = new ErrorCodes();
@@ -85,21 +89,11 @@ export class SearchResearchResultsComponent {
this.pagingLimit = data.envSpecific.pagingLimit;
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
- // this.searchLink = "/search/research-results";
- // this.searchUtils.baseUrl = this.searchLink;
+
this.simpleSearchLink = this.properties.searchLinkToResults;
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults;
this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink;
- // } else if(this.resultType == "dataset") {
- // this.simpleSearchLink = this.properties.searchLinkToDatasets;
- // this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedDatasets;
- // } else if(this.resultType == "software") {
- // this.simpleSearchLink = this.properties.searchLinkToSoftware;
- // this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedSoftware;
- // } else if(this.resultType == "other") {
- // this.simpleSearchLink = this.properties.searchLinkToOrps;
- // this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedOrps;
- // }
+
});
this.searchUtils.status = this.errorCodes.LOADING;
diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts
index 52d3a773..7ad70dc1 100644
--- a/searchPages/searchUtils/newSearchPage.component.ts
+++ b/searchPages/searchUtils/newSearchPage.component.ts
@@ -62,12 +62,7 @@ export class NewSearchPageComponent {
@Input() simpleView: boolean = true;
@Input() formPlaceholderText = "Type Keywords...";
@Input() @Output() resultTypes = null;
- @Input() @Output() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
- filter: null,
- selected: true,
- filterId: "resultbestaccessright",
- value: "Open Access"
- };
+ @Input() @Output() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string };
piwiksub: any;
public parameterNames: string[] = [];
@@ -301,7 +296,7 @@ export class NewSearchPageComponent {
}
}
- } else if (this.quickFilter.filterId == filter.filterId && this.quickFilter.selected) {
+ } else if (this.quickFilter && this.quickFilter.filterId == filter.filterId && this.quickFilter.selected) {
for (let filterValue of filter.values) {
if (filterValue.id == this.quickFilter.value) {
filterValue.selected = true;
@@ -315,7 +310,7 @@ export class NewSearchPageComponent {
filterValue.selected = false;
}
}
- if (filter.filterId == this.quickFilter.filterId) {
+ if (this.quickFilter && filter.filterId == this.quickFilter.filterId) {
this.quickFilter.filter = filter;
}
}
@@ -548,6 +543,7 @@ export class NewSearchPageComponent {
/**
* Create Search API query based on the filters of refine fields
* @param URLparams
+ * @param firstLoad
*/
getSearchAPIQueryForRefineFields(URLparams, firstLoad: boolean) {
@@ -764,7 +760,7 @@ export class NewSearchPageComponent {
let filterId = this.refineFields[i];
if (URLparams[filterId] != undefined) {
let filter = new Filter();
- filter.title = fields.getFieldName(filterId, "publication");
+ filter.title = fields.getFieldName(filterId, this.entityType);
filter.filterId = filterId;
filter.originalFilterId = filterId;
filter.values = [];
diff --git a/searchPages/searchUtils/quick-selections.component.ts b/searchPages/searchUtils/quick-selections.component.ts
index bf8ab697..86c09b54 100644
--- a/searchPages/searchUtils/quick-selections.component.ts
+++ b/searchPages/searchUtils/quick-selections.component.ts
@@ -107,10 +107,10 @@ export class QuickSelectionsComponent implements OnChanges {
setFormValues() {
this.control.setValue({
- publication: this.resultTypes.publication,
- dataset: this.resultTypes.dataset,
- software: this.resultTypes.software,
- other: this.resultTypes.software,
+ publication: (this.resultTypes && this.resultTypes.publication)?this.resultTypes.publication:null,
+ dataset: (this.resultTypes && this.resultTypes.dataset)?this.resultTypes.dataset:null,
+ software: (this.resultTypes && this.resultTypes.software)?this.resultTypes.software:null,
+ other: (this.resultTypes && this.resultTypes.other)?this.resultTypes.other:null,
QFselected: this.QFselected
});
}
diff --git a/services/searchDataproviders.service.ts b/services/searchDataproviders.service.ts
index 95769d19..de720691 100644
--- a/services/searchDataproviders.service.ts
+++ b/services/searchDataproviders.service.ts
@@ -34,7 +34,7 @@ export class SearchDataprovidersService {
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)]));
}
//((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
- advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties ):any {
+ advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any {
let url = properties.searchResourcesAPIURL;
var basicQuery = "(oaftype exact datasource) " +
'and (datasourcecompatibilityid <> "UNKNOWN")';
@@ -44,13 +44,18 @@ export class SearchDataprovidersService {
}else{
url +=" ( "+basicQuery+ " ) ";
}
-
+ if(refineParams!= null && refineParams != '' ) {
+ url += refineParams;
+ }
+ if(refineQuery) {
+ url += "&" + refineQuery;
+ }
url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => res.json())
//.do(res => console.info(res))
- .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]))
+ .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
}
searchCompatibleDataprovidersTable ( properties:EnvProperties):any {
diff --git a/services/searchOrganizations.service.ts b/services/searchOrganizations.service.ts
index 97e3d51e..5b6ee4b0 100644
--- a/services/searchOrganizations.service.ts
+++ b/services/searchOrganizations.service.ts
@@ -56,7 +56,7 @@ export class SearchOrganizationsService {
//.map(res => res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]));
}
- advancedSearchOrganizations (params: string, page: number, size: number, properties:EnvProperties ):any {
+ advancedSearchOrganizations (params: string, page: number, size: number, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any {
let url = properties.searchResourcesAPIURL;
var basicQuery = "oaftype exact organization and "
+"(reldatasourcecompatibilityid exact driver or reldatasourcecompatibilityid exact driver-openaire2.0 or " +
@@ -69,14 +69,19 @@ export class SearchOrganizationsService {
}else{
url +=" ( "+basicQuery+ " ) ";
}
-
+ if(refineParams!= null && refineParams != '' ) {
+ url += refineParams;
+ }
+ if(refineQuery) {
+ url += "&" + refineQuery;
+ }
url += "&page="+(page-1)+"&size="+size;
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => res.json())
- .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
+ .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]));
}
parseResults(data: any): SearchResult[] {
let results: SearchResult[] = [];
diff --git a/services/searchProjects.service.ts b/services/searchProjects.service.ts
index fb59d086..c1c1088d 100644
--- a/services/searchProjects.service.ts
+++ b/services/searchProjects.service.ts
@@ -51,7 +51,7 @@ export class SearchProjectsService {
//.map(res => res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
- advancedSearchProjects (params: string, page: number, size: number, properties:EnvProperties ):any {
+ advancedSearchProjects (params: string, page: number, size: number, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any {
let url = properties.searchResourcesAPIURL;
var basicQuery = "(oaftype exact project) "
url += "?query=";
@@ -60,12 +60,17 @@ export class SearchProjectsService {
}else{
url +=" ( "+basicQuery+ " ) ";
}
-
+ if(refineParams!= null && refineParams != '' ) {
+ url += refineParams;
+ }
+ if(refineQuery) {
+ url += "&" + refineQuery;
+ }
url += "&page="+(page-1)+"&size="+size;
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => res.json())
- .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
+ .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]));
}
getProjectsForOrganizations (organizationId: string, filterquery: string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
diff --git a/utils/properties/searchFields.ts b/utils/properties/searchFields.ts
index 5019b60e..9983e42d 100644
--- a/utils/properties/searchFields.ts
+++ b/utils/properties/searchFields.ts
@@ -160,7 +160,7 @@ export class SearchFields {
constructor (){
}
getFieldName(fieldId:string,fieldType:string):string{
- if(fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other"){
+ if(fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other" || fieldType == "result"){
return this.RESULT_FIELDS[fieldId].name;
}else if(fieldType == "project"){
return this.PROJECT_FIELDS[fieldId].name;
@@ -174,7 +174,7 @@ export class SearchFields {
}
fieldHasUniqueValue(fieldId:string,fieldType:string,usedBy:string="search"):boolean{
- if(fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other"){
+ if(fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other"|| fieldType == "result"){
return this.RESULT_FIELDS[fieldId].uniqueValue;
}else if(fieldType == "project"){
return this.PROJECT_FIELDS[fieldId].uniqueValue;