[develop | WIP] Search pages (projects, organizations, datasources ) use SearchBase component

This commit is contained in:
argirok 2023-11-13 14:02:18 +02:00
parent b8caff57d4
commit dfa7c2a8c2
11 changed files with 126 additions and 288 deletions

View File

@ -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: `
<search-dataproviders *ngIf="initialized" [simpleView]="false"
[customFilter]=customFilter [hasPrefix]="false" [searchForm]="searchForm"
[includeOnlyResultsAndFilter]="false" [showSwitchSearchLink]="showSwitchSearchLink">
<search-dataproviders *ngIf="customFilters" [simpleView]="false"
[customFilters]=customFilters
[hasPrefix]="false"
[showBreadcrumb]="false"
[showSwitchSearchLink]="false"
[searchForm]="{dark: false, class: 'search-form'}"
[openaireLink]="'https://'+(properties.environment != 'production'?'beta.':'')+'explore.openaire.eu/search/simple/projects'">
</search-dataproviders>
`
})
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);
super.initSearch();
}
this.initialized = true;
}
}));
}
}));
}
}

View File

@ -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: `
<search-organizations *ngIf="initialized" [simpleView]="false" [showSwitchSearchLink]="false" [customFilter]="customFilter" [searchForm]="searchForm">
<search-organizations *ngIf="customFilters" [simpleView]="false" [showSwitchSearchLink]="true" [customFilters]="customFilters"
[hasPrefix]="false"
[showBreadcrumb]="false"
[showSwitchSearchLink]="false"
[searchForm]="{dark: false, class: 'search-form'}"
[openaireLink]="'https://'+(properties.environment != 'production'?'beta.':'')+'explore.openaire.eu/search/simple/projects'">
</search-organizations>
`
})
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();
}
}

View File

@ -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: `
<search-projects *ngIf="initialized" [simpleView]="false"
[customFilter]=customFilter [hasPrefix]="false"
[includeOnlyResultsAndFilter]="false" [showSwitchSearchLink]="showSwitchSearchLink"
<search-projects *ngIf="customFilters" [simpleView]="false"
[customFilters]=customFilters
[hasPrefix]="false"
[showBreadcrumb]="false"
[showSwitchSearchLink]="false"
[searchForm]="{dark: false, class: 'search-form'}"
[openaireLink]="'https://'+(properties.environment != 'production'?'beta.':'')+'explore.openaire.eu/search/simple/projects'"
[searchForm]="searchForm"
>
</search-projects>
`
})
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);
super.initSearch();
}
this.initialized = true;
}
}));
}
}));
}
}

View File

@ -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: `
<search-research-results *ngIf="initialized" resultType="result" [simpleView]="false"
<search-research-results *ngIf="customFilters" resultType="result" [simpleView]="false"
[customFilters]=customFilters [hasPrefix]="false"
[includeOnlyResultsAndFilter]="false"
[showBreadcrumb]="false"
[showSwitchSearchLink]="true"
[searchForm]="{dark: false, class: 'search-form'}"
[openaireLink]="'https://'+(properties.environment != 'production'?'beta.':'')+'explore.openaire.eu/search/advanced/research-outcomes'"
[searchForm]="searchForm"
></search-research-results>
`
})
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) {

View File

@ -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{

View File

@ -5,11 +5,12 @@ 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: [

View File

@ -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: `
<search-dataproviders *ngIf="initialized"
[customFilter]=customFilter [hasPrefix]="false" [searchForm]="searchForm"
[includeOnlyResultsAndFilter]="false" [showSwitchSearchLink]="showSwitchSearchLink">
<div class=" uk-flex uk-flex-center ">
<div search-input [(value)]="keyword" [placeholder]="'Search content providers'"
[searchInputClass]="'inner background'" (searchEmitter)="search()" class="uk-width-xlarge@l uk-width-large@m"></div>
</div>
<search-dataproviders *ngIf="customFilters"
[customFilters]=customFilters
[hasPrefix]="false"
[includeOnlyResultsAndFilter]="true" [showBreadcrumb]="false"
[showSwitchSearchLink]="false"
[searchForm]="{dark: false, class: 'search-form'}">
</search-dataproviders>
`
})
export class MonitorSearchDataprovidersComponent {
@Input() searchForm: SearchForm = {class: 'search-form', dark: false};
customFilter: SearchCustomFilter = null;
initialized: boolean = false;
showSwitchSearchLink: boolean = false;
public properties: EnvProperties = properties;
export class MonitorSearchDataprovidersComponent extends SearchBaseComponent{
constructor(private route: ActivatedRoute,
private router: Router,
private stakeholderService: StakeholderService) {
}
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
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) {
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;
}
}));
}
}));
super.initSearch();
}
navigateToError() {
this.router.navigate([this.properties.errorLink], {queryParams: {'page': this.router.url}});
}
}

View File

@ -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: `
<search-organizations *ngIf="initialized" [searchForm]="searchForm">
<div class=" uk-flex uk-flex-center ">
<div search-input [(value)]="keyword" [placeholder]="'Search organizations'"
[searchInputClass]="'inner background'" (searchEmitter)="search()" class="uk-width-xlarge@l uk-width-large@m"></div>
</div>
<search-organizations *ngIf="customFilters" [customFilters]="customFilters"
[hasPrefix]="false"
[includeOnlyResultsAndFilter]="true" [showBreadcrumb]="false"
[showSwitchSearchLink]="false"
[searchForm]="{dark: false, class: 'search-form'}">
</search-organizations>
`
})
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();
}
}

View File

@ -6,12 +6,13 @@ 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: [

View File

@ -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: `
<search-projects *ngIf="initialized"
[customFilter]=customFilter [hasPrefix]="false"
[includeOnlyResultsAndFilter]="false"
<div class=" uk-flex uk-flex-center ">
<div search-input [(value)]="keyword" [placeholder]="'Search projects'"
[searchInputClass]="'inner background'" (searchEmitter)="search()" class="uk-width-xlarge@l uk-width-large@m"></div>
</div>
<search-projects *ngIf="customFilters"
[customFilters]="customFilters" [hasPrefix]="false"
[includeOnlyResultsAndFilter]="true" [showBreadcrumb]="false"
[showSwitchSearchLink]="false"
[searchForm]="{dark: false, class: 'search-form'}"
[openaireLink]="'https://'+(properties.environment != 'production'?'beta.':'')+'explore.openaire.eu/search/simple/projects'"
[searchForm]="searchForm">
>
</search-projects>
`
})
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}});
}
}

View File

@ -6,10 +6,11 @@ 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: [