On inventory tree widget, has_active_failures turns node text color to red. Checkbox at bottom filters nodes based on value of has_active_failures.

This commit is contained in:
chouseknecht
2013-06-13 16:08:17 -04:00
parent 365a21f103
commit 6806619e98
8 changed files with 83 additions and 19 deletions

View File

@@ -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'
];

View File

@@ -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',

View File

@@ -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();

View File

@@ -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 }]
}
},