From bfc49c0e183b41db21605c1cd80c0384d01ddce6 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Wed, 22 Apr 2020 13:00:13 +0000 Subject: [PATCH] [Library|Trunk] Connect - Production release with links to beta: Connect helper ignore community id in domain if in production Search Page: option to include breadcrumb show quickFilters for only results view Quick Filters: one line if they fit Entities Selection Component: add option to show only result types add check if different result types are enabled Add search bar component: select different result types Navbar: apply changes for searchbar to fit git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58517 d315682c-612b-4755-9ff5-7f18f6832af3 --- connect/connectHelper.ts | 4 +- searchPages/find/searchAll.component.ts | 2 +- .../searchResearchResults.component.ts | 3 +- .../advancedSearchForm.component.html | 4 +- .../entitiesSelection.component.ts | 107 +++++++++---- .../searchUtils/newSearchPage.component.html | 18 ++- .../searchUtils/newSearchPage.component.ts | 1 + .../searchUtils/newSearchPage.module.ts | 3 +- .../searchUtils/quick-selections.component.ts | 9 +- sharedComponents/navigationBar.component.html | 48 +++--- sharedComponents/navigationBar.module.ts | 3 +- .../searchBar/searchBar.component.html | 42 ++++++ .../searchBar/searchBar.component.ts | 142 ++++++++++++++++++ .../searchBar/searchBar.module.ts | 24 +++ 14 files changed, 350 insertions(+), 60 deletions(-) create mode 100644 sharedComponents/searchBar/searchBar.component.html create mode 100644 sharedComponents/searchBar/searchBar.component.ts create mode 100644 sharedComponents/searchBar/searchBar.module.ts diff --git a/connect/connectHelper.ts b/connect/connectHelper.ts index cdd65994..fa5bba4b 100644 --- a/connect/connectHelper.ts +++ b/connect/connectHelper.ts @@ -13,7 +13,9 @@ export class ConnectHelper { } else if (domain.indexOf('test.') !== -1) { return null; } else { - domain = domain.substr(0, domain.indexOf('.')); + //for production: ignore communities + // domain = domain.substr(0, domain.indexOf('.')); + return null; } if (domain === 'connect' || domain === 'explore' || domain === 'monitor' || domain === 'admin'){ return null; diff --git a/searchPages/find/searchAll.component.ts b/searchPages/find/searchAll.component.ts index 4f77edae..0a8a9527 100644 --- a/searchPages/find/searchAll.component.ts +++ b/searchPages/find/searchAll.component.ts @@ -91,7 +91,7 @@ export class SearchAllComponent { properties: EnvProperties; @Input() logoURL; @Input() name; - @Input() customFilter: SearchCustomFilter = null; + @Input() customFilter: SearchCustomFilter = null; @Input() piwikSiteId = null; @Input() formPlaceholderText = "Search for research results, projects, content providers & organizations in OpenAIRE"; diff --git a/searchPages/searchResearchResults.component.ts b/searchPages/searchResearchResults.component.ts index 735333cd..d94b0de6 100644 --- a/searchPages/searchResearchResults.component.ts +++ b/searchPages/searchResearchResults.component.ts @@ -33,7 +33,7 @@ import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; [filters]="filters" [quickFilter]="quickFilter" [rangeFilters]="rangeFilters" [rangeFields]="rangeFields" [simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..." - [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" + [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [showBreadcrumb]="showBreadcrumb" > @@ -82,6 +82,7 @@ export class SearchResearchResultsComponent { value: "Open Access" }; @Input() includeOnlyResultsAndFilter: boolean = false; + @Input() showBreadcrumb:boolean = false; @Output() searchPageUpdates = new EventEmitter(); subs: any[]=[]; constructor(private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService) { diff --git a/searchPages/searchUtils/advancedSearchForm.component.html b/searchPages/searchUtils/advancedSearchForm.component.html index 2405f920..1b16878f 100644 --- a/searchPages/searchUtils/advancedSearchForm.component.html +++ b/searchPages/searchUtils/advancedSearchForm.component.html @@ -18,9 +18,9 @@ -
+
diff --git a/searchPages/searchUtils/entitiesSelection.component.ts b/searchPages/searchUtils/entitiesSelection.component.ts index f9d071b9..60fdc481 100644 --- a/searchPages/searchUtils/entitiesSelection.component.ts +++ b/searchPages/searchUtils/entitiesSelection.component.ts @@ -1,16 +1,18 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; import {FormBuilder} from "@angular/forms"; import {EnvProperties} from "../../utils/properties/env-properties"; import {SearchCustomFilter} from "./searchUtils.class"; import {ConfigurationService} from "../../utils/configuration/configuration.service"; import {Router} from "@angular/router"; +import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; +import {MatSelect} from "@angular/material"; @Component({ selector: 'entities-selection', template: ` - - + + All content @@ -20,17 +22,44 @@ import {Router} from "@angular/router"; Content providers Organizations -
-
- All content - Research outcomes - Projects - Content providers - Organizations -
- + + All research outcomes + + Publications + Datasets + Software + Other Research products + + + + +
+ {{onlyresults ? 'All research outcomes' : 'All content'}} + Research outcomes + Projects + Content providers + Organizations + Publications + Datasets + Software + Other Research products
-
+ + @@ -41,6 +70,10 @@ import {Router} from "@angular/router"; export class EntitiesSelectionComponent { showResearchOutcomes: boolean = false; + showPublications: boolean = false; + showDatasets: boolean = false; + showSoftware: boolean = false; + showOther: boolean = false; showProjects: boolean = false; showDataProviders: boolean = false; showOrganizations: boolean = false; @@ -51,7 +84,11 @@ export class EntitiesSelectionComponent { @Input() simpleView: boolean = true; @Input() onChangeNavigate: boolean = true; @Output() selectionChange = new EventEmitter(); + @Input() onlyresults: boolean = false; + @Input() matPanelClass="matSelectionPanel"; + @Input() disableSelect:boolean=false; show = 0; + @ViewChild(MatSelect)matSelect:MatSelect; constructor(private _fb: FormBuilder, private config: ConfigurationService, private router: Router) { @@ -71,6 +108,10 @@ export class EntitiesSelectionComponent { showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"]; } this.showResearchOutcomes = showEntity["publication"] || showEntity["dataset"] || showEntity["software"] || showEntity["orp"]; + this.showPublications = showEntity["publication"]; + this.showDatasets = showEntity["dataset"]; + this.showSoftware = showEntity["software"]; + this.showOther = showEntity["orp"]; this.showProjects = showEntity["project"]; this.showOrganizations = showEntity["organization"]; this.showDataProviders = showEntity["datasource"]; @@ -94,8 +135,9 @@ export class EntitiesSelectionComponent { if(this.showProjects){ this.show++; } - - + if(this.show ==1){ + this.disableSelect = true; + } }); } this.selectedEntity = this.currentEntity; @@ -123,19 +165,32 @@ export class EntitiesSelectionComponent { getUrl(simpleView: boolean) { let url = ""; - if (this.selectedEntity == "all") { - url = (simpleView ? "/search/find/" : null); - } else if (this.selectedEntity == "result") { + if(!this.onlyresults) { + if (this.selectedEntity == "all") { + url = (simpleView ? "/search/find/" : null); + } else if (this.selectedEntity == "result") { + url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults); + } else if (this.selectedEntity == "project") { + url = (simpleView ? this.properties.searchLinkToProjects : this.properties.searchLinkToAdvancedProjects); + } else if (this.selectedEntity == "dataprovider") { + url = (simpleView ? this.properties.searchLinkToDataProviders : this.properties.searchLinkToAdvancedDataProviders); + } else if (this.selectedEntity == "organization") { + url = (simpleView ? this.properties.searchLinkToOrganizations : this.properties.searchLinkToAdvancedOrganizations); + } + }else{ url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults); - } else if (this.selectedEntity == "project") { - url = (simpleView ? this.properties.searchLinkToProjects : this.properties.searchLinkToAdvancedProjects); - } else if (this.selectedEntity == "dataprovider") { - url = (simpleView ? this.properties.searchLinkToDataProviders : this.properties.searchLinkToAdvancedDataProviders); - } else if (this.selectedEntity == "organization") { - url = (simpleView ? this.properties.searchLinkToOrganizations : this.properties.searchLinkToAdvancedOrganizations); } return url; } - + toggle(){ + if(this.matSelect) { + this.matSelect.toggle(); + } + } + open(){ + if(this.matSelect && !this.matSelect.focused) { + this.matSelect.open(); + } + } } diff --git a/searchPages/searchUtils/newSearchPage.component.html b/searchPages/searchUtils/newSearchPage.component.html index b09cfb27..81643e77 100644 --- a/searchPages/searchUtils/newSearchPage.component.html +++ b/searchPages/searchUtils/newSearchPage.component.html @@ -79,7 +79,8 @@
-
+
+ +
Home > Search
@@ -246,6 +249,19 @@
+
diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index 9df9d8f9..5d27b47a 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -76,6 +76,7 @@ export class NewSearchPageComponent { @Input() resultTypes = null; @Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string }; @Input() includeOnlyResultsAndFilter:boolean = false; + @Input() showBreadcrumb:boolean = false; @Input() lastIndex: boolean = true; piwiksub: any; diff --git a/searchPages/searchUtils/newSearchPage.module.ts b/searchPages/searchUtils/newSearchPage.module.ts index 613a68dd..f8ae7522 100644 --- a/searchPages/searchUtils/newSearchPage.module.ts +++ b/searchPages/searchUtils/newSearchPage.module.ts @@ -24,6 +24,7 @@ import {CommunitySearchResultsModule} from "./communitySearchResults.module"; import {SearchResultsModule} from "./searchResults.module"; import {SearchResultsInDepositModule} from "../../deposit/searchResultsInDeposit.module"; import {AdvancedSearchFormModule} from "./advancedSearchForm.module"; +import {QuickSelectionsModule} from "./quick-selections.module"; @NgModule({ imports: [ @@ -32,7 +33,7 @@ import {AdvancedSearchFormModule} from "./advancedSearchForm.module"; SearchPagingModule, SearchResultsPerPageModule, SearchSortingModule, SearchDownloadModule, ModalModule, SearchFilterModule, RangeFilterModule, PiwikServiceModule, HelperModule, Schema2jsonldModule, SEOServiceModule, SearchResultsModule, - SearchResultsInDepositModule, AdvancedSearchFormModule + SearchResultsInDepositModule, AdvancedSearchFormModule, QuickSelectionsModule ], declarations: [ NewSearchPageComponent diff --git a/searchPages/searchUtils/quick-selections.component.ts b/searchPages/searchUtils/quick-selections.component.ts index 47a7aac0..142fdf63 100644 --- a/searchPages/searchUtils/quick-selections.component.ts +++ b/searchPages/searchUtils/quick-selections.component.ts @@ -9,14 +9,14 @@ import {debounceTime} from "rxjs/operators"; @Component({ selector: 'quick-selections', template: ` -
-
+ +
{{quickFilter.value}}
-
+
Include: Publications @@ -144,6 +144,9 @@ export class QuickSelectionsComponent implements OnChanges { } } + if (changes.resultTypes) { + this.setFormValues(); + } } setFormValues() { diff --git a/sharedComponents/navigationBar.component.html b/sharedComponents/navigationBar.component.html index ded7cdda..a2eb5677 100644 --- a/sharedComponents/navigationBar.component.html +++ b/sharedComponents/navigationBar.component.html @@ -16,21 +16,26 @@
+ + +
+ +
diff --git a/sharedComponents/navigationBar.module.ts b/sharedComponents/navigationBar.module.ts index 165c2f21..0f8df7ec 100644 --- a/sharedComponents/navigationBar.module.ts +++ b/sharedComponents/navigationBar.module.ts @@ -8,12 +8,13 @@ import { NavigationBarComponent} from './navigationBar.component'; import { UserMiniModule} from '../login/userMiniModule.module'; import { ConfigurationServiceModule } from '../utils/configuration/configurationService.module'; +import {SearchBarModule} from "./searchBar/searchBar.module"; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, ConfigurationServiceModule, - UserMiniModule + UserMiniModule, SearchBarModule ], declarations: [ NavigationBarComponent diff --git a/sharedComponents/searchBar/searchBar.component.html b/sharedComponents/searchBar/searchBar.component.html new file mode 100644 index 00000000..4e564521 --- /dev/null +++ b/sharedComponents/searchBar/searchBar.component.html @@ -0,0 +1,42 @@ +
+ + + +
+
+ + +
+
+
+ + +
+ +
+
+ + +
+
+ +
diff --git a/sharedComponents/searchBar/searchBar.component.ts b/sharedComponents/searchBar/searchBar.component.ts new file mode 100644 index 00000000..b075d98a --- /dev/null +++ b/sharedComponents/searchBar/searchBar.component.ts @@ -0,0 +1,142 @@ +import {Component, Input} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {EnvProperties} from "../../utils/properties/env-properties"; +import {SearchCustomFilter} from "../../searchPages/searchUtils/searchUtils.class"; + +@Component({ + selector: 'search-bar', + templateUrl: 'searchBar.component.html', + styles:[` + .mat-select-panel-wrap { + z-index: 2001 + } + `] + +}) +export class SearchBarComponent { + + @Input() searchRoute: string = "/search/find"; + @Input() searchPlaceHolder: string = "Search for research results"; + @Input() entitiesSelection:boolean = true; + @Input() properties:EnvProperties; + keyword: string = ""; + entityType = "all"; + enableSearchbar:boolean = true; + @Input() customFilter: SearchCustomFilter = null; + parameters = {}; + constructor(private router: Router, + private route: ActivatedRoute ) { + } + + ngOnInit() { + + // this.activeRouteEnabled = false; + this.route.queryParams.subscribe(params => { + console.log("Init"); + console.log(params); + this.parameters = Object.assign({}, params); + this.entityType = "all"; + if (params["type"] && params["type"].length > 0) { + let types= params["type"].split(","); + if(types.length == 1){ + if(types.indexOf("publications")!=-1 ){ + this.entityType = "publications"; + }else if(types.indexOf("datasets")!=-1 ){ + this.entityType = "datasets"; + }else if(types.indexOf("software")!=-1 ){ + this.entityType = "software"; + }else if(types.indexOf("other")!=-1 ){ + this.entityType = "other"; + } + } + } +console.log(this.entityType); + if(this.getCurrentRoute() == "/search/advanced/research-outcomes" ){ + this.enableSearchbar = false; + }else{ + this.enableSearchbar = true; + } + // this.initialize(); + }); + + } + +/* + ngOnDestroy() { + this.sub.unsubscribe(); + } + + initialize() { + this.activeRouteEnabled = false; + this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user); + /!*if (this.properties.adminToolsAPIURL && this.communityId) { + this.config.getCommunityInformation(this.properties, this.communityId).subscribe(data => { + for (var i = 0; i < data['entities'].length; i++) { + + this.showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"]; + } + for (var i = 0; i < data['pages'].length; i++) { + this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"]; + + } + + }, + error => { + this.handleError("Error getting community information (e.g. pages,entities) for community with id: " + this.communityId, error); + }); + }*!/ + + }*/ + + isEnabled(required, enabled) { + if (!required) { + return true; + } + for (let requiredEntity of required) { + if (typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false) { + return false; + } + } + return true; + } + + + + private handleError(message: string, error) { + console.error("NavigationBar (component): " + message, error); + } + + getCurrentRoute() { + return this.router.url.split('?')[0]; + } + entityChanged($event){ + this.entityType = $event.entity; + this.searchRoute = $event.simpleUrl; + + // this.selectedEntityAdvancedUrl = $event.advancedUrl; +// check if it is search or not + //no search page + + } + keywordChanged(){ + // this.parameters = {}; + if ( this.keyword.length > 0) { + this.parameters["fv0"] = this.keyword; + this.parameters["f0"] = "q"; + }else{ + delete this.parameters['fv0']; + delete this.parameters['f0']; + } + if(this.entityType != "all"){ + this.parameters["type"] = this.entityType; + }else{ + delete this.parameters['type']; + } + //set true only if it is not set allready + if(!this.parameters["qf"]) { + this.parameters["qf"] = true; + } + console.log(this.parameters); + this.router.navigate([this.searchRoute], {queryParams: this.parameters} ); + } +} diff --git a/sharedComponents/searchBar/searchBar.module.ts b/sharedComponents/searchBar/searchBar.module.ts new file mode 100644 index 00000000..fa0a6847 --- /dev/null +++ b/sharedComponents/searchBar/searchBar.module.ts @@ -0,0 +1,24 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { RouterModule } from "@angular/router"; + +import { SearchBarComponent} from './searchBar.component'; +import {AdvancedSearchFormModule} from "../../searchPages/searchUtils/advancedSearchForm.module"; +import {EntitiesSelectionModule} from "../../searchPages/searchUtils/entitiesSelection.module"; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + RouterModule, AdvancedSearchFormModule, EntitiesSelectionModule + ], + declarations: [ + SearchBarComponent + ], + providers:[], + exports: [ + SearchBarComponent + ] +}) +export class SearchBarModule{ }
Field to search