From 7fc478f933af962402d5ae286d29169899b227cb Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Tue, 29 Nov 2016 10:42:17 +0000 Subject: [PATCH] update angular-universal-starter project, use API resources for advanced Search, put totalResults in searchUtils.class, use new API version for publications simple search git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44726 d315682c-612b-4755-9ff5-7f18f6832af3 --- portal-2/package.json | 36 +++-- portal-2/src/__workaround.browser.ts | 3 - .../app/deposit/depositResult.component.ts | 6 +- .../dataProvider/datasetsTab.component.ts | 6 +- .../dataProvider/publicationsTab.component.ts | 6 +- .../dataProvider/tabs.component.ts | 8 +- .../organization/organization.component.html | 8 +- .../organization/organization.component.ts | 6 +- .../landingPages/person/person.component.html | 16 +- .../landingPages/person/person.component.ts | 4 +- .../project/project.component.html | 16 +- .../landingPages/project/project.component.ts | 4 +- .../advancedSearchDataProviders.component.ts | 32 ++-- .../advancedSearchDatasets.component.ts | 24 +-- .../advancedSearchOrganizations.component.ts | 24 +-- .../advancedSearchPeople.component.ts | 24 +-- .../advancedSearchProjects.component.ts | 24 +-- .../advancedSearchPublications.component.ts | 23 ++- .../compatibleDataProviders.component.ts | 12 +- .../entityRegistries.component.ts | 11 +- .../app/searchPages/find/search.component.ts | 34 ++--- .../advancedSearchForm.component.ts | 6 +- .../advancedSearchPage.component.ts | 32 ++-- .../searchUtils/searchPage.component.ts | 86 +++++++---- .../searchUtils/searchPaging.component.ts | 26 ++-- .../searchUtils/searchUtils.class.ts | 1 + .../simple/searchDataproviders.component.ts | 28 ++-- .../simple/searchDatasets.component.ts | 26 ++-- .../simple/searchOrganizations.component.ts | 14 +- .../simple/searchPeople.component.ts | 19 ++- .../simple/searchProjects.component.ts | 14 +- .../simple/searchPublications.component.ts | 30 ++-- .../services/searchDataproviders.service.ts | 34 ++++- .../app/services/searchDatasets.service.ts | 23 +++ .../services/searchOrganizations.service.ts | 31 +++- .../src/app/services/searchPeople.service.ts | 23 +++ .../app/services/searchProjects.service.ts | 23 +++ .../services/searchPublications.service.ts | 27 +++- portal-2/src/app/test/test.component.ts | 2 +- .../utils/properties/openaireProperties.ts | 22 ++- .../src/app/utils/properties/searchFields.ts | 140 +++++++++--------- portal-2/src/browser.module.ts | 7 +- portal-2/src/client.aot.ts | 10 +- portal-2/src/client.ts | 12 +- portal-2/src/index.html | 1 + portal-2/src/node.module.ts | 8 +- portal-2/src/server.aot.ts | 15 +- portal-2/src/server.ts | 3 + portal-2/webpack.config.ts | 2 +- portal-2/webpack.prod.config.ts | 58 ++++++-- 50 files changed, 644 insertions(+), 406 deletions(-) diff --git a/portal-2/package.json b/portal-2/package.json index f3abc9ec..1b7b4ff6 100644 --- a/portal-2/package.json +++ b/portal-2/package.json @@ -10,7 +10,7 @@ "watch": "webpack --watch", "watch:dev": "npm run server & npm run watch", "clean:dist": "rimraf dist", - "clean:ngc": "rimraf **/*.ngfactory.ts", + "clean:ngc": "rimraf **/*.ngfactory.ts **/*.css.shim.ts", "prebuild": "npm run clean:dist", "build": "webpack --progress", "build:prod:ngc": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod", @@ -37,33 +37,34 @@ "Mark Pieszak " ], "dependencies": { - "@angular/common": "~2.2.1", - "@angular/compiler": "~2.2.1", - "@angular/compiler-cli": "~2.2.1", - "@angular/core": "~2.2.1", - "@angular/forms": "~2.2.1", - "@angular/http": "~2.2.1", - "@angular/platform-browser": "~2.2.1", - "@angular/platform-browser-dynamic": "~2.2.1", - "@angular/platform-server": "~2.2.1", - "@angular/router": "~3.2.1", - "@angular/upgrade": "~2.2.1", - "@ngtools/webpack": "~1.1.7", + "@angular/common": "~2.1.2", + "@angular/compiler": "~2.1.2", + "@angular/compiler-cli": "~2.1.2", + "@angular/core": "~2.1.2", + "@angular/forms": "~2.1.2", + "@angular/http": "~2.1.2", + "@angular/platform-browser": "~2.1.2", + "@angular/platform-browser-dynamic": "~2.1.2", + "@angular/platform-server": "~2.1.2", + "@angular/router": "~3.1.2", + "@angular/upgrade": "~2.1.2", "angular2-express-engine": "~2.1.0-rc.1", "angular2-platform-node": "~2.1.0-rc.1", "angular2-universal": "~2.1.0-rc.1", "angular2-universal-polyfills": "~2.1.0-rc.1", "body-parser": "^1.15.2", - "bootstrap": "^4.0.0-alpha.4", + "compression": "^1.6.2", "express": "^4.14.0", "js.clone": "0.0.3", "methods": "~1.1.2", + "morgan": "^1.7.0", "preboot": "~4.5.2", "rxjs": "5.0.0-beta.12", "webfontloader": "^1.6.26", "zone.js": "~0.6.26" }, "devDependencies": { + "@types/morgan": "^1.7.32", "@types/body-parser": "0.0.29", "@types/compression": "0.0.29", "@types/cookie-parser": "^1.3.29", @@ -74,21 +75,26 @@ "@types/node": "^6.0.38", "@types/serve-static": "^1.7.27", "@types/webfontloader": "^1.6.27", + "@ngtools/webpack": "~1.1.7", + "accepts": "^1.3.3", "angular2-template-loader": "^0.4.0", "awesome-typescript-loader": "^2.2.4", "cookie-parser": "^1.4.3", + "express-interceptor": "^1.2.0", + "iltorb": "^1.0.13", "imports-loader": "^0.6.5", "json-loader": "^0.5.4", "nodemon": "^1.10.0", "raw-loader": "^0.5.1", + "reflect-metadata": "0.1.8", "rimraf": "^2.5.4", "string-replace-loader": "^1.0.5", "ts-helpers": "^1.1.2", "ts-node": "^1.3.0", "typescript": "2.0.2", "v8-lazy-parse-webpack-plugin": "^0.3.0", - "webpack-bundle-analyzer": "1.4.1", "webpack": "2.1.0-beta.27", + "webpack-bundle-analyzer": "1.4.1", "webpack-dev-middleware": "^1.8.4", "webpack-dev-server": "2.1.0-beta.11", "webpack-merge": "~0.16.0" diff --git a/portal-2/src/__workaround.browser.ts b/portal-2/src/__workaround.browser.ts index a109822c..026f505f 100644 --- a/portal-2/src/__workaround.browser.ts +++ b/portal-2/src/__workaround.browser.ts @@ -7,16 +7,13 @@ let __compiler__ = require('@angular/compiler'); import { __platform_browser_private__ } from '@angular/platform-browser'; import { __core_private__ } from '@angular/core'; -let patch = false; if (!__core_private__['ViewUtils']) { - patch = true; __core_private__['ViewUtils'] = __core_private__['view_utils']; } if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) { - patch = true; (__compiler__).__compiler_private__ = { SelectorMatcher: __compiler__.SelectorMatcher, CssSelector: __compiler__.CssSelector diff --git a/portal-2/src/app/deposit/depositResult.component.ts b/portal-2/src/app/deposit/depositResult.component.ts index 567f1ffa..2ec63628 100644 --- a/portal-2/src/app/deposit/depositResult.component.ts +++ b/portal-2/src/app/deposit/depositResult.component.ts @@ -22,7 +22,7 @@ import {OrganizationService} from '../services/organization.service'; Loading... -
+

Data providers for institution: @@ -33,10 +33,10 @@ import {OrganizationService} from '../services/organization.service';

-
+

Please use the information/contacts shown below to deposit your publications.

-
+
diff --git a/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts b/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts index 483c9899..b95be74c 100644 --- a/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/datasetsTab.component.ts @@ -8,17 +8,17 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties'; @Component({ selector: 'datasetsTab', template: ` -
+
There are no datasets
-
+ ` diff --git a/portal-2/src/app/landingPages/dataProvider/publicationsTab.component.ts b/portal-2/src/app/landingPages/dataProvider/publicationsTab.component.ts index e7a44f3d..56961a5d 100644 --- a/portal-2/src/app/landingPages/dataProvider/publicationsTab.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/publicationsTab.component.ts @@ -8,17 +8,17 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties'; @Component({ selector: 'publicationsTab', template: ` -
+
There are no publications
-
+ ` diff --git a/portal-2/src/app/landingPages/dataProvider/tabs.component.ts b/portal-2/src/app/landingPages/dataProvider/tabs.component.ts index 6198b707..3e69e9ca 100644 --- a/portal-2/src/app/landingPages/dataProvider/tabs.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/tabs.component.ts @@ -15,10 +15,10 @@ import { SearchDatasetsService } from '../../services/searchDatasets.service'; data-toggle="tab" href="#{{tabs[0].content}}"> {{tabs[0].name}} - {{searchPublicationsComponent.totalResults}} + {{searchPublicationsComponent.searchUtils.totalResults}} - {{searchDatasetsComponent.totalResults}} + {{searchDatasetsComponent.searchUtils.totalResults}} @@ -28,10 +28,10 @@ import { SearchDatasetsService } from '../../services/searchDatasets.service'; (click)="search(tab.content)" data-toggle="tab" href="#{{tab.content}}"> {{tab.name}} - {{searchPublicationsComponent.totalResults}} + {{searchPublicationsComponent.searchUtils.totalResults}} - {{searchDatasetsComponent.totalResults}} + {{searchDatasetsComponent.searchUtils.totalResults}} diff --git a/portal-2/src/app/landingPages/organization/organization.component.html b/portal-2/src/app/landingPages/organization/organization.component.html index 211627cc..23483e8f 100644 --- a/portal-2/src/app/landingPages/organization/organization.component.html +++ b/portal-2/src/app/landingPages/organization/organization.component.html @@ -41,7 +41,7 @@ {{organizationInfo.dataProviders.length}} - {{searchDataprovidersComponent.totalResults}} + {{searchDataprovidersComponent.searchUtils.totalResults}} @@ -108,17 +108,17 @@
-
+
There are no dataproviders
- diff --git a/portal-2/src/app/landingPages/organization/organization.component.ts b/portal-2/src/app/landingPages/organization/organization.component.ts index 62c82092..6f8aa1f2 100644 --- a/portal-2/src/app/landingPages/organization/organization.component.ts +++ b/portal-2/src/app/landingPages/organization/organization.component.ts @@ -62,8 +62,8 @@ export class OrganizationComponent { this.subDataprovidersCount = this.route.queryParams.subscribe(params => { this._searchDataprovidersService.numOfDataproviders("organizations/"+this.organizationId+"/datasources/count").subscribe( data => { - this.searchDataprovidersComponent.totalResults = data; - console.info("this.searchDataprovidersComponent.totalResults = "+this.searchDataprovidersComponent.totalResults); + this.searchDataprovidersComponent.searchUtils.totalResults = data; + console.info("this.searchDataprovidersComponent.searchUtils.totalResults = "+this.searchDataprovidersComponent.searchUtils.totalResults); }, err => { console.error(err); @@ -211,7 +211,7 @@ export class OrganizationComponent { } private searchDataprovidersInit() { - if(this.subDataproviders == undefined && this.searchDataprovidersComponent.totalResults > 0) { + if(this.subDataproviders == undefined && this.searchDataprovidersComponent.searchUtils.totalResults > 0) { this.subDataproviders = this.route.queryParams.subscribe(params => { this.searchDataproviders(); }); diff --git a/portal-2/src/app/landingPages/person/person.component.html b/portal-2/src/app/landingPages/person/person.component.html index 066b83a2..0084906b 100644 --- a/portal-2/src/app/landingPages/person/person.component.html +++ b/portal-2/src/app/landingPages/person/person.component.html @@ -25,7 +25,7 @@ Publications - {{searchPublicationsComponent.totalResults}} + {{searchPublicationsComponent.searchUtils.totalResults}} @@ -33,7 +33,7 @@ Research Data - {{searchDatasetsComponent.totalResults}} + {{searchDatasetsComponent.searchUtils.totalResults}} @@ -42,33 +42,33 @@
-
+
There are no publications
-
-
+
There are no research data
- diff --git a/portal-2/src/app/landingPages/person/person.component.ts b/portal-2/src/app/landingPages/person/person.component.ts index 4ba19b23..6dddfd38 100644 --- a/portal-2/src/app/landingPages/person/person.component.ts +++ b/portal-2/src/app/landingPages/person/person.component.ts @@ -63,7 +63,7 @@ export class PersonComponent { this.subDatasetsCount = this.route.queryParams.subscribe(params => { this._searchDatasetsService.numOfEntityDatasets(this.personId, "people/").subscribe( data => { - this.searchDatasetsComponent.totalResults = data; + this.searchDatasetsComponent.searchUtils.totalResults = data; }, err => { console.error(err); @@ -73,7 +73,7 @@ export class PersonComponent { } private searchDatasetsInit() { - if(this.subDatasets == undefined && this.searchDatasetsComponent.totalResults > 0) { + if(this.subDatasets == undefined && this.searchDatasetsComponent.searchUtils.totalResults > 0) { this.subDatasets = this.route.queryParams.subscribe(params => { this.searchDatasets(); }); diff --git a/portal-2/src/app/landingPages/project/project.component.html b/portal-2/src/app/landingPages/project/project.component.html index c9484cb6..5421538a 100644 --- a/portal-2/src/app/landingPages/project/project.component.html +++ b/portal-2/src/app/landingPages/project/project.component.html @@ -63,7 +63,7 @@ Publications - {{searchPublicationsComponent.totalResults}} + {{searchPublicationsComponent.searchUtils.totalResults}} @@ -71,7 +71,7 @@ Research Data - {{searchDatasetsComponent.totalResults}} + {{searchDatasetsComponent.searchUtils.totalResults}} @@ -85,33 +85,33 @@
-
+
There are no publications
-
-
+
There are no research data
- diff --git a/portal-2/src/app/landingPages/project/project.component.ts b/portal-2/src/app/landingPages/project/project.component.ts index 2ba9c4e9..31c8755a 100644 --- a/portal-2/src/app/landingPages/project/project.component.ts +++ b/portal-2/src/app/landingPages/project/project.component.ts @@ -63,7 +63,7 @@ export class ProjectComponent{ this.subDatasetsCount = this._searchDatasetsService.numOfEntityDatasets(this.projectId, "projects/").subscribe( data => { - this.searchDatasetsComponent.totalResults = data; + this.searchDatasetsComponent.searchUtils.totalResults = data; }, err => { console.error(err); @@ -99,7 +99,7 @@ export class ProjectComponent{ } private searchDatasetsInit() { - if(this.subDatasets == undefined && this.searchDatasetsComponent.totalResults > 0) { + if(this.subDatasets == undefined && this.searchDatasetsComponent.searchUtils.totalResults > 0) { // this.subDatasets = this.route.queryParams.subscribe(params => { this.searchDatasets(); // }); diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts index 96bcbd30..c3a900e2 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -15,7 +15,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; selector: 'advanced-search-dataprovider', template: ` @@ -27,17 +27,17 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class AdvancedSearchDataProvidersComponent { private results =[]; private filters =[]; - private totalResults:number = 0 ; + // private totalResults:number = 0 ; // private page :number = 1; // private size :number = 10; // public status:number; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); - private baseUrl: string; + // private baseUrl: string; private searchFields:SearchFields = new SearchFields(); private fieldIds: string[] = this.searchFields.ADVANCED_DATAPROVIDER_PARAM; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; private selectedFields:AdvancedField[] = []; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; @@ -47,18 +47,15 @@ export class AdvancedSearchDataProvidersComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; - this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); - - + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedDataProviders; + console.info("Con -base url:"+this.searchUtils.baseUrl ); } ngOnInit() { - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { - let page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.page = ( page <= 0 ) ? 1 : page; + let page = (params['page']=== undefined)?0:+params['page']; + this.searchUtils.page = ( page < 1 ) ? 1 : page; this.searchPage.fieldIds = this.fieldIds; this.searchPage.selectedFields = this.selectedFields; this.searchPage.fieldIdsMap = this.fieldIdsMap; @@ -75,15 +72,15 @@ export class AdvancedSearchDataProvidersComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Publications: Execute search query "+parameters); - this._searchDataProvidersService.searchDataproviders(parameters, null, page, size, []).subscribe( + this._searchDataProvidersService.advancedSearchDataproviders(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("Adv Search Data providers total="+this.totalResults); + this.searchUtils.totalResults = data[0]; + console.info("Adv Search Data providers total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -99,9 +96,6 @@ export class AdvancedSearchDataProvidersComponent { } ); } - private setFilters(){ - //TODO set filters from - } private queryChanged($event) { var parameters = $event.value; diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts index ec5027a8..c893a33a 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.component.ts @@ -14,8 +14,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; selector: 'advanced-search-datasets', template: ` @@ -26,17 +26,17 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class AdvancedSearchDatasetsComponent { private results =[]; private filters =[]; - private totalResults:number = 0 ; + // private totalResults:number = 0 ; // private page :number = 1; // private size :number = 10; // public status:number; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); - private baseUrl: string; + // private searchUtils.baseUrl: string; private searchFields:SearchFields = new SearchFields(); private fieldIds: string[] = this.searchFields.ADVANCED_SEARCH_DATASET_PARAM; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATASET_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.DATASET_FIELDS_MAP; private selectedFields:AdvancedField[] = []; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; @@ -46,15 +46,15 @@ export class AdvancedSearchDatasetsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; - this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedDatasets; } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; @@ -74,15 +74,15 @@ export class AdvancedSearchDatasetsComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Datasets: Execute search query "+parameters); - this._searchDatasetsService.searchDatasets(parameters, null, page, size, []).subscribe( + this._searchDatasetsService.advancedSearchDatasets(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search Datasets total="+this.totalResults); + this.searchUtils.totalResults = data[0]; + console.info("search Datasets total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts index bc87cfdc..8624cf84 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -14,8 +14,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; selector: 'advanced-search-organizations', template: ` @@ -26,17 +26,17 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class AdvancedSearchOrganizationsComponent { private results =[]; private filters =[]; - private totalResults:number = 0 ; + // private totalResults:number = 0 ; // private page :number = 1; // private size :number = 10; // public status:number; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); - private baseUrl: string; + // private baseUrl: string; private searchFields:SearchFields = new SearchFields(); private fieldIds: string[] = this.searchFields.ADVANCED_SEARCH_ORGANIZATION_PARAM; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.ORGANIZATION_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.ORGANIZATION_FIELDS_MAP; private selectedFields:AdvancedField[] = []; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; @@ -46,15 +46,15 @@ export class AdvancedSearchOrganizationsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; - this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedOrganizations; } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; @@ -74,15 +74,15 @@ export class AdvancedSearchOrganizationsComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Organizations: Execute search query "+parameters); - this._searchOrganizationsService.searchOrganizations(parameters, null, page, size, []).subscribe( + this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search Organizations total="+this.totalResults); + this.searchUtils.totalResults = data[0]; + console.info("search Organizations total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts index eb766dab..853792e0 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPeople.component.ts @@ -14,8 +14,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; selector: 'advanced-search-organizations', template: ` @@ -26,17 +26,17 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class AdvancedSearchPeopleComponent { private results =[]; private filters =[]; - private totalResults:number = 0 ; + // private totalResults:number = 0 ; // private page :number = 1; // private size :number = 10; // public status:number; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); - private baseUrl: string; + // private baseUrl: string; private searchFields:SearchFields = new SearchFields(); private fieldIds: string[] = this.searchFields.ADVANCED_SEARCH_PERSON_PARAM; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.PERSON_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PERSON_FIELDS_MAP; private selectedFields:AdvancedField[] = []; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; @@ -46,15 +46,15 @@ export class AdvancedSearchPeopleComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; - this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedPeople; } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; @@ -74,15 +74,15 @@ export class AdvancedSearchPeopleComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search People: Execute search query "+parameters); - this._searchPeopleService.searchPeople(parameters, null, page, size, []).subscribe( + this._searchPeopleService.advancedSearchPeople(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search People total="+this.totalResults); + this.searchUtils.totalResults = data[0]; + console.info("search People total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts index 0421fb0a..47e18cc6 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.component.ts @@ -13,8 +13,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; selector: 'advanced-search-projects', template: ` @@ -25,17 +25,17 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class AdvancedSearchProjectsComponent { private results =[]; private filters =[]; - private totalResults:number = 0 ; + // private totalResults:number = 0 ; // private page :number = 1; // private size :number = 10; // public status:number; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); - private baseUrl: string; + // private baseUrl: string; private searchFields:SearchFields = new SearchFields(); private fieldIds: string[] = this.searchFields.ADVANCED_PROJECTS_PARAM; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.PROJECT_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PROJECT_FIELDS_MAP; private selectedFields:AdvancedField[] = []; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; @@ -45,15 +45,15 @@ export class AdvancedSearchProjectsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; - this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedProjects; } ngOnInit() { var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.size =errorCodes.LOADING; + this.searchUtils.status =errorCodes.LOADING; this.sub = this.route.queryParams.subscribe(params => { let page = (params['page']=== undefined)?1:+params['page']; this.searchUtils.page = ( page <= 0 ) ? 1 : page; @@ -73,15 +73,15 @@ export class AdvancedSearchProjectsComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Publications: Execute search query "+parameters); - this._searchProjectsService.searchProjects(parameters, null, page, size, []).subscribe( + this._searchProjectsService.advancedSearchProjects(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("Advanced Search Projects total="+this.totalResults); + this.searchUtils.totalResults = data[0]; + console.info("Advanced Search Projects total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts index ec8badc1..29d36bdd 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts @@ -14,8 +14,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; selector: 'advanced-search-publications', template: ` @@ -26,14 +26,14 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class AdvancedSearchPublicationsComponent { private results =[]; private filters =[]; - private totalResults:number = 0 ; + // private totalResults:number = 0 ; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); - private baseUrl: string; + // private baseUrl: string; private searchFields:SearchFields = new SearchFields(); private fieldIds: string[] = this.searchFields.ADVANCED_SEARCH_PUBLICATIONS_PARAM; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.PUBLICATION_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PUBLICATION_FIELDS_MAP; private selectedFields:AdvancedField[] = []; @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; @@ -44,7 +44,7 @@ export class AdvancedSearchPublicationsComponent { this.results =[]; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status =errorCodes.LOADING; - this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedPublications; @@ -71,15 +71,15 @@ export class AdvancedSearchPublicationsComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; console.info("Advanced Search Publications: Execute search query "+parameters); - this._searchPublicationsService.searchPublications(parameters, null, page, size, []).subscribe( + this._searchPublicationsService.advancedSearchPublications(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("searchPubl total="+this.totalResults); + this.searchUtils.totalResults = data[0]; + console.info("searchPubl total="+this.searchUtils.totalResults); this.results = data[1]; this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -95,9 +95,6 @@ export class AdvancedSearchPublicationsComponent { } ); } - private setFilters(){ - //TODO set filters from - } private queryChanged($event) { var parameters = $event.value; diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts index 67df3407..92fea7f2 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts @@ -15,7 +15,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; template: ` @@ -26,7 +26,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class SearchCompatibleDataprovidersComponent { public results =[]; private filters =[]; - public totalResults:number = 0 ; + // public totalResults:number = 0 ; private baseUrl:string; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; @@ -34,7 +34,7 @@ export class SearchCompatibleDataprovidersComponent { private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.DATAPROVIDER_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.DATAPROVIDER_INDEX_PARAM_MAP; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; private _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[{field:"compatibility",opName:"cm",opValue:"not", values:["UNKNOWN","hostedBy","notCompatible"]},{field:"type",opName:"tp",opValue:"not",values: ["other"]}]; // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; private _prefixQuery: string = ""; @@ -78,14 +78,14 @@ export class SearchCompatibleDataprovidersComponent { this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( data => { - this.totalResults = data[0]; - console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts index 77e46610..5dfda5c3 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts @@ -16,7 +16,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; template: ` @@ -26,7 +26,6 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class SearchEntityRegistriesComponent { public results =[]; private filters =[]; - public totalResults:number = 0 ; private baseUrl:string; private searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; @@ -34,7 +33,7 @@ export class SearchEntityRegistriesComponent { private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.DATAPROVIDER_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.DATAPROVIDER_INDEX_PARAM_MAP; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; private _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[ {field:"type",opName:"tp",opValue:"and",values: ["other"]}]; // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; @@ -79,14 +78,14 @@ export class SearchEntityRegistriesComponent { private _getResults(parameters:string,refine:boolean, page: number, size: number){ this.subResults = this._searchDataprovidersService.searchEntityRegistries(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( data => { - this.totalResults = data[0]; - console.info("search Entity Registries: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Entity Registries: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/find/search.component.ts b/portal-2/src/app/searchPages/find/search.component.ts index 6555e8a8..568fa260 100644 --- a/portal-2/src/app/searchPages/find/search.component.ts +++ b/portal-2/src/app/searchPages/find/search.component.ts @@ -38,58 +38,58 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties'; @@ -280,7 +280,7 @@ private subPub;private subData;private subProjects;private subOrg;private subPeo this.subPublicationsCount = this.route.queryParams.subscribe(params => { this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword).subscribe( data => { - this.searchPublicationsComponent.totalResults = data; + this.searchPublicationsComponent.searchUtils.totalResults = data; }, err => { console.error(err); @@ -291,7 +291,7 @@ private subPub;private subData;private subProjects;private subOrg;private subPeo this.subDatasetsCount = this.route.queryParams.subscribe(params => { this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword).subscribe( data => { - this.searchDatasetsComponent.totalResults = data; + this.searchDatasetsComponent.searchUtils.totalResults = data; }, err => { console.error(err); @@ -302,7 +302,7 @@ private subPub;private subData;private subProjects;private subOrg;private subPeo this.subProjectsCount = this.route.queryParams.subscribe(params => { this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword).subscribe( data => { - this.searchProjectsComponent.totalResults = data; + this.searchProjectsComponent.searchUtils.totalResults = data; }, err => { console.error(err); @@ -315,7 +315,7 @@ private subPub;private subData;private subProjects;private subOrg;private subPeo this.subOrganizationsCount = this.route.queryParams.subscribe(params => { this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword).subscribe( data => { - this.searchOrganizationsComponent.totalResults = data; + this.searchOrganizationsComponent.searchUtils.totalResults = data; }, err => { console.error(err); @@ -326,7 +326,7 @@ private subPub;private subData;private subProjects;private subOrg;private subPeo this.subPeopleCount = this.route.queryParams.subscribe(params => { this.subPeople = this._searchPeopleService.numOfSearchPeople(this.keyword).subscribe( data => { - this.searchPeopleComponent.totalResults = data; + this.searchPeopleComponent.searchUtils.totalResults = data; }, err => { console.error(err); diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts b/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts index ae46a289..f50e7bc5 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts @@ -38,10 +38,10 @@ import {SearchFields} from '../../utils/properties/searchFields';
- +
- +
@@ -87,7 +87,7 @@ import {SearchFields} from '../../utils/properties/searchFields'; export class AdvancedSearchFormComponent { @Input() entityType; @Input() fieldIds: string[]; - @Input() fieldIdsMap:{ [key:string]:{ name:string, operator:string, type:string, indexField:string }} ; + @Input() fieldIdsMap:{ [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ; @Input() selectedFields:AdvancedField[]; @Output() queryChange = new EventEmitter(); newFieldId:string; diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts index 29a129b2..657b1b42 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchPage.component.ts @@ -36,7 +36,7 @@ import {SearchUtilsClass} from './searchUtils.class'; (queryChange)="queryChanged($event)"> - +
@@ -54,11 +54,11 @@ export class AdvancedSearchPageComponent { @Input() results = []; @Input() entityType; @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); - @Input() totalResults: number = 0; + // @Input() totalResults: number = 0; @Input() fieldIds: string[]; - @Input() fieldIdsMap:{ [key:string]:{ name:string, operator:string, type:string, indexField:string }} ; + @Input() fieldIdsMap:{ [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ; @Input() selectedFields:AdvancedField[]; - @Input() baseUrl:string = ''; + // @Input() baseUrl:string = ''; @Input() simpleSearchUrl: string; private baseURLWithParameters:string = ''; @@ -72,9 +72,9 @@ export class AdvancedSearchPageComponent { } ngOnInit() { - console.log("Init: AdvancedSearchPageComponent"); - - this.totalResults = this.results.length; + console.log("Init: AdvancedSearchPageComponent"+this.searchUtils.totalResults+this.searchUtils.baseUrl); + this.updateBaseUrlWithParameters(); + // this.searchUtils.totalResults = this.results.length; } public getSelectedFiltersFromUrl(params){ for(var i=0; i< this.fieldIds.length ; i++){ @@ -126,11 +126,16 @@ export class AdvancedSearchPageComponent { public createQueryParameters(){ var params=""; for(var i = 0; i< this.selectedFields.length; i++){ - console.info("Creating Parameter:" + this.selectedFields[i].id+" :"+this.selectedFields[i].value); if(this.fieldIdsMap[this.selectedFields[i].id] != undefined && this.selectedFields[i].value != ""){ - params +="&"+ this.selectedFields[i].id - + "="+ encodeURIComponent(this.selectedFields[i].value)+"&"+this.fieldIdsMap[this.selectedFields[i].id].operator - + "=" + this.selectedFields[i].operatorId; + if(this.selectedFields[i].id == "q"){ + params += (i == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + encodeURIComponent(this.selectedFields[i].value) + '"' + " "; + }else{ + params += (i == 0 ? "" : this.selectedFields[i].operatorId + " " ) + this.fieldIdsMap[this.selectedFields[i].id].indexField + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator+'"' + encodeURIComponent(this.selectedFields[i].value) +'"' + " "; + + } + // params +="&"+ this.selectedFields[i].id + // + "="+ encodeURIComponent(this.selectedFields[i].value)+"&"+this.fieldIdsMap[this.selectedFields[i].id].operator + // + "=" + this.selectedFields[i].operatorId; } } @@ -166,6 +171,9 @@ export class AdvancedSearchPageComponent { * Update the url with proper parameters. This is used as base url in Paging Component */ public updateBaseUrlWithParameters(){ - this.baseURLWithParameters = this.baseUrl + this.createUrlParameters(false); + console.info("Going to "+this.searchUtils.baseUrl + this.createUrlParameters(false)); + + this.baseURLWithParameters = this.searchUtils.baseUrl + this.createUrlParameters(false); + console.info("Updtae!!!"+this.baseURLWithParameters); } } diff --git a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts index d87f1ccd..f4f3e167 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts @@ -12,7 +12,7 @@ import {SearchUtilsClass} from './searchUtils.class';
-

{{pageTitle}}

+

{{pageTitle}} {{type}}

@@ -22,12 +22,12 @@ import {SearchUtilsClass} from './searchUtils.class';
Keywords: - {{searchUtils.keyword}} + {{searchUtils.keyword}} {{filter.title}}: - {{value.name}} + {{value.name}} , @@ -43,17 +43,17 @@ import {SearchUtilsClass} from './searchUtils.class';
- - - + + +
- - + +
@@ -65,9 +65,9 @@ export class SearchPageComponent { @Input() pageTitle = ""; @Input() results = []; @Input() filters = []; - @Input() type; + @Input() type:string = ""; @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); - @Input() totalResults: number = 0; + // @Input() totalResults: number = 0; @Output() queryChange = new EventEmitter(); @Output() downloadClick = new EventEmitter(); @Input() baseUrl:string = ''; @@ -75,7 +75,7 @@ export class SearchPageComponent { @Input() showRefine:boolean = true; @Input() refineFields = []; public indexIdsMap: { [key:string]:string } ; - public fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }}; + public fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }}; private searchFieldsHelper:SearchFields = new SearchFields(); private queryParameters: Map = new Map(); private baseURLWithParameters:string = ''; @@ -91,8 +91,12 @@ export class SearchPageComponent { ngAfterViewChecked(){ } + public getQueryParametersFromUrl(params){ + //TODO when final search is done-allFqs/fq + var parameters = ""; + var allFqs = ""; for(var i=0; i< this.refineFields.length ; i++){ var filterId = this.refineFields[i]; @@ -103,24 +107,33 @@ export class SearchPageComponent { } this.queryParameters[filterId]=decodeURIComponent(params[filterId]); let values = decodeURIComponent(this.queryParameters[filterId]).split(","); - var countvalues = 0 + var countvalues = 0; + var fq = ""; for(let value of values) { countvalues++; var paramId = this.indexIdsMap[filterId]; parameters+='&' + paramId+ '='+ value+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or"); - + fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId +" exact " + this.quote(value) ; } - } + if(countvalues > 0){ + fq="&fq="+fq; + } + allFqs += fq; + } + + } var keyword = params['keyword']; - return (keyword && keyword.length > 0?'q='+keyword+"&op=and":'')+parameters; + console.info("Type:" + this.type + "filters: "+(this.type == 'publication'?allFqs:parameters)); + return (keyword && keyword.length > 0?'q='+keyword+"&op=and":'')+(this.type == 'publication'?allFqs:parameters); } public getIndexQueryParametersFromUrl(params){ var parameters = ""; + var allFqs = ""; for(var i=0; i< this.refineFields.length ; i++){ var filterId = this.refineFields[i]; - + var fq = ""; if(params[filterId] != undefined) { if(this.queryParameters == undefined){ this.queryParameters = new Map(); @@ -131,14 +144,21 @@ export class SearchPageComponent { for(let value of values) { countvalues++; parameters+= ((countvalues == 1)?" and (":" or ")+ filterId+ '='+ value; - + fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId + " exact " + this.quote(value); } parameters+= " ) " + if(countvalues > 0){ + fq="&fq="+fq; + } + allFqs += fq; } + } var keyword = params['keyword']; parameters += (keyword && keyword.length > 0?' and '+keyword+' ':''); - return parameters; + // allFqs += ; + + return (keyword && keyword.length > 0?' and '+keyword+' ':'')+allFqs; } /* * Mark as check the new filters that are selected, when you get them from search @@ -203,45 +223,59 @@ export class SearchPageComponent { * */ private createSearchQueryParameters(filters:Filter[]){ + //TODO when final search is done- remove allLimits/filterLimits and use allFqs/fq var allLimits=""; + var allFqs = ""; for (let filter of filters){ if(filter.countSelectedValues > 0){ var filterLimits=""; + var fq = ""; var count_selected=0; var fieldId = this.indexIdsMap[filter.filterId]; for (let value of filter.values){ if(value.selected == true){ count_selected++; filterLimits+='&' + fieldId+ '='+ value.id+"&" + this.fieldIdsMap[fieldId].operator + "="+((count_selected == 1)?"and":filter.filterOperator); - + fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + this.quote(value.id); } } + fq="&fq="+fq; allLimits += filterLimits; + allFqs += fq; } } - - return (this.searchUtils.keyword.length > 0?'q='+this.searchUtils.keyword+"&op=and":'')+allLimits; +//TODO when final search is done- remove op=and from keyword + return (this.searchUtils.keyword.length > 0?'q='+this.searchUtils.keyword+"&op=and":'')+(this.type == 'publication'?allFqs:allLimits); } private createIndexQueryParameters(filters:Filter[]){ + //TODO var allLimits=""; + var allFqs = ""; for (let filter of filters){ if(filter.countSelectedValues > 0){ var filterLimits=""; var count_selected=0; + var fq = ""; + var fieldId = this.indexIdsMap[filter.filterId]; for (let value of filter.values){ if(value.selected == true){ count_selected++; filterLimits+=((count_selected == 1)?" and (":" "+filter.filterOperator+" ") + filter.filterId+ '='+ value.id; + fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + this.quote(value.id); } } filterLimits+=(filterLimits.length > 0 )?' ) ':''; allLimits += filterLimits; + if(count_selected > 0){ + fq="&fq="+fq; + allFqs += fq; + } } } - allLimits += (this.searchUtils.keyword && this.searchUtils.keyword.length > 0?' and '+this.searchUtils.keyword+' ':''); - return allLimits; + // allLimits += (this.searchUtils.keyword && this.searchUtils.keyword.length > 0?' and '+this.searchUtils.keyword+' ':''); + return (this.searchUtils.keyword && this.searchUtils.keyword.length > 0?' and '+this.searchUtils.keyword+' ':'')+allFqs; } // private isFiltered(){ @@ -305,7 +339,6 @@ export class SearchPageComponent { } filterChanged($event){ - console.log("HEEEEERE"); this.goTo(1); } keywordChanged($event) { @@ -380,6 +413,9 @@ export class SearchPageComponent { } return "&refine=true"+fieldsStr; } - + private quote(params: string):string { + // return encodeURIComponent('"'+params+'"'); + return encodeURIComponent(''+params+''); + } } diff --git a/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts index f5adc39a..2ed3a4f2 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPaging.component.ts @@ -5,22 +5,22 @@ import {Observable} from 'rxjs/Observable'; selector: 'search-paging', template: `
-
- +
+
-
- {{totalResults}} documents, page {{page}} of {{(currentPage())}} +
+ {{searchUtils.totalResults}} documents, page {{searchUtils.page}} of {{(totalPages())}}
` }) export class SearchPagingComponent { - @Input() page:number = 1; - @Input() size:number = 1; + @Input() searchUtils; @Input() results; - @Input() baseUrl:string = ""; - @Input() totalResults:number = 0; + @Input() baseUrl; + + // @Input() totalResults:number = 0; constructor () { } @@ -28,12 +28,12 @@ export class SearchPagingComponent { } - currentPage(): number { - let curPage: any = this.totalResults/this.size; - if(!(Number.isInteger(curPage))) { - curPage = (parseInt(curPage, 10) + 1); + totalPages(): number { + let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); } - return curPage; + return totalPages; } diff --git a/portal-2/src/app/searchPages/searchUtils/searchUtils.class.ts b/portal-2/src/app/searchPages/searchUtils/searchUtils.class.ts index 1c3a1447..25e50999 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchUtils.class.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchUtils.class.ts @@ -4,5 +4,6 @@ export class SearchUtilsClass{ status:number = 1; keyword:string = ""; baseUrl:string = ""; + totalResults = 0; } diff --git a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts index dde2e2a0..d92ae4cd 100644 --- a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts +++ b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts @@ -15,7 +15,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; template: ` @@ -26,13 +26,13 @@ export class SearchDataprovidersComponent { private filters =[]; public totalResults:number = 0 ; private baseUrl:string; - private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private _location:Location; private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.DATAPROVIDER_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.DATAPROVIDER_INDEX_PARAM_MAP; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; private CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], "export":[] }; @@ -82,7 +82,7 @@ console.info("PAGE init = "+this.searchUtils.page); this._searchDataprovidersService.numOfDataproviders(parameters).subscribe( data => { - this.totalResults = data; + this.searchUtils.totalResults = data; }, err => { console.error(err); @@ -104,7 +104,7 @@ console.info("PAGE init = "+this.searchUtils.page); } this._searchDataprovidersService.numOfDataproviders(parameters).subscribe( data => { - this.totalResults = data; + this.searchUtils.totalResults = data; }, err => { console.error(err); @@ -125,13 +125,13 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) this._searchDataprovidersService.searchDataprovidersForDeposit(id,type, page, size).subscribe( data => { - this.totalResults = data[0]; + this.searchUtils.totalResults = data[0]; console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ] [total results:"+this.totalResults+"]"); this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -158,13 +158,13 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) this._searchDataprovidersService.searchDataprovidersForEntity(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -194,8 +194,8 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { - this.totalResults = data[0]; - console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + 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]; this.searchPage.checkSelectedFilters(this.filters); @@ -203,7 +203,7 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -244,7 +244,7 @@ console.info("PAGE queryChanged = "+this.searchUtils.page); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/simple/searchDatasets.component.ts b/portal-2/src/app/searchPages/simple/searchDatasets.component.ts index f8c43604..02dc0ece 100644 --- a/portal-2/src/app/searchPages/simple/searchDatasets.component.ts +++ b/portal-2/src/app/searchPages/simple/searchDatasets.component.ts @@ -15,7 +15,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; template: ` @@ -25,16 +25,16 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class SearchDatasetsComponent { public results =[]; private filters: Filter[] =[]; - public totalResults:number = 0 ; + // public totalResults:number = 0 ; private baseUrl:string; - private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.DATASET_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.DATASET_INDEX_PARAM_MAP; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATASET_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.DATASET_FIELDS_MAP; private urlParams : Map; private _location:Location; @@ -87,13 +87,13 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) this._searchDatasetsService.searchDatasetsForEntity(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search Datasets for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Datasets for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -122,13 +122,13 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s this._searchDatasetsService.searchDatasetsForDataproviders(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search Datasets for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Datasets for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -158,15 +158,15 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } this.subResults = this._searchDatasetsService.searchDatasets(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { - this.totalResults = data[0]; - console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.filters = data[2]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts b/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts index 08eb693a..60601682 100644 --- a/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts +++ b/portal-2/src/app/searchPages/simple/searchOrganizations.component.ts @@ -14,7 +14,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; template: ` @@ -24,15 +24,15 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class SearchOrganizationsComponent { public results =[]; private filters =[]; - public totalResults:number = 0 ; + // public totalResults:number = 0 ; private baseUrl:string; - private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.ORGANIZATION_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.ORGANIZATION_INDEX_PARAM_MAP; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.ORGANIZATION_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.ORGANIZATION_FIELDS_MAP; private urlParams : Map; private _location:Location; @@ -84,15 +84,15 @@ export class SearchOrganizationsComponent { } this.subResults = this._searchOrganizationsService.searchOrganizations(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { - this.totalResults = data[0]; - console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.filters = data[2]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/simple/searchPeople.component.ts b/portal-2/src/app/searchPages/simple/searchPeople.component.ts index 8bc02ca9..5ba03877 100644 --- a/portal-2/src/app/searchPages/simple/searchPeople.component.ts +++ b/portal-2/src/app/searchPages/simple/searchPeople.component.ts @@ -16,7 +16,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; template: ` @@ -26,9 +26,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class SearchPeopleComponent { public results =[]; private filters =[]; - public totalResults:number = 0 ; - private baseUrl:string; - private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private _location:Location; private refineFields = []; @@ -122,12 +121,12 @@ export class SearchPeopleComponent { this._searchPeopleService.searchPeople(parameters, page, searchUtils.size).subscribe( data => { - this.totalResults = data[0]; - console.info("search People total="+this.totalResults); + 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.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -156,14 +155,14 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number this._searchPeopleService.searchPeople(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { - this.totalResults = data[0]; - console.info("search People: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search People: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.filters = this.searchPage.checkSelectedFilters(data[2]); this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/simple/searchProjects.component.ts b/portal-2/src/app/searchPages/simple/searchProjects.component.ts index c0870325..4df9b4a0 100644 --- a/portal-2/src/app/searchPages/simple/searchProjects.component.ts +++ b/portal-2/src/app/searchPages/simple/searchProjects.component.ts @@ -14,7 +14,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; template: ` @@ -24,15 +24,15 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; export class SearchProjectsComponent { public results =[]; private filters: Filter[] =[]; - public totalResults:number = 0 ; + // public totalResults:number = 0 ; private baseUrl:string; - private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.PROJECT_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.PROJECT_INDEX_PARAM_MAP; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.PROJECT_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PROJECT_FIELDS_MAP; private urlParams : Map; private _location:Location; @@ -89,8 +89,8 @@ export class SearchProjectsComponent { } this.subResults = this._searchProjectsService.searchProjects(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { - this.totalResults = data[0]; - console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.filters = data[2]; this.searchPage.checkSelectedFilters(this.filters); @@ -98,7 +98,7 @@ export class SearchProjectsComponent { this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/searchPages/simple/searchPublications.component.ts b/portal-2/src/app/searchPages/simple/searchPublications.component.ts index 6844548e..1f6ad91e 100644 --- a/portal-2/src/app/searchPages/simple/searchPublications.component.ts +++ b/portal-2/src/app/searchPages/simple/searchPublications.component.ts @@ -16,7 +16,7 @@ import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; template: ` @@ -26,15 +26,15 @@ import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; export class SearchPublicationsComponent { public results =[]; private filters =[]; - public totalResults:number = 0 ; - private searchUtils:SearchUtilsClass = new SearchUtilsClass(); + // public totalResults:number = 0 ; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); private baseUrl:string = ""; private sub: any; private subResults: any; private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.PUBLICATION_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.PUBLICATION_INDEX_PARAM_MAP; - private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.PUBLICATION_FIELDS_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PUBLICATION_FIELDS_MAP; private urlParams : Map; @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; private _location:Location; @@ -43,7 +43,6 @@ export class SearchPublicationsComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchPublications(); - console.log("SP con: "+this.baseUrl); } @@ -51,11 +50,11 @@ export class SearchPublicationsComponent { this.searchPage.refineFields = this.refineFields; this.searchPage.indexIdsMap = this.indexIdsMap; this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.type = "publication"; this.sub = this.route.queryParams.subscribe(params => { this.searchUtils.keyword = (params['keyword']?params['keyword']:''); this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - console.log("SP init: "+this.baseUrl); var queryParameters = this.searchPage.getQueryParametersFromUrl(params); this._getResults(queryParameters, true, this.searchUtils.page, this.searchUtils.size); @@ -108,13 +107,13 @@ public getResultsForEntity(entity:string, id:string, page: number, size: number) this._searchPublicationsService.searchPublicationsForEntity(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search Publications for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Publications for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -143,13 +142,13 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s this._searchPublicationsService.searchPublicationsForDataproviders(parameters, page, size).subscribe( data => { - this.totalResults = data[0]; - console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, @@ -179,16 +178,15 @@ private _getResults(parameters:string,refine:boolean, page: number, size: number } this.subResults = this._searchPublicationsService.searchPublications(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { - this.totalResults = data[0]; - console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.searchUtils.totalResults = data[0]; + console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.filters = data[2]; this.searchPage.checkSelectedFilters(this.filters); this.searchPage.updateBaseUrlWithParameters(this.filters); - console.log("SP getResults: "+this.baseUrl); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; - if(this.totalResults == 0 ){ + if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } }, diff --git a/portal-2/src/app/services/searchDataproviders.service.ts b/portal-2/src/app/services/searchDataproviders.service.ts index 2696e105..4001ffa9 100644 --- a/portal-2/src/app/services/searchDataproviders.service.ts +++ b/portal-2/src/app/services/searchDataproviders.service.ts @@ -23,7 +23,7 @@ export class SearchDataprovidersService { if(refineParams!= null && refineParams != '' ) { url += refineParams; } - url += "&page="+page+"&size="+size; + url += "&page="+(page)+"&size="+size; let key = url; if (this._cache.has(key)) { @@ -37,7 +37,30 @@ export class SearchDataprovidersService { this._cache.set(key, res); }); } + advancedSearchDataproviders (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact datasource) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + .do(res => { + this._cache.set(key, res); + }); + } searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any { let url = OpenaireProperties.getSearchResourcesAPIURL(); url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = hostedBy) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))" @@ -47,7 +70,8 @@ export class SearchDataprovidersService { if(refineParams!= null && refineParams != '' ) { url += refineParams; } - url += "&page="+page+"&size="+size; + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; let key = url; if (this._cache.has(key)) { return Observable.of(this._cache.get(key)); @@ -69,7 +93,8 @@ export class SearchDataprovidersService { if(refineParams!= null && refineParams != '' ) { url += refineParams; } - url += "&page="+page+"&size="+size; + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; let key = url; if (this._cache.has(key)) { return Observable.of(this._cache.get(key)); @@ -92,6 +117,9 @@ export class SearchDataprovidersService { compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)" } let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+compatibilities+" ":"")+") and (relorganizationid exact "+id+")"; + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; if (this._cache.has(key)) { return Observable.of(this._cache.get(key)); diff --git a/portal-2/src/app/services/searchDatasets.service.ts b/portal-2/src/app/services/searchDatasets.service.ts index 8917104d..716470af 100644 --- a/portal-2/src/app/services/searchDatasets.service.ts +++ b/portal-2/src/app/services/searchDatasets.service.ts @@ -40,7 +40,30 @@ export class SearchDatasetsService { }); } + advancedSearchDatasets (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact result) and (resulttypeid exact dataset) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + .do(res => { + this._cache.set(key, res); + }); + } searchDatasetsForEntity (params: string, page: number, size: number):any { let link = OpenaireProperties.getSearchAPIURL(); let url = link+params+"/datasets"; diff --git a/portal-2/src/app/services/searchOrganizations.service.ts b/portal-2/src/app/services/searchOrganizations.service.ts index d2c6a45e..a386bf1b 100644 --- a/portal-2/src/app/services/searchOrganizations.service.ts +++ b/portal-2/src/app/services/searchOrganizations.service.ts @@ -24,11 +24,15 @@ export class SearchOrganizationsService { if(params!= null && params != '' ) { url += "((oaftype exact organization and deletedbyinference=false and "+ "(reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=*))"+ - " and ((organizationlegalname all "+this.quote(params)+") or (organizationlegalshortname all "+this.quote(params)+")) and (collectedfromdatasourcename exact "+collectedFrom+")) " + " and ((organizationlegalname all "+this.quote(params)+") or (organizationlegalshortname all "+this.quote(params)+")) " + + // "and " + this.quote(params) + " " + + "and (collectedfromdatasourcename exact "+collectedFrom+")) " } - url += "&page="+page+"&size="+size; + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; if (this._cache.has(key)) { @@ -99,7 +103,30 @@ export class SearchOrganizationsService { this._cache.set(key, res); }); } + advancedSearchOrganizations (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact organization) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + .do(res => { + this._cache.set(key, res); + }); + } parseResults(data: any): SearchResult[] { let results: SearchResult[] = []; diff --git a/portal-2/src/app/services/searchPeople.service.ts b/portal-2/src/app/services/searchPeople.service.ts index 877eacfb..4b0ffff3 100644 --- a/portal-2/src/app/services/searchPeople.service.ts +++ b/portal-2/src/app/services/searchPeople.service.ts @@ -41,7 +41,30 @@ export class SearchPeopleService { this._cache.set(key, res); }); } + advancedSearchPeople (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact person) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + .do(res => { + this._cache.set(key, res); + }); + } parseResults(data: any): SearchResult[] { let results: SearchResult[] = []; diff --git a/portal-2/src/app/services/searchProjects.service.ts b/portal-2/src/app/services/searchProjects.service.ts index 38a03b49..44b5f154 100644 --- a/portal-2/src/app/services/searchProjects.service.ts +++ b/portal-2/src/app/services/searchProjects.service.ts @@ -42,7 +42,30 @@ export class SearchProjectsService { this._cache.set(key, res); }); } + advancedSearchProjects (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact project) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + .do(res => { + this._cache.set(key, res); + }); + } getFunders():any { let url = OpenaireProperties.getSearchAPIURL()+"projects?refine=true&fields=funderid&size=0"; let key = url; diff --git a/portal-2/src/app/services/searchPublications.service.ts b/portal-2/src/app/services/searchPublications.service.ts index 6da967fc..db5aed2f 100644 --- a/portal-2/src/app/services/searchPublications.service.ts +++ b/portal-2/src/app/services/searchPublications.service.ts @@ -18,9 +18,9 @@ export class SearchPublicationsService { searchPublications (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any { - let link = OpenaireProperties.getSearchAPIURL()+"publications"; + let link = OpenaireProperties.getSearchAPIURLLast()+"publications"; - let url = link+"?"; + let url = link+"?"+"&format=json&"; if(params!= null && params != '' ) { url += params; } @@ -43,7 +43,30 @@ export class SearchPublicationsService { }); } + advancedSearchPublications (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact result) and (resulttypeid exact publication) "; + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + .do(res => { + this._cache.set(key, res); + }); + } searchPublicationsForEntity (params: string, page: number, size: number):any { let link = OpenaireProperties.getSearchAPIURL(); let url = link+params+"/publications"; diff --git a/portal-2/src/app/test/test.component.ts b/portal-2/src/app/test/test.component.ts index e7d93bb1..e2fd8060 100644 --- a/portal-2/src/app/test/test.component.ts +++ b/portal-2/src/app/test/test.component.ts @@ -9,7 +9,7 @@ import {Dates} from '../utils/dates.class'; template: `
- +
diff --git a/portal-2/src/app/utils/properties/openaireProperties.ts b/portal-2/src/app/utils/properties/openaireProperties.ts index bf12ada2..e4bce948 100644 --- a/portal-2/src/app/utils/properties/openaireProperties.ts +++ b/portal-2/src/app/utils/properties/openaireProperties.ts @@ -15,7 +15,12 @@ export class OpenaireProperties { private static searchLinkToOrganizations = "search/find/organizations"; private static searchLinkToPeople = "search/find/people"; //Advanced Search pages - private static searchLinkToAdvancedPublications = "search/advanced/publications"; + public static searchLinkToAdvancedPublications = "search/advanced/publications"; + public static searchLinkToAdvancedProjects = "search/advanced/projects"; + public static searchLinkToAdvancedDatasets = "search/advanced/datasets"; + public static searchLinkToAdvancedDataProviders = "search/advanced/dataproviders"; + public static searchLinkToAdvancedOrganizations = "search/advanced/organizations"; + public static searchLinkToAdvancedPeople = "search/advanced/people"; // Services - APIs @@ -28,7 +33,10 @@ export class OpenaireProperties { // private static searchAPIURL = "http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"; // private searchAPIURL = "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/"; private static searchAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/"; - private static searchResourcesAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/resources"; + + private static searchAPIURLLAst = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT-last/rest/v2/api/"; + + private static searchResourcesAPIURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT-last/rest/v2/api/resources"; //private static searchServiveURL = "http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/"; private static searchServiveURL = "http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/"; @@ -99,15 +107,15 @@ export class OpenaireProperties { public static getLinkToSearchPeople():string{ return this.baseSearchLink + this.searchLinkToPeople; } - //Advanced Search Pages - public static getLinkToSearchAdvancedPublications(){ - return this.baseSearchLink + this.searchLinkToAdvancedPublications; - } - + // Services - APIs' getters public static getSearchAPIURL():string{ return this.searchAPIURL; } + // Services - APIs' getters + public static getSearchAPIURLLast():string{ + return this.searchAPIURLLAst; + } //query using full query: // public static getSearchResourcesAPIURL():string{ diff --git a/portal-2/src/app/utils/properties/searchFields.ts b/portal-2/src/app/utils/properties/searchFields.ts index 62819afd..35a3b073 100644 --- a/portal-2/src/app/utils/properties/searchFields.ts +++ b/portal-2/src/app/utils/properties/searchFields.ts @@ -3,28 +3,28 @@ export class SearchFields { //PUBLICATIONS public PUBLICATION_INDEX:string[] = ["instancetypenameid", "resultlanguageid", "communityid", "relfunderid", "relfundinglevel0_id","relfundinglevel1_id","relfundinglevel2_id", - "resultacceptanceyear","resultbestlicense","resulthostingdatasourceid","collectedfromdatasourceid"]; + "resultacceptanceyear","resultbestlicenseid","resulthostingdatasourceid","collectedfromdatasourceid"]; public ADVANCED_SEARCH_PUBLICATIONS_PARAM:string[] = ["q","title","author","publisher","type", "lang", "funder", "funderlv0", "funderlv1","funderlv2","community","access","hostedBy","collectedFrom"]; public PUBLICATION_INDEX_PARAM_MAP:{ [key:string]:string } = {["instancetypenameid"]:"type", ["resultlanguageid"]:"lang",["communityid"]:"community", [ "relfunderid"]:"funder", ["relfundinglevel0_id"]:"funderlv0",["relfundinglevel1_id"]:"funderlv1",["relfundinglevel2_id"]:"funderlv2", - ["resultacceptanceyear"]:"year",["resultbestlicense"]:"access",["resulthostingdatasourceid"]:"hostedBy",["collectedfromdatasourceid"]:"collectedFrom"}; - public PUBLICATION_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={ - ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null}, - ["title"]:{name:"Title",operator:"tt", type:"keyword" , indexField:"resulttitle"}, - ["author"]:{name:"Author",operator:"at", type:"keyword", indexField:"relperson"}, - ["publisher"]:{name:"Publisher",operator:"pb", type:"keyword", indexField:"resultpublisher"}, - ["funder"]:{name:"Funder",operator:"fn", type:"refine", indexField:"relfunderid"}, - ["funderlv0"]:{name:"Funding Stream",operator:"fn0", type:"refine", indexField:"relfundinglevel0_id"}, - ["funderlv1"]:{name:"Funding Substream Level 1",operator:"fn1", type:"refine", indexField:"relfundinglevel1_id"}, - ["funderlv2"]:{name:"Funding Substream Level 2",operator:"fn2", type:"refine", indexField:"relfundinglevel2_id"}, - ["type"]:{name:"Type",operator:"tp", type:"vocabulary", indexField:"instancetypenameid"}, - ["lang"]: {name:"Language",operator:"ln", type:"vocabulary", indexField:"resultlanguageid"}, - ["community"]: {name:"Community",operator:"cm", type:"refine", indexField:"communityid"}, - ["access"]: {name:"Access Mode",operator:"ac", type:"vocabulary", indexField:'resultbestlicense'}, - ["hostedBy"]: {name:"Hosted by data provider",operator:"hs", type:"refine", indexField:"resulthostingdatasourceid"}, - ["collectedFrom"]: {name:"Collected from data provider",operator:"cl", type:"refine", indexField:"collectedfromdatasourceid"} + ["resultacceptanceyear"]:"year",["resultbestlicenseid"]:"access",["resulthostingdatasourceid"]:"hostedBy",["collectedfromdatasourceid"]:"collectedFrom"}; + public PUBLICATION_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={ + ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator: "="}, + ["title"]:{name:"Title",operator:"tt", type:"keyword" , indexField:"resulttitle", equalityOperator: "="}, + ["author"]:{name:"Author",operator:"at", type:"keyword", indexField:"relperson", equalityOperator: "="}, + ["publisher"]:{name:"Publisher",operator:"pb", type:"keyword", indexField:"resultpublisher", equalityOperator: "="}, + ["funder"]:{name:"Funder",operator:"fn", type:"refine", indexField:"relfunderid", equalityOperator: " exact "}, + ["funderlv0"]:{name:"Funding Stream",operator:"fn0", type:"refine", indexField:"relfundinglevel0_id", equalityOperator: " exact "}, + ["funderlv1"]:{name:"Funding Substream Level 1",operator:"fn1", type:"refine", indexField:"relfundinglevel1_id", equalityOperator: " exact "}, + ["funderlv2"]:{name:"Funding Substream Level 2",operator:"fn2", type:"refine", indexField:"relfundinglevel2_id", equalityOperator: " exact "}, + ["type"]:{name:"Type",operator:"tp", type:"vocabulary", indexField:"instancetypenameid", equalityOperator: " exact "}, + ["lang"]: {name:"Language",operator:"ln", type:"vocabulary", indexField:"resultlanguageid", equalityOperator: " exact "}, + ["community"]: {name:"Community",operator:"cm", type:"refine", indexField:"communityid", equalityOperator: " exact "}, + ["access"]: {name:"Access Mode",operator:"ac", type:"vocabulary", indexField:'resultbestlicenseid', equalityOperator: " exact "}, + ["hostedBy"]: {name:"Hosted by data provider",operator:"hs", type:"refine", indexField:"resulthostingdatasourceid", equalityOperator: " exact "}, + ["collectedFrom"]: {name:"Collected from data provider",operator:"cl", type:"refine", indexField:"collectedfromdatasourceid", equalityOperator: " exact "} }; //PROJECT @@ -35,19 +35,19 @@ export class SearchFields { [ "funderid"]:"funder", ["fundinglevel0_id"]:"funderlv0",["fundinglevel1_id"]:"funderlv1",["fundinglevel2_id"]:"funderlv2", ["projectstartyear"]:"startyear",["projectendyear"]:"endyear",["projectecsc39"]:"sc39"}; - public PROJECT_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={ - ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null}, - ["keywords"]:{name:"Keywords",operator:"ky", type:"keyword" , indexField:"projectkeywords"}, - ["acronym"]: {name:"Acronym",operator:"ar", type:"keyword", indexField:'projectacronym'}, - ["title"]: {name:"Title",operator:"tt", type:"keyword", indexField:"projecttitle"}, - ["funder"]:{name:"Funder",operator:"fn", type:"refine", indexField:"funderid"}, - ["funderlv0"]:{name:"Funding Stream",operator:"fn0", type:"refine", indexField:"fundinglevel0_id"}, - ["funderlv1"]:{name:"Funding Substream Level 1",operator:"fn1", type:"refine", indexField:"fundinglevel1_id"}, - ["funderlv2"]:{name:"Funding Substream Level 2",operator:"fn2", type:"refine", indexField:"fundinglevel2_id"}, - ["startyear"]:{name:"Start Year",operator:"sa", type:"keyword", indexField:"projectstartyear"}, - ["endyear"]: {name:"End Year",operator:"ed", type:"keyword", indexField:"projectendyear"}, - ["sc39"]: {name:"Special Clause 39",operator:"sc", type:"boolean", indexField:"projectecsc39"}, - ["code"]: {name:"Project Code",operator:"cd", type:"keyword", indexField:"projectcode"} + public PROJECT_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={ + ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator: "="}, + ["keywords"]:{name:"Keywords",operator:"ky", type:"keyword" , indexField:"projectkeywords", equalityOperator: "="}, + ["acronym"]: {name:"Acronym",operator:"ar", type:"keyword", indexField:'projectacronym', equalityOperator: "="}, + ["title"]: {name:"Title",operator:"tt", type:"keyword", indexField:"projecttitle", equalityOperator: "="}, + ["funder"]:{name:"Funder",operator:"fn", type:"refine", indexField:"funderid", equalityOperator: " exact "}, + ["funderlv0"]:{name:"Funding Stream",operator:"fn0", type:"refine", indexField:"fundinglevel0_id", equalityOperator: " exact "}, + ["funderlv1"]:{name:"Funding Substream Level 1",operator:"fn1", type:"refine", indexField:"fundinglevel1_id", equalityOperator: " exact "}, + ["funderlv2"]:{name:"Funding Substream Level 2",operator:"fn2", type:"refine", indexField:"fundinglevel2_id", equalityOperator: " exact "}, + ["startyear"]:{name:"Start Year",operator:"sa", type:"keyword", indexField:"projectstartyear", equalityOperator: " exact "}, + ["endyear"]: {name:"End Year",operator:"ed", type:"keyword", indexField:"projectendyear", equalityOperator: " exact "}, + ["sc39"]: {name:"Special Clause 39",operator:"sc", type:"boolean", indexField:"projectecsc39", equalityOperator: " exact "}, + ["code"]: {name:"Project Code",operator:"cd", type:"keyword", indexField:"projectcode", equalityOperator: " exact "} }; //DATAPROVIDERS @@ -59,16 +59,16 @@ export class SearchFields { [ "datasourcetypeuiid"]:"type", [ "datasourcetypeid"]:"datasourcetype", ["datasourceodlanguages"]:"lang",["datasourceodcontenttypes"]:"contenttype", ["datasourcecompatibilityid"]:"compatibility"}; - public DATAPROVIDER_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={ - ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null}, - ["officialname"]:{name:"Official Name",operator:"of", type:"keyword", indexField:"datasourceofficialname"}, - ["engname"]:{name:"Start Year",operator:"eg", type:"keyword", indexField:"datasourceenglishname"}, - ["subjects"]: {name:"Subject",operator:"sb", type:"keyword", indexField:"datasourceodsubjects"}, - ["type"]:{name:"Type",operator:"tp", type:"vocabulary" , indexField:"datasourcetypeuiid"}, - ["datasourcetype"]:{name:"Type",operator:"tp", type:"vocabulary" , indexField:"datasourcetypeid"}, - ["lang"]:{name:"Language",operator:"ln", type:"vocabulary", indexField:"datasourceodlanguages"}, - ["contenttype"]:{name:"Content Type",operator:"cn", type:"refine", indexField:"datasourceodcontenttypes"}, - ["compatibility"]:{name:"Compatibility Level",operator:"cm", type:"vocabulary", indexField:"datasourcecompatibilityid"}, + public DATAPROVIDER_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={ + ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator:"="}, + ["officialname"]:{name:"Official Name",operator:"of", type:"keyword", indexField:"datasourceofficialname", equalityOperator:"="}, + ["engname"]:{name:"English name",operator:"eg", type:"keyword", indexField:"datasourceenglishname", equalityOperator:"="}, + ["subjects"]: {name:"Subject",operator:"sb", type:"keyword", indexField:"datasourceodsubjects", equalityOperator:"="}, + ["type"]:{name:"Type",operator:"tp", type:"vocabulary" , indexField:"datasourcetypeuiid", equalityOperator: " exact "}, + ["datasourcetype"]:{name:"Type",operator:"tp", type:"vocabulary" , indexField:"datasourcetypeid", equalityOperator: " exact "}, + ["lang"]:{name:"Language",operator:"ln", type:"vocabulary", indexField:"datasourceodlanguages", equalityOperator: " exact "}, + ["contenttype"]:{name:"Content Type",operator:"cn", type:"refine", indexField:"datasourceodcontenttypes", equalityOperator: " exact "}, + ["compatibility"]:{name:"Compatibility Level",operator:"cm", type:"vocabulary", indexField:"datasourcecompatibilityid", equalityOperator: " exact "}, }; public COMPATIBLE_DATAPROVIDER_FIELDS:string[] = ["type","compatibility"]; @@ -79,28 +79,28 @@ export class SearchFields { //DATASET public DATASET_INDEX:string[] = ["instancetypenameid", "resultlanguageid", //"communityid", "relfunderid", "relfundinglevel0_id","relfundinglevel1_id","relfundinglevel2_id", - "resultacceptanceyear","resultbestlicense","resulthostingdatasourceid","collectedfromdatasourceid"]; + "resultacceptanceyear","resultbestlicenseid","resulthostingdatasourceid","collectedfromdatasourceid"]; public ADVANCED_SEARCH_DATASET_PARAM:string[] = ["q","title","author","publisher","type", "lang", "funder", "funderlv0", "funderlv1","funderlv2","community","access","hostedBy","collectedFrom"]; public DATASET_INDEX_PARAM_MAP:{ [key:string]:string } = {["instancetypenameid"]:"type", ["resultlanguageid"]:"lang",["communityid"]:"community", [ "relfunderid"]:"funder", ["relfundinglevel0_id"]:"funderlv0",["relfundinglevel1_id"]:"funderlv1",["relfundinglevel2_id"]:"funderlv2", - ["resultacceptanceyear"]:"year",["resultbestlicense"]:"access",["resulthostingdatasourceid"]:"hostedBy",["collectedfromdatasourceid"]:"collectedFrom"}; - public DATASET_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={ - ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null}, - ["title"]:{name:"Title",operator:"tt", type:"keyword" , indexField:"resulttitle"}, - ["author"]:{name:"Author",operator:"at", type:"keyword", indexField:"relperson"}, - ["publisher"]:{name:"Publisher",operator:"pb", type:"keyword", indexField:"resultpublisher"}, - ["funder"]:{name:"Funder",operator:"fn", type:"refine", indexField:"relfunderid"}, - ["funderlv0"]:{name:"Funding Stream",operator:"fn0", type:"refine", indexField:"relfundinglevel0_id"}, - ["funderlv1"]:{name:"Funding Substream Level 1",operator:"fn1", type:"refine", indexField:"relfundinglevel1_id"}, - ["funderlv2"]:{name:"Funding Substream Level 2",operator:"fn2", type:"refine", indexField:"relfundinglevel2_id"}, - ["type"]:{name:"Type",operator:"tp", type:"vocabulary", indexField:"instancetypenameid"}, - ["lang"]: {name:"Language",operator:"ln", type:"vocabulary", indexField:"resultlanguageid"}, - ["community"]: {name:"Community",operator:"cm", type:"refine", indexField:"communityid"}, - ["access"]: {name:"Access Mode",operator:"ac", type:"vocabulary", indexField:'resultbestlicense'}, - ["hostedBy"]: {name:"Hosted by data provider",operator:"hs", type:"refine", indexField:"resulthostingdatasourceid"}, - ["collectedFrom"]: {name:"Collected from data provider",operator:"cl", type:"refine", indexField:"collectedfromdatasourceid"} + ["resultacceptanceyear"]:"year",["resultbestlicenseid"]:"access",["resulthostingdatasourceid"]:"hostedBy",["collectedfromdatasourceid"]:"collectedFrom"}; + public DATASET_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={ + ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator: "="}, + ["title"]:{name:"Title",operator:"tt", type:"keyword" , indexField:"resulttitle", equalityOperator: "="}, + ["author"]:{name:"Author",operator:"at", type:"keyword", indexField:"relperson", equalityOperator: "="}, + ["publisher"]:{name:"Publisher",operator:"pb", type:"keyword", indexField:"resultpublisher", equalityOperator: "="}, + ["funder"]:{name:"Funder",operator:"fn", type:"refine", indexField:"relfunderid", equalityOperator: " exact "}, + ["funderlv0"]:{name:"Funding Stream",operator:"fn0", type:"refine", indexField:"relfundinglevel0_id", equalityOperator: " exact "}, + ["funderlv1"]:{name:"Funding Substream Level 1",operator:"fn1", type:"refine", indexField:"relfundinglevel1_id", equalityOperator: " exact "}, + ["funderlv2"]:{name:"Funding Substream Level 2",operator:"fn2", type:"refine", indexField:"relfundinglevel2_id", equalityOperator: " exact "}, + ["type"]:{name:"Type",operator:"tp", type:"vocabulary", indexField:"instancetypenameid", equalityOperator: " exact "}, + ["lang"]: {name:"Language",operator:"ln", type:"vocabulary", indexField:"resultlanguageid", equalityOperator: " exact "}, + ["community"]: {name:"Community",operator:"cm", type:"refine", indexField:"communityid", equalityOperator: " exact "}, + ["access"]: {name:"Access Mode",operator:"ac", type:"vocabulary", indexField:'resultbestlicenseid', equalityOperator: " exact "}, + ["hostedBy"]: {name:"Hosted by data provider",operator:"hs", type:"refine", indexField:"resulthostingdatasourceid", equalityOperator: " exact "}, + ["collectedFrom"]: {name:"Collected from data provider",operator:"cl", type:"refine", indexField:"collectedfromdatasourceid", equalityOperator: " exact "} }; @@ -109,12 +109,12 @@ export class SearchFields { public ADVANCED_SEARCH_ORGANIZATION_PARAM:string[] = ["q","contenttype","compatibility","country","type"]; public ORGANIZATION_INDEX_PARAM_MAP:{ [key:string]:string } = {["organizationlegalname"]:"contenttype", ["organizationlegalshortname"]:"type", ["organizationcountryid"]:"country",["organizationeclegalbody"]:"type"}; - public ORGANIZATION_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={ - ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null}, - ["contenttype"]:{name:"Legal Name",operator:"cn", type:"keyword" , indexField:"organizationlegalname"}, - ["compatibility"]:{name:"Legal Short Name",operator:"cm", type:"keyword", indexField:"organizationlegalshortname"}, - ["country"]:{name:"Country",operator:"cu", type:"vocabulary", indexField:"organizationcountryid"}, - ["type"]:{name:"Type",operator:"tp", type:"refine", indexField:"organizationeclegalbody"}, + public ORGANIZATION_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string , equalityOperator:string}} ={ + ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator: "="}, + ["contenttype"]:{name:"Legal Name",operator:"cn", type:"keyword" , indexField:"organizationlegalname", equalityOperator: "="}, + ["compatibility"]:{name:"Legal Short Name",operator:"cm", type:"keyword", indexField:"organizationlegalshortname", equalityOperator: "="}, + ["country"]:{name:"Country",operator:"cu", type:"vocabulary", indexField:"organizationcountryid", equalityOperator: " exact "}, + ["type"]:{name:"Type",operator:"tp", type:"refine", indexField:"organizationeclegalbody", equalityOperator: " exact "}, }; @@ -125,13 +125,11 @@ export class SearchFields { public ADVANCED_SEARCH_PERSON_PARAM:string[] = ["q","contenttype","compatibility","country","type"]; public PERSON_INDEX_PARAM_MAP:{ [key:string]:string } = {["personsecondnames"]:"surname", ["personfirstname"]:"name", ["personfullname"]:"fullname"}; - public PERSON_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={ - ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null}, - ["surname"]:{name:"Surname",operator:"sr", type:"keyword" , indexField:"personsecondnames"}, - ["name"]:{name:"Name",operator:"nm", type:"keyword", indexField:"personfirstname"}, - ["fullname"]:{name:"Full name",operator:"fl", type:"keyword", indexField:"personfullname"}}; - - + public PERSON_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={ + ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator: "="}, + ["surname"]:{name:"Surname",operator:"sr", type:"keyword" , indexField:"personsecondnames", equalityOperator: "="}, + ["name"]:{name:"Name",operator:"nm", type:"keyword", indexField:"personfirstname", equalityOperator: "="}, + ["fullname"]:{name:"Full name",operator:"fl", type:"keyword", indexField:"personfullname", equalityOperator: "="}}; public HIDDEN_FIELDS:string[] = ["fundinglevel0_id","fundinglevel1_id","fundinglevel2_id", @@ -147,7 +145,7 @@ export class SearchFields { ["fundinglevel1_id"]:"Funding Substream Level 1", ["fundinglevel2_id"]:"Funding Substream Level 2", ["relfunderid"]:"Funder", ["relfundinglevel0_id"]:"Funding Stream",["relfundinglevel1_id"]:"Funding Substream Level 1", ["relfundinglevel2_id"]:"Funding Substream Level 2", ["instancetypenameid"]:"Type",["resultlanguageid"]: "Language",["communityid"]: "Context",["resultacceptanceyear"]:"Year", - ["resultbestlicense"]:"Access Mode",["resulthostingdatasourceid"]:"Hosting Data provider", + ["resultbestlicenseid"]:"Access Mode",["resulthostingdatasourceid"]:"Hosting Data provider", ["collectedfromdatasourceid"]:"Collected from", ["datasourcetypeuiid"]:"Compatibility Type", ["datasourceodlanguages"]:"Language", ["datasourceodcontenttypes"]: "Type", ["datasourcecompatibilityid"]:"Compatibility Type", ["organizationcountryid"]:"Country", ["organizationeclegalbody"]:"Type",["projectstartyear"]:"Start Year",["projectendyear"]:"End Year",["projectecsc39"]:"Special Clause 39"}; diff --git a/portal-2/src/browser.module.ts b/portal-2/src/browser.module.ts index ec9d99a4..283ea80d 100755 --- a/portal-2/src/browser.module.ts +++ b/portal-2/src/browser.module.ts @@ -19,10 +19,12 @@ export function getLRU(lru?: any) { return lru || new Map(); } export function getRequest() { - return Zone.current.get('req') || {}; + // the request object only lives on the server + return { cookie: document.cookie }; } export function getResponse() { - return Zone.current.get('res') || {}; + // the response object is sent as the index.html and lives on the server + return {}; } @@ -32,6 +34,7 @@ export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE'; @NgModule({ bootstrap: [ AppComponent ], imports: [ + // MaterialModule.forRoot() should be included first UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included FormsModule, diff --git a/portal-2/src/client.aot.ts b/portal-2/src/client.aot.ts index 77f94688..7f5a6a41 100644 --- a/portal-2/src/client.aot.ts +++ b/portal-2/src/client.aot.ts @@ -22,11 +22,11 @@ export const platformRef = platformBrowser(); export function main() { // Load fonts async // https://github.com/typekit/webfontloader#configuration - loadWebFont({ - google: { - families: ['Droid Sans'] - } - }); + // loadWebFont({ + // google: { + // families: ['Droid Sans'] + // } + // }); return platformRef.bootstrapModuleFactory(MainModuleNgFactory); } diff --git a/portal-2/src/client.ts b/portal-2/src/client.ts index a55dd7b3..90161c45 100644 --- a/portal-2/src/client.ts +++ b/portal-2/src/client.ts @@ -10,7 +10,7 @@ import { platformUniversalDynamic } from 'angular2-universal/browser'; import { load as loadWebFont } from 'webfontloader'; // enable prod for faster renders -// enableProdMode(); +enableProdMode(); import { MainModule } from './browser.module'; @@ -20,11 +20,11 @@ export const platformRef = platformUniversalDynamic(); export function main() { // Load fonts async // https://github.com/typekit/webfontloader#configuration - loadWebFont({ - google: { - families: ['Droid Sans'] - } - }); + // loadWebFont({ + // google: { + // families: ['Droid Sans'] + // } + // }); return platformRef.bootstrapModule(MainModule); } diff --git a/portal-2/src/index.html b/portal-2/src/index.html index 5212919b..00e6dae0 100644 --- a/portal-2/src/index.html +++ b/portal-2/src/index.html @@ -21,6 +21,7 @@ .searchFilterBox .values {overflow:auto; max-height:200px; } .selected-filters-box {margin:5px; background-color:#F8F8F8; } .search-form {margin:5px; } + .clickable { cursor:pointer; } diff --git a/portal-2/src/node.module.ts b/portal-2/src/node.module.ts index e8c1f974..c7a8ad62 100755 --- a/portal-2/src/node.module.ts +++ b/portal-2/src/node.module.ts @@ -15,10 +15,10 @@ export function getLRU() { return new Map(); } export function getRequest() { - return {}; + return Zone.current.get('req') || {}; } export function getResponse() { - return {}; + return Zone.current.get('res') || {}; } // TODO(gdi2290): refactor into Universal @@ -27,9 +27,12 @@ export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE'; @NgModule({ bootstrap: [ AppComponent ], imports: [ + // MaterialModule.forRoot() should be included first UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included + FormsModule, RouterModule.forRoot([], { useHash: false }), + SharedModule.forRoot(), AppModule, ], @@ -49,6 +52,7 @@ export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE'; }) export class MainModule { constructor(public cache: CacheService) { + } /** diff --git a/portal-2/src/server.aot.ts b/portal-2/src/server.aot.ts index 1e72fa77..0c8f95ba 100644 --- a/portal-2/src/server.aot.ts +++ b/portal-2/src/server.aot.ts @@ -6,11 +6,17 @@ import 'angular2-universal-polyfills'; import 'ts-helpers'; import './__workaround.node'; // temporary until 2.1.1 things are patched in Core +import * as fs from 'fs'; import * as path from 'path'; import * as express from 'express'; import * as bodyParser from 'body-parser'; import * as cookieParser from 'cookie-parser'; -import * as compression from 'compression'; +import * as morgan from 'morgan'; + +const { gzipSync } = require('zlib'); +const accepts = require('accepts'); +const { compressSync } = require('iltorb'); +const interceptor = require('express-interceptor'); // Angular 2 import { enableProdMode } from '@angular/core'; @@ -49,6 +55,13 @@ app.use(cookieParser('Angular 2 Universal')); app.use(bodyParser.json()); app.use(compression()); +const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', {flags: 'a'}) + +app.use(morgan('common', { + skip: (req, res) => res.statusCode < 400, + stream: accessLogStream +})); + function cacheControl(req, res, next) { // instruct browser to revalidate in 60 seconds res.header('Cache-Control', 'max-age=60'); diff --git a/portal-2/src/server.ts b/portal-2/src/server.ts index 3771db21..8b12182d 100644 --- a/portal-2/src/server.ts +++ b/portal-2/src/server.ts @@ -10,6 +10,7 @@ import * as path from 'path'; import * as express from 'express'; import * as bodyParser from 'body-parser'; import * as cookieParser from 'cookie-parser'; +import * as morgan from 'morgan'; import * as compression from 'compression'; // Angular 2 @@ -48,6 +49,8 @@ app.use(cookieParser('Angular 2 Universal')); app.use(bodyParser.json()); app.use(compression()); +app.use(morgan('dev')); + function cacheControl(req, res, next) { // instruct browser to revalidate in 60 seconds res.header('Cache-Control', 'max-age=60'); diff --git a/portal-2/webpack.config.ts b/portal-2/webpack.config.ts index 09e8f780..cbec9f48 100644 --- a/portal-2/webpack.config.ts +++ b/portal-2/webpack.config.ts @@ -93,7 +93,7 @@ export var serverConfig = { __dirname: true, __filename: true, process: true, - Buffer: false + Buffer: true } }; diff --git a/portal-2/webpack.prod.config.ts b/portal-2/webpack.prod.config.ts index 703b5f7a..a0f1b663 100644 --- a/portal-2/webpack.prod.config.ts +++ b/portal-2/webpack.prod.config.ts @@ -1,18 +1,21 @@ -var webpack = require('webpack'); -var path = require('path'); -var clone = require('js.clone'); -var webpackMerge = require('webpack-merge'); -var V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin'); +const webpack = require('webpack'); +const path = require('path'); +const clone = require('js.clone'); +const webpackMerge = require('webpack-merge'); +const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; import webpackConfig, { root, includeClientPackages } from './webpack.config'; -// var CompressionPlugin = require('compression-webpack-plugin'); +// const CompressionPlugin = require('compression-webpack-plugin'); -export var commonPlugins = [ +export const commonPlugins = [ new V8LazyParseWebpackPlugin(), new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify('production'), + 'process.env': { + 'NODE_ENV': JSON.stringify('production'), + 'AOT': true + } }), // Loader options @@ -43,7 +46,7 @@ export var commonPlugins = [ ), ]; -export var commonConfig = { +export const commonConfig = { output: { filename: '[name].bundle.js', chunkFilename: '[chunkhash].js' @@ -51,9 +54,9 @@ export var commonConfig = { }; // Client. -export var clientPlugins = [ +export const clientPlugins = [ new BundleAnalyzerPlugin({ - analyzerMode: 'disabled', // change it to `server` to view bundle stats + analyzerMode: 'disabled', // change it to `server` to view bundle stats reportFilename: 'report.html', generateStatsFile: true, statsFilename: 'stats.json', @@ -87,7 +90,8 @@ export var clientPlugins = [ if_return: true, join_vars: true, negate_iife: false // we need this for lazy v8 - } + }, + sourceMap: true }), new webpack.NormalModuleReplacementPlugin( @@ -127,19 +131,41 @@ export var clientPlugins = [ // }), ]; -export var clientConfig = { +export const clientConfig = { entry: './src/client.aot', recordsOutputPath: root('webpack.records.json') }; // Server. -export var serverPlugins = [ +export const serverPlugins = [ + new webpack.optimize.UglifyJsPlugin({ + // beautify: true, + mangle: false, // to ensure process.env still works + output: { + comments: false + }, + compress: { + warnings: false, + conditionals: true, + unused: true, + comparisons: true, + sequences: true, + dead_code: true, + evaluate: true, + if_return: true, + join_vars: true, + negate_iife: false // we need this for lazy v8 + }, + sourceMap: true + }), ]; -export var serverConfig = { +export const serverConfig = { entry: './src/server.aot', output: { - filename: 'index.js' + filename: 'index.js', + chunkFilename: '[id].bundle.js', + crossOriginLoading: false }, };