diff options
author | Chris Houseknecht <chouse@ansible.com> | 2014-06-12 18:43:43 +0200 |
---|---|---|
committer | Chris Houseknecht <chouse@ansible.com> | 2014-06-12 18:43:43 +0200 |
commit | 0810194ceedb368d30bb42bce07e53e15b1bbb3e (patch) | |
tree | c4984385d5d9e21be3d3a487fc6bb7da6c84d154 | |
parent | Fixed inventory real-time updates (diff) | |
download | awx-0810194ceedb368d30bb42bce07e53e15b1bbb3e.tar.xz awx-0810194ceedb368d30bb42bce07e53e15b1bbb3e.zip |
Fixed real-time updates for inventory
Live updates now working on the inventory detail page and on home/groups page.
-rw-r--r-- | awx/ui/static/js/controllers/Home.js | 43 | ||||
-rw-r--r-- | awx/ui/static/js/controllers/Inventories.js | 5 | ||||
-rw-r--r-- | awx/ui/static/js/lists/HomeGroups.js | 5 |
3 files changed, 41 insertions, 12 deletions
diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index edb51ca0b4..385ac067a6 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -122,9 +122,9 @@ Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', ]; -function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, +function HomeGroups($log, $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, GroupsCancelUpdate, Store) { + Alert, Rest, Empty, InventoryUpdate, Find, GroupsCancelUpdate, Store, Socket) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -134,7 +134,8 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe defaultUrl = GetBasePath('groups'), scope = $scope, modal_scope = $scope.$new(), - opt, PreviousSearchParams; + opt, PreviousSearchParams, + io; generator.inject(list, { mode: 'edit', scope: scope }); @@ -290,8 +291,40 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe scope.search(list.iterator); + scope.$emit('WatchUpdateStatus'); // Start watching for live updates + LoadBreadCrumbs(); + io = Socket({ scope: $scope, endpoint: "jobs" }); + io.init(); + $log.debug('Watching for job updates: '); + io.on("status_changed", function(data) { + var stat, group; + if (data.group_id) { + group = Find({ list: scope[list.name], key: 'id', val: data.group_id }); + if (group && (data.status === "failed" || data.status === "successful")) { + // job completed, fefresh all groups + $log.debug('Update completed. Refreshing the list'); + scope.refresh(); + } + else if (group) { + // incremental update, just update + $log.debug('Status of group: ' + data.group_id + ' changed to: ' + data.status); + stat = GetSyncStatusMsg({ + status: data.status, + has_inventory_sources: group.has_inventory_sources, + source: group.source + }); + $log.debug('changing tooltip to: ' + stat.tooltip); + group.status = data.status; + group.status_class = stat['class']; + group.status_tooltip = stat.tooltip; + group.launch_tooltip = stat.launch_tip; + group.launch_class = stat.launch_class; + } + } + }); + scope.showActivity = function () { Stream({ scope: scope @@ -508,9 +541,9 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe } -HomeGroups.$inject = ['$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', +HomeGroups.$inject = ['$log', '$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', 'GroupsCancelUpdate', 'Store' + 'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find', 'GroupsCancelUpdate', 'Store', 'Socket' ]; diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index b9557f085b..9f4a27fbd0 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -490,7 +490,8 @@ function InventoriesEdit ($log, $scope, $location, $routeParams, $compile, Gener var PreviousSearchParams, url, - hostScope = $scope.$new(); + hostScope = $scope.$new(), + io; ClearScope(); @@ -677,7 +678,7 @@ function InventoriesEdit ($log, $scope, $location, $routeParams, $compile, Gener $scope.removeWatchUpdateStatus(); } $scope.removeWatchUpdateStatus = $scope.$on('WatchUpdateStatus', function() { - var io = Socket({ scope: $scope, endpoint: "jobs" }); + io = Socket({ scope: $scope, endpoint: "jobs" }); io.init(); $log.debug('Watching for job updates: '); io.on("status_changed", function(data) { diff --git a/awx/ui/static/js/lists/HomeGroups.js b/awx/ui/static/js/lists/HomeGroups.js index bcaf22fcac..de6e4b2c8e 100644 --- a/awx/ui/static/js/lists/HomeGroups.js +++ b/awx/ui/static/js/lists/HomeGroups.js @@ -153,11 +153,6 @@ angular.module('HomeGroupListDefinition', []) }, actions: { - refresh: { - mode: 'all', - awToolTip: "Refresh the page", - ngClick: "refresh()" - }, stream: { ngClick: "showActivity()", awToolTip: "View Activity Stream", |