host summary > disable failed filter option if no hosts return failed events. Resolves #1587

fix comment
This commit is contained in:
Leigh Johnson
2016-04-19 11:20:19 -04:00
parent e3d01d0967
commit ec2661a7dc
3 changed files with 11 additions and 10 deletions

View File

@@ -985,7 +985,7 @@ export default
.showLabels(true) .showLabels(true)
.showLegend(false) .showLegend(false)
.growOnHover(false) .growOnHover(false)
//.labelThreshold(0) .labelThreshold(0.01)
.tooltipContent(function(x, y) { .tooltipContent(function(x, y) {
return '<p>'+x+'</p>'+ '<p>' + Math.floor(y.replace(',','')) + ' HOSTS ' + '</p>'; return '<p>'+x+'</p>'+ '<p>' + Math.floor(y.replace(',','')) + ' HOSTS ' + '</p>';
}) })

View File

@@ -14,7 +14,7 @@
var buildGraph = function(hosts){ var buildGraph = function(hosts){
// status waterfall: unreachable > failed > changed > ok > skipped // status waterfall: unreachable > failed > changed > ok > skipped
var count var count;
count = { count = {
ok : _.filter(hosts, function(o){ ok : _.filter(hosts, function(o){
return o.failures === 0 && o.changed === 0 && o.ok > 0; return o.failures === 0 && o.changed === 0 && o.ok > 0;
@@ -32,7 +32,7 @@
return o.changed > 0; return o.changed > 0;
}) })
}; };
return count return count;
}; };
var socketListener = function(){ var socketListener = function(){
// emitted by the API in the same function used to persist host summary data // emitted by the API in the same function used to persist host summary data
@@ -40,7 +40,7 @@
jobSocket.on('summary_complete', function(data) { jobSocket.on('summary_complete', function(data) {
// discard socket msgs we don't care about in this context // discard socket msgs we don't care about in this context
if ($stateParams.id == data['unified_job_id']){ if ($stateParams.id == data['unified_job_id']){
init() init();
} }
}); });
// UnifiedJob.def socketio_emit_status() from /awx/main.models.unified_jobs.py // UnifiedJob.def socketio_emit_status() from /awx/main.models.unified_jobs.py
@@ -83,14 +83,14 @@
} }
}; };
$scope.search = function(){ $scope.search = function(){
Wait('start') Wait('start');
JobDetailService.getJobHostSummaries($stateParams.id, { JobDetailService.getJobHostSummaries($stateParams.id, {
page_size: page_size, page_size: page_size,
host_name__icontains: $scope.searchTerm, host_name__icontains: $scope.searchTerm,
}).success(function(res){ }).success(function(res){
$scope.hosts = res.results; $scope.hosts = res.results;
$scope.next = res.next; $scope.next = res.next;
Wait('stop') Wait('stop');
}) })
}; };
$scope.setFilter = function(filter){ $scope.setFilter = function(filter){
@@ -116,11 +116,12 @@
$scope.next = res.next; $scope.next = res.next;
}); });
} }
var get = filter == 'all' ? getAll() : getFailed() var get = filter == 'all' ? getAll() : getFailed();
}; };
$scope.$watchCollection('hosts', function(curr, prev){ $scope.$watchCollection('hosts', function(curr, prev){
DrawGraph({count: buildGraph(curr), resize:true}); $scope.count = buildGraph(curr);
DrawGraph({count: $scope.count, resize:true});
}); });
var init = function(){ var init = function(){
@@ -133,7 +134,7 @@
}); });
JobDetailService.getJob({id: $stateParams.id}) JobDetailService.getJob({id: $stateParams.id})
.success(function(res){ .success(function(res){
$scope.status = status; $scope.status = res.results[0].status;
}); });
}; };
socketListener(); socketListener();

View File

@@ -16,7 +16,7 @@
ng-click="setFilter('all')" ng-click="setFilter('all')"
class="JobDetail-tableToggle btn btn-xs" ng-class="{'btn-default': filter == 'failed', 'btn-primary': filter == 'all'}">All</button> class="JobDetail-tableToggle btn btn-xs" ng-class="{'btn-default': filter == 'failed', 'btn-primary': filter == 'all'}">All</button>
<button ng-click="setFilter('failed')" <button ng-click="setFilter('failed')"
ng-class="{'btn-default': filter == 'all', 'btn-primary': filter == 'failed'}" class="JobDetail-tableToggle btn btn-xs">Failed</button> ng-class="{'btn-default': filter == 'all', 'btn-primary': filter == 'failed'}" ng-disabled='count.failures == 0' class="JobDetail-tableToggle btn btn-xs">Failed</button>
</div> </div>
</div> </div>
</div> </div>