2023-12-14 17:14:57 +01:00
|
|
|
import {ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
|
2020-02-11 15:56:20 +01:00
|
|
|
import {ActivatedRoute} from '@angular/router';
|
2020-10-20 16:47:54 +02:00
|
|
|
import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
|
2020-02-11 15:56:20 +01:00
|
|
|
import {SearchProjectsService} from '../services/searchProjects.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-02-11 15:56:20 +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";
|
[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
|
|
|
import {properties} from "../../../environments/environment";
|
2023-12-14 17:14:57 +01:00
|
|
|
import {RefineFieldResultsService} from "../services/refineFieldResults.service";
|
2024-05-30 15:33:43 +02:00
|
|
|
import {zip} from "rxjs";
|
2020-02-11 15:56:20 +01:00
|
|
|
|
|
|
|
@Component({
|
2022-04-15 14:38:41 +02:00
|
|
|
selector: 'search-projects',
|
|
|
|
template: `
|
|
|
|
<new-search-page
|
2022-05-05 19:35:08 +02:00
|
|
|
pageTitle="{{(simpleView?'':'Advanced ')}} Search for {{ openaireEntities.PROJECTS | titlecase }}"
|
2020-02-11 15:56:20 +01:00
|
|
|
entityType="project"
|
2022-05-05 19:35:08 +02:00
|
|
|
[type]="openaireEntities.PROJECTS"
|
2020-02-19 16:35:48 +01:00
|
|
|
[results]="results"
|
|
|
|
[searchUtils]="searchUtils"
|
2022-04-15 14:38:41 +02:00
|
|
|
[sortedByChanged]="searchUtils.sortBy"
|
2020-02-19 16:35:48 +01:00
|
|
|
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
|
2022-05-05 19:35:08 +02:00
|
|
|
[csvParams]="csvParams" [csvPath]="openaireEntities.PROJECTS_FILE"
|
2020-02-11 15:56:20 +01: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-02-11 15:56:20 +01:00
|
|
|
[loadPaging]="loadPaging"
|
|
|
|
[oldTotalResults]="oldTotalResults"
|
2023-07-12 14:05:25 +02:00
|
|
|
[openaireLink]=openaireLink [hasPrefix]="hasPrefix"
|
2022-04-15 14:38:41 +02:00
|
|
|
[searchForm]="searchForm"
|
2020-02-19 16:35:48 +01:00
|
|
|
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter"
|
|
|
|
[filters]="filters"
|
2020-02-17 15:19:14 +01:00
|
|
|
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields"
|
2020-08-13 13:15:10 +02:00
|
|
|
[simpleView]="simpleView" formPlaceholderText="Search by title, acronym, project code..."
|
|
|
|
[showSwitchSearchLink]="showSwitchSearchLink"
|
|
|
|
[sort]="false" [showBreadcrumb]="showBreadcrumb"
|
2024-07-09 16:19:13 +02:00
|
|
|
(filterRequestAll)="filterRequestedAll($event)"
|
|
|
|
[hasCompactView]="true">
|
2022-04-15 14:38:41 +02:00
|
|
|
</new-search-page>
|
|
|
|
|
|
|
|
`
|
|
|
|
})
|
2020-02-11 15:56:20 +01:00
|
|
|
|
|
|
|
export class SearchProjectsComponent {
|
|
|
|
private errorCodes: ErrorCodes;
|
|
|
|
private errorMessages: ErrorMessagesComponent;
|
2023-11-13 12:46:42 +01:00
|
|
|
@Input() customFilters: SearchCustomFilter[] = null;
|
|
|
|
@Input()
|
|
|
|
set customFilter(customFilter: SearchCustomFilter | SearchCustomFilter[]) {
|
|
|
|
if(!Array.isArray(customFilter)) {
|
2024-02-14 09:28:54 +01:00
|
|
|
this.customFilters = customFilter?[customFilter]:null;
|
2023-11-13 12:46:42 +01:00
|
|
|
}else{
|
|
|
|
this.customFilters = customFilter;
|
|
|
|
}
|
|
|
|
} @Input() searchForm: SearchForm = {class: 'search-form', dark: true};
|
2022-04-15 14:38:41 +02:00
|
|
|
public results = [];
|
|
|
|
public filters = [];
|
2020-02-17 15:19:14 +01:00
|
|
|
public rangeFilters: RangeFilter[] = [];
|
2022-04-15 14:38:41 +02:00
|
|
|
|
|
|
|
public searchUtils: SearchUtilsClass = new SearchUtilsClass();
|
|
|
|
public searchFields: SearchFields = new SearchFields();
|
|
|
|
|
|
|
|
public fieldIds: string[] = this.searchFields.PROJECT_ADVANCED_FIELDS;
|
2020-02-11 15:56:20 +01:00
|
|
|
public fieldIdsMap = this.searchFields.PROJECT_FIELDS;
|
2022-04-15 14:38:41 +02:00
|
|
|
public rangeFields: string[][] = this.searchFields.PROJECT_RANGE_FIELDS;
|
|
|
|
public selectedFields: AdvancedField[] = [];
|
2024-07-02 12:51:15 +02:00
|
|
|
properties: EnvProperties = properties;
|
2022-05-05 19:35:08 +02:00
|
|
|
public openaireEntities = OpenaireEntities;
|
|
|
|
|
2020-02-11 15:56:20 +01:00
|
|
|
public resourcesQuery = "(oaftype exact project)";
|
|
|
|
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-02-11 15:56:20 +01:00
|
|
|
public loadPaging: boolean = true;
|
|
|
|
public oldTotalResults: number = 0;
|
|
|
|
public pagingLimit: number = 0;
|
|
|
|
public refineFields: string[] = this.searchFields.PROJECT_REFINE_FIELDS;
|
2022-04-15 14:38:41 +02:00
|
|
|
@ViewChild(NewSearchPageComponent, {static: true}) searchPage: NewSearchPageComponent;
|
2020-02-11 15:56:20 +01:00
|
|
|
@Input() simpleView: boolean = true;
|
2020-02-19 16:35:48 +01:00
|
|
|
@Input() simpleSearchLink: string = "";
|
2020-02-11 15:56:20 +01:00
|
|
|
advancedSearchLink: string = "";
|
|
|
|
@Input() hasPrefix: boolean = true;
|
2022-08-08 16:45:31 +02:00
|
|
|
@Input() openaireLink: string = null;
|
2020-02-19 16:35:48 +01:00
|
|
|
@Input() includeOnlyResultsAndFilter: boolean = false;
|
|
|
|
@Output() searchPageUpdates = new EventEmitter();
|
2022-04-15 14:38:41 +02:00
|
|
|
@Input() showSwitchSearchLink: boolean = true;
|
2020-08-13 13:15:10 +02:00
|
|
|
@Input() showBreadcrumb: 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
|
|
|
subs: any[] = [];
|
2020-10-20 16:47:54 +02:00
|
|
|
searchResultsSub: any;
|
|
|
|
searchFiltersSub: any;
|
2023-12-14 17:14:57 +01:00
|
|
|
|
|
|
|
private refineQuery: string = "";
|
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService,
|
|
|
|
private _refineFieldsResultsService: RefineFieldResultsService,
|
|
|
|
private cdr: ChangeDetectorRef) {
|
2022-04-15 14:38:41 +02:00
|
|
|
this.results = [];
|
2020-02-11 15:56:20 +01:00
|
|
|
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;
|
2022-06-23 16:30:45 +02:00
|
|
|
|
|
|
|
this.searchFields.sortFieldsByName(this.fieldIds, this.fieldIdsMap);
|
2020-02-11 15:56:20 +01:00
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-02-11 15:56:20 +01:00
|
|
|
ngOnInit() {
|
2020-11-11 15:43:13 +01:00
|
|
|
if (!this.simpleSearchLink) {
|
|
|
|
this.simpleSearchLink = this.properties.searchLinkToProjects;
|
|
|
|
}
|
|
|
|
this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects;
|
2022-04-15 14:38:41 +02:00
|
|
|
this.searchUtils.baseUrl = (this.simpleView) ? this.simpleSearchLink : this.advancedSearchLink;
|
|
|
|
this.pagingLimit = properties.pagingLimit;
|
2020-02-11 15:56:20 +01:00
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
var firstLoad = true;
|
2022-04-15 14:38:41 +02: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
|
|
|
this.subs.push(this.route.queryParams.subscribe(params => {
|
2020-02-11 15:56:20 +01:00
|
|
|
this.loadPaging = true;
|
2022-04-15 14:38:41 +02:00
|
|
|
if (params['page'] && this.searchUtils.page != params['page']) {
|
2020-02-11 15:56:20 +01:00
|
|
|
this.loadPaging = false;
|
|
|
|
this.oldTotalResults = this.searchUtils.totalResults;
|
|
|
|
}
|
|
|
|
var refine = true;
|
2022-04-15 14:38:41 +02:00
|
|
|
if (this.searchPage.searchUtils.refineStatus == this.errorCodes.DONE) {
|
2021-05-12 16:22:08 +02:00
|
|
|
if (params['page'] != undefined && this.filters && !firstLoad && this.searchUtils.page != +params['page']) {
|
|
|
|
refine = false;
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2021-05-12 16:22:08 +02:00
|
|
|
if (params['size'] != undefined && this.filters && !firstLoad && this.searchUtils.size != params['size']) {
|
|
|
|
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
|
|
|
}
|
2022-04-15 14:38:41 +02: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']);
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-02-11 15:56:20 +01:00
|
|
|
this.searchPage.fieldIds = this.fieldIds;
|
|
|
|
this.selectedFields = [];
|
2023-12-15 15:46:43 +01:00
|
|
|
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields,[], this.fieldIdsMap, this.customFilters, params, "project");
|
2022-04-15 14:38:41 +02:00
|
|
|
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
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
|
2020-02-11 15:56:20 +01:00
|
|
|
firstLoad = false;
|
2023-12-14 17:14:57 +01:00
|
|
|
|
|
|
|
this.refineQuery = this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad);
|
[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-02-11 15:56:20 +01:00
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-02-11 15:56:20 +01:00
|
|
|
ngOnDestroy() {
|
2022-04-15 14:38:41 +02:00
|
|
|
if (this.searchResultsSub) {
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchResultsSub.unsubscribe();
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
if (this.searchFiltersSub) {
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchFiltersSub.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
|
|
|
for (let sub of this.subs) {
|
|
|
|
sub.unsubscribe();
|
|
|
|
}
|
2020-02-11 15:56:20 +01:00
|
|
|
}
|
2022-04-15 14:38:41 +02: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
|
|
|
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;
|
2022-04-15 14:38:41 +02:00
|
|
|
this.searchPageUpdates.emit({
|
|
|
|
disableForms: this.disableForms,
|
|
|
|
disableRefineForms: this.disableRefineForms,
|
|
|
|
searchUtils: this.searchUtils
|
|
|
|
});
|
2024-05-30 15:33:43 +02:00
|
|
|
|
|
|
|
let filterQueries;
|
|
|
|
let filterIds = [];
|
|
|
|
let fields = this.searchPage.getFields();
|
|
|
|
for(let filter of this.searchPage.URLCreatedFilters) {
|
|
|
|
filterIds.push(filter.filterId);
|
|
|
|
fields = fields.filter(field => field != filter.filterId);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(filterIds.length > 0) {
|
|
|
|
filterQueries = zip(this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery(filterIds) : null, filterIds, refineFieldsFilterQuery, false),
|
|
|
|
this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery(fields) : null, fields, refineFieldsFilterQuery, true)
|
2020-10-20 16:47:54 +02:00
|
|
|
);
|
2024-05-30 15:33:43 +02:00
|
|
|
} else {
|
|
|
|
filterQueries = this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery(fields) : null, fields, refineFieldsFilterQuery, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
this.searchFiltersSub = filterQueries.subscribe(
|
|
|
|
data => {
|
|
|
|
let totalResults = filterIds.length > 0 ? data[0][0] : data[0];
|
|
|
|
let filters = filterIds.length > 0 ? data[0][2].concat(data[1][2]) : data[2];
|
|
|
|
|
|
|
|
this.filtersReturned(refine, filters, totalResults, page);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.filters = this.searchPage.prepareFiltersToShow([], 0);
|
|
|
|
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
|
|
|
|
|
|
|
|
this.handleError("Error getting refine filters for projects: ", err);
|
|
|
|
this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status);
|
|
|
|
|
|
|
|
this.disableRefineForms = false;
|
|
|
|
this.searchPageUpdates.emit({
|
|
|
|
disableForms: this.disableForms,
|
|
|
|
disableRefineForms: this.disableRefineForms,
|
|
|
|
searchUtils: this.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
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
public filtersReturned(refine: boolean, filters: Filter[], totalResults, page: number) {
|
|
|
|
if (refine) {
|
|
|
|
this.filters = this.searchPage.prepareFiltersToShow(filters, totalResults);
|
|
|
|
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchUtils.refineStatus = this.errorCodes.DONE;
|
2022-04-15 14:38:41 +02:00
|
|
|
if (totalResults == 0) {
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchUtils.refineStatus = this.errorCodes.NONE;
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
|
|
|
if (this.searchUtils.refineStatus != this.errorCodes.DONE && this.searchUtils.status != this.searchUtils.refineStatus) {
|
2020-10-20 16:47:54 +02:00
|
|
|
if (this.searchResultsSub) {
|
|
|
|
this.searchResultsSub.unsubscribe();
|
|
|
|
}
|
|
|
|
this.resultsReturned(refine, [], totalResults, page);
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
this.disableRefineForms = false;
|
2022-04-15 14:38:41 +02:00
|
|
|
this.searchPageUpdates.emit({
|
|
|
|
disableForms: this.disableForms,
|
|
|
|
disableRefineForms: this.disableRefineForms,
|
|
|
|
searchUtils: this.searchUtils
|
|
|
|
})
|
2020-10-20 16:47:54 +02:00
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
|
|
|
public getResults(parameters: string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null) {
|
|
|
|
if (page > this.pagingLimit) {
|
|
|
|
size = 0;
|
2020-02-11 15:56:20 +01:00
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
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;
|
|
|
|
// }
|
|
|
|
// this.csvParams += (refineFieldsFilterQuery?refineFieldsFilterQuery:'');
|
|
|
|
//
|
|
|
|
// //var errorCodes:ErrorCodes = new ErrorCodes();
|
2022-04-15 14:38:41 +02:00
|
|
|
|
|
|
|
this.csvParams = (parameters ? ("&fq=(" + parameters) : "") + (parameters ? ")" : "");
|
2020-02-24 14:45:22 +01:00
|
|
|
this.csvParams += (refineFieldsFilterQuery ? refineFieldsFilterQuery : "");
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-02-11 15:56:20 +01:00
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
//this.searchPage.openLoading();
|
|
|
|
this.disableForms = true;
|
2022-04-15 14:38:41 +02:00
|
|
|
this.searchPageUpdates.emit({
|
|
|
|
disableForms: this.disableForms,
|
|
|
|
disableRefineForms: this.disableRefineForms,
|
|
|
|
searchUtils: this.searchUtils
|
|
|
|
});
|
2020-02-11 15:56:20 +01:00
|
|
|
this.results = [];
|
|
|
|
this.searchUtils.totalResults = 0;
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-02-11 15:56:20 +01:00
|
|
|
//console.info("Advanced Search for Publications: Execute search query "+parameters);
|
2022-04-15 14:38:41 +02:00
|
|
|
this.searchResultsSub = this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, null, this.searchPage.getFields(), refineFieldsFilterQuery).subscribe(
|
|
|
|
//this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties,(refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery).subscribe(
|
|
|
|
data => {
|
|
|
|
let totalResults = data[0];
|
|
|
|
let results = data[1];
|
|
|
|
this.resultsReturned(refine, results, totalResults, page);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error getting projects", err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
//this.searchUtils.totalResults = null;
|
|
|
|
//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
|
|
|
|
})
|
|
|
|
this.searchPage.hideFilters = false;
|
|
|
|
}
|
2020-10-20 16:47:54 +02:00
|
|
|
);
|
2020-02-11 15:56:20 +01:00
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:38:41 +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;
|
2022-04-15 14:38:41 +02:00
|
|
|
if (!refine) {
|
2023-12-14 16:30:29 +01:00
|
|
|
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, [], false);
|
2020-10-20 16:47:54 +02:00
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchPage.hideFilters = false;
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
|
|
|
if (this.searchUtils.status != this.errorCodes.DONE && this.searchUtils.refineStatus != this.searchUtils.status) {
|
|
|
|
if (this.searchFiltersSub) {
|
2020-10-20 16:47:54 +02:00
|
|
|
this.searchFiltersSub.unsubscribe();
|
|
|
|
}
|
|
|
|
this.filtersReturned(refine, [], totalResults, page);
|
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-10-20 16:47:54 +02:00
|
|
|
this.disableForms = false;
|
2022-04-15 14:38:41 +02:00
|
|
|
this.searchPageUpdates.emit({
|
|
|
|
disableForms: this.disableForms,
|
|
|
|
disableRefineForms: this.disableRefineForms,
|
|
|
|
searchUtils: this.searchUtils
|
|
|
|
})
|
2020-10-20 16:47:54 +02:00
|
|
|
}
|
2022-04-15 14:38:41 +02:00
|
|
|
|
2020-02-11 15:56:20 +01:00
|
|
|
private handleError(message: string, error) {
|
2022-04-15 14:38:41 +02:00
|
|
|
console.error("Projects advanced Search Page: " + message, error);
|
2020-02-11 15:56:20 +01:00
|
|
|
}
|
2023-12-14 17:14:57 +01:00
|
|
|
|
|
|
|
public filterRequestedAll(oldFilter: Filter) {
|
|
|
|
let fieldsStr: string = "&fields=" + oldFilter.filterId+"&refine=true";
|
|
|
|
|
|
|
|
this.searchFiltersSub = this._searchProjectsService.advancedSearchProjects(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), 1, 0, properties, fieldsStr, [oldFilter.filterId], this.refineQuery).subscribe(
|
|
|
|
// this.searchFiltersSub = this._refineFieldsResultsService.getAllRefineFieldResultsByFieldName(oldFilter.filterId, "project", this.properties, this.refineQuery).subscribe(
|
|
|
|
res => {
|
2024-02-27 00:42:15 +01:00
|
|
|
let filter: Filter = res[2][0];
|
2023-12-14 17:14:57 +01:00
|
|
|
if(filter.values.length == 0) {
|
|
|
|
filter = oldFilter;
|
|
|
|
filter.countAllValues = 0;
|
|
|
|
} else {
|
|
|
|
filter.countAllValues = filter.values.length;
|
|
|
|
// console.log(filter);
|
|
|
|
for (let value of filter.values) {
|
|
|
|
for (let oldValue of oldFilter.values) {
|
|
|
|
if (oldValue.id == value.id && oldValue.selected) {
|
|
|
|
value.selected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == filter.filterId);
|
2023-12-20 23:06:32 +01:00
|
|
|
filter.isViewAllOpen = true;
|
2023-12-14 17:14:57 +01:00
|
|
|
this.filters[index] = filter;
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == oldFilter.filterId);
|
|
|
|
oldFilter.countAllValues = 0;
|
|
|
|
this.filters[index] = oldFilter;
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2020-02-11 15:56:20 +01:00
|
|
|
}
|