mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 10:40:01 -03:30
Fixed real-time updates for inventory
Live updates now working on the inventory detail page and on home/groups page.
This commit is contained in:
@@ -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,
|
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
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -134,7 +134,8 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
|
|||||||
defaultUrl = GetBasePath('groups'),
|
defaultUrl = GetBasePath('groups'),
|
||||||
scope = $scope,
|
scope = $scope,
|
||||||
modal_scope = $scope.$new(),
|
modal_scope = $scope.$new(),
|
||||||
opt, PreviousSearchParams;
|
opt, PreviousSearchParams,
|
||||||
|
io;
|
||||||
|
|
||||||
generator.inject(list, { mode: 'edit', scope: scope });
|
generator.inject(list, { mode: 'edit', scope: scope });
|
||||||
|
|
||||||
@@ -290,8 +291,40 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
|
|||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
|
scope.$emit('WatchUpdateStatus'); // Start watching for live updates
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
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 () {
|
scope.showActivity = function () {
|
||||||
Stream({
|
Stream({
|
||||||
scope: scope
|
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',
|
'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'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -490,7 +490,8 @@ function InventoriesEdit ($log, $scope, $location, $routeParams, $compile, Gener
|
|||||||
|
|
||||||
var PreviousSearchParams,
|
var PreviousSearchParams,
|
||||||
url,
|
url,
|
||||||
hostScope = $scope.$new();
|
hostScope = $scope.$new(),
|
||||||
|
io;
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -677,7 +678,7 @@ function InventoriesEdit ($log, $scope, $location, $routeParams, $compile, Gener
|
|||||||
$scope.removeWatchUpdateStatus();
|
$scope.removeWatchUpdateStatus();
|
||||||
}
|
}
|
||||||
$scope.removeWatchUpdateStatus = $scope.$on('WatchUpdateStatus', function() {
|
$scope.removeWatchUpdateStatus = $scope.$on('WatchUpdateStatus', function() {
|
||||||
var io = Socket({ scope: $scope, endpoint: "jobs" });
|
io = Socket({ scope: $scope, endpoint: "jobs" });
|
||||||
io.init();
|
io.init();
|
||||||
$log.debug('Watching for job updates: ');
|
$log.debug('Watching for job updates: ');
|
||||||
io.on("status_changed", function(data) {
|
io.on("status_changed", function(data) {
|
||||||
|
|||||||
@@ -153,11 +153,6 @@ angular.module('HomeGroupListDefinition', [])
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh: {
|
|
||||||
mode: 'all',
|
|
||||||
awToolTip: "Refresh the page",
|
|
||||||
ngClick: "refresh()"
|
|
||||||
},
|
|
||||||
stream: {
|
stream: {
|
||||||
ngClick: "showActivity()",
|
ngClick: "showActivity()",
|
||||||
awToolTip: "View Activity Stream",
|
awToolTip: "View Activity Stream",
|
||||||
|
|||||||
Reference in New Issue
Block a user