From f9f4df43c3a108315b03f986e510a026fa0ce7fe Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Thu, 13 Jun 2019 12:40:03 +0000 Subject: [PATCH] [Aggregator|Trunk] Get custom filter from aggregators class use one aggregator as the default one git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-aggregator-portal/trunk@56072 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/app-routing.module.ts | 5 +- src/app/app.component.ts | 19 ++++-- src/app/app.module.ts | 37 +++++------ src/app/home/home.component.html | 2 +- src/app/home/home.component.ts | 18 ++++-- src/app/home/home.module.ts | 7 ++- .../advancedSearchDatasets.component.ts | 15 +++-- .../advancedSearchOrganizations.component.ts | 15 +++-- .../advanced/advancedSearchOrps.component.ts | 15 +++-- .../advancedSearchPublications.component.ts | 15 +++-- .../advancedSearchSoftware.component.ts | 15 +++-- src/app/searchPages/find/search.component.ts | 24 ++----- .../simple/searchDatasets.component.ts | 13 ++-- .../simple/searchOrganizations.component.ts | 16 +++-- .../simple/searchOrps.component.ts | 18 ++++-- .../simple/searchPublications.component.ts | 18 ++---- .../simple/searchSoftware.component.ts | 12 ++-- src/app/utils/aggregatorNavBar.component.ts | 63 +++++++++++++++++++ src/app/utils/aggregators.ts | 55 ++++++++++++++++ src/tsconfig.server.json | 2 +- 20 files changed, 267 insertions(+), 117 deletions(-) create mode 100644 src/app/utils/aggregatorNavBar.component.ts create mode 100644 src/app/utils/aggregators.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 1a301e4..36c34d2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -9,6 +9,7 @@ import { OpenaireErrorPageComponent } from './error/errorPage.component'; const routes: Routes = [ { path: '', loadChildren: './home/home.module#HomeModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, + { path: ':id', loadChildren: './home/home.module#HomeModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'search/publication', loadChildren: './landingPages/publication/libPublication.module#LibPublicationModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'search/dataset', loadChildren: './landingPages/dataset/libDataset.module#LibDatasetModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'search/software', loadChildren: './landingPages/software/libSoftware.module#LibSoftwareModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, @@ -34,8 +35,8 @@ const routes: Routes = [ { path: 'search/advanced/dataproviders', loadChildren: './searchPages/advanced/advancedSearchDataProviders.module#LibAdvancedSearchDataProvidersModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'search/advanced/projects', loadChildren: './searchPages/advanced/advancedSearchProjects.module#LibAdvancedSearchProjectsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'project-report', loadChildren: './landingPages/htmlProjectReport/libHtmlProjectReport.module#LibHtmlProjectReportModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, - { path: 'reload', loadChildren: './reload/libReload.module#LibReloadModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, - { path: 'user-info', loadChildren: './login/libUser.module#LibUserModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, + // { path: 'reload', loadChildren: './reload/libReload.module#LibReloadModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, + // { path: 'user-info', loadChildren: './login/libUser.module#LibUserModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'error', component: OpenaireErrorPageComponent, resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: '**',pathMatch: 'full',component: OpenaireErrorPageComponent, resolve: { envSpecific: EnvironmentSpecificResolver }} ]; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f30b182..b9cf9f5 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -5,6 +5,7 @@ import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class"; +import {FilterInfo, PortalAggregators} from "./utils/aggregators"; @Component({ //changeDetection: ChangeDetectionStrategy.Default, @@ -14,10 +15,9 @@ import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class"; `], template: ` - + [userMenu]="false" [community]="community" [showCommunityName]="true">
@@ -33,7 +33,7 @@ import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class"; ratio="1"> - + ` @@ -54,14 +54,16 @@ export class AppComponent { ] } ]; - community = {id: "CA", name: "Canada Aggregator", logoUrl:"assets/common-assets/logo-small-aggregator.png"}; + community = null; properties: EnvProperties; constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, private router: Router) { + router.events.forEach((event) => { + if (event instanceof NavigationStart) { HelperFunctions.scroll(); } @@ -69,6 +71,13 @@ export class AppComponent { } ngOnInit() { + let id = this.router.url; + + console.log("Id is:"+id); + let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + if(agg){ + this.community = {id: agg.menuId, name: agg.title, logoUrl:agg.logoUrl}; + } if (typeof document !== 'undefined') { try { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1941730..a4b6108 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,26 +1,23 @@ -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { SharedModule } from './shared/shared.module'; -import { BrowserModule } from '@angular/platform-browser'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { APP_BASE_HREF, CommonModule } from '@angular/common'; -import { HttpClientModule } from '@angular/common/http'; -import { RouterModule } from '@angular/router'; -import { AppComponent } from './app.component'; +import {NgModule} from '@angular/core'; +import {SharedModule} from './shared/shared.module'; +import {BrowserModule} from '@angular/platform-browser'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; +import {CommonModule} from '@angular/common'; +import {HttpClientModule} from '@angular/common/http'; +import {AppComponent} from './app.component'; import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module'; -import { CookieLawModule } from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module'; +import {CookieLawModule} from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module'; import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module'; import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module'; -import { EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; -//import { EnvironmentSpecificService, REQUEST_TOKEN} from './openaireLibrary/utils/properties/environment-specific.service'; +import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; +import {ErrorModule} from './openaireLibrary/error/error.module'; -import { ErrorModule} from './openaireLibrary/error/error.module'; - -import { OpenaireErrorPageComponent } from './error/errorPage.component'; -import { AppRoutingModule } from './app-routing.module'; +import {OpenaireErrorPageComponent} from './error/errorPage.component'; +import {AppRoutingModule} from './app-routing.module'; +import {AggregatorNavBarComponent} from "./utils/aggregatorNavBar.component"; @NgModule({ @@ -29,7 +26,7 @@ import { AppRoutingModule } from './app-routing.module'; NoopAnimationsModule, CommonModule, HttpClientModule, -ErrorModule, + ErrorModule, NavigationBarModule, FeedbackModule, BottomModule, CookieLawModule, BrowserModule.withServerTransition({appId: 'my-app'}), @@ -38,14 +35,10 @@ NavigationBarModule, FeedbackModule, BottomModule, declarations: [ AppComponent, OpenaireErrorPageComponent], exports: [ AppComponent ], providers:[ - /*{ - provide: REQUEST_TOKEN, - useClass: EnvironmentSpecificService - },*/ EnvironmentSpecificResolver ], bootstrap: [AppComponent] }) -// + export class AppModule {} diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 901e5f1..005e995 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -1,5 +1,5 @@ - +
{ this.properties = data.envSpecific; @@ -168,7 +174,7 @@ export class HomeComponent { } private getNumbers() { - let refineQuery = null + let refineQuery = null; if(this.customFilter){ refineQuery= "&fq="+StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId ))); } diff --git a/src/app/home/home.module.ts b/src/app/home/home.module.ts index c04982e..bdd6559 100644 --- a/src/app/home/home.module.ts +++ b/src/app/home/home.module.ts @@ -26,6 +26,7 @@ import { SEOServiceModule } from '../openaireLibrary/sharedComponents/SEO/SEOSer import {ErrorMessagesModule} from '../openaireLibrary/utils/errorMessages.module'; import {SoftwareServiceModule} from "../openaireLibrary/services/softwareService.module"; import {OrpsServiceModule} from "../openaireLibrary/services/orpsService.module"; +// import {AggregatorNavBarComponent} from "../utils/aggregatorNavBar.component"; @NgModule({ imports: [ @@ -39,16 +40,16 @@ import {OrpsServiceModule} from "../openaireLibrary/services/orpsService.module" HomeRoutingModule, HelperModule, ErrorMessagesModule, - Schema2jsonldModule, SEOServiceModule + Schema2jsonldModule, SEOServiceModule, ], declarations: [ - HomeComponent + HomeComponent//, AggregatorNavBarComponent ], providers:[ FreeGuard, PreviousRouteRecorder, ConfigurationService ], exports: [ - HomeComponent + HomeComponent//, AggregatorNavBarComponent ] }) export class HomeModule { } diff --git a/src/app/searchPages/advanced/advancedSearchDatasets.component.ts b/src/app/searchPages/advanced/advancedSearchDatasets.component.ts index 5624637..4f85a24 100644 --- a/src/app/searchPages/advanced/advancedSearchDatasets.component.ts +++ b/src/app/searchPages/advanced/advancedSearchDatasets.component.ts @@ -1,5 +1,7 @@ import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ @@ -12,12 +14,15 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ }) export class OpenaireAdvancedSearchDatasetsComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); - } - ngOnInit() { + customFilter:SearchCustomFilter= null; + constructor(private route: ActivatedRoute) { } + ngOnInit() { + let id = this.route.snapshot.paramMap.get('id'); + let agg: FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + } + } diff --git a/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts b/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts index 95e52ee..4ad24a5 100644 --- a/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts +++ b/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -1,5 +1,7 @@ import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ @@ -13,11 +15,14 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ export class OpenaireAdvancedSearchOrganizationsComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); - } - ngOnInit() { + customFilter:SearchCustomFilter= null; + constructor(private route: ActivatedRoute) { } + + ngOnInit() { + let id = this.route.snapshot.paramMap.get('id'); + let agg: FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + } } diff --git a/src/app/searchPages/advanced/advancedSearchOrps.component.ts b/src/app/searchPages/advanced/advancedSearchOrps.component.ts index c7e7d26..0485eae 100644 --- a/src/app/searchPages/advanced/advancedSearchOrps.component.ts +++ b/src/app/searchPages/advanced/advancedSearchOrps.component.ts @@ -1,5 +1,7 @@ import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ @@ -12,12 +14,15 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ }) export class OpenaireAdvancedSearchOrpsComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); - } - ngOnInit() { + customFilter:SearchCustomFilter= null; + constructor(private route: ActivatedRoute) { } + ngOnInit() { + let id = this.route.snapshot.paramMap.get('id'); + let agg: FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + } + } diff --git a/src/app/searchPages/advanced/advancedSearchPublications.component.ts b/src/app/searchPages/advanced/advancedSearchPublications.component.ts index 6a23f3e..a82396c 100644 --- a/src/app/searchPages/advanced/advancedSearchPublications.component.ts +++ b/src/app/searchPages/advanced/advancedSearchPublications.component.ts @@ -1,5 +1,7 @@ import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ @@ -11,11 +13,14 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ }) export class OpenaireAdvancedSearchPublicationsComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); - } - ngOnInit() { + customFilter:SearchCustomFilter= null; + constructor(private route: ActivatedRoute) { } + + ngOnInit() { + let id = this.route.snapshot.paramMap.get('id'); + let agg: FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + } } diff --git a/src/app/searchPages/advanced/advancedSearchSoftware.component.ts b/src/app/searchPages/advanced/advancedSearchSoftware.component.ts index 973b667..8ea7e3d 100644 --- a/src/app/searchPages/advanced/advancedSearchSoftware.component.ts +++ b/src/app/searchPages/advanced/advancedSearchSoftware.component.ts @@ -1,5 +1,7 @@ import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ selector: 'openaire-advanced-search-software', @@ -12,11 +14,14 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ export class OpenaireAdvancedSearchSoftwareComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); - } - ngOnInit() { + customFilter:SearchCustomFilter= null; + constructor(private route: ActivatedRoute) { } + + ngOnInit() { + let id = this.route.snapshot.paramMap.get('id'); + let agg: FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + } } diff --git a/src/app/searchPages/find/search.component.ts b/src/app/searchPages/find/search.component.ts index 92c7cd4..e041967 100644 --- a/src/app/searchPages/find/search.component.ts +++ b/src/app/searchPages/find/search.component.ts @@ -1,6 +1,7 @@ -import {Component, ViewChild, ElementRef} from '@angular/core'; +import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ selector: 'openaire-search-find', @@ -10,7 +11,7 @@ import {ActivatedRoute} from "@angular/router"; `, }) export class OpenaireSearchComponent{ - customFilter:SearchCustomFilter= new SearchCustomFilter(); + customFilter:SearchCustomFilter= null; constructor ( private route: ActivatedRoute ) { @@ -18,26 +19,11 @@ export class OpenaireSearchComponent{ ngOnInit() { let id = this.route.snapshot.paramMap.get('id'); - if(id && id.length > 0){ - this.customFilter.set("Country", "country", id , ""); - }else{ - this.customFilter.set("Country", "country", "CA" , "Canada"); - } + let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); this.route.data .subscribe((data: { envSpecific: any }) => { - // this.piwikSiteId = PiwikHelper.siteIDs[communityId]; - // if(communityId){ - // this.connectCommunityId = communityId - // }else{ - // this.route.queryParams.subscribe(data => { - // - // if(data['communityId'] && data['communityId']!=""){ - // this.connectCommunityId = data['communityId']; - // this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId]; - // } - // }); - // } }); } diff --git a/src/app/searchPages/simple/searchDatasets.component.ts b/src/app/searchPages/simple/searchDatasets.component.ts index 02d1783..027959d 100644 --- a/src/app/searchPages/simple/searchDatasets.component.ts +++ b/src/app/searchPages/simple/searchDatasets.component.ts @@ -1,5 +1,7 @@ import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ selector: 'openaire-search-datasets', @@ -11,13 +13,14 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ }) export class OpenaireSearchDatasetsComponent { - customFilter: SearchCustomFilter = new SearchCustomFilter(); + customFilter: SearchCustomFilter = null; + + constructor ( private route: ActivatedRoute ) { - constructor() { - this.customFilter.set("Country", "country", "CA", "Canada"); } - ngOnInit() { - + let id = this.route.snapshot.paramMap.get('id'); + let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); } } diff --git a/src/app/searchPages/simple/searchOrganizations.component.ts b/src/app/searchPages/simple/searchOrganizations.component.ts index 336e27e..bb4607d 100644 --- a/src/app/searchPages/simple/searchOrganizations.component.ts +++ b/src/app/searchPages/simple/searchOrganizations.component.ts @@ -1,5 +1,7 @@ -import {Component, Input, ViewChild} from '@angular/core'; +import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ selector: 'openaire-search-organizations', @@ -12,11 +14,13 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ }) export class OpenaireSearchOrganizationsComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); - } - ngOnInit() { + customFilter:SearchCustomFilter= null; + constructor ( private route: ActivatedRoute ) { } + ngOnInit() { + let id = this.route.snapshot.paramMap.get('id'); + let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + } } diff --git a/src/app/searchPages/simple/searchOrps.component.ts b/src/app/searchPages/simple/searchOrps.component.ts index bfde86d..07d02e9 100644 --- a/src/app/searchPages/simple/searchOrps.component.ts +++ b/src/app/searchPages/simple/searchOrps.component.ts @@ -1,5 +1,7 @@ -import {Component, Input, ViewChild} from '@angular/core'; +import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ selector: 'openaire-search-orps', @@ -11,11 +13,15 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ }) export class OpenaireSearchOrpsComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); - } - ngOnInit() { + customFilter: SearchCustomFilter = null; + + constructor(private route: ActivatedRoute) { } + + ngOnInit() { + let id = this.route.snapshot.paramMap.get('id'); + let agg: FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + } } diff --git a/src/app/searchPages/simple/searchPublications.component.ts b/src/app/searchPages/simple/searchPublications.component.ts index dac1cdb..713800b 100644 --- a/src/app/searchPages/simple/searchPublications.component.ts +++ b/src/app/searchPages/simple/searchPublications.component.ts @@ -1,11 +1,11 @@ -import {Component, Input, ViewChild} from '@angular/core'; +import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {ActivatedRoute} from "@angular/router"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; @Component({ selector: 'openaire-search-publications', - template: ` - + template: ` @@ -13,19 +13,13 @@ import {ActivatedRoute} from "@angular/router"; }) export class OpenaireSearchPublicationsComponent { - - customFilter:SearchCustomFilter= new SearchCustomFilter(); + customFilter:SearchCustomFilter= null; constructor ( private route: ActivatedRoute ) { } ngOnInit() { let id = this.route.snapshot.paramMap.get('id'); - if(id && id.length > 0){ - this.customFilter.set("Country", "country", id , ""); - }else{ - this.customFilter.set("Country", "country", "CA" , "Canada"); - } + let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); } - - } diff --git a/src/app/searchPages/simple/searchSoftware.component.ts b/src/app/searchPages/simple/searchSoftware.component.ts index ee05c8c..d5d917a 100644 --- a/src/app/searchPages/simple/searchSoftware.component.ts +++ b/src/app/searchPages/simple/searchSoftware.component.ts @@ -1,5 +1,7 @@ import {Component} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {FilterInfo, PortalAggregators} from "../../utils/aggregators"; +import {ActivatedRoute} from "@angular/router"; @Component({ selector: 'openaire-search-software', @@ -11,12 +13,14 @@ import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/ }) export class OpenaireSearchSoftwareComponent { - customFilter:SearchCustomFilter= new SearchCustomFilter(); - constructor () { - this.customFilter.set("Country", "country", "CA" , "Canada"); + customFilter:SearchCustomFilter= null; + constructor ( private route: ActivatedRoute ) { + } ngOnInit() { - + let id = this.route.snapshot.paramMap.get('id'); + let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); } } diff --git a/src/app/utils/aggregatorNavBar.component.ts b/src/app/utils/aggregatorNavBar.component.ts new file mode 100644 index 0000000..8bfd88c --- /dev/null +++ b/src/app/utils/aggregatorNavBar.component.ts @@ -0,0 +1,63 @@ +import {Component} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import "rxjs/add/observable/zip"; +import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; +import {FilterInfo, PortalAggregators} from "../utils/aggregators"; +import {MenuItem, RootMenuItem} from "../openaireLibrary/sharedComponents/menu"; + +@Component({ + selector: 'aggNavbar', + templateUrl: ` + +`, +}) +export class AggregatorNavBarComponent { + + properties: EnvProperties; + menuItems: RootMenuItem [] = [ + {rootItem: new MenuItem("home", "Home", "", "/", false, [], null, {}), items: []}, + { + rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}), + items: [new MenuItem("", "Publications", "", "/search/find/publications", false, ["publication"], ["/search/find/publications"], {}), + new MenuItem("", "Research Data", "", "/search/find/datasets", false, ["dataset"], ["/search/find/datasets"], {}), + new MenuItem("", "Software", "", "/search/find/software", false, ["software"], ["/search/find/software"], {}), + new MenuItem("", "Other Research Products", "", "/search/find/other", false, ["orp"], ["/search/find/other"], {}), + // new MenuItem("", "Projects", "", "/search/find/projects/", false, ["project"], ["/search/find/projects"], {}), + // new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {}), + new MenuItem("", "Organizations", "", "/search/find/organizations/", false, ["organization"], ["/search/find/organizations"], {}) + ] + } + ]; + community = {id: "CA", name: "Canada Aggregator", logoUrl:"assets/common-assets/logo-small-aggregator.png"}; + + + constructor( + private route: ActivatedRoute, + + ) { + let id = this.route.snapshot.paramMap.get('id'); + console.log(id); + let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id); + // this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(agg); + // console.log(this.customFilter); + + + + } + + public ngOnInit() { + + this.route.data + .subscribe((data: { envSpecific: EnvProperties }) => { + this.properties = data.envSpecific; + + + + }); + + } + +} diff --git a/src/app/utils/aggregators.ts b/src/app/utils/aggregators.ts new file mode 100644 index 0000000..ddbdd04 --- /dev/null +++ b/src/app/utils/aggregators.ts @@ -0,0 +1,55 @@ +import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class"; + +export class FilterInfo { + menuId: string; + title: string; + logoUrl: string; + fieldName: string; //Country + queryFieldName: string; //country + valueId: string; //gr + valueName: string; // Greece + + constructor(menuId: string, title: string, logoUrl: string, fieldName: string, queryFieldName: string, valueId: string, valueName: string) { + this.menuId = menuId; + this.title = title; + this.logoUrl = logoUrl; + this.fieldName = fieldName; + this.queryFieldName = queryFieldName; + this.valueId = valueId; + this.valueName = valueName; + } +} + +export class PortalAggregators { + static list: FilterInfo[] = [ + new FilterInfo("canada", "Canadian Aggregator", "assets/common-assets/logo-small-aggregator.png", "Country", "country", "CA", "Canada"), + new FilterInfo("italy", "Italian Aggregator", "assets/common-assets/logo-small-aggregator.png", "Country", "country", "IT", "Italy"), + new FilterInfo("greece", "Greek Aggregator", "assets/common-assets/logo-small-aggregator.png", "Country", "country", "GR", "Greece"), + + ]; + static defaultAggregator: FilterInfo = PortalAggregators.list[0]; + + public static getList(): FilterInfo[] { + return PortalAggregators.list; + } + + public static getFilterInfoByMenuId(menuId: string): FilterInfo { + for (let agg of this.getList()) { + if (agg.menuId == menuId) { + return agg; + } + } + return PortalAggregators.defaultAggregator; + } + + public static getSearchCustomFilterByAggregator(agg: FilterInfo): SearchCustomFilter { + let filter:SearchCustomFilter = null; + if(agg) { + filter = new SearchCustomFilter(agg.fieldName, agg.queryFieldName, agg.valueId, agg.valueName); + } + return filter; + } +} + + + diff --git a/src/tsconfig.server.json b/src/tsconfig.server.json index 7e55994..f1c66ca 100644 --- a/src/tsconfig.server.json +++ b/src/tsconfig.server.json @@ -14,7 +14,7 @@ "**/*.spec.ts" ], // Add "angularCompilerOptions" with the AppServerModule you wrote - // set as the "entryModule". + // setValues as the "entryModule". "angularCompilerOptions": { "entryModule": "app/app.server.module#AppServerModule" }