mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02:30
Merge pull request #5104 from jaredevantabor/inventory-manage-sockets
Websocket data returns new data, without refreshing the entire page
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export function JobsListController($state, $rootScope, $log, $scope, $compile, $stateParams,
|
export function JobsListController($state, $rootScope, $log, $scope, $compile, $stateParams,
|
||||||
ClearScope, Find, DeleteJob, RelaunchJob, AllJobsList, ScheduledJobsList, GetBasePath, Dataset) {
|
ClearScope, Find, DeleteJob, RelaunchJob, AllJobsList, ScheduledJobsList, GetBasePath, Dataset, qs) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -93,10 +93,6 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $
|
|||||||
RelaunchJob({ scope: $scope, id: typeId, type: job.type, name: job.name });
|
RelaunchJob({ scope: $scope, id: typeId, type: job.type, name: job.name });
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.refreshJobs = function() {
|
|
||||||
$state.go('.', null, { reload: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.viewJobDetails = function(job) {
|
$scope.viewJobDetails = function(job) {
|
||||||
|
|
||||||
var goToJobDetails = function(state) {
|
var goToJobDetails = function(state) {
|
||||||
@@ -126,7 +122,12 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on('ws-jobs', function(){
|
$scope.$on('ws-jobs', function(){
|
||||||
$scope.refreshJobs();
|
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
||||||
|
qs.search(path, $state.params[`${list.iterator}_search`])
|
||||||
|
.then(function(searchResponse) {
|
||||||
|
$scope[`${list.iterator}_dataset`] = searchResponse.data;
|
||||||
|
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on('ws-schedules', function(){
|
$scope.$on('ws-schedules', function(){
|
||||||
@@ -135,5 +136,5 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $
|
|||||||
}
|
}
|
||||||
|
|
||||||
JobsListController.$inject = ['$state', '$rootScope', '$log', '$scope', '$compile', '$stateParams',
|
JobsListController.$inject = ['$state', '$rootScope', '$log', '$scope', '$compile', '$stateParams',
|
||||||
'ClearScope', 'Find', 'DeleteJob', 'RelaunchJob', 'AllJobsList', 'ScheduledJobsList', 'GetBasePath', 'Dataset'
|
'ClearScope', 'Find', 'DeleteJob', 'RelaunchJob', 'AllJobsList', 'ScheduledJobsList', 'GetBasePath', 'Dataset','QuerySet'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
export default
|
export default
|
||||||
['$scope', '$rootScope', '$state', '$stateParams', 'InventoryGroups', 'generateList', 'InventoryUpdate',
|
['$scope', '$rootScope', '$state', '$stateParams', 'InventoryGroups', 'generateList', 'InventoryUpdate',
|
||||||
'GroupManageService', 'GroupsCancelUpdate', 'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
'GroupManageService', 'GroupsCancelUpdate', 'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
||||||
'InventoryManageService', 'groupsUrl', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'groupsDataset', 'Find',
|
'InventoryManageService', 'groupsUrl', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'groupsDataset', 'Find', 'QuerySet',
|
||||||
function($scope, $rootScope, $state, $stateParams, InventoryGroups, generateList, InventoryUpdate,
|
function($scope, $rootScope, $state, $stateParams, InventoryGroups, generateList, InventoryUpdate,
|
||||||
GroupManageService, GroupsCancelUpdate, ViewUpdateStatus, rbacUiControlService, GetBasePath,
|
GroupManageService, GroupsCancelUpdate, ViewUpdateStatus, rbacUiControlService, GetBasePath,
|
||||||
InventoryManageService, groupsUrl, GetSyncStatusMsg, GetHostsStatusMsg, groupsDataset, Find){
|
InventoryManageService, groupsUrl, GetSyncStatusMsg, GetHostsStatusMsg, groupsDataset, Find, qs){
|
||||||
|
|
||||||
let list = InventoryGroups;
|
let list = InventoryGroups;
|
||||||
|
|
||||||
@@ -160,7 +160,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(data.status === 'failed' || data.status === 'successful'){
|
if(data.status === 'failed' || data.status === 'successful'){
|
||||||
$state.reload();
|
let path;
|
||||||
|
if($stateParams && $stateParams.group && $stateParams.group.length > 0) {
|
||||||
|
path = GetBasePath('groups') + _.last($stateParams.group) + '/children';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//reaches here if the user is on the root level group
|
||||||
|
path = GetBasePath('inventory') + $stateParams.inventory_id + '/root_groups';
|
||||||
|
}
|
||||||
|
qs.search(path, $state.params[`${list.iterator}_search`])
|
||||||
|
.then(function(searchResponse) {
|
||||||
|
$scope[`${list.iterator}_dataset`] = searchResponse.data;
|
||||||
|
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||||
|
_.forEach($scope[list.name], buildStatusIndicators);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
var status = GetSyncStatusMsg({
|
var status = GetSyncStatusMsg({
|
||||||
status: data.status,
|
status: data.status,
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
export default
|
export default
|
||||||
['$scope', '$rootScope', '$state', '$stateParams', 'InventoryHosts', 'generateList', 'InventoryManageService', 'HostManageService',
|
['$scope', '$rootScope', '$state', '$stateParams', 'InventoryHosts', 'generateList', 'InventoryManageService', 'HostManageService',
|
||||||
'hostsUrl', 'SetStatus', 'Prompt', 'Wait', 'inventoryData', '$filter', 'hostsDataset', 'GetBasePath', 'rbacUiControlService',
|
'hostsUrl', 'SetStatus', 'Prompt', 'Wait', 'inventoryData', '$filter', 'hostsDataset', 'GetBasePath', 'rbacUiControlService', 'QuerySet',
|
||||||
function($scope, $rootScope, $state, $stateParams, InventoryHosts, generateList, InventoryManageService, HostManageService,
|
function($scope, $rootScope, $state, $stateParams, InventoryHosts, generateList, InventoryManageService, HostManageService,
|
||||||
hostsUrl, SetStatus, Prompt, Wait, inventoryData, $filter, hostsDataset, GetBasePath, rbacUiControlService){
|
hostsUrl, SetStatus, Prompt, Wait, inventoryData, $filter, hostsDataset, GetBasePath, rbacUiControlService, qs){
|
||||||
var list = InventoryHosts;
|
var list = InventoryHosts;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@@ -32,6 +32,17 @@
|
|||||||
host: host}));
|
host: host}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.$on(`ws-jobs`, function(e, data){
|
||||||
|
if(data.status === 'failed' || data.status === 'successful'){
|
||||||
|
let path = hostsUrl;
|
||||||
|
qs.search(path, $state.params[`${list.iterator}_search`])
|
||||||
|
.then(function(searchResponse) {
|
||||||
|
$scope[`${list.iterator}_dataset`] = searchResponse.data;
|
||||||
|
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// The ncy breadcrumb directive will look at this attribute when attempting to bind to the correct scope.
|
// The ncy breadcrumb directive will look at this attribute when attempting to bind to the correct scope.
|
||||||
// In this case, we don't want to incidentally bind to this scope when editing a host or a group. See:
|
// In this case, we don't want to incidentally bind to this scope when editing a host or a group. See:
|
||||||
// https://github.com/ncuillery/angular-breadcrumb/issues/42 for a little more information on the
|
// https://github.com/ncuillery/angular-breadcrumb/issues/42 for a little more information on the
|
||||||
|
|||||||
@@ -7,18 +7,22 @@
|
|||||||
export default ['$scope', '$rootScope', '$location', '$log',
|
export default ['$scope', '$rootScope', '$location', '$log',
|
||||||
'$stateParams', 'Rest', 'Alert', 'Prompt', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
'$stateParams', 'Rest', 'Alert', 'Prompt', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
||||||
'GetBasePath', 'JobTemplateForm', 'InitiatePlaybookRun', 'Wait',
|
'GetBasePath', 'JobTemplateForm', 'InitiatePlaybookRun', 'Wait',
|
||||||
'$compile', '$state', 'OrgJobTemplateList', 'OrgJobTemplateDataset',
|
'$compile', '$state', 'OrgJobTemplateList', 'OrgJobTemplateDataset', 'QuerySet',
|
||||||
function($scope, $rootScope, $location, $log,
|
function($scope, $rootScope, $location, $log,
|
||||||
$stateParams, Rest, Alert, Prompt, ReturnToCaller, ClearScope, ProcessErrors,
|
$stateParams, Rest, Alert, Prompt, ReturnToCaller, ClearScope, ProcessErrors,
|
||||||
GetBasePath, JobTemplateForm, InitiatePlaybookRun, Wait,
|
GetBasePath, JobTemplateForm, InitiatePlaybookRun, Wait,
|
||||||
$compile, $state, OrgJobTemplateList, Dataset) {
|
$compile, $state, OrgJobTemplateList, Dataset, qs) {
|
||||||
|
|
||||||
var list = OrgJobTemplateList,
|
var list = OrgJobTemplateList,
|
||||||
orgBase = GetBasePath('organizations');
|
orgBase = GetBasePath('organizations');
|
||||||
|
|
||||||
$scope.$on(`ws-jobs`, function () {
|
$scope.$on(`ws-jobs`, function () {
|
||||||
// @issue old search
|
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
||||||
//$scope.search(list.iterator);
|
qs.search(path, $state.params[`${list.iterator}_search`])
|
||||||
|
.then(function(searchResponse) {
|
||||||
|
$scope[`${list.iterator}_dataset`] = searchResponse.data;
|
||||||
|
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ export function PortalModeJobsController($scope, $rootScope, $state, $stateParam
|
|||||||
var list = PortalJobsList;
|
var list = PortalJobsList;
|
||||||
|
|
||||||
$scope.$on('ws-jobs', function() {
|
$scope.$on('ws-jobs', function() {
|
||||||
$state.go('.', null, { reload: true });
|
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
||||||
|
qs.search(path, $state.params[`${list.iterator}_search`])
|
||||||
|
.then(function(searchResponse) {
|
||||||
|
$scope[`${list.iterator}_dataset`] = searchResponse.data;
|
||||||
|
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -72,10 +72,6 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest',
|
|||||||
|
|
||||||
|
|
||||||
$scope.$on(`ws-jobs`, function () {
|
$scope.$on(`ws-jobs`, function () {
|
||||||
// @issue - this is no longer quite as ham-fisted but I'd like for someone else to take a peek
|
|
||||||
// calling $state.reload(); here was problematic when launching a job because job launch also
|
|
||||||
// attempts to transition the state and they were squashing each other.
|
|
||||||
|
|
||||||
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
||||||
qs.search(path, $state.params[`${list.iterator}_search`])
|
qs.search(path, $state.params[`${list.iterator}_search`])
|
||||||
.then(function(searchResponse) {
|
.then(function(searchResponse) {
|
||||||
|
|||||||
Reference in New Issue
Block a user