diff --git a/src/app/search/searchPages/advanced/searchDataproviders.component.ts b/src/app/search/searchPages/advanced/searchDataproviders.component.ts index a235af1..f83afe9 100644 --- a/src/app/search/searchPages/advanced/searchDataproviders.component.ts +++ b/src/app/search/searchPages/advanced/searchDataproviders.component.ts @@ -1,61 +1,29 @@ -import {Component, Input} from '@angular/core'; -import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {Component, Input, OnInit} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; -import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; -import {Subscriber} from "rxjs"; import {SearchForm} from "../../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; +import {SearchBaseComponent} from "../searchBaseComponent"; +import {CustomFilterService} from "../../../shared/customFilter.service"; @Component({ selector: 'monitor-advanced-search-dataproviders', template: ` - + ` }) -export class MonitorAdvancedSearchDataprovidersComponent { - @Input() searchForm: SearchForm = {class: 'search-form', dark: false}; - customFilter: SearchCustomFilter = null; - initialized: boolean = false; - showSwitchSearchLink: boolean = false; - - constructor(private route: ActivatedRoute, - private router: Router, - private stakeholderService: StakeholderService) { +export class MonitorAdvancedSearchDataprovidersComponent extends SearchBaseComponent implements OnInit{ + constructor(protected route: ActivatedRoute, + protected router: Router, + protected customFilterService: CustomFilterService) { + super(); } - - subscriptions = []; - - ngOnDestroy() { - this.subscriptions.forEach(subscription => { - if (subscription instanceof Subscriber) { - subscription.unsubscribe(); - } - }); - } - ngOnInit() { - this.subscriptions.push(this.route.params.subscribe(params => { - if (params['stakeholder']) { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - if (stakeholder) { - if (stakeholder.type === "organization") { - let value = stakeholder.index_id; - this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, ""); - this.showSwitchSearchLink = true; - } else if (stakeholder.type === "funder") { - let value = stakeholder.index_id + "||" + stakeholder.index_name + "||" + stakeholder.index_shortName; - this.customFilter = new SearchCustomFilter("Funder", "relfunder", value, stakeholder.name); - } else if (stakeholder.type === "ri") { - let value = stakeholder.index_id + "||" + stakeholder.index_name; - this.customFilter = new SearchCustomFilter("Community", "community", value, stakeholder.name); - } - this.initialized = true; - } - })); - } - })); + super.initSearch(); } - } diff --git a/src/app/search/searchPages/advanced/searchOrganizations.component.ts b/src/app/search/searchPages/advanced/searchOrganizations.component.ts index 1f4db89..25a25f9 100644 --- a/src/app/search/searchPages/advanced/searchOrganizations.component.ts +++ b/src/app/search/searchPages/advanced/searchOrganizations.component.ts @@ -1,57 +1,29 @@ -import {Component, Input} from '@angular/core'; +import {Component, Input, OnInit} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; -import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; -import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; -import {Subscriber} from "rxjs"; import {SearchForm} from "../../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; +import {SearchBaseComponent} from "../searchBaseComponent"; +import {CustomFilterService} from "../../../shared/customFilter.service"; @Component({ selector: 'monitor-advanced-search-organizations', template: ` - + ` }) -export class MonitorAdvancedSearchOrganizationsComponent { - @Input() searchForm: SearchForm = {class: 'search-form', dark: false}; - initialized: boolean = false; - customFilter: SearchCustomFilter = null; - - constructor(private route: ActivatedRoute, - private router: Router, - private stakeholderService: StakeholderService) { +export class MonitorAdvancedSearchOrganizationsComponent extends SearchBaseComponent implements OnInit{ + constructor(protected route: ActivatedRoute, + protected router: Router, + protected customFilterService: CustomFilterService) { + super(); } - subscriptions = []; - ngOnDestroy() { - this.subscriptions.forEach(subscription => { - if (subscription instanceof Subscriber) { - subscription.unsubscribe(); - } - }); - } - ngOnInit() { - this.subscriptions.push(this.route.params.subscribe(params => { - if (params['stakeholder']) { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - if (stakeholder) { - if (stakeholder.type === "funder") { - let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; - this.customFilter = new SearchCustomFilter("Funder", "relfunder", value, stakeholder.name); - this.customFilter.isHiddenFilter = false; - } else if (stakeholder.type === "organization") { - let value = stakeholder.index_id; - this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, stakeholder.name); - this.customFilter.isHiddenFilter = false; - } else if (stakeholder.type === "ri") { - let value = stakeholder.index_id+"||"+stakeholder.index_name; - this.customFilter = new SearchCustomFilter("Community", "community", value, stakeholder.name); - this.customFilter.isHiddenFilter = false; - } - this.initialized = true; - } - })); - } - })); + super.initSearch(); } } + diff --git a/src/app/search/searchPages/advanced/searchProjects.component.ts b/src/app/search/searchPages/advanced/searchProjects.component.ts index cdbe0fe..692df92 100644 --- a/src/app/search/searchPages/advanced/searchProjects.component.ts +++ b/src/app/search/searchPages/advanced/searchProjects.component.ts @@ -1,67 +1,31 @@ -import {Component, Input} from '@angular/core'; -import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {Component, Input, OnInit} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; -import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; -import {Subscriber} from "rxjs"; -import {properties} from "../../../../environments/environment"; import {SearchForm} from "../../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; +import {SearchBaseComponent} from "../searchBaseComponent"; +import {CustomFilterService} from "../../../shared/customFilter.service"; @Component({ selector: 'monitor-advanced-search-projects', template: ` - ` }) -export class MonitorAdvancedSearchProjectsComponent { - @Input() searchForm: SearchForm = {class: 'search-form', dark: false}; - customFilter: SearchCustomFilter = null; - initialized: boolean = false; - showSwitchSearchLink:boolean = false; - properties; - - constructor(private route: ActivatedRoute, - private router: Router, - private stakeholderService: StakeholderService) { +export class MonitorAdvancedSearchProjectsComponent extends SearchBaseComponent implements OnInit{ + constructor(protected route: ActivatedRoute, + protected router: Router, + protected customFilterService: CustomFilterService) { + super(); } - subscriptions = []; - ngOnDestroy() { - this.subscriptions.forEach(subscription => { - if (subscription instanceof Subscriber) { - subscription.unsubscribe(); - } - }); - } - ngOnInit() { - this.properties = properties; - this.subscriptions.push(this.route.params.subscribe(params => { - if (params['stakeholder']) { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - if (stakeholder) { - if (stakeholder.type === "funder") { - let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; - this.customFilter = new SearchCustomFilter("Funder", "funder", value, ""); - this.showSwitchSearchLink = true; - } else if (stakeholder.type === "organization") { - let value = stakeholder.index_id; - this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, ""); - this.showSwitchSearchLink = true; - } else if (stakeholder.type === "ri") { - let value = stakeholder.index_id+"||"+stakeholder.index_name; - this.customFilter = new SearchCustomFilter("Community", "community", value, stakeholder.name); - } - this.initialized = true; - } - })); - } - })); + super.initSearch(); } - } diff --git a/src/app/search/searchPages/advanced/searchResearchResults.component.ts b/src/app/search/searchPages/advanced/searchResearchResults.component.ts index 8fa2713..f4c4c71 100644 --- a/src/app/search/searchPages/advanced/searchResearchResults.component.ts +++ b/src/app/search/searchPages/advanced/searchResearchResults.component.ts @@ -1,29 +1,22 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {Component, OnInit} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; -import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; -import {Subscriber} from "rxjs"; -import {properties} from "../../../../environments/environment"; -import {ConfigurationService} from "../../../openaireLibrary/utils/configuration/configuration.service"; -import {SearchForm} from "../../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; -import {BaseComponent} from "../../../openaireLibrary/sharedComponents/base/base.component"; import {SearchBaseComponent} from "../searchBaseComponent"; import {CustomFilterService} from "../../../shared/customFilter.service"; @Component({ selector: 'monitor-advanced-search-results', template: ` - ` }) export class MonitorAdvancedSearchResearchResultsComponent extends SearchBaseComponent implements OnInit{ - @Input() searchForm: SearchForm = {class: 'search-form', dark: false}; constructor(protected route: ActivatedRoute, protected router: Router, protected customFilterService: CustomFilterService) { diff --git a/src/app/search/searchPages/searchBaseComponent.ts b/src/app/search/searchPages/searchBaseComponent.ts index c4b9268..377cfe9 100644 --- a/src/app/search/searchPages/searchBaseComponent.ts +++ b/src/app/search/searchPages/searchBaseComponent.ts @@ -11,7 +11,6 @@ export abstract class SearchBaseComponent extends BaseComponent { protected route: ActivatedRoute; protected router: Router; customFilters: SearchCustomFilter[]; - initialized: boolean = false; properties; keyword = ""; parameters = {}; @@ -22,7 +21,6 @@ export abstract class SearchBaseComponent extends BaseComponent { this.subscriptions.push((this.customFilterService.getCustomFilterAsObservable().subscribe(customFilters => { if(customFilters && customFilters.length > 0) { this.customFilters = customFilters; - this.initialized = true; } }))); this.subscriptions.push(this.route.params.subscribe(params => { @@ -31,7 +29,6 @@ export abstract class SearchBaseComponent extends BaseComponent { this.subscriptions.push((this.customFilterService.getCustomFilterAsObservable().subscribe(customFilters => { if(customFilters && customFilters.length > 0) { this.customFilters = customFilters; - this.initialized = true; } }))); }else{ diff --git a/src/app/search/searchPages/simple/searchDataProviders.module.ts b/src/app/search/searchPages/simple/searchDataProviders.module.ts index 9fd7257..f894f47 100644 --- a/src/app/search/searchPages/simple/searchDataProviders.module.ts +++ b/src/app/search/searchPages/simple/searchDataProviders.module.ts @@ -5,12 +5,13 @@ import {MonitorSearchDataprovidersComponent} from './searchDataproviders.compone import {SearchDataProvidersRoutingModule} from './searchDataProviders-routing.module'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {SearchDataProvidersModule} from '../../../openaireLibrary/searchPages/searchDataProviders.module'; +import {SearchInputModule} from "../../../openaireLibrary/sharedComponents/search-input/search-input.module"; @NgModule({ imports: [ CommonModule, FormsModule, - SearchDataProvidersModule, SearchDataProvidersRoutingModule - + SearchDataProvidersModule, SearchDataProvidersRoutingModule, SearchInputModule + ], declarations: [ MonitorSearchDataprovidersComponent diff --git a/src/app/search/searchPages/simple/searchDataproviders.component.ts b/src/app/search/searchPages/simple/searchDataproviders.component.ts index 8e5c3d5..8915926 100644 --- a/src/app/search/searchPages/simple/searchDataproviders.component.ts +++ b/src/app/search/searchPages/simple/searchDataproviders.component.ts @@ -7,59 +7,36 @@ import {ConfigurationService} from "../../../openaireLibrary/utils/configuration import {SearchForm} from "../../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; import {EnvProperties} from "../../../openaireLibrary/utils/properties/env-properties"; import {properties} from "../../../../environments/environment"; +import {SearchBaseComponent} from "../searchBaseComponent"; +import {CustomFilterService} from "../../../shared/customFilter.service"; @Component({ selector: 'monitor-search-dataproviders', template: ` - +
+
+
+ ` }) -export class MonitorSearchDataprovidersComponent { - @Input() searchForm: SearchForm = {class: 'search-form', dark: false}; - customFilter: SearchCustomFilter = null; - initialized: boolean = false; - showSwitchSearchLink: boolean = false; - public properties: EnvProperties = properties; - - constructor(private route: ActivatedRoute, - private router: Router, - private stakeholderService: StakeholderService) { +export class MonitorSearchDataprovidersComponent extends SearchBaseComponent{ + + constructor(protected route: ActivatedRoute, + protected router: Router, + protected customFilterService: CustomFilterService) { + super(); } - - subscriptions = []; - - ngOnDestroy() { - this.subscriptions.forEach(subscription => { - if (subscription instanceof Subscriber) { - subscription.unsubscribe(); - } - }); - } - + ngOnInit() { - this.subscriptions.push(this.route.params.subscribe(params => { - if (params['stakeholder']) { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - if (stakeholder) { - if (stakeholder.type === "funder") { - this.navigateToError(); - } else if (stakeholder.type === "organization") { - let value = stakeholder.index_id; - this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, ""); - } else if (stakeholder.type === "ri") { - this.navigateToError(); - } - this.initialized = true; - } - })); - } - })); - } - - navigateToError() { - this.router.navigate([this.properties.errorLink], {queryParams: {'page': this.router.url}}); + super.initSearch(); } + + } diff --git a/src/app/search/searchPages/simple/searchOrganizations.component.ts b/src/app/search/searchPages/simple/searchOrganizations.component.ts index e708257..ac46af3 100644 --- a/src/app/search/searchPages/simple/searchOrganizations.component.ts +++ b/src/app/search/searchPages/simple/searchOrganizations.component.ts @@ -1,42 +1,34 @@ -import {Component, Input} from '@angular/core'; +import {Component} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; -import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; -import {Subscriber} from "rxjs"; -import {ConfigurationService} from "../../../openaireLibrary/utils/configuration/configuration.service"; -import {SearchForm} from "../../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; +import {SearchBaseComponent} from "../searchBaseComponent"; +import {CustomFilterService} from "../../../shared/customFilter.service"; @Component({ selector: 'monitor-search-organizations', template: ` - +
+
+
+ ` }) -export class MonitorSearchOrganizationsComponent { - @Input() searchForm: SearchForm = {class: 'search-form', dark: false}; - initialized: boolean = false; - constructor(private route: ActivatedRoute, - private router: Router, - private stakeholderService: StakeholderService, private configurationService: ConfigurationService) { - } - subscriptions = []; - ngOnDestroy() { - this.subscriptions.forEach(subscription => { - if (subscription instanceof Subscriber) { - subscription.unsubscribe(); - } - }); +export class MonitorSearchOrganizationsComponent extends SearchBaseComponent{ + + constructor(protected route: ActivatedRoute, + protected router: Router, + protected customFilterService: CustomFilterService) { + super(); } ngOnInit() { - this.subscriptions.push(this.route.params.subscribe(params => { - if (params['stakeholder']) { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - if (stakeholder) { - this.initialized = true; - } - })); - } - })); + super.initSearch(); } + + } diff --git a/src/app/search/searchPages/simple/searchOrganizations.module.ts b/src/app/search/searchPages/simple/searchOrganizations.module.ts index 7b839b5..113c56e 100644 --- a/src/app/search/searchPages/simple/searchOrganizations.module.ts +++ b/src/app/search/searchPages/simple/searchOrganizations.module.ts @@ -6,13 +6,14 @@ import {SearchOrganizationsRoutingModule} from './searchOrganizations-routing.mo import {MonitorSearchOrganizationsComponent} from './searchOrganizations.component'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {SearchOrganizationsModule} from "../../../openaireLibrary/searchPages/searchOrganizations.module"; +import {SearchInputModule} from "../../../openaireLibrary/sharedComponents/search-input/search-input.module"; @NgModule({ imports: [ CommonModule, FormsModule, - SearchOrganizationsRoutingModule, SearchOrganizationsModule - + SearchOrganizationsRoutingModule, SearchOrganizationsModule, SearchInputModule + ], declarations: [ MonitorSearchOrganizationsComponent diff --git a/src/app/search/searchPages/simple/searchProjects.component.ts b/src/app/search/searchPages/simple/searchProjects.component.ts index 306dbc0..dd94ef6 100644 --- a/src/app/search/searchPages/simple/searchProjects.component.ts +++ b/src/app/search/searchPages/simple/searchProjects.component.ts @@ -1,65 +1,37 @@ -import {Component, Input} from '@angular/core'; -import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; +import {Component} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; -import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; -import {Subscriber} from "rxjs"; -import {properties} from "../../../../environments/environment"; -import {SearchForm} from "../../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; +import {SearchBaseComponent} from "../searchBaseComponent"; +import {CustomFilterService} from "../../../shared/customFilter.service"; @Component({ selector: 'monitor-search-projects', template: ` - +
+ + + > ` }) -export class MonitorSearchProjectsComponent { - @Input() searchForm: SearchForm = {class: 'search-form', dark: false}; - customFilter: SearchCustomFilter = null; - initialized: boolean = false; - properties; - constructor(private route: ActivatedRoute, - private router: Router, - private stakeholderService: StakeholderService) { - } - subscriptions = []; - ngOnDestroy() { - this.subscriptions.forEach(subscription => { - if (subscription instanceof Subscriber) { - subscription.unsubscribe(); - } - }); +export class MonitorSearchProjectsComponent extends SearchBaseComponent{ + + constructor(protected route: ActivatedRoute, + protected router: Router, + protected customFilterService: CustomFilterService) { + super(); } ngOnInit() { - this.properties = properties; - this.subscriptions.push(this.route.params.subscribe(params => { - if (params['stakeholder']) { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - if (stakeholder) { - if (stakeholder.type === "funder") { - let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; - this.customFilter = new SearchCustomFilter("Funder", "funder", value, ""); - } else if (stakeholder.type === "organization") { - let value = stakeholder.index_id; - this.customFilter = new SearchCustomFilter("Organization", "relorganizationid", value, ""); - } else if (stakeholder.type === "ri") { - this.navigateToError(); - } - this.initialized = true; + super.initSearch(); + } + - } - })); - } - })); - } - - navigateToError() { - this.router.navigate([this.properties.errorLink], {queryParams: {'page': this.router.url}}); - } } diff --git a/src/app/search/searchPages/simple/searchProjects.module.ts b/src/app/search/searchPages/simple/searchProjects.module.ts index 357da27..221d2d6 100644 --- a/src/app/search/searchPages/simple/searchProjects.module.ts +++ b/src/app/search/searchPages/simple/searchProjects.module.ts @@ -6,11 +6,12 @@ import {SearchProjectsRoutingModule} from './searchProjects-routing.module'; import {MonitorSearchProjectsComponent} from './searchProjects.component'; import {SearchProjectsModule} from "../../../openaireLibrary/searchPages/searchProjects.module"; import {PreviousRouteRecorder} from "../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard"; +import {SearchInputModule} from "../../../openaireLibrary/sharedComponents/search-input/search-input.module"; @NgModule({ imports: [ - CommonModule, FormsModule, SearchProjectsRoutingModule, SearchProjectsModule - + CommonModule, FormsModule, SearchProjectsRoutingModule, SearchProjectsModule, SearchInputModule + ], declarations: [ MonitorSearchProjectsComponent