From 4ea3c23e5a1779df18e8573623b79e178f39746d Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Thu, 22 Aug 2013 11:26:23 -0400 Subject: [PATCH] AC-331 final clean up --- awx/ui/static/js/controllers/Inventories.js | 13 ++++++---- awx/ui/static/js/controllers/Jobs.js | 5 ++++ awx/ui/static/js/forms/Inventories.js | 3 ++- awx/ui/static/js/lists/Inventories.js | 25 ++++++++----------- .../static/lib/ansible/generator-helpers.js | 21 +++++++++++----- awx/ui/static/lib/ansible/list-generator.js | 19 +++++++++++--- 6 files changed, 57 insertions(+), 29 deletions(-) diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 56914cfdb8..7e211ca337 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -77,6 +77,10 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res scope.viewJobs = function(id) { $location.url('/jobs/?inventory__int=' + id + '&order_by=status'); } + + scope.viewFailedJobs = function(id) { + $location.url('/jobs/?inventory__int=' + id + '&status=failed&order_by=status'); + } } InventoriesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList', @@ -482,11 +486,10 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP HostsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id, host_id: host_id, host_name: host_name, request: 'delete' }); } - - /* scope.removeHost = function(host_id, host_name) { - HostsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id, host_id: host_id, host_name: host_name, - request: 'remove' }); - } */ + + scope.viewJobs = function(last_job) { + $location.url('/jobs/?id__int=' + last_job ); + } scope.viewLastEvents = function(host_id, last_job, host_name, last_job_name) { // Choose View-> Latest job events diff --git a/awx/ui/static/js/controllers/Jobs.js b/awx/ui/static/js/controllers/Jobs.js index 566dc1ba83..69a7535d34 100644 --- a/awx/ui/static/js/controllers/Jobs.js +++ b/awx/ui/static/js/controllers/Jobs.js @@ -50,6 +50,11 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, scope[list.iterator + 'SearchValue'] = $routeParams['inventory__int']; scope[list.iterator + 'SearchFieldLabel'] = 'Inventory ID'; } + if ($routeParams['id__int']) { + scope[list.iterator + 'SearchField'] = 'id'; + scope[list.iterator + 'SearchValue'] = $routeParams['id__int']; + scope[list.iterator + 'SearchFieldLabel'] = 'Job ID'; + } scope.search(list.iterator); // Called from Inventories page, failed jobs link. Now sort by status so faild jobs appear at top of list diff --git a/awx/ui/static/js/forms/Inventories.js b/awx/ui/static/js/forms/Inventories.js index b7632bc8a1..1ac5acbd59 100644 --- a/awx/ui/static/js/forms/Inventories.js +++ b/awx/ui/static/js/forms/Inventories.js @@ -122,9 +122,10 @@ angular.module('InventoryFormDefinition', []) dropdown: { type: 'DropDown', label: 'View', + "class": "btn-sm", ngDisabled: 'host.last_job == null', options: [ - { ngClick: 'viewJobs(\{\{ host.id \}\})', label: 'Jobs' }, + { ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job' }, { ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " + "'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest job events' }, { ngClick: "viewLastSummary(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " + diff --git a/awx/ui/static/js/lists/Inventories.js b/awx/ui/static/js/lists/Inventories.js index 66f754b734..c61f7e8ce0 100644 --- a/awx/ui/static/js/lists/Inventories.js +++ b/awx/ui/static/js/lists/Inventories.js @@ -37,20 +37,6 @@ angular.module('InventoriesListDefinition', []) sourceField: 'name', excludeModal: true } - /*, - has_active_failures: { - label: 'Failed Jobs?', - showValue: false, - text: 'View failures', - 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 }], - excludeModal: true - }*/ }, actions: { @@ -65,6 +51,17 @@ angular.module('InventoriesListDefinition', []) }, fieldActions: { + + dropdown: { + type: 'DropDown', + label: 'View', + 'class': 'btn-xs', + options: [ + { ngClick: 'viewJobs(\{\{ inventory.id \}\})', label: 'Jobs' }, + { ngClick: "viewFailedJobs(\{\{ inventory.id \}\})", label: 'Failed jobs' } + ] + }, + edit: { label: 'Edit', ngClick: "editInventory(\{\{ inventory.id \}\})", diff --git a/awx/ui/static/lib/ansible/generator-helpers.js b/awx/ui/static/lib/ansible/generator-helpers.js index 4a080f15f8..e8b6536af2 100644 --- a/awx/ui/static/lib/ansible/generator-helpers.js +++ b/awx/ui/static/lib/ansible/generator-helpers.js @@ -98,14 +98,22 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers']) var list = params['list']; var fld = params['fld']; var options = params['options']; - var base = params['base']; - var field = list['fields'][fld]; + var field; - html = "\n"; - html += "
\n"; + if (params.type) { + field = list[params.type][fld]; + } + else { + field = list['fields'][fld]; + } + + html = (params.td == undefined || params.td !== false) ? "\n" : ""; + html += "
\n"; html += "\n"; html += "
    \n"; @@ -118,7 +126,8 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers']) } html += "
\n"; html += "
\n"; - html += "\n"; + + html += (params.td == undefined || params.td !== false) ? "\n" : ""; return html; diff --git a/awx/ui/static/lib/ansible/list-generator.js b/awx/ui/static/lib/ansible/list-generator.js index 7f3201abcf..e36e48503a 100644 --- a/awx/ui/static/lib/ansible/list-generator.js +++ b/awx/ui/static/lib/ansible/list-generator.js @@ -9,8 +9,8 @@ angular.module('ListGenerator', ['GeneratorHelpers']) .factory('GenerateList', [ '$location', '$compile', '$rootScope', 'SearchWidget', 'PaginateWidget', 'Attr', 'Icon', - 'Column', - function($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column) { + 'Column', 'DropDown', + function($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column, DropDown) { return { setList: function(list) { @@ -279,7 +279,20 @@ angular.module('ListGenerator', ['GeneratorHelpers']) // Row level actions html += ""; for (action in list.fieldActions) { - html += this.button(list.fieldActions[action]); + if (list.fieldActions[action].type && list.fieldActions[action].type == 'DropDown') { + html += DropDown({ + list: list, + fld: action, + options: options, + base: base, + type: 'fieldActions', + td: false + }); + } + else { + console.log('here'); + html += this.button(list.fieldActions[action]); + } } html += ""; }