[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:
Konstantina Galouni 2024-09-09 13:15:10 +03:00
parent 1d3ab8f645
commit f32dfc0ac6
3 changed files with 14 additions and 8 deletions

View File

@ -6,7 +6,7 @@ import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousR
import {OrpRoutingModule} from './orp-routing.module'; import {OrpRoutingModule} from './orp-routing.module';
@NgModule({ @NgModule({
imports: [ResultLandingModule, OrpRoutingModule], imports: [OrpRoutingModule, ResultLandingModule],
declarations:[OpenaireOrpComponent], declarations:[OpenaireOrpComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[FreeGuard, PreviousRouteRecorder],
exports:[OpenaireOrpComponent] exports:[OpenaireOrpComponent]

View File

@ -53,7 +53,7 @@
No results found for your query No results found for your query
</div> </div>
</ng-container> </ng-container>
<ng-container *ngIf="results"> <ng-container *ngIf="results && results.data">
<div class="uk-margin-medium-bottom"> <div class="uk-margin-medium-bottom">
<div class="uk-flex uk-flex-middle uk-margin-small-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" <img src="assets/common-assets/common/Logo_Small.png" alt="OpenAIRE" loading="lazy"

View File

@ -33,19 +33,25 @@ export class NaturalLanguageSearchComponent {
} }
search() { search() {
this.results = null;
this.queryPhrase = this.phrase; this.queryPhrase = this.phrase;
this.errorMessage = null; this.errorMessage = null;
this.showLoading = true; this.showLoading = true;
this.subscriptions.push(this.naturalLanguageSearchService.getResults(this.properties.naturalLanguageSearchAPI, this.queryPhrase).subscribe(data => { this.subscriptions.push(this.naturalLanguageSearchService.getResults(this.properties.naturalLanguageSearchAPI, this.queryPhrase).subscribe(data => {
if(data && data['columns']) { if(data && data['data'] && data['data'].length > 0) {
for(let i = 0; i < data['columns'].length - 1; i++) { if(data && data['columns']) {
if(data['columns'][i] == 'id') { for(let i = 0; i < data['columns'].length - 1; i++) {
this.indexColumnId = i; if(data['columns'][i] == 'id') {
break; this.indexColumnId = i;
break;
}
} }
} }
this.results = data;
} else {
this.results = [];
} }
this.results = data;
this.showLoading = false; this.showLoading = false;
}, error => { }, error => {
if(error.status == 500) { if(error.status == 500) {