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

AC-230 only-hosts-with-failures checkbox added implemented. Notice that it stays in sync wit the regular filter, providing a one-click short cut to filter hosts with failed jobs.

This commit is contained in:
chouseknecht 2013-07-26 12:20:07 -04:00
parent 4aaeb9506f
commit 559b8c96af
4 changed files with 53 additions and 11 deletions

View File

@ -184,7 +184,8 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt,
OrganizationList, TreeInit, GetBasePath, GroupsList, GroupsAdd, GroupsEdit, LoadInventory,
GroupsDelete, HostsList, HostsAdd, HostsEdit, HostsDelete, RefreshGroupName, ParseTypeChange)
GroupsDelete, HostsList, HostsAdd, HostsEdit, HostsDelete, RefreshGroupName, ParseTypeChange,
HostsReload)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -247,6 +248,10 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
RefreshTree({ scope: scope });
}
scope.filterHosts = function() {
HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] });
}
function PostSave() {
// Make sure the inventory name in the tree is correct
RefreshGroupName($('#inventory-node'), scope['inventory_name'], scope['inventory_description']);
@ -450,13 +455,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
scope.groupTitle = '<h4>All Hosts</h4>';
scope.group_id = null;
}
scope.relatedSets['hosts'] = { url: url, iterator: 'host' };
RelatedSearchInit({ scope: scope, form: form, relatedSets: scope.relatedSets });
RelatedPaginateInit({ scope: scope, relatedSets: scope.relatedSets });
scope.search('host');
if (!scope.$$phase) {
scope.$digest();
}
HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] });
});
scope.addGroup = function() {
@ -513,6 +512,6 @@ InventoriesEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$l
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt',
'OrganizationList', 'TreeInit', 'GetBasePath', 'GroupsList', 'GroupsAdd', 'GroupsEdit', 'LoadInventory',
'GroupsDelete', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete', 'RefreshGroupName',
'ParseTypeChange'
'ParseTypeChange', 'HostsReload'
];

View File

@ -406,6 +406,20 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
var relatedSets = { hosts: { url: url, iterator: 'host' } };
RelatedSearchInit({ scope: params.scope, form: InventoryForm, relatedSets: relatedSets });
RelatedPaginateInit({ scope: params.scope, relatedSets: relatedSets });
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';
scope['hostSelectShow'] = true;
scope.setSearchField('host','has_active_failures','Failed jobs?');
for (var i=0; i < scope['hostSearchSelectOpts'].length; i++) {
if (scope['hostSearchSelectOpts'][i].value == 1) {
scope['hostSearchSelectValue'] = scope['hostSearchSelectOpts'][i];
}
}
}
params.scope.search('host');
if (!params.scope.$$phase) {
params.scope.$digest();

View File

@ -83,6 +83,15 @@ 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);
}
@ -97,6 +106,17 @@ angular.module('RelatedSearchHelper', ['RestServices', 'Utilities','RefreshRelat
scope[iterator + 'SearchSpin'] = true;
scope[iterator + 'Loading'] = true;
if (iterator == 'host') {
if (scope['hostSearchField'] == 'has_active_failures') {
if (scope['hostSearchSelectValue'] && scope['hostSearchSelectValue'].value == 1) {
scope['hostFailureFilter'] = true;
}
else {
scope['hostFailureFilter'] = false;
}
}
}
var set, url, iterator, sort_order;
for (var key in relatedSets) {
if (relatedSets[key].iterator == iterator) {

View File

@ -965,6 +965,15 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
// End List
html += "</tbody>\n";
html += "</table>\n";
// Failure filter checkbox
html += "<div class=\"host-filter\">\n";
html += "<span ng-show=\"has_active_failures == true\">";
html += "<label class=\"checkbox inline\">";
html += "<input ng-model=\"hostFailureFilter\" ng-change=\"filterHosts()\" type=\"checkbox\"" +
">Show only hosts with failures</label></span>\n"
html += "</div>\n";
html += "</div>\n"; // close well
html += "</div>\n"; // close group-view