diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index 09475cfe90..a91030b871 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -122,7 +122,7 @@ Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', ]; -function HomeGroups($filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, +function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait, Alert, Rest, Empty, InventoryUpdate, Find) { @@ -132,9 +132,12 @@ function HomeGroups($filter, $compile, $location, $routeParams, LogViewer, HomeG var generator = GenerateList, list = HomeGroupList, defaultUrl = GetBasePath('groups'), - scope = generator.inject(list, { mode: 'edit' }), + scope = $scope, + modal_scope = $scope.$new(), opt; + generator.inject(list, { mode: 'edit', scope: scope }); + function ellipsis(a) { if (a.length > 20) { return a.substr(0,20) + '...'; @@ -285,13 +288,21 @@ function HomeGroups($filter, $compile, $location, $routeParams, LogViewer, HomeG }); }; + if (modal_scope.removeHomeGroupsRefresh) { + modal_scope.removeHomeGroupsRefresh(); + } + modal_scope.removeHomeGroupsRefresh = scope.$on('HomeGroupsRefresh', function() { + scope.search(list.iterator); + }); + scope.editGroup = function (group_id, inventory_id) { GroupsEdit({ - scope: scope, + scope: modal_scope, group_id: group_id, inventory_id: inventory_id, groups_reload: false, - mode: 'edit' + mode: 'edit', + callback: 'HomeGroupsRefresh' }); }; @@ -440,13 +451,21 @@ function HomeGroups($filter, $compile, $location, $routeParams, LogViewer, HomeG Rest.get() .success( function(data) { data.results.forEach(function(host) { - host.summary_fields.recent_jobs.every(function(job) { - if (job.id === host.last_job) { - jobs.push(job); + var found = false; + jobs.every(function(existing_job) { + if (host.last_job === existing_job.id) { + found = true; return false; } return true; }); + if (!found) { + jobs.push({ + id: host.last_job, + status: host.summary_fields.last_job.status, + name: host.summary_fields.last_job.name + }); + } }); scope.$emit('HostSummaryReady', event, jobs); }) @@ -468,13 +487,13 @@ function HomeGroups($filter, $compile, $location, $routeParams, LogViewer, HomeG } -HomeGroups.$inject = ['$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', +HomeGroups.$inject = ['$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus', 'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find' ]; -function HomeHosts($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, +function HomeHosts($scope, $location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GetBasePath, SearchInit, PaginateInit, FormatDate, SetStatus, ToggleHostEnabled, HostsEdit, Stream, Find, ShowJobSummary) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior @@ -482,95 +501,98 @@ function HomeHosts($location, $routeParams, HomeHostList, GenerateList, ProcessE var generator = GenerateList, list = HomeHostList, - defaultUrl = GetBasePath('hosts'), - scope = generator.inject(list, { mode: 'edit' }); + defaultUrl = GetBasePath('hosts'); - if (scope.removePostRefresh) { - scope.removePostRefresh(); + generator.inject(list, { mode: 'edit', scope: $scope }); + + if ($scope.removePostRefresh) { + $scope.removePostRefresh(); } - scope.removePostRefresh = scope.$on('PostRefresh', function () { - for (var i = 0; i < scope.hosts.length; i++) { - scope.hosts[i].inventory_name = scope.hosts[i].summary_fields.inventory.name; - //SetHostStatus(scope['hosts'][i]); + $scope.removePostRefresh = $scope.$on('PostRefresh', function () { + for (var i = 0; i < $scope.hosts.length; i++) { + $scope.hosts[i].inventory_name = $scope.hosts[i].summary_fields.inventory.name; + //SetHostStatus($scope['hosts'][i]); SetStatus({ - scope: scope, - host: scope.hosts[i] + $scope: $scope, + host: $scope.hosts[i] }); } }); SearchInit({ - scope: scope, + scope: $scope, set: 'hosts', list: list, url: defaultUrl }); + PaginateInit({ - scope: scope, + scope: $scope, list: list, url: defaultUrl }); // Process search params if ($routeParams.name) { - scope[HomeHostList.iterator + 'InputDisable'] = false; - scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.name; - scope[HomeHostList.iterator + 'SearchField'] = 'name'; - scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.name.label; + $scope[HomeHostList.iterator + 'InputDisable'] = false; + $scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.name; + $scope[HomeHostList.iterator + 'SearchField'] = 'name'; + $scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.name.label; } if ($routeParams.id) { - scope[HomeHostList.iterator + 'InputDisable'] = false; - scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.id; - scope[HomeHostList.iterator + 'SearchField'] = 'id'; - scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.id.label; - scope[HomeHostList.iterator + 'SearchSelectValue'] = null; + $scope[HomeHostList.iterator + 'InputDisable'] = false; + $scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.id; + $scope[HomeHostList.iterator + 'SearchField'] = 'id'; + $scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.id.label; + $scope[HomeHostList.iterator + 'SearchSelectValue'] = null; } if ($routeParams.has_active_failures) { - scope[HomeHostList.iterator + 'InputDisable'] = true; - scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.has_active_failures; - scope[HomeHostList.iterator + 'SearchField'] = 'has_active_failures'; - scope[HomeHostList.iterator + 'SearchFieldLabel'] = HomeHostList.fields.has_active_failures.label; - scope[HomeHostList.iterator + 'SearchSelectValue'] = ($routeParams.has_active_failures === 'true') ? { value: 1 } : { value: 0 }; + $scope[HomeHostList.iterator + 'InputDisable'] = true; + $scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.has_active_failures; + $scope[HomeHostList.iterator + 'SearchField'] = 'has_active_failures'; + $scope[HomeHostList.iterator + 'SearchFieldLabel'] = HomeHostList.fields.has_active_failures.label; + $scope[HomeHostList.iterator + 'SearchSelectValue'] = ($routeParams.has_active_failures === 'true') ? { value: 1 } : { value: 0 }; } - scope.search(list.iterator); + $scope.search(list.iterator); LoadBreadCrumbs(); - scope.showActivity = function () { + $scope.showActivity = function () { Stream({ - scope: scope + scope: $scope }); }; - scope.toggle_host_enabled = function (id, sources) { + $scope.toggleHostEnabled = function (id, sources) { ToggleHostEnabled({ host_id: id, external_source: sources, - scope: scope + scope: $scope }); }; - scope.editHost = function (host_id) { + $scope.editHost = function (host_id) { var host = Find({ - list: scope.hosts, + list: $scope.hosts, key: 'id', val: host_id }); if (host) { HostsEdit({ - scope: scope, + scope: $scope, host_id: host_id, inventory_id: host.inventory, group_id: null, - hostsReload: false + hostsReload: false, + mode: 'edit' }); } }; - scope.showJobSummary = function (job_id) { + $scope.showJobSummary = function (job_id) { ShowJobSummary({ job_id: job_id }); @@ -578,7 +600,7 @@ function HomeHosts($location, $routeParams, HomeHostList, GenerateList, ProcessE } -HomeHosts.$inject = ['$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', +HomeHosts.$inject = ['$scope', '$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'SetStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream', 'Find', 'ShowJobSummary' ]; \ No newline at end of file diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 84c966304b..cb9f16478c 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -125,6 +125,7 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com // ignore } $scope.inventories.forEach(function(inventory, idx) { + $scope.inventories[idx].launch_class = ""; if (inventory.has_inventory_sources) { if (inventory.inventory_sources_with_failures > 0) { $scope.inventories[idx].syncStatus = 'error'; @@ -138,15 +139,20 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com else { $scope.inventories[idx].syncStatus = 'na'; $scope.inventories[idx].syncTip = 'Not configured for inventory sync.'; + $scope.inventories[idx].launch_class = "btn-disabled"; } if (inventory.has_active_failures) { $scope.inventories[idx].hostsStatus = 'error'; $scope.inventories[idx].hostsTip = inventory.hosts_with_active_failures + ' hosts with failures. Click for details.'; } - else { + else if (inventory.total_hosts) { $scope.inventories[idx].hostsStatus = 'successful'; $scope.inventories[idx].hostsTip = 'No hosts with failures. Click for details.'; } + else { + $scope.inventories[idx].hostsStatus = 'none'; + $scope.inventories[idx].hostsTip = 'Inventory contains 0 hosts.'; + } }); }); @@ -252,20 +258,25 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com }; $scope.showHostSummary = function(event, id) { - var url; + var url, inventory; if (!Empty(id)) { - Wait('start'); - url = GetBasePath('jobs') + "?type=job&inventory=" + id + "&order_by=-finished&page_size=5"; - Rest.setUrl(url); - Rest.get() - .success( function(data) { - $scope.$emit('HostSummaryReady', event, data); - }) - .error( function(data, status) { - ProcessErrors( $scope, data, status, null, { hdr: 'Error!', - msg: 'Call to ' + url + ' failed. GET returned: ' + status + inventory = Find({ list: $scope.inventories, key: 'id', val: id }); + if (inventory.total_hosts > 0) { + Wait('start'); + url = GetBasePath('jobs') + "?type=job&inventory=" + id + "&failed="; + url += (inventory.has_active_failures) ? 'true' : "false"; + url += "&order_by=-finished&page_size=5"; + Rest.setUrl(url); + Rest.get() + .success( function(data) { + $scope.$emit('HostSummaryReady', event, data); + }) + .error( function(data, status) { + ProcessErrors( $scope, data, status, null, { hdr: 'Error!', + msg: 'Call to ' + url + ' failed. GET returned: ' + status + }); }); - }); + } } }; diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 069e0386e3..7898372d5a 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -617,6 +617,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P mode = params.mode, // 'add' or 'edit' inventory_id = params.inventory_id, groups_reload = params.groups_reload, + callback = params.callback, generator = GenerateForm, defaultUrl, master = {}, @@ -1044,29 +1045,26 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P source: (sources_scope.source && sources_scope.source.value) ? sources_scope.source.value : '' } }); - } else if (parent_scope.home_groups) { - // When home.groups controller is calling, update the groups array - var g = Find({ - list: parent_scope.home_groups, - key: 'id', - val: group_id - }); - if (g) { - g.name = properties_scope.name; - g.description = properties_scope.description; + } else if (callback) { + try { + $('#group-modal-dialog').dialog('close'); + } + catch(err) { + //ignore + } + parent_scope.$emit(callback); + } else { + if (mode === 'add') { + BuildTree({ + scope: parent_scope, + inventory_id: inventory_id, + refresh: true, + new_group_id: group_id + }); + } + else { + parent_scope.$emit('GroupTreeRefreshed'); } - } - - if (mode === 'add') { - BuildTree({ - scope: parent_scope, - inventory_id: inventory_id, - refresh: true, - new_group_id: group_id - }); - } - else { - parent_scope.$emit('GroupTreeRefreshed'); } } }); @@ -1142,10 +1140,15 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P catch(e) { //ignore } - if (modal_scope.searchCleanup) { - modal_scope.searchCleanup(); + if (callback) { + parent_scope.$emit(callback); + } + else { + if (modal_scope.searchCleanup) { + modal_scope.searchCleanup(); + } + WatchInventoryWindowResize(); } - WatchInventoryWindowResize(); }; // Save diff --git a/awx/ui/static/js/lists/HomeGroups.js b/awx/ui/static/js/lists/HomeGroups.js index 2dfe3c6e9d..d7f0060170 100644 --- a/awx/ui/static/js/lists/HomeGroups.js +++ b/awx/ui/static/js/lists/HomeGroups.js @@ -141,7 +141,7 @@ angular.module('HomeGroupListDefinition', []) edit: { label: 'Edit', mode: 'all', - ngClick: "editGroup(group.id)", + ngClick: "editGroup(group.id, group.inventory)", awToolTip: 'Edit group', dataPlacement: "top" } diff --git a/awx/ui/static/js/lists/HomeHosts.js b/awx/ui/static/js/lists/HomeHosts.js index a391a6ac8e..1c4fdf2a87 100644 --- a/awx/ui/static/js/lists/HomeHosts.js +++ b/awx/ui/static/js/lists/HomeHosts.js @@ -22,6 +22,17 @@ angular.module('HomeHostListDefinition', []) well: true, fields: { + status: { + label: "Status", + iconOnly: true, + icon: "{{ 'icon-job-' + host.active_failures }}", + awToolTip: "{{ host.badgeToolTip }}", + awTipPlacement: "top", + ngClick:"bob", + columnClass: "col-md-1 col-sm-2 col-xs-3", + searchable: false, + nosort: true + }, name: { key: true, label: 'Name', @@ -71,7 +82,7 @@ angular.module('HomeHostListDefinition', []) dataTipWatch: "host.enabledToolTip", ngClick: "toggleHostEnabled(host.id, host.has_inventory_sources)" }, - active_failures: { + /*active_failures: { //label: 'Job Status', //ngHref: "\{\{'/#/hosts/' + host.id + '/job_host_summaries/?inventory=' + inventory_id \}\}", awPopOver: "{{ host.job_status_html }}", @@ -80,7 +91,7 @@ angular.module('HomeHostListDefinition', []) awTipPlacement: 'top', dataPlacement: 'left', iconClass: "{{ 'fa icon-failures-' + host.has_active_failures }}" - }, + }*/ edit: { label: 'Edit', ngClick: "editHost(host.id)", diff --git a/awx/ui/static/js/lists/Inventories.js b/awx/ui/static/js/lists/Inventories.js index 1f6b18a411..88c8cc4948 100644 --- a/awx/ui/static/js/lists/Inventories.js +++ b/awx/ui/static/js/lists/Inventories.js @@ -32,12 +32,14 @@ angular.module('InventoriesListDefinition', []) icon: "{{ 'icon-cloud-' + inventory.syncStatus }}", awToolTip: "{{ inventory.syncTip }}", awTipPlacement: "top", - ngClick: "showGroupSummary($event, inventory.id)" + ngClick: "showGroupSummary($event, inventory.id)", + ngClass: "inventory.launch_class" },{ icon: "{{ 'icon-job-' + inventory.hostsStatus }}", awToolTip: "{{ inventory.hostsTip }}", awTipPlacement: "top", - ngClick: "showHostSummary($event, inventory.id)" + ngClick: "showHostSummary($event, inventory.id)", + ngClass: "" }] }, name: {