openaire-library/searchPages/searchResearchResults.compo...

310 lines
14 KiB
TypeScript
Raw Normal View History

import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
import {SearchResearchResultsService} from '../services/searchResearchResults.service';
import {ErrorCodes} from '../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../utils/errorMessages.component';
import {SearchFields} from '../utils/properties/searchFields';
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component";
import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class";
import {properties} from "../../../environments/environment";
@Component({
selector: 'search-research-results',
template: `
<new-search-page
pageTitle="{{(simpleView?'':'Advanced ')}} Search for {{ getEntityName(resultType, true, true) | titlecase }}"
[entityType]="resultType"
[type]="getEntityName(resultType, true, true)"
[results]="results"
[searchUtils]="searchUtils"
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
[sortedByChanged]="searchUtils.sortBy" [resultsPerPageChanged]="searchUtils.size"
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
[csvParams]="csvParams" [csvPath]="getEntityName(resultType, true, false)"
[simpleSearchLink]="simpleSearchLink" [advancedSearchLink]="advancedSearchLink"
[disableForms]="disableForms"
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
[disableRefineForms]="disableRefineForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults"
[openaireLink]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
searchFormClass="publicationsSearchForm"
[filters]="filters" [quickFilter]="quickFilter"
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields"
[simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..."
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [showBreadcrumb]="showBreadcrumb"
[showAdvancedSearchLink]="showAdvancedSearchLink"
>
</new-search-page>
`
})
export class SearchResearchResultsComponent {
@Input() resultType: string = "result";
@Input() simpleSearchLink: string = "";
advancedSearchLink: string = "";
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = properties.piwikSiteId;
@Input() hasPrefix: boolean = true;
public results = [];
public filters = [];
public rangeFilters: RangeFilter[] = [];
public searchUtils: SearchUtilsClass = new SearchUtilsClass();
public searchFields: SearchFields = new SearchFields();
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
public fieldIdsMap = this.searchFields.RESULT_FIELDS;
public rangeFields: string[][] = this.searchFields.RESULT_RANGE_FIELDS;
public selectedFields: AdvancedField[] = [];
public resourcesQuery = "((oaftype exact result) and (resulttypeid exact " + this.resultType + "))";
public csvParams: string;
public disableForms: boolean = false;
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
public disableRefineForms: boolean = false;
public loadPaging: boolean = true;
public oldTotalResults: number = 0;
@Input() openaireLink: string;
@Input() customFilter: SearchCustomFilter = null;
public pagingLimit: number = 0;
public isPiwikEnabled;
properties: EnvProperties = properties;
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
@ViewChild(NewSearchPageComponent) searchPage: NewSearchPageComponent;
@Input() simpleView: boolean = true;
quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
filter: null,
selected: true,
filterId: "resultbestaccessright",
value: "Open Access"
};
@Input() includeOnlyResultsAndFilter: boolean = false;
@Input() showBreadcrumb: boolean = false;
@Output() searchPageUpdates = new EventEmitter();
@Input() showAdvancedSearchLink: boolean = true;
subs: any[] = [];
constructor(private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService) {
this.results = [];
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
this.searchUtils.status = this.errorCodes.LOADING;
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
this.searchUtils.refineStatus = this.errorCodes.LOADING;
}
ngOnInit() {
//TODO add checks about which result types are enabled!
this.pagingLimit = this.properties.pagingLimit;
this.isPiwikEnabled = this.properties.enablePiwikTrack;
if (!this.simpleSearchLink) {
this.simpleSearchLink = this.properties.searchLinkToResults;
}
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults;
this.searchUtils.baseUrl = (this.simpleView) ? this.simpleSearchLink : this.advancedSearchLink;
this.searchUtils.status = this.errorCodes.LOADING;
var firstLoad = true;
this.subs.push(this.route.queryParams.subscribe(params => {
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
//this.subs.push(this.route.queryParams.switchMap(params => {
this.loadPaging = true;
if (params['page'] && this.searchUtils.page != params['page']) {
this.loadPaging = false;
this.oldTotalResults = this.searchUtils.totalResults;
}
var refine = true;
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
if (
(
this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page'])
&& (this.searchUtils.page == 1 || params['page'])
)
&& this.filters && !firstLoad
) {
refine = false;
this.searchUtils.status = this.errorCodes.DONE;
}
if (
(
this.searchUtils.sortBy != ((params['sortBy'] === undefined) ? "" : params['sortBy'])
&& (this.searchUtils.sortBy == "" || params['sortBy'])
)
&& this.filters && !firstLoad
) {
refine = false;
this.searchUtils.status = this.errorCodes.DONE;
}
if (
(
this.searchUtils.size != ((params['size'] === undefined) ? 10 : +params['size'])
&& (this.searchUtils.size == 10 || params['size'])
)
&& this.filters && !firstLoad
) {
refine = false;
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
this.searchUtils.status = this.errorCodes.DONE;
}
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
let page = (params['page'] === undefined) ? 1 : +params['page'];
this.searchUtils.page = (page <= 0) ? 1 : page;
this.searchUtils.size = (params['size'] === undefined) ? 10 : +params['size'];
if (this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
this.searchUtils.size = 10;
}
this.searchUtils.sortBy = (params['sortBy']) ? params['sortBy'] : '';
if (this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
this.searchUtils.sortBy = "";
}
this.selectedFields = [];
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter);
if(refine) {
this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
}
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
firstLoad = false;
}));
}
ngOnDestroy() {
for (let sub of this.subs) {
sub.unsubscribe();
}
}
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
public _getFilters(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null) {
if (page <= this.pagingLimit || this.searchUtils.refineStatus == this.errorCodes.LOADING) {
this.searchUtils.refineStatus = this.errorCodes.LOADING;
this.disableRefineForms = true;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils});
this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
//.switchMap(
.subscribe(
data => {
if (refine) {
this.filters = this.searchPage.prepareFiltersToShow(data[2], data[0]);
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
}
this.searchUtils.refineStatus = this.errorCodes.DONE;
// if (this.searchUtils.totalResults == 0) {
// this.searchUtils.status = this.errorCodes.NONE;
// }
this.disableRefineForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils})
},
err => {
this.handleError("Error getting " + this.getEntityName(this.resultType, true, true), err);
this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status);
this.disableRefineForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils})
}
));
}
}
public _getResults(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null) {
if (page > this.pagingLimit) {
size = 0;
}
if (page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
// if (parameters != null && parameters != '') {
// this.csvParams = "&fq=(" + this.resourcesQuery + " and (" + parameters + "))";
// } else {
// this.csvParams = "&fq=" + this.resourcesQuery;
// }
this.csvParams = (parameters ? ("&fq=(" + parameters) : "") + (parameters ? ")" : "");
this.csvParams += (refineFieldsFilterQuery ? refineFieldsFilterQuery : "");
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils});
this.results = [];
this.searchUtils.totalResults = 0;
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
//this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery)
.subscribe(
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
data => {
this.searchUtils.totalResults = data[0];
this.results = data[1];
// if (refine) {
// this.filters = this.searchPage.prepareFiltersToShow(data[2],this.searchUtils.totalResults);
// this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
// } else {
if(!refine) {
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
}
this.searchUtils.status = this.errorCodes.DONE;
if (this.searchUtils.totalResults == 0) {
this.searchUtils.status = this.errorCodes.NONE;
}
this.disableForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils})
if (this.searchUtils.status == this.errorCodes.DONE) {
// Page out of limit!!!
let totalPages: any = this.searchUtils.totalResults / (this.searchUtils.size);
if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1);
}
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
if (totalPages < page) {
this.searchUtils.totalResults = 0;
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
}
}
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
},
err => {
this.handleError("Error getting " + this.getEntityName(this.resultType, true, true), err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
//TODO check erros (service not available, bad request)
// if( ){
// this.searchUtils.status = ErrorCodes.ERROR;
// }
//var errorCodes:ErrorCodes = new ErrorCodes();
//this.searchUtils.status = errorCodes.NOT_AVAILABLE;
/*if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}*/
//this.searchPage.closeLoading();
this.disableForms = false;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils})
}
));
}
}
private handleError(message: string, error) {
console.error(this.getEntityName(this.resultType, true, true) + " advanced Search Page: " + message, error);
}
public 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");
} else if (entityType == "result") {
return (full ? ("research outcome" + (plural ? "s" : "")) : "result");
}
}
}