diff --git a/ansibleworks/ui/static/css/ansible-ui.css b/ansibleworks/ui/static/css/ansible-ui.css index fcc3e983c3..f7d0044294 100644 --- a/ansibleworks/ui/static/css/ansible-ui.css +++ b/ansibleworks/ui/static/css/ansible-ui.css @@ -348,6 +348,24 @@ margin-left: 5px; } + .inventory-filter { + padding: 0 3px 3px 3px; + margin-top: 3px; + text-align: right; + background-color: #f5f5f5; + border: 1px solid #e3e3e3; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); + } + + .inventory-filter label { + margin-right: 10px; + } + #hosts-well { padding-top: 10px; } diff --git a/ansibleworks/ui/static/js/controllers/Inventories.js b/ansibleworks/ui/static/js/controllers/Inventories.js index ce388c1032..123817e751 100644 --- a/ansibleworks/ui/static/js/controllers/Inventories.js +++ b/ansibleworks/ui/static/js/controllers/Inventories.js @@ -217,7 +217,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, OrganizationList, TreeInit, GetBasePath, GroupsList, GroupsEdit, LoadInventory, - GroupsDelete, HostsList, HostsAdd, HostsEdit, HostsDelete) + GroupsDelete, HostsList, HostsAdd, HostsEdit, HostsDelete, RefreshTree) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -231,7 +231,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP var id = $routeParams.id; scope['inventory_id'] = id; - + // Retrieve each related set and any lookups if (scope.inventoryLoadedRemove) { scope.inventoryLoadedRemove(); @@ -252,6 +252,10 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP LoadInventory({ scope: scope }); + scope.filterInventory = function() { + RefreshTree({ scope: scope }); + } + // Save changes to the parent scope.formSave = function() { Rest.setUrl(defaultUrl + $routeParams.id + '/'); @@ -419,6 +423,6 @@ InventoriesEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$l 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'OrganizationList', 'TreeInit', 'GetBasePath', 'GroupsList', 'GroupsEdit', 'LoadInventory', - 'GroupsDelete', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete' + 'GroupsDelete', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete', 'RefreshTree' ]; diff --git a/ansibleworks/ui/static/js/forms/Inventories.js b/ansibleworks/ui/static/js/forms/Inventories.js index ffc076e6e0..fed4ccedd0 100644 --- a/ansibleworks/ui/static/js/forms/Inventories.js +++ b/ansibleworks/ui/static/js/forms/Inventories.js @@ -42,6 +42,11 @@ angular.module('InventoryFormDefinition', []) addRequired: true, editRequired: true, ngClick: 'lookUpOrganization()' + }, + has_active_failures: { + label: 'Active Failures', + readonly: true, + type: 'text' } }, @@ -96,7 +101,7 @@ angular.module('InventoryFormDefinition', []) has_active_failures: { label: 'Failures', showValue: false, - ngShow: "\{\{ host.has_active_failures \}\}", + ngShowIcon: "\{\{ host.has_active_failures \}\}", icon: 'icon-circle', "class": 'active-failures-\{\{ host.has_active_failures \}\}', searchField: 'has_active_failures', diff --git a/ansibleworks/ui/static/js/helpers/inventory.js b/ansibleworks/ui/static/js/helpers/inventory.js index 8ecf0a5370..0db4f474d3 100644 --- a/ansibleworks/ui/static/js/helpers/inventory.js +++ b/ansibleworks/ui/static/js/helpers/inventory.js @@ -25,6 +25,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi var inventory_name = inventory.name; var inventory_url = inventory.url; var inventory_id = inventory.id; + var has_active_failures = inventory.has_active_failures; var inventory_descr = inventory.description; var idx=0; var treeData = []; @@ -34,7 +35,9 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi scope.HostLoadedRemove(); } scope.HostLoadedRemove = scope.$on('hostsLoaded', function() { - Rest.setUrl(groups + '?order_by=name'); + var filter = (scope.inventoryFailureFilter) ? "has_active_failures__int=1&" : ""; + var url = groups + '?' + filter + 'order_by=name'; + Rest.setUrl(url); Rest.get() .success( function(data, status, headers, config) { for (var i=0; i < data.results.length; i++) { @@ -52,7 +55,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi all: data.results[i].related.all_hosts, children: data.results[i].related.children, hosts: data.results[i].related.hosts, - variable: data.results[i].related.variable_data + variable: data.results[i].related.variable_data, + "data-failures": data.results[i].has_active_failures }, state: 'closed' }); @@ -81,7 +85,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi 'inventory_id': inventory_id, hosts: hosts, name: inventory_name, - description: inventory_descr + description: inventory_descr, + "data-failures": inventory.has_active_failures }, state: 'open', children:[] @@ -133,7 +138,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi }, headers: { 'Authorization': 'Token ' + Authorization.getToken() }, success: function(data) { - var response = []; + var response = []; + var filter = (scope.inventoryFailureFilter) ? "has_active_failures__int=1&" : ""; for (var i=0; i < data.results.length; i++) { response.push({ data: { @@ -147,9 +153,10 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi description: data.results[i].description, inventory: data.results[i].inventory, all: data.results[i].related.all_hosts, - children: data.results[i].related.children + '?order_by=name', + children: data.results[i].related.children + '?' + filter + 'order_by=name', hosts: data.results[i].related.hosts, - variable: data.results[i].related.variable_data + variable: data.results[i].related.variable_data, + "data-failures": data.results[i].has_active_failures }, state: 'closed' }); @@ -244,7 +251,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi var scope = params.scope; var openId = []; - var selectedId; + var selectedId; if (scope.treeLoadedRemove) { scope.treeLoadedRemove(); diff --git a/ansibleworks/ui/static/js/lists/Inventories.js b/ansibleworks/ui/static/js/lists/Inventories.js index 4a6de1105d..6ee8001291 100644 --- a/ansibleworks/ui/static/js/lists/Inventories.js +++ b/ansibleworks/ui/static/js/lists/Inventories.js @@ -31,6 +31,16 @@ angular.module('InventoriesListDefinition', []) ngBind: 'inventory.summary_fields.organization.name', sourceModel: 'organization', sourceField: 'name' + }, + has_active_failures: { + label: 'Failures', + showValue: false, + ngShowIcon: "\{\{ inventory.has_active_failures \}\}", + icon: 'icon-circle', + "class": 'active-failures-\{\{ inventory.has_active_failures \}\}', + searchField: 'has_active_failures', + searchType: 'boolean', + searchOptions: [{ name: "No", value: 0 }, { name: "Yes", value: 1 }] } }, diff --git a/ansibleworks/ui/static/lib/ansible/form-generator.js b/ansibleworks/ui/static/lib/ansible/form-generator.js index b16151be76..3b9eaf82ef 100644 --- a/ansibleworks/ui/static/lib/ansible/form-generator.js +++ b/ansibleworks/ui/static/lib/ansible/form-generator.js @@ -691,6 +691,8 @@ angular.module('FormGenerator', ['GeneratorHelpers']) " Delete Group"; html += "\n"; html += "
\n"; + html += "\n"; html += "\n"; } else { @@ -757,11 +759,11 @@ angular.module('FormGenerator', ['GeneratorHelpers']) html += (rfield['class']) ? 'class="'+ rfield['class'] + '"' : ""; html += ">"; if (rfield.icon) { - if (rfield.ngShow) { - html += ""; + if (rfield.ngShowIcon) { + html += ""; } else { - html += this.attr(rfield,'icon'); + html += this.icon(rfield.icon); } } if (rfield.showValue == undefined || rfield.showValue == true) { diff --git a/ansibleworks/ui/static/lib/ansible/list-generator.js b/ansibleworks/ui/static/lib/ansible/list-generator.js index 8f64842b16..b59dc2c941 100644 --- a/ansibleworks/ui/static/lib/ansible/list-generator.js +++ b/ansibleworks/ui/static/lib/ansible/list-generator.js @@ -239,13 +239,23 @@ angular.module('ListGenerator', ['GeneratorHelpers']) html += ""; } } - html += (list.fields[fld].icon) ? this.icon(list.fields[fld].icon) : ""; - if (list.fields[fld].ngBind) { - html += "{{ " + list.fields[fld].ngBind + " }}"; + + if (list.fields[fld].ngShowIcon) { + html += ""; } else { - html += "{{" + list.iterator + "." + fld + "}}"; + html += this.icon(list.fields[fld].icon); } + + if (list.fields[fld].showValue == undefined || list.fields[fld].showValue == true) { + if (list.fields[fld].ngBind) { + html += "{{ " + list.fields[fld].ngBind + " }}"; + } + else { + html += "{{" + list.iterator + "." + fld + "}}"; + } + } + html += ((list.fields[fld].key || list.fields[fld].link) && options.mode != 'lookup' && options.mode != 'select') ? "" : ""; html += "\n"; } diff --git a/ansibleworks/ui/static/lib/jstree/themes/ansible/style.css b/ansibleworks/ui/static/lib/jstree/themes/ansible/style.css index 38cbec692d..8f76e784c5 100644 --- a/ansibleworks/ui/static/lib/jstree/themes/ansible/style.css +++ b/ansibleworks/ui/static/lib/jstree/themes/ansible/style.css @@ -30,6 +30,13 @@ .jstree-ansible .jstree-hovered { background:#e7f4f9; border:1px solid #e7f4f9; padding:0 2px 0 1px; } .jstree-ansible .jstree-clicked { background:#d9edf7; border:1px solid #3a87ad; padding:0 2px 0 1px; color: #000; } + +/* if data-failures=true (set usng has_active_failures on hosts, groups, inventory), link color is red */ +.jstree-ansible li[data-failures="true"] .jstree-clicked { color: #FF0000; } +.jstree-ansible li[data-failures="false"] .jstree-clicked { color: #000; } +.jstree-ansible li[data-failures="true"] a { color: #FF0000; } +.jstree-ansible li[data-failures="false"] a { color: #000; } + .jstree-ansible a .jstree-icon { background-position:-56px -19px; } .jstree-ansible .jstree-open > a .jstree-icon { background-position:-56px -36px; } .jstree-ansible a.jstree-loading .jstree-icon { background:url("throbber.gif") center center no-repeat !important; } @@ -90,4 +97,5 @@ .jstree-ansible .jstree-undetermined a .jstree-checkbox { _background-position:-20px -19px; } .jstree-ansible .jstree-checked a .jstree-checkbox { _background-position:-38px -19px; } .jstree-ansible .jstree-unchecked a .jstree-checkbox { _background-position:-2px -19px; } -/* IE6 END */ \ No newline at end of file +/* IE6 END */ +