1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 22:21:13 +03:00

Inventory refactory: fixed status messages on hosts view.

This commit is contained in:
chris Houseknecht 2014-01-15 14:49:01 -05:00
parent c62718493c
commit 28cbed72c8
2 changed files with 34 additions and 41 deletions

View File

@ -93,7 +93,8 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
}
else {
// many hosts with 0 failures
scope.inventories[i].failed_hosts_tip = "No job failures. Click to view details.";
scope.inventories[i].failed_hosts_tip = scope.inventories[i].total_hosts +
( (scope.inventories[i].total_hosts > 1) ? ' hosts' : ' host' ) + " with no failures. Click to view details.";
scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
scope.inventories[i].failed_hosts_class = 'false';
}
@ -118,8 +119,8 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
else {
// many hosts with 0 failures
scope.inventories[i].status_tip = scope.inventories[i].total_inventory_sources +
' cloud ' + ( (scope.inventories[i].total_inventory_sources > 0) ? 'sources' : 'source' ) +
' and 0 failures. Click to view details.';
' cloud ' + ( (scope.inventories[i].total_inventory_sources > 1) ? 'sources' : 'source' ) +
' with no failures. Click to view details.';
scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
scope.inventories[i].status_class = 'successful';
}

View File

@ -26,9 +26,34 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
}
}
}])
.factory('SetHostStatus', ['SetEnabledMsg', function(SetEnabledMsg) {
return function(host) {
// Set status related fields on a host object
host.activeFailuresLink = '/#/hosts/' + host.id + '/job_host_summaries/?inventory=' + host.inventory +
'&host_name=' + escape(host.name);
if (host.has_active_failures == true) {
host.badgeToolTip = 'Most recent job failed. Click to view jobs.';
host.active_failures = 'failed';
}
else if (host.has_active_failures == false && host.last_job == null) {
host.has_active_failures = 'none';
host.badgeToolTip = "No job data available.";
host.active_failures = 'n/a';
}
else if (host.has_active_failures == false && host.last_job !== null) {
host.badgeToolTip = "Most recent job successful. Click to view jobs.";
host.active_failures = 'success';
}
host.enabled_flag = host.enabled;
SetEnabledMsg(host);
}
}])
.factory('HostsReload', [ 'Empty', 'InventoryHosts', 'GetBasePath', 'SearchInit', 'PaginateInit', 'Wait', 'SetEnabledMsg',
function(Empty, InventoryHosts, GetBasePath, SearchInit, PaginateInit, Wait, SetEnabledMsg) {
.factory('HostsReload', [ 'Empty', 'InventoryHosts', 'GetBasePath', 'SearchInit', 'PaginateInit', 'Wait', 'SetHostStatus',
function(Empty, InventoryHosts, GetBasePath, SearchInit, PaginateInit, Wait, SetHostStatus) {
return function(params) {
var scope = params.scope;
@ -37,7 +62,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
var inventory_id = params.inventory_id;
var url = ( !Empty(group_id) ) ? GetBasePath('groups') + group_id + '/all_hosts/' :
GetBasePath('inventory') + inventory_id + '/hosts/';
GetBasePath('inventory') + inventory_id + '/hosts/';
scope.search_place_holder='Search ' + scope.selected_group_name;
@ -48,7 +73,8 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
for (var i=0; i < scope.hosts.length; i++) {
//Set tooltip for host enabled flag
scope.hosts[i].enabled_flag = scope.hosts[i].enabled;
SetEnabledMsg(scope.hosts[i]);
//SetEnabledMsg(scope.hosts[i]);
SetHostStatus(scope.hosts[i]);
}
Wait('stop');
scope.$emit('HostReloadComplete');
@ -78,40 +104,6 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
}
}])
.factory('SetHostStatus', [ function() {
return function(host) {
// Set status related fields on a host object
host.activeFailuresLink = '/#/hosts/' + host.id + '/job_host_summaries/?inventory=' + host.inventory +
'&host_name=' + escape(host.name);
if (host.has_active_failures == true) {
host.badgeToolTip = 'Most recent job failed. Click to view jobs.';
host.active_failures = 'failed';
}
else if (host.has_active_failures == false && host.last_job == null) {
host.has_active_failures = 'none';
host.badgeToolTip = "No job data available.";
host.active_failures = 'n/a';
}
else if (host.has_active_failures == false && host.last_job !== null) {
host.badgeToolTip = "Most recent job successful. Click to view jobs.";
host.active_failures = 'success';
}
host.enabled_flag = host.enabled;
if (host.has_inventory_sources) {
// Inventory sync managed, so not clickable
host.enabledToolTip = (host.enabled) ? 'Ready! Availabe to running jobs.' :
'Out to lunch! This host is not available to running jobs.';
}
else {
// Clickable
host.enabledToolTip = (host.enabled) ? 'Ready! Available to running jobs. Click to toggle.' :
'Out to lunch! Host not available to running jobs. Click to toggle.';
}
}
}])
.factory('ToggleHostEnabled', [ 'GetBasePath', 'Rest', 'Wait', 'ProcessErrors', 'Alert', 'Find', 'SetEnabledMsg',
function(GetBasePath, Rest, Wait, ProcessErrors, Alert, Find, SetEnabledMsg) {
return function(params) {