fixed the host status bar graph

This commit is contained in:
John Mitchell
2016-09-29 16:46:03 -04:00
committed by jaredevantabor
parent fcb9d8b6b5
commit 68041ee50d
5 changed files with 108 additions and 30 deletions

View File

@@ -1,39 +1,75 @@
@import '../../shared/branding/colors.default.less'; @import '../../shared/branding/colors.default.less';
.JobResults-hostStatusBar{ .HostStatusBar {
display: flex; display: flex;
flex: 1 0 auto; flex: 0 0 auto;
width: 100%; width: 100%;
margin-top: 10px; margin-top: 10px;
} }
.JobResults-hostStatusBar--ok{ .HostStatusBar-ok {
background-color: @default-succ; background-color: @default-succ;
display: flex; display: flex;
flex: 1 0 auto; flex: 0 0 auto;
height: 5px; height: 5px;
} }
.JobResults-hostStatusBar--changed{ .HostStatusBar-changed {
background-color: @default-warning; background-color: @default-warning;
flex: 1 0 auto; flex: 0 0 auto;
height: 5px; height: 5px;
} }
.JobResults-hostStatusBar--unreachable{ .HostStatusBar-unreachable {
background-color: @default-unreachable; background-color: @default-unreachable;
flex: 1 0 auto; flex: 0 0 auto;
height: 5px; height: 5px;
} }
.JobResults-hostStatusBar--failures{ .HostStatusBar-failures {
background-color: @default-err; background-color: @default-err;
flex: 0 0 auto;
height: 5px;
}
.HostStatusBar-skipped {
background-color: @default-link;
flex: 0 0 auto;
height: 5px;
}
.HostStatusBar-noData {
background-color: @default-icon-hov;
flex: 1 0 auto; flex: 1 0 auto;
height: 5px; height: 5px;
} }
.JobResults-hostStatusBar--skipped{ .HostStatusBar-tooltipLabel {
background-color: @default-link; text-transform: uppercase;
flex: 1 0 auto; margin-right: 15px;
height: 5px; }
.HostStatusBar-tooltipBadge {
border-radius: 5px;
}
.HostStatusBar-tooltipBadge--ok {
background-color: @default-succ;
}
.HostStatusBar-tooltipBadge--unreachable {
background-color: @default-unreachable;
}
.HostStatusBar-tooltipBadge--skipped {
background-color: @default-link;
}
.HostStatusBar-tooltipBadge--changed {
background-color: @default-warning;
}
.HostStatusBar-tooltipBadge--failures {
background-color: @default-err;
} }

View File

@@ -8,15 +8,32 @@
export default [ 'templateUrl', export default [ 'templateUrl',
function(templateUrl) { function(templateUrl) {
return { return {
scope: { scope: true,
jobData: '='
},
templateUrl: templateUrl('job-results/host-status-bar/host-status-bar'), templateUrl: templateUrl('job-results/host-status-bar/host-status-bar'),
restrict: 'E', restrict: 'E',
// controller: standardOutLogController, // controller: standardOutLogController,
link: function(scope) { link: function(scope) {
// All of our DOM related stuff will go in here // as count is changed by event data coming in,
// update the host status bar
scope.$watch('count', function(val) {
Object.keys(val).forEach(key => {
// reposition the hosts status bar by setting the
// various flex values to the count of those hosts
$(`.HostStatusBar-${key}`)
.css('flex', `${val[key]} 0 auto`);
// set the tooltip to give how many hosts of each
// type
if (val[key] > 0) {
scope[`${key}CountTip`] = `<span class='HostStatusBar-tooltipLabel'>${key}</span><span class='badge HostStatusBar-tooltipBadge HostStatusBar-tooltipBadge--${key}'>${val[key]}</span>`;
}
});
// if there are any hosts that have finished, don't show
// default grey bar
scope.hostsFinished = (Object
.keys(val).filter(key => (val[key] > 0)).length > 0);
});
} }
} };
}]; }];

View File

@@ -1,7 +1,26 @@
<div class="JobResults-hostStatusBar"> <div class="HostStatusBar">
<div class="JobResults-hostStatusBar--ok"></div> <div class="HostStatusBar-ok"
<div class="JobResults-hostStatusBar--changed"></div> data-placement="top"
<div class="JobResults-hostStatusBar--failures"></div> aw-tool-tip="{{okCountTip}}"
<div class="JobResults-hostStatusBar--unreachable"></div> data-tip-watch="okCountTip"></div>
<div class="JobResults-hostStatusBar--skipped"></div> <div class="HostStatusBar-changed"
data-placement="top"
aw-tool-tip="{{changedCountTip}}"
data-tip-watch="changedCountTip"></div>
<div class="HostStatusBar-failures"
data-placement="top"
aw-tool-tip="{{failuresCountTip}}"
data-tip-watch="failuresCountTip"></div>
<div class="HostStatusBar-unreachable"
data-placement="top"
aw-tool-tip="{{unreachableCountTip}}"
data-tip-watch="unreachableCountTip"></div>
<div class="HostStatusBar-skipped"
data-placement="top"
aw-tool-tip="{{skippedCountTip}}"
data-tip-watch="skippedCountTip"></div>
<div class="HostStatusBar-noData"
aw-tool-tip="NO HOSTS FINISHED"
ng-hide="hostsFinished"
data-placement="top"></div>
</div> </div>

View File

@@ -58,6 +58,9 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', '$scope', 'ParseTypeCh
$scope.stdoutFullScreen = !$scope.stdoutFullScreen; $scope.stdoutFullScreen = !$scope.stdoutFullScreen;
}; };
// Initially set the count data to have no hosts as finsihed
$scope.count = {ok: 0, skipped: 0, unreachable: 0, failures: 0, changed: 0};
$scope.deleteJob = function() { $scope.deleteJob = function() {
jobResultsService.deleteJob($scope.job); jobResultsService.deleteJob($scope.job);
}; };
@@ -67,20 +70,17 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', '$scope', 'ParseTypeCh
}; };
$rootScope.event_socket.on("job_events-" + $scope.job.id, function(data) { $rootScope.event_socket.on("job_events-" + $scope.job.id, function(data) {
console.log(data);
if(data.event_name === "playbook_on_stats"){ if(data.event_name === "playbook_on_stats"){
// get the data for populating the host status bar // get the data for populating the host status bar
jobResultsService.getHostStatusBarCounts(data.event_data); $scope.count = jobResultsService
.getHostStatusBarCounts(data.event_data);
} }
}); });
$rootScope.$on('JobStatusChange-jobDetails', function(e, data) { $rootScope.$on('JobStatusChange-jobDetails', function(e, data) {
console.log(data);
if (parseInt(data.unified_job_id, 10) === parseInt($scope.job.id,10)) { if (parseInt(data.unified_job_id, 10) === parseInt($scope.job.id,10)) {
$scope.job.status = data.status; $scope.job.status = data.status;
// $scope.job.elapsed = data.elapsed;
} }
}); });

View File

@@ -5,7 +5,7 @@
*************************************************/ *************************************************/
export default ['Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErrors', '$rootScope', function (Prompt, $filter, Wait, Rest, $state, ProcessErrors, $rootScope) { export default ['Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErrors', function (Prompt, $filter, Wait, Rest, $state, ProcessErrors) {
var val = { var val = {
getHostStatusBarCounts: function(event_data) { getHostStatusBarCounts: function(event_data) {
var hosts = {}; var hosts = {};
@@ -64,6 +64,12 @@ export default ['Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErrors',
}) })
}; };
// turn the count into an actual count, rather than a list of host
// names
Object.keys(count).forEach(key => {
count[key] = count[key].length;
});
return count; return count;
}, },
deleteJob: function(job) { deleteJob: function(job) {