2021-05-12 16:22:08 +02:00
|
|
|
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
|
2021-02-10 10:26:47 +01:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
2020-02-11 15:56:20 +01:00
|
|
|
import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
|
2020-01-31 16:12:51 +01:00
|
|
|
import {SearchResearchResultsService} from '../services/searchResearchResults.service';
|
|
|
|
import {ErrorCodes} from '../utils/properties/errorCodes';
|
|
|
|
import {ErrorMessagesComponent} from '../utils/errorMessages.component';
|
2022-05-05 19:35:08 +02:00
|
|
|
import {OpenaireEntities, SearchFields} from '../utils/properties/searchFields';
|
2020-01-31 16:12:51 +01:00
|
|
|
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
|
|
|
|
import {EnvProperties} from '../utils/properties/env-properties';
|
2022-04-15 14:38:41 +02:00
|
|
|
import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
|
2020-02-17 15:19:14 +01:00
|
|
|
import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class";
|
2020-06-29 15:15:52 +02:00
|
|
|
import {properties} from "../../../environments/environment";
|
2020-10-20 16:47:54 +02:00
|
|
|
import {ContextsService} from "../claims/claim-utils/service/contexts.service";
|
2022-06-03 12:01:55 +02:00
|
|
|
import {StringUtils} from "../utils/string-utils.class";
|
2020-01-31 16:12:51 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'search-research-results',
|
2020-06-29 15:15:52 +02:00
|
|
|
template: `
|
2020-01-31 16:12:51 +01:00
|
|
|
<new-search-page
|
2020-06-29 15:15:52 +02:00
|
|
|
pageTitle="{{(simpleView?'':'Advanced ')}} Search for {{ getEntityName(resultType, true, true) | titlecase }}"
|
|
|
|
[entityType]="resultType"
|
|
|
|
[type]="getEntityName(resultType, true, true)"
|
|
|
|
[results]="results"
|
|
|
|
[searchUtils]="searchUtils"
|
2021-08-13 11:42:50 +02:00
|
|
|
[sortedByChanged]="searchUtils.sortBy"
|
2020-06-29 15:15:52 +02:00
|
|
|
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
|
2022-05-05 19:35:08 +02:00
|
|
|
[csvParams]="csvParams" [csvPath]="getEntityFileName(resultType)"
|
2020-06-29 15:15:52 +02:00
|
|
|
[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"
|
2020-06-29 15:15:52 +02:00
|
|
|
[loadPaging]="loadPaging"
|
|
|
|
[oldTotalResults]="oldTotalResults"
|
|
|
|
[openaireLink]=openaireLink
|
|
|
|
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
2022-04-15 14:38:41 +02:00
|
|
|
[searchForm]="searchForm"
|
2020-06-29 15:15:52 +02:00
|
|
|
[filters]="filters" [quickFilter]="quickFilter"
|
|
|
|
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields"
|
|
|
|
[simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..."
|
|
|
|
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [showBreadcrumb]="showBreadcrumb"
|
2020-08-13 13:15:10 +02:00
|
|
|
[showSwitchSearchLink]="showSwitchSearchLink"
|
2020-08-17 10:51:46 +02:00
|
|
|
[stickyForm]="stickyForm"
|
2020-01-31 16:12:51 +01:00
|
|
|
>
|
|
|
|
</new-search-page>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchResearchResultsComponent {
|
2020-02-11 12:58:51 +01:00
|
|
|
@Input() resultType: string = "result";
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-02-19 16:35:48 +01:00
|
|
|
@Input() simpleSearchLink: string = "";
|
2020-01-31 16:12:51 +01:00
|
|
|
advancedSearchLink: string = "";
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
private errorCodes: ErrorCodes;
|
|
|
|
private errorMessages: ErrorMessagesComponent;
|
2020-06-29 15:15:52 +02:00
|
|
|
@Input() piwikSiteId = properties.piwikSiteId;
|
2020-01-31 16:12:51 +01:00
|
|
|
@Input() hasPrefix: boolean = true;
|
2022-04-15 14:38:41 +02:00
|
|
|
@Input() searchForm: SearchForm = {class: 'search-form', dark: true};
|
2020-01-31 16:12:51 +01:00
|
|
|
public results = [];
|
|
|
|
public filters = [];
|
2020-02-17 15:19:14 +01:00
|
|
|
public rangeFilters: RangeFilter[] = [];
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
public searchUtils: SearchUtilsClass = new SearchUtilsClass();
|
|
|
|
public searchFields: SearchFields = new SearchFields();
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
|
|
|
|
public fieldIdsMap = this.searchFields.RESULT_FIELDS;
|
2020-06-29 15:15:52 +02:00
|
|
|
public rangeFields: string[][] = this.searchFields.RESULT_RANGE_FIELDS;
|
2020-01-31 16:12:51 +01:00
|
|
|
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;
|
2020-01-31 16:12:51 +01:00
|
|
|
public loadPaging: boolean = true;
|
|
|
|
public oldTotalResults: number = 0;
|
|
|
|
@Input() openaireLink: string;
|
|
|
|
@Input() customFilter: SearchCustomFilter = null;
|
|
|
|
public pagingLimit: number = 0;
|
|
|
|
public isPiwikEnabled;
|
2020-06-29 15:15:52 +02:00
|
|
|
properties: EnvProperties = properties;
|
2022-05-05 19:35:08 +02:00
|
|
|
public openaireEntities = OpenaireEntities;
|
2020-01-31 16:12:51 +01:00
|
|
|
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
|
2021-07-14 13:19:57 +02:00
|
|
|
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
|
2020-01-31 16:12:51 +01:00
|
|
|
@Input() simpleView: boolean = true;
|
2020-02-11 15:56:20 +01:00
|
|
|
quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
|
|
|
filter: null,
|
|
|
|
selected: true,
|
|
|
|
filterId: "resultbestaccessright",
|
|
|
|
value: "Open Access"
|
|
|
|
};
|
2020-02-19 16:35:48 +01:00
|
|
|
@Input() includeOnlyResultsAndFilter: boolean = false;
|
2020-06-29 15:15:52 +02:00
|
|
|
@Input() showBreadcrumb: boolean = false;
|
2020-02-19 16:35:48 +01:00
|
|
|
@Output() searchPageUpdates = new EventEmitter();
|
2020-08-13 13:15:10 +02:00
|
|
|
@Input() showSwitchSearchLink: boolean = true;
|
2020-06-29 15:15:52 +02:00
|
|
|
subs: any[] = [];
|
2020-10-20 16:47:54 +02:00
|
|
|
searchResultsSub: any;
|
|
|
|
searchFiltersSub: any;
|
2020-08-17 10:51:46 +02:00
|
|
|
@Input() stickyForm:boolean = false;
|
2020-10-20 16:47:54 +02:00
|
|
|
|
|
|
|
private timeoutId;
|
|
|
|
private promise: Promise<boolean> = null;
|
|
|
|
private publicCommunities = null;
|
|
|
|
|
2021-02-10 10:26:47 +01:00
|
|
|
@Input() usedBy: string = "search";
|
|
|
|
@Input() orcidQuery: string = "";
|
|
|
|
@Input() identifiers: string[] = [];
|
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute, private _router: Router,
|
|
|
|
private _searchResearchResultsService: SearchResearchResultsService,
|
2020-10-20 16:47:54 +02:00
|
|
|
private _contextService: ContextsService) {
|
2020-01-31 16:12:51 +01:00
|
|
|
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;
|
2020-10-20 16:47:54 +02:00
|
|
|
this.getPublicCommunities();
|
2020-02-19 16:35:48 +01:00
|
|
|
}
|
2021-02-10 10:26:47 +01:00
|
|
|
|
|
|
|
getRoute(){
|
|
|
|
return this._router.url.split("?")[0];
|
|
|
|
}
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
ngOnInit() {
|
2020-02-13 15:44:51 +01:00
|
|
|
//TODO add checks about which result types are enabled!
|
2020-06-29 15:15:52 +02:00
|
|
|
this.pagingLimit = this.properties.pagingLimit;
|
|
|
|
this.isPiwikEnabled = this.properties.enablePiwikTrack;
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-06-29 15:15:52 +02:00
|
|
|
if (!this.simpleSearchLink) {
|
|
|
|
this.simpleSearchLink = this.properties.searchLinkToResults;
|
|
|
|
}
|
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults;
|
2021-02-10 10:26:47 +01:00
|
|
|
this.searchUtils.baseUrl = this.getRoute();//(this.simpleView) ? this.simpleSearchLink : this.advancedSearchLink;
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
var firstLoad = true;
|
2020-03-30 16:24:56 +02:00
|
|
|
this.subs.push(this.route.queryParams.subscribe(params => {
|
2021-02-10 10:26:47 +01:00
|
|
|
if(this.usedBy == "orcid"){
|
|
|
|
this.searchPage.usedBy = "orcid";
|
|
|
|
}
|
|
|
|
|
[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 => {
|
2020-03-28 01:33:55 +01:00
|
|
|
this.loadPaging = true;
|
2020-01-31 16:12:51 +01:00
|
|
|
if (params['page'] && this.searchUtils.page != params['page']) {
|
|
|
|
this.loadPaging = false;
|
|
|
|
this.oldTotalResults = this.searchUtils.totalResults;
|
|
|
|
}
|
|
|
|
var refine = true;
|
2021-05-12 16:22:08 +02:00
|
|
|
if(this.searchPage.searchUtils.refineStatus == this.errorCodes.DONE) {
|
|
|
|
if (params['page'] != undefined && this.filters && !firstLoad && this.searchUtils.page != +params['page']) {
|
|
|
|
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
|
|
|
|
2021-05-12 16:22:08 +02:00
|
|
|
if (params['sortBy'] != undefined && this.filters && !firstLoad && this.searchUtils.sortBy != params['sortBy']) {
|
|
|
|
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
|
|
|
|
2021-05-12 16:22:08 +02:00
|
|
|
if (params['size'] != undefined && this.filters && !firstLoad && this.searchUtils.size != params['size']) {
|
|
|
|
refine = false;
|
|
|
|
}
|
2020-01-31 16:12:51 +01:00
|
|
|
}
|
[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
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
let page = (params['page'] === undefined) ? 1 : +params['page'];
|
|
|
|
this.searchUtils.page = (page <= 0) ? 1 : page;
|
2021-08-13 11:42:50 +02:00
|
|
|
|
|
|
|
this.searchUtils.validateSize(params['size']);
|
2020-01-31 16:12:51 +01:00
|
|
|
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));
|
2020-07-24 13:21:22 +02:00
|
|
|
} else {
|
|
|
|
this.searchUtils.refineStatus = 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
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
|
2020-02-19 16:35:48 +01:00
|
|
|
firstLoad = false;
|
2020-03-30 16:24:56 +02:00
|
|
|
}));
|
2020-01-31 16:12:51 +01:00
|
|
|
}
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
ngOnDestroy() {
|
2020-10-20 16:47:54 +02:00
|
|
|
if(this.searchResultsSub) {
|
|
|
|
this.searchResultsSub.unsubscribe();
|
|
|
|
}
|
|
|
|
if(this.searchFiltersSub) {
|
|
|
|
this.searchFiltersSub.unsubscribe();
|
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
for (let sub of this.subs) {
|
2020-03-30 16:24:56 +02:00
|
|
|
sub.unsubscribe();
|
|
|
|
}
|
2020-01-31 16:12:51 +01:00
|
|
|
}
|
2020-10-20 16:47:54 +02:00
|
|
|
|
|
|
|
public getPublicCommunities() {
|
|
|
|
this.promise = new Promise<any>(resolve => {
|
|
|
|
this._contextService.getPublicCommunitiesByState().subscribe(
|
|
|
|
data => {
|
|
|
|
if(this.publicCommunities == null) {
|
|
|
|
this.publicCommunities = data.map(value => value.id);
|
|
|
|
}
|
|
|
|
resolve();
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
this.handleError("Error getting communities status", error);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
racePromiseWithTimeout() {
|
|
|
|
const timeoutPromise = new Promise((_, reject) => {
|
|
|
|
this.timeoutId = setTimeout(() => {
|
|
|
|
this.publicCommunities = [];
|
|
|
|
reject(new Error('Request timed out'));
|
|
|
|
}, 300);
|
|
|
|
});
|
|
|
|
|
|
|
|
return Promise.race([this.promise, timeoutPromise]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
[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) {
|
2021-02-10 10:26:47 +01:00
|
|
|
if(this.usedBy == "orcid" && this.orcidQuery) {
|
|
|
|
parameters += (parameters ? ' and ' : '') + "(" + this.orcidQuery + ")";
|
|
|
|
}
|
[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 (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});
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchFiltersSub = 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, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
|
[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
|
|
|
//.switchMap(
|
|
|
|
.subscribe(
|
|
|
|
data => {
|
2020-10-20 16:47:54 +02:00
|
|
|
let totalResults = data[0];
|
|
|
|
let filters = data[2];
|
|
|
|
|
|
|
|
// if (refine) {
|
|
|
|
// this.filters = this.searchPage.prepareFiltersToShow(filters, totalResults);
|
|
|
|
// this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
|
[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
|
|
|
// }
|
2020-10-20 16:47:54 +02:00
|
|
|
//
|
|
|
|
// this.searchUtils.refineStatus = this.errorCodes.DONE;
|
|
|
|
//
|
|
|
|
// this.disableRefineForms = false;
|
|
|
|
this.filtersReturned(refine, filters, totalResults, page);
|
[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})
|
|
|
|
},
|
|
|
|
err => {
|
2021-05-12 16:22:08 +02:00
|
|
|
this.filters = this.searchPage.prepareFiltersToShow([], 0);
|
|
|
|
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
|
|
|
|
|
|
|
|
this.handleError("Error getting refine filters for " + this.getEntityName(this.resultType, true, true), err);
|
[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.errorMessages.getErrorCode(err.status);
|
|
|
|
|
|
|
|
this.disableRefineForms = false;
|
|
|
|
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils})
|
|
|
|
}
|
2020-10-20 16:47:54 +02:00
|
|
|
);//);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async filtersReturned(refine: boolean, filters: Filter[], totalResults, page: number) {
|
|
|
|
if(!this.timeoutId) {
|
|
|
|
try {
|
|
|
|
await this.racePromiseWithTimeout();
|
|
|
|
} catch (error) {
|
|
|
|
this.handleError("Getting communities status was over 300ms - timeout", error);
|
|
|
|
} finally {
|
|
|
|
clearTimeout(this.timeoutId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let communitiesFilter = filters.find(filters => filters.filterId == "community");
|
|
|
|
if(communitiesFilter && this.publicCommunities && this.publicCommunities.length > 0) {
|
|
|
|
communitiesFilter.values = communitiesFilter.values.filter(value => {
|
|
|
|
let valueId = "";
|
|
|
|
if(value.id) {
|
|
|
|
let idArray = value.id.split("||");
|
|
|
|
if(idArray) {
|
|
|
|
valueId = idArray[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//for(let publicCom of this.publicCommunities) {
|
|
|
|
//if(valueId && publicCom['id'] == valueId) {
|
|
|
|
if(valueId && this.publicCommunities.includes(valueId)) {
|
|
|
|
return true;
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (refine) {
|
|
|
|
this.filters = this.searchPage.prepareFiltersToShow(filters, totalResults);
|
|
|
|
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
|
[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
|
|
|
}
|
2020-10-20 16:47:54 +02:00
|
|
|
|
|
|
|
this.searchUtils.refineStatus = this.errorCodes.DONE;
|
|
|
|
if(totalResults == 0) {
|
|
|
|
this.searchUtils.refineStatus = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.searchUtils.refineStatus == this.errorCodes.DONE) {
|
|
|
|
// Page out of limit!!!
|
|
|
|
let totalPages: any = totalResults / (this.searchUtils.size);
|
|
|
|
if (!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
|
|
|
}
|
|
|
|
if (totalPages < page) {
|
|
|
|
this.searchUtils.refineStatus = this.errorCodes.OUT_OF_BOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.searchUtils.refineStatus != this.errorCodes.DONE && this.searchUtils.status != this.searchUtils.refineStatus) {
|
|
|
|
if (this.searchResultsSub) {
|
|
|
|
this.searchResultsSub.unsubscribe();
|
|
|
|
}
|
|
|
|
this.resultsReturned(refine, [], totalResults, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.disableRefineForms = 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
|
|
|
}
|
|
|
|
|
2020-03-31 12:14:13 +02:00
|
|
|
public _getResults(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null) {
|
2021-02-10 10:26:47 +01:00
|
|
|
if(this.usedBy == "orcid" && this.orcidQuery) {
|
|
|
|
parameters += (parameters ? ' and ' : '') + "(" + this.orcidQuery + ")";
|
|
|
|
}
|
2020-01-31 16:12:51 +01:00
|
|
|
if (page > this.pagingLimit) {
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
if (page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
2020-02-24 14:45:22 +01:00
|
|
|
// if (parameters != null && parameters != '') {
|
|
|
|
// this.csvParams = "&fq=(" + this.resourcesQuery + " and (" + parameters + "))";
|
|
|
|
// } else {
|
|
|
|
// this.csvParams = "&fq=" + this.resourcesQuery;
|
|
|
|
// }
|
2020-06-29 15:15:52 +02:00
|
|
|
this.csvParams = (parameters ? ("&fq=(" + parameters) : "") + (parameters ? ")" : "");
|
2020-02-24 14:45:22 +01:00
|
|
|
this.csvParams += (refineFieldsFilterQuery ? refineFieldsFilterQuery : "");
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
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});
|
2020-01-31 16:12:51 +01:00
|
|
|
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)
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchResultsSub = this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery)
|
|
|
|
//this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery)
|
2020-03-30 16:24:56 +02:00
|
|
|
.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 => {
|
2020-10-20 16:47:54 +02:00
|
|
|
let totalResults = data[0];
|
|
|
|
let results = data[1];
|
2020-07-24 13:21:22 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
// this.searchUtils.totalResults = totalResults;
|
|
|
|
// this.results = results;
|
|
|
|
// // 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.searchPage.hideFilters = false;
|
|
|
|
//
|
|
|
|
// this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
// if (this.searchUtils.totalResults == 0) {
|
|
|
|
// this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
// }
|
|
|
|
// this.disableForms = false;
|
|
|
|
this.resultsReturned(refine, results, totalResults, page);
|
[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})
|
2020-07-24 13:21:22 +02:00
|
|
|
this.searchPage.hideFilters = 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
|
|
|
}
|
2020-10-20 16:47:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public resultsReturned(refine: boolean, results: any, totalResults, page: number) {
|
|
|
|
this.searchUtils.totalResults = totalResults;
|
|
|
|
this.results = results;
|
|
|
|
if(!refine) {
|
|
|
|
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
|
2020-01-31 16:12:51 +01:00
|
|
|
}
|
2020-10-20 16:47:54 +02:00
|
|
|
|
|
|
|
this.searchPage.hideFilters = false;
|
|
|
|
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
if (totalPages < page) {
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.searchUtils.status != this.errorCodes.DONE && this.searchUtils.refineStatus != this.searchUtils.status) {
|
|
|
|
if(this.searchFiltersSub) {
|
|
|
|
this.searchFiltersSub.unsubscribe();
|
|
|
|
}
|
|
|
|
this.filtersReturned(refine, [], totalResults, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.disableForms = false;
|
2020-12-15 13:45:02 +01:00
|
|
|
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils});
|
2020-01-31 16:12:51 +01:00
|
|
|
}
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error(this.getEntityName(this.resultType, true, true) + " advanced Search Page: " + message, error);
|
|
|
|
}
|
2021-08-13 11:42:50 +02:00
|
|
|
|
2020-01-31 16:12:51 +01:00
|
|
|
public getEntityName(entityType: string, plural: boolean, full: boolean): string {
|
2022-06-03 12:01:55 +02:00
|
|
|
return StringUtils.getEntityName(entityType, plural);
|
2022-05-05 19:35:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public getEntityFileName(entityType: string) {
|
2022-06-03 12:01:55 +02:00
|
|
|
return StringUtils.getEntityFileName(entityType);
|
2020-01-31 16:12:51 +01:00
|
|
|
}
|
|
|
|
}
|