Skip to content

Commit

Permalink
allow visualize view to hand off “no results” scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Nov 4, 2015
1 parent b2ae798 commit 586720e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/plugins/metric_vis/public/metric_vis.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<div ng-controller="KbnMetricVisController" class="metric-vis">
<div class="metric-container" ng-repeat="metric in metrics">
<div class="metric-value" ng-style="{'font-size': vis.params.fontSize+'pt'}">{{metric.value}}</div>
<div>{{metric.label}}</div>
<div class="metric-container" ng-repeat="metric in metrics">
<div ng-hide="!metric.value">
<div class="metric-value" ng-style="{'font-size': vis.params.fontSize+'pt'}">{{metric.value}}</div>
<div>{{metric.label}}</div>
</div>
<div ng-if="!metric.value">
<div class="item top"></div>
<div class="item">
<h2 aria-hidden="true"><i aria-hidden="true" class="fa fa-meh-o"></i></h2>
<div>No data available for {{metric.label}}</div>
</div>
<div class="item bottom"></div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions src/ui/public/visualize/visualize.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div ng-if="vis.type.requiresSearch && esResp.hits.total === 0"
<div ng-show="showNoResultsMessage(this);"
class="text-center visualize-error visualize-chart">
<div class="item top"></div>
<div class="item">
Expand All @@ -7,7 +7,7 @@ <h4>No results found</h4>
</div>
<div class="item bottom"></div>
</div>
<div ng-hide="vis.type.requiresSearch && esResp.hits.total === 0"
<div ng-show="hasResults(this);"
ng-style="loadingStyle"
ng-class="{ loading: vis.type.requiresSearch && searchSource.activeFetchCount > 0 }"
class="visualize-chart"></div>
Expand Down
18 changes: 18 additions & 0 deletions src/ui/public/visualize/visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ define(function (require) {
$scope.spy = {};
$scope.spy.mode = ($scope.uiState) ? $scope.uiState.get('spy.mode', {}) : {};

$scope.showNoResultsMessage = function (scope) {
var requiresSearch = _.get(scope, 'vis.type.requiresSearch');
var hasZeroHits = _.get(scope, 'esResp.hits.total') === 0;
if (requiresSearch && hasZeroHits) {
// check for any visType that can visualize zero hits
return _.get(scope, 'vis.type.name') !== 'metric';
}
return true;
};

$scope.hasResults = function (scope) {
var requiresSearch = _.get(scope, 'vis.type.requiresSearch');
var hasZeroHits = _.get(scope, 'esResp.hits.total') === 0;
var canBeZero = _.get(scope, 'vis.type.name') === 'metric';

return requiresSearch && (hasZeroHits || canBeZero);
};

var applyClassNames = function () {
var $spyEl = getSpyEl();
var $visEl = getVisEl();
Expand Down

0 comments on commit 586720e

Please sign in to comment.