2019-09-11 11:45:54 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
2019-06-14 15:06:58 +02:00
|
|
|
import {ChangeDetectionStrategy} from '@angular/core';
|
|
|
|
import {ViewEncapsulation} from '@angular/core';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Location} from '@angular/common';
|
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
|
|
|
|
2019-09-11 11:45:54 +02:00
|
|
|
import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResearchResults.class';
|
2019-06-14 15:06:58 +02:00
|
|
|
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
|
|
|
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
|
|
|
import {FetchOrganizations} from '../../utils/fetchEntitiesClasses/fetchOrganizations.class';
|
|
|
|
|
2019-09-11 11:45:54 +02:00
|
|
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
2019-06-14 15:06:58 +02:00
|
|
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
|
|
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
|
|
|
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
|
|
|
|
|
2019-09-11 11:45:54 +02:00
|
|
|
import {SearchFields} from '../../utils/properties/searchFields';
|
2019-06-14 15:06:58 +02:00
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
|
|
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
|
|
|
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
|
|
|
import {ConfigurationService} from '../../utils/configuration/configuration.service';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
|
|
|
import {StringUtils} from '../../utils/string-utils.class';
|
2019-06-12 16:13:56 +02:00
|
|
|
import {SearchCustomFilter} from "../searchUtils/searchUtils.class";
|
2019-09-16 11:34:49 +02:00
|
|
|
import {Observable} from "rxjs";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
changeDetection: ChangeDetectionStrategy.Default,
|
|
|
|
encapsulation: ViewEncapsulation.Emulated,
|
2019-06-14 15:06:58 +02:00
|
|
|
selector: 'search-find',
|
|
|
|
templateUrl: 'search.component.html'
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
|
|
|
export class SearchComponent {
|
2019-06-14 15:06:58 +02:00
|
|
|
public sub: any;
|
|
|
|
piwiksub: any;
|
2017-12-19 13:53:46 +01:00
|
|
|
public reloadPublications: boolean;
|
|
|
|
public reloadDatasets: boolean;
|
|
|
|
public reloadSoftware: boolean;
|
2018-07-25 15:27:22 +02:00
|
|
|
public reloadOrps: boolean;
|
2017-12-19 13:53:46 +01:00
|
|
|
public reloadProjects: boolean;
|
|
|
|
public reloadDataproviders: boolean;
|
|
|
|
public reloadOrganizations: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
public pageTitle = "Search in OpenAIRE"
|
2019-06-14 15:06:58 +02:00
|
|
|
public keyword: string = "";
|
|
|
|
public publications: string[];
|
|
|
|
public datasets: string[];
|
|
|
|
public software: string[];
|
|
|
|
public orps: string[];
|
|
|
|
public projectsTab: string[];
|
|
|
|
public dataproviders: string[];
|
|
|
|
public organizations: string[];
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
public activeTab = "publications";
|
|
|
|
public linkToSearchPublications = "";
|
|
|
|
public linkToSearchProjects = "";
|
|
|
|
public linkToSearchDataproviders = "";
|
|
|
|
public linkToSearchDatasets = "";
|
|
|
|
public linkToSearchSoftware = "";
|
2018-07-25 15:27:22 +02:00
|
|
|
public linkToSearchOrps = "";
|
2017-12-19 13:53:46 +01:00
|
|
|
public linkToSearchOrganizations = "";
|
|
|
|
|
2019-09-11 11:45:54 +02:00
|
|
|
public fetchPublications: FetchResearchResults;
|
2019-06-14 15:06:58 +02:00
|
|
|
public fetchDataproviders: FetchDataproviders;
|
|
|
|
public fetchProjects: FetchProjects;
|
2019-09-11 11:45:54 +02:00
|
|
|
public fetchDatasets: FetchResearchResults;
|
|
|
|
public fetchSoftware: FetchResearchResults;
|
|
|
|
public fetchOrps: FetchResearchResults;
|
2017-12-19 13:53:46 +01:00
|
|
|
public fetchOrganizations: FetchOrganizations;
|
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
public searchFields: SearchFields = new SearchFields();
|
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
|
|
|
|
public publicationsSize: any = null;
|
|
|
|
public datasetsSize: any = null;
|
|
|
|
public softwareSize: any = null;
|
|
|
|
public oprsSize: any = null;
|
|
|
|
public fundersSize: any = null;
|
|
|
|
public projectsSize: any = null;
|
|
|
|
public datasourcesSize: any = null;
|
|
|
|
showPublications: boolean = false;
|
|
|
|
showDatasets: boolean = false;
|
|
|
|
showSoftware: boolean = false;
|
|
|
|
showOrps: boolean = false;
|
|
|
|
showProjects: boolean = false;
|
|
|
|
showDataProviders: boolean = false;
|
|
|
|
showOrganizations: boolean = false;
|
|
|
|
advancedSearchLink: string = "/search/advanced/publications";
|
2018-02-05 14:14:59 +01:00
|
|
|
properties: EnvProperties;
|
2018-11-12 16:36:20 +01:00
|
|
|
@Input() logoURL;
|
|
|
|
@Input() name;
|
2019-06-14 15:06:58 +02:00
|
|
|
@Input() customFilter: SearchCustomFilter = null;
|
2018-11-19 11:15:13 +01:00
|
|
|
@Input() piwikSiteId = null;
|
2018-12-07 12:07:19 +01:00
|
|
|
@Input() formPlaceholderText = "Search for research results, projects, content providers & organizations in OpenAIRE";
|
|
|
|
|
2018-11-14 11:38:53 +01:00
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
public subPub;
|
|
|
|
public subData;
|
|
|
|
public subSoftware;
|
|
|
|
public subOrps;
|
|
|
|
public subProjects;
|
|
|
|
public subOrg;
|
|
|
|
public subDataPr;
|
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute,
|
|
|
|
private _router: Router,
|
2019-09-11 11:45:54 +02:00
|
|
|
private _searchResearchResultsService: SearchResearchResultsService,
|
2019-06-14 15:06:58 +02:00
|
|
|
private _searchDataprovidersService: SearchDataprovidersService,
|
|
|
|
private _searchProjectsService: SearchProjectsService,
|
|
|
|
private _searchOrganizationsService: SearchOrganizationsService,
|
|
|
|
private _refineFieldResultsService: RefineFieldResultsService,
|
|
|
|
private location: Location,
|
|
|
|
private _meta: Meta,
|
|
|
|
private _title: Title,
|
|
|
|
private _piwikService: PiwikService,
|
|
|
|
private config: ConfigurationService,
|
|
|
|
private seoService: SEOService) {
|
2019-09-11 11:45:54 +02:00
|
|
|
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
|
2019-06-14 15:06:58 +02:00
|
|
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
|
|
|
this.fetchProjects = new FetchProjects(this._searchProjectsService);
|
2019-09-11 11:45:54 +02:00
|
|
|
this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService);
|
|
|
|
this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService);
|
|
|
|
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
|
2019-06-14 15:06:58 +02:00
|
|
|
this.fetchOrganizations = new FetchOrganizations(this._searchOrganizationsService);
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
|
|
|
|
var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
|
|
|
|
var title = "OpenAIRE | Search publications, research data, projects... | OpenAIRE";
|
|
|
|
this.properties = data.envSpecific;
|
2019-06-14 15:06:58 +02:00
|
|
|
var url = data.envSpecific.baseLink + this._router.url;
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
this._title.setTitle(title);
|
2019-06-14 15:06:58 +02:00
|
|
|
this._meta.updateTag({content: description}, "name='description'");
|
|
|
|
this._meta.updateTag({content: description}, "property='og:description'");
|
|
|
|
this._meta.updateTag({content: title}, "property='og:title'");
|
|
|
|
this._meta.updateTag({content: url}, "property='og:url'");
|
|
|
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url, false);
|
|
|
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
2018-11-19 11:15:13 +01:00
|
|
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe();
|
2018-02-05 14:14:59 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
if ((this.customFilter && this.customFilter.queryFieldName == "communitId") || this.properties.adminToolsCommunity) {
|
|
|
|
this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communitId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
|
|
|
var showEntity = {};
|
|
|
|
for (var i = 0; i < data['entities'].length; i++) {
|
|
|
|
|
|
|
|
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
|
|
|
}
|
|
|
|
this.showPublications = showEntity["publication"];
|
|
|
|
this.showDatasets = showEntity["dataset"];
|
|
|
|
this.showProjects = showEntity["project"];
|
|
|
|
this.showOrganizations = showEntity["organization"];
|
|
|
|
this.showDataProviders = showEntity["datasource"];
|
|
|
|
this.showSoftware = showEntity["software"];
|
|
|
|
this.showOrps = showEntity["orp"];
|
|
|
|
if (this.customFilter && this.customFilter.queryFieldName == "communityId") {
|
|
|
|
this.showProjects = false;
|
|
|
|
this.showOrganizations = false;
|
|
|
|
this.showDataProviders = false;
|
|
|
|
}
|
|
|
|
this.loadAll();
|
2018-02-05 14:14:59 +01:00
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if ((this.customFilter && this.customFilter.queryFieldName == "country")) {
|
|
|
|
this.showPublications =true;
|
|
|
|
this.showDatasets = true;
|
|
|
|
this.showDataProviders = true;
|
|
|
|
this.showSoftware = true;
|
|
|
|
this.showOrps = true;
|
|
|
|
this.showProjects = true;
|
|
|
|
this.showOrganizations = true;
|
|
|
|
this.showDataProviders = true;
|
2018-11-19 11:15:13 +01:00
|
|
|
}
|
2019-06-12 16:13:56 +02:00
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
this.loadAll();
|
|
|
|
});
|
|
|
|
}
|
2018-07-25 15:27:22 +02:00
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
loadAll() {
|
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
|
|
|
|
|
|
this.reloadTabs();
|
|
|
|
this.keyword = (params['keyword']) ? params['keyword'] : "";
|
|
|
|
if (this.keyword != null && this.keyword.length > 0) {
|
|
|
|
//if showPublications == false will setValues another entity as the first
|
|
|
|
if (this.showPublications) {
|
|
|
|
this.activeTab = "publications";
|
|
|
|
this.searchPublications();
|
|
|
|
} else if (this.showDatasets) {
|
|
|
|
this.activeTab = "research data";
|
|
|
|
this.searchDatasets();
|
|
|
|
} else if (this.showSoftware) {
|
|
|
|
this.activeTab = "software";
|
|
|
|
this.searchSoftware();
|
|
|
|
} else if (this.showOrps) {
|
|
|
|
this.activeTab = "other research products";
|
|
|
|
this.searchOrps();
|
|
|
|
} else if (this.showProjects) {
|
|
|
|
this.activeTab = "projects";
|
|
|
|
this.searchProjects();
|
|
|
|
} else if (this.showDataProviders) {
|
|
|
|
this.activeTab = "content providers";
|
|
|
|
this.searchDataProviders();
|
|
|
|
} else if (this.showOrganizations) {
|
|
|
|
this.activeTab = "organizations";
|
|
|
|
this.searchOrganizations();
|
|
|
|
}
|
|
|
|
this.count();
|
2018-02-05 14:14:59 +01:00
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
});
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
public ngOnDestroy() {
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.sub) {
|
2018-09-05 14:37:47 +02:00
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.piwiksub) {
|
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.keyword != null && this.keyword.length > 0) {
|
|
|
|
if (this.subPub) {
|
|
|
|
this.subPub.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subData) {
|
|
|
|
this.subData.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subSoftware) {
|
|
|
|
this.subSoftware.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subOrps) {
|
|
|
|
this.subOrps.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subProjects) {
|
|
|
|
this.subProjects.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subOrg) {
|
|
|
|
this.subOrg.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.subDataPr) {
|
|
|
|
this.subDataPr.unsubscribe();
|
2018-02-05 14:14:59 +01:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
public searchPublications() {
|
|
|
|
this.activeTab = "publications";
|
2019-09-16 11:34:49 +02:00
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedPublications;//"/search/advanced/publications";
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.reloadPublications &&
|
|
|
|
this.fetchPublications.searchUtils.status != this.errorCodes.NONE /*&&
|
2019-09-30 12:55:59 +02:00
|
|
|
this.fetchPublications.searchUtils.status != this.errorCodes.ERROR*/
|
|
|
|
&& (this.keyword != null && this.keyword.length > 0)) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.reloadPublications = false;
|
2019-09-11 11:45:54 +02:00
|
|
|
this.fetchPublications.getResultsByKeyword("publication", this.keyword, 1, 10, this.properties, this.customFilter);
|
2018-02-05 14:14:59 +01:00
|
|
|
this.linkToSearchPublications = this.properties.searchLinkToPublications;// + "?keyword=" + this.keyword;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public searchDatasets() {
|
|
|
|
this.activeTab = "research data";
|
2019-09-16 11:34:49 +02:00
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedDatasets;//"/search/advanced/datasets";
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.reloadDatasets &&
|
|
|
|
this.fetchDatasets.searchUtils.status != this.errorCodes.NONE /*&&
|
2019-09-30 12:55:59 +02:00
|
|
|
this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR*/
|
|
|
|
&& (this.keyword != null && this.keyword.length > 0)) {
|
2019-06-14 15:06:58 +02:00
|
|
|
this.reloadDatasets = false;
|
2019-09-11 11:45:54 +02:00
|
|
|
this.fetchDatasets.getResultsByKeyword("dataset", this.keyword, 1, 10, this.properties, this.customFilter);
|
2019-06-14 15:06:58 +02:00
|
|
|
this.linkToSearchDatasets = this.properties.searchLinkToDatasets;// + "?keyword=" + this.keyword;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchSoftware() {
|
|
|
|
|
|
|
|
this.activeTab = "software";
|
2019-09-16 11:34:49 +02:00
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedSoftware;//"/search/advanced/software";
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.reloadSoftware
|
|
|
|
&& this.fetchSoftware.searchUtils.status != this.errorCodes.NONE/* &&
|
2017-12-19 13:53:46 +01:00
|
|
|
( this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
|
2019-09-30 12:55:59 +02:00
|
|
|
this.fetchSoftware.searchUtils.status == this.errorCodes.DONE )*/
|
|
|
|
&& (this.keyword != null && this.keyword.length > 0)) {
|
2019-06-14 15:06:58 +02:00
|
|
|
this.reloadSoftware = false;
|
2019-09-11 11:45:54 +02:00
|
|
|
this.fetchSoftware.getResultsByKeyword("software", this.keyword, 1, 10, this.properties, this.customFilter);
|
2019-06-14 15:06:58 +02:00
|
|
|
this.linkToSearchSoftware = this.properties.searchLinkToSoftware;// + "?keyword=" + this.keyword;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchOrps() {
|
|
|
|
this.activeTab = "other research products";
|
2019-09-16 11:34:49 +02:00
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedOrps;//"/search/advanced/other";
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.reloadOrps &&
|
|
|
|
this.fetchOrps.searchUtils.status != this.errorCodes.NONE /*&&
|
2019-09-30 12:55:59 +02:00
|
|
|
this.fetchOrps.searchUtils.status != this.errorCodes.ERROR*/
|
|
|
|
&& (this.keyword != null && this.keyword.length > 0)) {
|
2019-06-14 15:06:58 +02:00
|
|
|
this.reloadOrps = false;
|
2019-09-11 11:45:54 +02:00
|
|
|
this.fetchOrps.getResultsByKeyword("other", this.keyword, 1, 10, this.properties, this.customFilter);
|
2019-06-14 15:06:58 +02:00
|
|
|
this.linkToSearchOrps = this.properties.searchLinkToOrps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchProjects() {
|
|
|
|
this.activeTab = "projects";
|
2019-09-16 11:34:49 +02:00
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects;//"/search/advanced/projects";
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.reloadProjects &&
|
|
|
|
this.fetchProjects.searchUtils.status != this.errorCodes.NONE /*&&
|
2019-09-30 12:55:59 +02:00
|
|
|
this.fetchProjects.searchUtils.status != this.errorCodes.ERROR*/
|
|
|
|
&& (this.keyword != null && this.keyword.length > 0)) {
|
2019-06-14 15:06:58 +02:00
|
|
|
this.reloadProjects = false;
|
|
|
|
this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
|
|
|
|
this.linkToSearchProjects = this.properties.searchLinkToProjects;// + "?keyword=" + this.keyword;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchDataProviders() {
|
|
|
|
this.activeTab = "content providers";
|
2019-09-16 11:34:49 +02:00
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedDataProviders;//"/search/advanced/dataproviders";
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.reloadDataproviders &&
|
|
|
|
this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE /*&&
|
2019-09-30 12:55:59 +02:00
|
|
|
this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR*/
|
|
|
|
&& (this.keyword != null && this.keyword.length > 0)) {
|
2019-06-14 15:06:58 +02:00
|
|
|
this.reloadDataproviders = false;
|
|
|
|
this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
|
|
|
|
this.linkToSearchDataproviders = this.properties.searchLinkToDataProviders;// + "?keyword=" + this.keyword;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public searchOrganizations() {
|
|
|
|
this.activeTab = "organizations";
|
2019-09-16 11:34:49 +02:00
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedOrganizations;//"/search/advanced/organizations";
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.reloadOrganizations &&
|
|
|
|
this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE /*&&
|
2019-09-30 12:55:59 +02:00
|
|
|
this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR*/
|
|
|
|
&& (this.keyword != null && this.keyword.length > 0)) {
|
2019-06-14 15:06:58 +02:00
|
|
|
this.reloadOrganizations = false;
|
|
|
|
this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
|
|
|
|
this.linkToSearchOrganizations = this.properties.searchLinkToOrganizations;// + "?keyword=" + this.keyword;
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
public keywordChanged($event) {
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
this.keyword = $event.value;
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("Search Find: search with keyword \"" + this.keyword + "\"" );
|
2019-06-14 15:06:58 +02:00
|
|
|
this.location.go(location.pathname, "?keyword=" + this.keyword);
|
2017-12-19 13:53:46 +01:00
|
|
|
this.reloadTabs();
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab == "publications") {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchPublications();
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab == "projects") {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchProjects();
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab == "content providers") {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchDataProviders();
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab == "research data") {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchDatasets();
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab == "software") {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchSoftware();
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab == "other research products") {
|
2018-07-25 15:27:22 +02:00
|
|
|
this.searchOrps();
|
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab == "organizations") {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchOrganizations();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.count();
|
2019-06-14 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private count() {
|
|
|
|
var refineParams = null;
|
|
|
|
if (this.customFilter) {
|
|
|
|
refineParams = (refineParams ? (refineParams + '&') : '') + "&fq=" + StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId)));
|
|
|
|
}
|
|
|
|
if (this.activeTab != "publications" && this.showPublications) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.fetchPublications.results = [];
|
2018-11-19 11:15:13 +01:00
|
|
|
|
2019-09-16 11:34:49 +02:00
|
|
|
this.subPub = this.numOfSearchResults("publication", this.fetchPublications, refineParams);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab != "research data" && this.showDatasets) {
|
|
|
|
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.fetchDatasets.results = [];
|
2019-09-16 11:34:49 +02:00
|
|
|
this.subData = this.numOfSearchResults("dataset", this.fetchDatasets, refineParams);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab != "software" && this.showSoftware) {
|
|
|
|
this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.fetchSoftware.results = [];
|
2019-09-16 11:34:49 +02:00
|
|
|
this.subSoftware = this.numOfSearchResults("software", this.fetchSoftware, refineParams);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab != "other research products" && this.showOrps) {
|
|
|
|
this.fetchOrps.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.fetchOrps.results = [];
|
2019-09-16 11:34:49 +02:00
|
|
|
this.subOrps = this.numOfSearchResults("other", this.fetchOrps, refineParams);
|
2018-07-25 15:27:22 +02:00
|
|
|
}
|
2019-06-14 15:06:58 +02:00
|
|
|
if (this.activeTab != "projects" && this.showProjects) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.fetchProjects.results = [];
|
2019-06-14 15:06:58 +02:00
|
|
|
this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword, this.properties, refineParams).subscribe(
|
|
|
|
data => {
|
|
|
|
this.fetchProjects.searchUtils.totalResults = data;
|
|
|
|
this.fetchProjects.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.fetchProjects.searchUtils.totalResults == 0) {
|
|
|
|
this.fetchProjects.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting number of Projects", err);
|
|
|
|
this.fetchProjects.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (this.activeTab != "content providers" && this.showDataProviders) {
|
|
|
|
this.fetchDataproviders.results = [];
|
|
|
|
this.fetchDataproviders.getNumForSearch(this.keyword, this.properties, refineParams);
|
|
|
|
}
|
|
|
|
if (this.activeTab != "organizations" && this.showOrganizations) {
|
|
|
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
this.fetchOrganizations.results = [];
|
|
|
|
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword, this.properties, refineParams).subscribe(
|
|
|
|
data => {
|
|
|
|
this.fetchOrganizations.searchUtils.totalResults = data;
|
|
|
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.fetchOrganizations.searchUtils.totalResults == 0) {
|
|
|
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting number of Organizations", err);
|
|
|
|
this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-09-16 11:34:49 +02:00
|
|
|
private numOfSearchResults(resultType: string, fetchClass: FetchResearchResults, refineParams): Observable<any> {
|
|
|
|
return this._searchResearchResultsService.numOfSearchResults(resultType, this.keyword, this.properties, refineParams).subscribe(
|
|
|
|
data => {
|
|
|
|
fetchClass.searchUtils.totalResults = data;
|
|
|
|
fetchClass.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (fetchClass.searchUtils.totalResults == 0) {
|
|
|
|
fetchClass.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting number of "+this.getEntityName(resultType, true, true), err);
|
|
|
|
fetchClass.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
private reloadTabs() {
|
|
|
|
this.reloadPublications = true;
|
|
|
|
this.reloadDatasets = true;
|
|
|
|
this.reloadSoftware = true;
|
|
|
|
this.reloadOrps = true;
|
|
|
|
this.reloadProjects = true;
|
|
|
|
this.reloadDataproviders = true;
|
|
|
|
this.reloadOrganizations = true;
|
|
|
|
this.fetchOrganizations.searchUtils.status = null;
|
|
|
|
this.fetchDataproviders.searchUtils.status = null;
|
|
|
|
this.fetchProjects.searchUtils.status = null;
|
|
|
|
this.fetchPublications.searchUtils.status = null;
|
|
|
|
this.fetchDatasets.searchUtils.status = null;
|
|
|
|
this.fetchSoftware.searchUtils.status = null;
|
|
|
|
this.fetchOrps.searchUtils.status = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error("General Search Page: " + message, error);
|
|
|
|
}
|
2019-09-16 11:34:49 +02:00
|
|
|
|
|
|
|
private getEntityName (entityType:string, plural:boolean, full:boolean): string {
|
|
|
|
if(entityType == "publication") {
|
|
|
|
return "publication" + (plural ? "s" : "");
|
|
|
|
} else if(entityType == "dataset") {
|
|
|
|
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
|
|
|
} else if(entityType == "software") {
|
|
|
|
return "software";
|
|
|
|
} else if(entityType == "other") {
|
|
|
|
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|