From 13b8b68449bc1137d656f629428cb0a303a2329e Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Mon, 24 Jun 2013 13:11:34 -0400 Subject: [PATCH] Failed jobs link on Inventories tab list now works. Clicking takes user to Jobs tab, filters jobs by Inventory ID and sorts by Status (so that failed jobs appear first in list). --- awx/ui/static/css/ansible-ui.css | 2 +- awx/ui/static/js/controllers/Inventories.js | 5 +++ awx/ui/static/js/controllers/Jobs.js | 12 +++++++ awx/ui/static/js/helpers/search.js | 5 +-- awx/ui/static/js/lists/Inventories.js | 1 + awx/ui/static/js/lists/Jobs.js | 5 +++ awx/ui/static/lib/ansible/list-generator.js | 38 ++++++++++++--------- 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/awx/ui/static/css/ansible-ui.css b/awx/ui/static/css/ansible-ui.css index 9751c10b02..8552a7d1bc 100644 --- a/awx/ui/static/css/ansible-ui.css +++ b/awx/ui/static/css/ansible-ui.css @@ -520,6 +520,6 @@ text-rendering: optimizeLegibility; } -.modal-body { +#form-modal-body, #password-body { padding-top: 30px; } diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 40c1bdeb0e..76a3545305 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -150,6 +150,11 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res } } } + + // Failed jobs link. Go to the jobs tabs, find all jobs for the inventory and sort by status + scope.viewJobs = function(id) { + $location.url('/jobs/?inventory__int=' + id + '&order_by=status'); + } } InventoriesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList', diff --git a/awx/ui/static/js/controllers/Jobs.js b/awx/ui/static/js/controllers/Jobs.js index e56a60178c..7336d4f345 100644 --- a/awx/ui/static/js/controllers/Jobs.js +++ b/awx/ui/static/js/controllers/Jobs.js @@ -36,8 +36,20 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, SearchInit({ scope: scope, set: 'jobs', list: list, url: defaultUrl }); PaginateInit({ scope: scope, list: list, url: defaultUrl }); + + // Called from Inventories page, failed jobs link. Find jobs for selected inventory. + if ($routeParams['inventory__int']) { + scope[list.iterator + 'SearchField'] = 'inventory'; + scope[list.iterator + 'SearchValue'] = $routeParams['inventory__int']; + scope[list.iterator + 'SearchFieldLabel'] = 'Inventory'; + } scope.search(list.iterator); + // Called from Inventories page, failed jobs link. Now sort by status so faild jobs appear at top of list + if ($routeParams.order_by) { + scope.sort($routeParams.order_by); + } + LoadBreadCrumbs(); scope.refreshJob = function() { diff --git a/awx/ui/static/js/helpers/search.js b/awx/ui/static/js/helpers/search.js index 571516c6c4..75cff9306f 100644 --- a/awx/ui/static/js/helpers/search.js +++ b/awx/ui/static/js/helpers/search.js @@ -145,8 +145,9 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) || list.fields[scope[iterator + 'SearchField']].searchType == 'select') ) { scope[iterator + 'SearchParams'] += scope[iterator + 'SearchSelectValue'].value; } - else if ( list.fields[scope[iterator + 'SearchField']].searchType == undefined || - list.fields[scope[iterator + 'SearchField']].searchType == 'gtzero' ) { + else { + //if ( list.fields[scope[iterator + 'SearchField']].searchType == undefined || + // list.fields[scope[iterator + 'SearchField']].searchType == 'gtzero' ) { scope[iterator + 'SearchParams'] += escape(scope[iterator + 'SearchValue']); } scope[iterator + 'SearchParams'] += (sort_order) ? '&order_by=' + escape(sort_order) : ''; diff --git a/awx/ui/static/js/lists/Inventories.js b/awx/ui/static/js/lists/Inventories.js index 38562879a6..68ca3783b1 100644 --- a/awx/ui/static/js/lists/Inventories.js +++ b/awx/ui/static/js/lists/Inventories.js @@ -39,6 +39,7 @@ angular.module('InventoriesListDefinition', []) ngShow: "\{\{ inventory.has_active_failures \}\}", icon: 'icon-exclamation-sign', "class": 'active-failures-\{\{ inventory.has_active_failures \}\}', + ngClick: 'viewJobs(\{\{ inventory.id \}\})', searchField: 'has_active_failures', searchType: 'boolean', searchOptions: [{ name: "No", value: 0 }, { name: "Yes", value: 1 }] diff --git a/awx/ui/static/js/lists/Jobs.js b/awx/ui/static/js/lists/Jobs.js index e1158221a1..b4e46bd075 100644 --- a/awx/ui/static/js/lists/Jobs.js +++ b/awx/ui/static/js/lists/Jobs.js @@ -23,6 +23,11 @@ angular.module('JobsListDefinition', []) key: true, desc: true, searchType: 'int' + }, + inventory: { + label: 'Inventory ID', + searchType: 'int', + searchOnly: true }, name: { label: 'Name', diff --git a/awx/ui/static/lib/ansible/list-generator.js b/awx/ui/static/lib/ansible/list-generator.js index 5d636d39c9..a1c1be830f 100644 --- a/awx/ui/static/lib/ansible/list-generator.js +++ b/awx/ui/static/lib/ansible/list-generator.js @@ -153,27 +153,29 @@ angular.module('ListGenerator', ['GeneratorHelpers']) html += "#\n"; } for (var fld in list.fields) { - html += ""; } - else { - html += "icon-sort"; - } - html += "\">"; + html += "\n"; } - html += "\n"; } if (options.mode == 'select') { html += "Select"; @@ -199,7 +201,9 @@ angular.module('ListGenerator', ['GeneratorHelpers']) base = base.replace(/^\//,''); for (fld in list.fields) { cnt++; - html += Column({ list: list, fld: fld, options: options, base: base }); + if (list.fields[fld].searchOnly == undefined || list.fields[fld].searchOnly == false) { + html += Column({ list: list, fld: fld, options: options, base: base }); + } } if (options.mode == 'select' ) {