Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
fix(search): gracefully handle more directory search failure modaliti…
Browse files Browse the repository at this point in the history
…es (#825)

When directory search fails for e.g. bad directory search URL config,
fail with user-facing message and console log message, and stop the loading indicator.

Removes `$scope.wiscDirectoryError`

`wiscDirectoryErrorMessage` *is* the flag that there's an error, we don't need a separate `wiscDirectoryError` to have to keep in compatible state with the message.
  • Loading branch information
apetro committed Jun 7, 2018
1 parent 0f2d59a commit 58473d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and this project adheres to

### Fixed

+ Gracefully handle case where directory search JSON URL is bad, as is the case
in naive localhost demo against stub data (#825)

## [8.2.0][] - 2018-06-22

### Changed
Expand Down
11 changes: 10 additions & 1 deletion web/src/main/webapp/my-app/search/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,24 @@ define([
results.errors[1] &&
results.errors[1].error_msg) {
if (results.errors[0].code == 4) {
$log.warn(
'Too many directory results for term ' + $scope.searchTerm);
$scope.wiscDirectoryTooManyResults = true;
} else {
$log.warn(
'Directory search error [' + results.errors[1].error_msg +
'] on term ' + $scope.searchTerm);
}

$scope.wiscDirectoryErrorMessage= results.errors[1].error_msg;
}
}
return results;
}).catch(function() {
$log.warn('Directory search error on term ' + $scope.searchTerm);
$scope.wiscDirectoryLoading = false;
$scope.wiscDirectoryError = true;
$scope.wiscDirectoryErrorMessage =
'Error. Unable to search the directory.';
}
);
};
Expand Down
16 changes: 12 additions & 4 deletions web/src/main/webapp/my-app/search/partials/directory-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@ <h4 class="md-subhead">
</h4>

<div layout="row" layout-align="center center">
<loading-gif data-object="wiscDirectoryResults" data-empty="wiscDirectoryResultsEmpty"></loading-gif>
<loading-gif
ng-show="wiscDirectoryLoading"
data-object="wiscDirectoryResults"
data-empty="wiscDirectoryResultsEmpty"></loading-gif>
</div>
<div ng-show="wiscDirectoryResultsEmpty && !wiscDirectoryTooManyResults" class='no-result'>
No directory results.
</div>

<div ng-if="wiscDirectoryErrorMessage"
layout="row" layout-align="center center">
<p>
{{wiscDirectoryErrorMessage}}
</p>
</div>

<div class="result" ng-repeat="item in wiscDirectoryResults | limitTo:wiscDirectoryResultLimit">
<h4>{{item.fullName}}</h4>
<p ng-if="item.formalName">Also known as {{item.formalName}}</p>
Expand Down Expand Up @@ -62,7 +73,4 @@ <h4>{{item.fullName}}</h4>
<p ng-if="wiscDirectoryResultCount>wiscDirectoryResultLimit">
<a href="" ng-click="showAllDirectoryResults()">See all {{wiscDirectoryResultCount}} directory results</a>
</p>
<p ng-if="wiscDirectoryErrorMessage">
{{wiscDirectoryErrorMessage}}
</p>
</div>

0 comments on commit 58473d3

Please sign in to comment.