[recommendations-and-nl-search | DONE | FIXED]: Fixed when and how error messages are displayed on NL Search page.
1. natural-language-search.component.html: Added check if results.data also exist. 2. natural-language-search.component.ts: In method "search()" initialize also results to null and added check if response has at least 1 row of results. 3. libOrp.module.ts: Changed order of imports to be loaded and initialized correctly - first OrpRoutingModule which is more specific and then ResultLandingModule.
This commit is contained in:
parent
1d3ab8f645
commit
f32dfc0ac6
|
@ -6,7 +6,7 @@ import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousR
|
|||
import {OrpRoutingModule} from './orp-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [ResultLandingModule, OrpRoutingModule],
|
||||
imports: [OrpRoutingModule, ResultLandingModule],
|
||||
declarations:[OpenaireOrpComponent],
|
||||
providers:[FreeGuard, PreviousRouteRecorder],
|
||||
exports:[OpenaireOrpComponent]
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
No results found for your query
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="results">
|
||||
<ng-container *ngIf="results && results.data">
|
||||
<div class="uk-margin-medium-bottom">
|
||||
<div class="uk-flex uk-flex-middle uk-margin-small-bottom">
|
||||
<img src="assets/common-assets/common/Logo_Small.png" alt="OpenAIRE" loading="lazy"
|
||||
|
|
|
@ -33,10 +33,12 @@ export class NaturalLanguageSearchComponent {
|
|||
}
|
||||
|
||||
search() {
|
||||
this.results = null;
|
||||
this.queryPhrase = this.phrase;
|
||||
this.errorMessage = null;
|
||||
this.showLoading = true;
|
||||
this.subscriptions.push(this.naturalLanguageSearchService.getResults(this.properties.naturalLanguageSearchAPI, this.queryPhrase).subscribe(data => {
|
||||
if(data && data['data'] && data['data'].length > 0) {
|
||||
if(data && data['columns']) {
|
||||
for(let i = 0; i < data['columns'].length - 1; i++) {
|
||||
if(data['columns'][i] == 'id') {
|
||||
|
@ -46,6 +48,10 @@ export class NaturalLanguageSearchComponent {
|
|||
}
|
||||
}
|
||||
this.results = data;
|
||||
} else {
|
||||
this.results = [];
|
||||
}
|
||||
|
||||
this.showLoading = false;
|
||||
}, error => {
|
||||
if(error.status == 500) {
|
||||
|
|
Loading…
Reference in New Issue