AC-331 checkbox for 'Only show hosts will failed jobs' now working on Hosts tabs. Removed from Groups tab.

This commit is contained in:
chouseknecht 2013-08-19 12:17:46 -04:00
parent ec7713ae28
commit 36d4795c12
5 changed files with 21 additions and 40 deletions

View File

@ -238,7 +238,9 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
});
scope.filterInventory = function() {
HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] });
$rootScope.hostFailureFilter = scope.hostFailureFilter;
LoadSearchTree({ scope: scope, inventory_id: scope['inventory_id'] });
//HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] });
}
scope.filterHosts = function() {
@ -383,10 +385,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
scope['selectedNode'] = node;
scope['selectedNodeName'] = node.attr('name');
scope['selectedNodeName'] += (node.attr('data-failures') == 'true') ?
' <span class="nav-badge">' +
'<i class="icon-exclamation-sign" title="Contains hosts with failed jobs"></i></span>' : '';
$('#tree-view').jstree('open_node',node);
if (type == 'group') {

View File

@ -477,7 +477,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
RelatedSearchInit({ scope: params.scope, form: InventoryForm, relatedSets: relatedSets });
RelatedPaginateInit({ scope: params.scope, relatedSets: relatedSets, pageSize: 40 });
if (scope['hostFailureFilter']) {
/*if (scope['hostFailureFilter']) {
// If the user checked 'show only hosts with failures', filter for hosts with failed jobs
scope['hostSearchFieldLabel'] = 'Failed jobs?';
scope['hostSearchField'] = 'has_active_failures';
@ -488,7 +488,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
scope['hostSearchSelectValue'] = scope['hostSearchSelectOpts'][i];
}
}
}
} */
scope.search('host');

View File

@ -35,17 +35,14 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
scope.inventoryLoadedRemove();
}
scope.inventoryLoadedRemove = scope.$on('inventoryLoaded', function() {
var filter = (scope.inventoryFailureFilter) ? "has_active_failures=true&" : "";
var url = groups + '?' + filter + 'order_by=name';
var title;
var url = groups + '?order_by=name';
Rest.setUrl(url);
Rest.get()
.success( function(data, status, headers, config) {
for (var i=0; i < data.results.length; i++) {
title = data.results[i].name;
treeData[0].children.push({
data: {
title: title
title: data.results[i].name
},
attr: {
id: idx,
@ -55,7 +52,7 @@ 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 + '?' + filter + 'order_by=name',
children: data.results[i].related.children + '?order_by=name',
hosts: data.results[i].related.hosts,
variable: data.results[i].related.variable_data,
"data-failures": data.results[i].has_active_failures
@ -71,13 +68,10 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
});
});
var title = inventory_name;
title += (has_active_failures) ? ' <span class="tree-badge" title="Contains hosts with failed jobs">' +
'<i class="icon-exclamation-sign"></i></span>' : '';
treeData =
[{
data: {
title: title
title: inventory_name
},
attr: {
type: 'inventory',
@ -142,13 +136,10 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
headers: { 'Authorization': 'Token ' + Authorization.getToken() },
success: function(data) {
var response = [];
var title;
var filter = (scope.inventoryFailureFilter) ? "has_active_failures=true&" : "";
for (var i=0; i < data.results.length; i++) {
title = data.results[i].name;
response.push({
data: {
title: title
title: data.results[i].name
},
attr: {
id: idx,
@ -158,7 +149,7 @@ 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 + '?' + filter + 'order_by=name',
children: data.results[i].related.children + '?order_by=name',
hosts: data.results[i].related.hosts,
variable: data.results[i].related.variable_data,
"data-failures": data.results[i].has_active_failures
@ -385,8 +376,6 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
node.attr('description', description);
scope = angular.element(getElementById('htmlTemplate')).scope();
scope['selectedNodeName'] = name;
scope['selectedNodeName'] += (node.attr('data-failures') == 'true') ?
' <span class="nav-badge"><i class="icon-exclamation-sign" title="Contains hosts with failed jobs"></i></span>' : '';
}
}])

View File

@ -83,15 +83,6 @@ angular.module('RelatedSearchHelper', ['RestServices', 'Utilities','RefreshRelat
scope[iterator + 'HideSearchType'] = true;
}
if (iterator == 'host') {
if (fld == 'has_active_failures') {
scope['hostFailureFilter'] = true;
}
else {
scope['hostFailureFilter'] = false;
}
}
scope.search(iterator);
}
@ -143,13 +134,13 @@ angular.module('RelatedSearchHelper', ['RestServices', 'Utilities','RefreshRelat
(scope[iterator + 'SelectShow'] && scope[iterator + 'SearchSelectValue']) || (f.searchType && f.searchType == 'gtzero') ) {
if (f.sourceModel) {
// handle fields whose source is a related model e.g. inventories.organization
scope[iterator + 'SearchParams'] = '?' + f.sourceModel + '__' + f.sourceField + '__';
scope[iterator + 'SearchParams'] = f.sourceModel + '__' + f.sourceField + '__';
}
else if (f.searchField) {
scope[iterator + 'SearchParams'] = '?' + f.searchField + '__';
scope[iterator + 'SearchParams'] = f.searchField + '__';
}
else {
scope[iterator + 'SearchParams'] = '?' + scope[iterator + 'SearchField'] + '__';
scope[iterator + 'SearchParams'] = scope[iterator + 'SearchField'] + '__';
}
if ( f.searchType && (f.searchType == 'int' || f.searchType == 'boolean' ) ) {
@ -171,11 +162,10 @@ angular.module('RelatedSearchHelper', ['RestServices', 'Utilities','RefreshRelat
scope[iterator + 'SearchParams'] += (sort_order) ? '&order_by=' + escape(sort_order) : '';
}
else {
scope[iterator + 'SearchParams'] = '';
scope[iterator + 'SearchParams'] += (sort_order) ? '?order_by=' + escape(sort_order) : '';
scope[iterator + 'SearchParams'] = (sort_order) ? 'order_by=' + escape(sort_order) : '';
}
scope[iterator + 'Page'] = 0;
url += (url.match(/\/$/)) ? '?' : '&';
url += scope[iterator + 'SearchParams'];
url += (scope[iterator + 'PageSize']) ? '&page_size=' + scope[iterator + 'PageSize'] : "";
RefreshRelated({ scope: scope, set: set, iterator: iterator, url: url });

View File

@ -474,10 +474,13 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
var url = parent.attr('data-groups');
var html = '';
var token = Authorization.getToken();
url += ($rootScope.hostFailureFilter) ? '?has_active_failures=true&order_by=name' : '?order_by=name';
/* For reasons unknown calling Rest fails. It just dies with no errors
or any info */
$.ajax({
url: url + '?order_by=name',
url: url,
headers: { 'Authorization': 'Token ' + token },
dataType: 'json',
success: function(data) {