Display message when errors occur whilst searching

Refs #144
This commit is contained in:
Will Abson
2016-06-07 13:34:06 +01:00
parent 11f0d08128
commit 8bdbccb138
3 changed files with 14 additions and 7 deletions

View File

@@ -6,6 +6,7 @@
"RESULTS": {
"SUMMARY": "Found {{numResults}} results for {{searchTerm}}",
"NONE": "No results found for {{searchTerm}}",
"ERROR": "An error occurred while running the search",
"COLUMNS": {
"NAME": "Name",
"MODIFIED_BY": "Modified by",

View File

@@ -1,7 +1,6 @@
<p *ngIf="searchTerm">
<p *ngIf="results.length">{{ 'SEARCH.RESULTS.SUMMARY' | translate:{numResults: results.length, searchTerm: searchTerm} }}</p>
<p *ngIf="results.length == 0">{{ 'SEARCH.RESULTS.NONE' | translate:{searchTerm: searchTerm} }}</p>
<table *ngIf="searchTerm && results.length" class="mdl-data-table mdl-js-data-table mdl-shadow--2dp full-width">
<p *ngIf="results && results.length">{{ 'SEARCH.RESULTS.SUMMARY' | translate:{numResults: results.length, searchTerm: searchTerm} }}</p>
<p *ngIf="results&& results.length == 0">{{ 'SEARCH.RESULTS.NONE' | translate:{searchTerm: searchTerm} }}</p>
<table *ngIf="results && results.length && searchTerm" class="mdl-data-table mdl-js-data-table mdl-shadow--2dp full-width">
<thead>
<tr>
<th>
@@ -28,3 +27,4 @@
</tr>
</tbody>
</table>
<p *ngIf="errorMessage">{{ 'SEARCH.RESULTS.ERROR' | translate:{errorMessage: errorMessage} }}</p>

View File

@@ -50,7 +50,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
{
translate.addComponent('node_modules/ng2-alfresco-search');
this.results = [];
this.results = null;
if (params) {
this.searchTerm = params.get('q');
}
@@ -97,8 +97,14 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
this._alfrescoService
.getLiveSearchResults(searchTerm)
.subscribe(
results => this.results = results.list.entries,
error => this.errorMessage = <any>error
results => {
this.results = results.list.entries
this.errorMessage = null;
},
error => {
this.results = null;
this.errorMessage = <any>error;
}
);
}
}