2020-02-19 16:35:48 +01:00
import { 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 { SearchDataprovidersService } from '../services/searchDataproviders.service' ;
import { ErrorCodes } from '../utils/properties/errorCodes' ;
import { ErrorMessagesComponent } from '../utils/errorMessages.component' ;
import { SearchFields } from '../utils/properties/searchFields' ;
import { SearchCustomFilter , SearchUtilsClass } from './searchUtils/searchUtils.class' ;
import { EnvProperties } from '../utils/properties/env-properties' ;
import { NewSearchPageComponent } from "./searchUtils/newSearchPage.component" ;
2020-02-25 16:40:56 +01:00
import { DatasourcesHelperClass } from "./searchUtils/datasourcesHelper.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" ;
2020-02-11 15:56:20 +01:00
@Component ( {
selector : 'search-dataproviders' ,
template : `
< new - search - page
2020-08-19 12:16:43 +02:00
pageTitle = "{{(simpleView?'':'Advanced ')}} Find research {{ pageTitle }}"
2020-02-24 14:45:22 +01:00
entityType = "dataprovider"
2020-02-11 15:56:20 +01:00
type = "content providers"
2020-02-19 16:35:48 +01:00
[ results ] = "results"
[ searchUtils ] = "searchUtils"
[Trunk | Library]:
1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries.
2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value".
3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts:
a. Add subscriptions in array to unsubscribe in ngOnDestroy.
b. Get properties from environment (no service needed).
c. Separate queries for refine and results.
d. Do not call refine query when page, results per page, sortBy change (there is still a bug here).
e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>.
4. newSearchPage.component.html:
a. Disable forms when "disableForms" or "disableRefineForms" is true.
b. Do not show filters, until results query returns, but show results while refine is loading.
c. Deleted old, unused code.
5. newSearchPage.component.ts:
a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;"
b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here).
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
[ sortedByChanged ] = "searchUtils.sortBy" [ resultsPerPageChanged ] = "searchUtils.size"
2020-02-19 16:35:48 +01:00
[ fieldIds ] = "fieldIds" [ fieldIdsMap ] = "fieldIdsMap" [ selectedFields ] = "selectedFields"
2020-02-24 14:45:22 +01:00
[ csvParams ] = "csvParams" csvPath = "datasources"
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"
2020-02-19 16:35:48 +01:00
[ openaireLink ] = openaireLink
[ includeOnlyResultsAndFilter ] = "includeOnlyResultsAndFilter"
2020-02-11 15:56:20 +01:00
[ piwikSiteId ] = piwikSiteId [ hasPrefix ] = "hasPrefix"
2020-03-12 18:03:35 +01:00
[ searchFormClass ] = "type!='deposit'?'datasourcesSearchForm':''"
2020-08-13 13:15:10 +02:00
[ entitiesSelection ] = "type=='all'" [ showSwitchSearchLink ] = "showSwitchSearchLink"
2020-02-19 16:35:48 +01:00
[ filters ] = "filters"
2020-03-26 13:18:18 +01:00
[ simpleView ] = "simpleView" formPlaceholderText = "Search by name, description, subject..."
2020-03-12 18:03:35 +01:00
[ showResultCount ] = "(type=='all' || type == 'deposit')" [ showLastIndex ] = "type!='deposit'"
2020-05-05 10:46:10 +02:00
[ tableViewLink ] = "tableViewLink"
2020-08-19 12:16:43 +02:00
[ sort ] = "false" [ showBreadcrumb ] = "showBreadcrumb" [ basicMetaDescription ] = "metaDescription" >
2020-08-13 13:15:10 +02:00
2020-02-11 15:56:20 +01:00
< / n e w - s e a r c h - p a g e >
2020-06-10 13:05:59 +02:00
<!-- [ filters ] = "filters" -- >
2020-02-11 15:56:20 +01:00
`
} )
export class SearchDataProvidersComponent {
private errorCodes : ErrorCodes ;
private errorMessages : ErrorMessagesComponent ;
@Input ( ) piwikSiteId = null ;
@Input ( ) customFilter :SearchCustomFilter = null ;
2020-03-12 18:03:35 +01:00
@Input ( ) tableViewLink ;
2020-02-11 15:56:20 +01:00
public results = [ ] ;
public filters = [ ] ;
public searchUtils :SearchUtilsClass = new SearchUtilsClass ( ) ;
public searchFields :SearchFields = new SearchFields ( ) ;
public fieldIds : string [ ] = this . searchFields . DATASOURCE_ADVANCED_FIELDS ;
public fieldIdsMap = this . searchFields . DATASOURCE_FIELDS ;
public selectedFields :AdvancedField [ ] = [ ] ;
public resourcesQuery = "(oaftype exact datasource)" ;
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 isPiwikEnabled ;
properties :EnvProperties ;
2020-03-12 18:03:35 +01:00
@Input ( ) type : "all" | "registries" | "journals" | "compatible" | "deposit" = "all" ;
public refineFields : string [ ] ;
pageTitle ;
2020-02-11 15:56:20 +01:00
@ViewChild ( NewSearchPageComponent ) searchPage : NewSearchPageComponent ;
@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 ;
@Input ( ) openaireLink : string ;
2020-02-19 16:35:48 +01:00
@Input ( ) includeOnlyResultsAndFilter : boolean = false ;
@Output ( ) searchPageUpdates = new EventEmitter ( ) ;
2020-08-13 13:15:10 +02:00
@Input ( ) showSwitchSearchLink :boolean ;
@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 ;
2020-08-19 12:16:43 +02:00
metaDescription = [ ] ;
[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
constructor ( private route : ActivatedRoute , private _searchDataProvidersService : SearchDataprovidersService ) {
this . results = [ ] ;
this . errorCodes = new ErrorCodes ( ) ;
this . errorMessages = new ErrorMessagesComponent ( ) ;
this . searchUtils . status = this . errorCodes . LOADING ;
}
ngOnInit() {
2020-03-12 18:03:35 +01:00
this . refineFields = DatasourcesHelperClass . getrefineFields ( this . type ) ;
this . pageTitle = DatasourcesHelperClass . getTitle ( this . type ) ;
2020-08-19 12:16:43 +02:00
this . metaDescription = DatasourcesHelperClass . getDescription ( this . type )
2020-08-13 13:15:10 +02:00
if ( this . showSwitchSearchLink == null ) {
this . showSwitchSearchLink = ( this . type == "all" ) ;
2020-06-29 13:10:32 +02:00
}
2020-11-11 15:43:13 +01:00
this . properties = properties ;
if ( ! this . simpleSearchLink ) {
this . simpleSearchLink = this . properties . searchLinkToDataProviders ;
} this . advancedSearchLink = this . properties . searchLinkToAdvancedDataProviders ;
this . searchUtils . baseUrl = ( this . simpleView ) ? this . simpleSearchLink :this.advancedSearchLink ;
this . pagingLimit = properties . pagingLimit ;
this . isPiwikEnabled = properties . enablePiwikTrack ;
2020-02-11 15:56:20 +01:00
2020-02-25 16:40:56 +01:00
let firstLoad = 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 . subs . push ( this . route . queryParams . subscribe ( params = > {
2020-02-11 15:56:20 +01:00
this . loadPaging = true ;
if ( params [ 'page' ] && this . searchUtils . page != params [ 'page' ] ) {
this . loadPaging = false ;
this . oldTotalResults = this . searchUtils . totalResults ;
}
var refine = true ;
2020-07-24 13:21:22 +02:00
if ( params [ 'page' ] != undefined && this . filters && ! firstLoad && this . searchUtils . page != + params [ '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
refine = false ;
}
2020-07-24 13:21:22 +02:00
if ( params [ 'size' ] != undefined && this . filters && ! firstLoad && this . searchUtils . size != params [ 'size' ] ) {
refine = false ;
}
2020-02-11 15:56:20 +01:00
2020-07-24 13:21:22 +02:00
let page = ( params [ 'page' ] === undefined ) ? 0 : + params [ 'page' ] ;
this . searchUtils . page = ( page < 1 ) ? 1 : page ;
2020-02-11 15:56:20 +01:00
2020-07-24 13:21:22 +02:00
this . searchUtils . size = ( params [ 'size' ] === undefined ) ? 10 : + params [ 'size' ] ;
if ( this . searchUtils . size != 5 && this . searchUtils . size != 10 && this . searchUtils . size != 20 && this . searchUtils . size != 50 ) {
this . searchUtils . size = 10 ;
}
this . searchPage . fieldIds = this . fieldIds ;
this . selectedFields = [ ] ;
if ( this . type == "deposit" ) {
this . searchPage . keywordFields = this . searchFields . DEPOSIT_DATASOURCE_KEYWORD_FIELDS ;
this . searchPage . usedBy = "deposit" ;
}
// console.log(this.refineFields)
this . searchPage . prepareSearchPage ( this . fieldIds , this . selectedFields , this . refineFields , [ ] , this . fieldIdsMap , this . customFilter , params , "dataprovider" ) ;
if ( refine && ( this . type == "all" || this . type == "deposit" ) ) {
this . _getFilters ( this . searchPage . getSearchAPIQueryForAdvancedSearhFields ( ) , this . searchUtils . page , 0 , true , this . searchPage . getSearchAPIQueryForRefineFields ( params , firstLoad ) ) ;
} else if ( refine ) { // static filters
this . searchUtils . refineStatus = this . errorCodes . LOADING ;
2020-11-12 10:51:34 +01:00
this . filters = DatasourcesHelperClass . createFilters ( this . type ) ;
2020-07-24 13:21:22 +02:00
} else {
this . searchUtils . refineStatus = this . errorCodes . DONE ;
}
this . getResults ( this . searchPage . getSearchAPIQueryForAdvancedSearhFields ( ) , this . searchUtils . page , this . searchUtils . size , refine , this . searchPage . getSearchAPIQueryForRefineFields ( params , firstLoad ) ) ;
firstLoad = 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-02-11 15:56:20 +01:00
}
ngOnDestroy() {
2020-10-20 16:47:54 +02:00
if ( this . searchResultsSub ) {
this . searchResultsSub . unsubscribe ( ) ;
}
if ( this . searchFiltersSub ) {
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 ( ) ;
}
}
public _getFilters ( parameters :string , page : number , size : number , refine : boolean , refineFieldsFilterQuery = null ) {
if ( page <= this . pagingLimit || this . searchUtils . refineStatus == this . errorCodes . LOADING ) {
this . searchUtils . refineStatus = this . errorCodes . LOADING ;
this . disableRefineForms = true ;
this . searchPageUpdates . emit ( { disableForms : this.disableForms , disableRefineForms : this.disableRefineForms , searchUtils : this.searchUtils } ) ;
let datasourceQueryPrefix = DatasourcesHelperClass . getQueryPrefix ( this . type ) ;
2020-10-20 16:47:54 +02:00
this . searchFiltersSub = this . _searchDataProvidersService . advancedSearchDataproviders ( datasourceQueryPrefix + ( datasourceQueryPrefix . length > 0 && parameters . length > 0 ? ' and (' : '' ) + parameters + ( datasourceQueryPrefix . length > 0 && parameters . length > 0 ? ' ) ' : '' ) , page , size , this . properties , ( refine && ( this . type == "all" || this . type == "deposit" ) ) ? this . searchPage . getRefineFieldsQuery ( ) : null , this . searchPage . getFields ( ) , refineFieldsFilterQuery , ( this . type == "deposit" ) )
[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 ] ;
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
} ,
err = > {
this . handleError ( "Error getting organizations: " , err ) ;
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
) ;
[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
}
[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 filtersReturned ( refine : boolean , filters : Filter [ ] , totalResults , page : number ) {
if ( refine ) {
this . filters = this . searchPage . prepareFiltersToShow ( filters , totalResults ) ;
}
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 ;
2020-12-15 13:45:02 +01:00
this . searchPageUpdates . emit ( { disableForms : this.disableForms , disableRefineForms : this.disableRefineForms , searchUtils : this.searchUtils } )
2020-10-20 16:47:54 +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
2020-02-11 15:56:20 +01:00
public getResults ( parameters :string , page : number , size : number , refine : boolean , refineFieldsFilterQuery = null ) {
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;
// }
// this.csvParams += (refineFieldsFilterQuery?refineFieldsFilterQuery:'');
this . csvParams = ( parameters ? ( "&fq=(" + parameters ) : "" ) + ( parameters ? ")" : "" ) ;
this . csvParams += ( refineFieldsFilterQuery ? refineFieldsFilterQuery : "" ) ;
2020-02-11 15:56:20 +01:00
//var errorCodes:ErrorCodes = new ErrorCodes();
this . searchUtils . status = this . errorCodes . LOADING ;
//this.searchPage.openLoading();
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-02-19 16:35:48 +01:00
2020-02-11 15:56:20 +01:00
this . results = [ ] ;
this . searchUtils . totalResults = 0 ;
//console.info("Advanced Search for Content Providers: Execute search query "+parameters);
2020-02-25 16:40:56 +01:00
let datasourceQueryPrefix = DatasourcesHelperClass . getQueryPrefix ( this . type ) ;
[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._searchDataProvidersService.advancedSearchDataproviders( datasourceQueryPrefix +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' and (':'') + parameters +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' ) ':''), page, size, this.properties, (refine && (this.type=="all" || this.type == "deposit")) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery, (this.type == "deposit")).subscribe(
2020-10-20 16:47:54 +02:00
this . searchResultsSub = this . _searchDataProvidersService . advancedSearchDataproviders ( datasourceQueryPrefix + ( datasourceQueryPrefix . length > 0 && parameters . length > 0 ? ' and (' : '' ) + parameters + ( datasourceQueryPrefix . length > 0 && parameters . length > 0 ? ' ) ' : '' ) , page , size , this . properties , null , this . searchPage . getFields ( ) , refineFieldsFilterQuery , ( this . type == "deposit" ) ) . 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-11-12 10:51:34 +01:00
if ( refine && ! ( this . type == "all" || this . type == "deposit" ) ) {
this . filtersReturned ( refine , this . filters , totalResults , page ) ;
}
2020-10-20 16:47:54 +02:00
this . resultsReturned ( refine , results , totalResults , page ) ;
2020-02-11 15:56:20 +01:00
} ,
err = > {
//console.log(err);
this . handleError ( "Error getting content providers" , 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;
/ * i f ( e r r . s t a t u s = = ' 4 0 4 ' ) {
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 ;
[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-07-24 13:21:22 +02:00
this . searchPage . hideFilters = false ;
2020-02-11 15:56:20 +01:00
}
2020-10-20 16:47:54 +02:00
) ;
2020-02-11 15:56:20 +01: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 , [ ] , false ) ;
}
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-10-20 16:47:54 +02:00
}
2020-02-11 15:56:20 +01:00
private handleError ( message : string , error ) {
console . error ( "Content Providers advanced Search Page: " + message , error ) ;
}
}