mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 09:57:33 -02:30
updating sockets to only init once.
This commit is contained in:
@@ -220,6 +220,18 @@ var tower = angular.module('Tower', [
|
|||||||
resolve: {
|
resolve: {
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
return FeaturesService.get();
|
return FeaturesService.get();
|
||||||
|
}],
|
||||||
|
jobEventsSocket: ['Socket', '$rootScope', function(Socket, $rootScope) {
|
||||||
|
if (!$rootScope.event_socket) {
|
||||||
|
$rootScope.event_socket = Socket({
|
||||||
|
scope: $rootScope,
|
||||||
|
endpoint: "job_events"
|
||||||
|
});
|
||||||
|
$rootScope.event_socket.init();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
@@ -231,6 +243,18 @@ var tower = angular.module('Tower', [
|
|||||||
resolve: {
|
resolve: {
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
return FeaturesService.get();
|
return FeaturesService.get();
|
||||||
|
}],
|
||||||
|
jobEventsSocket: ['Socket', '$rootScope', function(Socket, $rootScope) {
|
||||||
|
if (!$rootScope.event_socket) {
|
||||||
|
$rootScope.event_socket = Socket({
|
||||||
|
scope: $rootScope,
|
||||||
|
endpoint: "job_events"
|
||||||
|
});
|
||||||
|
$rootScope.event_socket.init();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
@@ -242,6 +266,18 @@ var tower = angular.module('Tower', [
|
|||||||
resolve: {
|
resolve: {
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
return FeaturesService.get();
|
return FeaturesService.get();
|
||||||
|
}],
|
||||||
|
jobEventsSocket: ['Socket', '$rootScope', function(Socket, $rootScope) {
|
||||||
|
if (!$rootScope.event_socket) {
|
||||||
|
$rootScope.event_socket = Socket({
|
||||||
|
scope: $rootScope,
|
||||||
|
endpoint: "job_events"
|
||||||
|
});
|
||||||
|
$rootScope.event_socket.init();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
@@ -942,16 +978,49 @@ var tower = angular.module('Tower', [
|
|||||||
// Listen for job changes and issue callbacks to initiate
|
// Listen for job changes and issue callbacks to initiate
|
||||||
// DOM updates
|
// DOM updates
|
||||||
function openSocket() {
|
function openSocket() {
|
||||||
|
var schedule_socket;
|
||||||
|
|
||||||
sock = Socket({ scope: $rootScope, endpoint: "jobs" });
|
sock = Socket({ scope: $rootScope, endpoint: "jobs" });
|
||||||
sock.init();
|
sock.init();
|
||||||
sock.on("status_changed", function(data) {
|
sock.on("status_changed", function(data) {
|
||||||
$log.debug('Job ' + data.unified_job_id + ' status changed to ' + data.status);
|
$log.debug('Job ' + data.unified_job_id +
|
||||||
$rootScope.$emit('JobStatusChange', data);
|
' status changed to ' + data.status +
|
||||||
|
' send to ' + $location.$$url);
|
||||||
|
|
||||||
|
// this acts as a router...it emits the proper
|
||||||
|
// value based on what URL the user is currently
|
||||||
|
// accessing.
|
||||||
|
if ($location.$$url === '/jobs') {
|
||||||
|
$rootScope.$emit('JobStatusChange-jobs', data);
|
||||||
|
} else if (/\/jobs\/(\d)+/.test($location.$$url)) {
|
||||||
|
$rootScope.$emit('JobStatusChange-jobDetails', data);
|
||||||
|
} else if ($location.$$url === '/home') {
|
||||||
|
$rootScope.$emit('JobStatusChange-home', data);
|
||||||
|
} else if ($location.$$url === '/portal') {
|
||||||
|
$rootScope.$emit('JobStatusChange-portal', data);
|
||||||
|
} else if ($location.$$url === '/projects') {
|
||||||
|
$rootScope.$emit('JobStatusChange-projects', data);
|
||||||
|
} else if (/\/jobs\/(\d)+\/stdout/.test($location.$$url) ||
|
||||||
|
/\/ad_hoc_commands\/(\d)+/.test($location.$$url)) {
|
||||||
|
$rootScope.$emit('JobStatusChange-jobStdout', data);
|
||||||
|
} else if (/\/inventory\/(\d)+\/manage/.test($location.$$url)) {
|
||||||
|
$rootScope.$emit('JobStatusChange-inventory', data);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
sock.on("summary_complete", function(data) {
|
sock.on("summary_complete", function(data) {
|
||||||
$log.debug('Job summary_complete ' + data.unified_job_id);
|
$log.debug('Job summary_complete ' + data.unified_job_id);
|
||||||
$rootScope.$emit('JobSummaryComplete', data);
|
$rootScope.$emit('JobSummaryComplete', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
schedule_socket = Socket({
|
||||||
|
scope: $rootScope,
|
||||||
|
endpoint: "schedules"
|
||||||
|
});
|
||||||
|
schedule_socket.init();
|
||||||
|
schedule_socket.on("schedule_changed", function(data) {
|
||||||
|
$log.debug('Schedule ' + data.unified_job_id + ' status changed to ' + data.status);
|
||||||
|
$rootScope.$emit('ScheduleStatusChange', data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
openSocket();
|
openSocket();
|
||||||
|
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location',
|
|||||||
* @description This controls the 'home/groups' page that is loaded from the dashboard
|
* @description This controls the 'home/groups' page that is loaded from the dashboard
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function HomeGroups($log, $scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
export function HomeGroups($rootScope, $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, Socket) {
|
Alert, Rest, Empty, InventoryUpdate, Find, GroupsCancelUpdate, Store) {
|
||||||
|
|
||||||
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.
|
||||||
@@ -127,8 +127,7 @@ export function HomeGroups($log, $scope, $filter, $compile, $location, $routePar
|
|||||||
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, breadCrumbs: true });
|
generator.inject(list, { mode: 'edit', scope: scope, breadCrumbs: true });
|
||||||
|
|
||||||
@@ -296,10 +295,10 @@ export function HomeGroups($log, $scope, $filter, $compile, $location, $routePar
|
|||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
io = Socket({ scope: $scope, endpoint: "jobs" });
|
if ($rootScope.removeJobStatusChange) {
|
||||||
io.init();
|
$rootScope.removeJobStatusChange();
|
||||||
$log.debug('Watching for job updates: ');
|
}
|
||||||
io.on("status_changed", function(data) {
|
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange-home', function(e, data) {
|
||||||
var stat, group;
|
var stat, group;
|
||||||
if (data.group_id) {
|
if (data.group_id) {
|
||||||
group = Find({ list: scope[list.name], key: 'id', val: data.group_id });
|
group = Find({ list: scope[list.name], key: 'id', val: data.group_id });
|
||||||
@@ -539,7 +538,7 @@ export function HomeGroups($log, $scope, $filter, $compile, $location, $routePar
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeGroups.$inject = ['$log', '$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'generateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
HomeGroups.$inject = ['$rootScope', '$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', 'Socket'
|
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find', 'GroupsCancelUpdate', 'Store', 'Socket'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -849,12 +849,11 @@ export function InventoriesManage ($log, $scope, $rootScope, $location,
|
|||||||
ViewUpdateStatus, GroupsDelete, Store, HostsEdit, HostsDelete,
|
ViewUpdateStatus, GroupsDelete, Store, HostsEdit, HostsDelete,
|
||||||
EditInventoryProperties, ToggleHostEnabled, Stream, ShowJobSummary,
|
EditInventoryProperties, ToggleHostEnabled, Stream, ShowJobSummary,
|
||||||
InventoryGroupsHelp, HelpDialog, ViewJob,
|
InventoryGroupsHelp, HelpDialog, ViewJob,
|
||||||
GroupsCopy, HostsCopy, Socket) {
|
GroupsCopy, HostsCopy) {
|
||||||
|
|
||||||
var PreviousSearchParams,
|
var PreviousSearchParams,
|
||||||
url,
|
url,
|
||||||
hostScope = $scope.$new(),
|
hostScope = $scope.$new();
|
||||||
io;
|
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -1095,38 +1094,33 @@ export function InventoriesManage ($log, $scope, $rootScope, $location,
|
|||||||
if ($scope.removeWatchUpdateStatus) {
|
if ($scope.removeWatchUpdateStatus) {
|
||||||
$scope.removeWatchUpdateStatus();
|
$scope.removeWatchUpdateStatus();
|
||||||
}
|
}
|
||||||
$scope.removeWatchUpdateStatus = $scope.$on('WatchUpdateStatus', function() {
|
$scope.removeWatchUpdateStatus = $scope.$on('JobStatusChange-inventory', function(data) {
|
||||||
io = Socket({ scope: $scope, endpoint: "jobs" });
|
var stat, group;
|
||||||
io.init();
|
if (data.group_id) {
|
||||||
$log.debug('Watching for job updates: ');
|
group = Find({ list: $scope.groups, key: 'id', val: data.group_id });
|
||||||
io.on("status_changed", function(data) {
|
if (data.status === "failed" || data.status === "successful") {
|
||||||
var stat, group;
|
if (data.group_id === $scope.selected_group_id || group) {
|
||||||
if (data.group_id) {
|
// job completed, fefresh all groups
|
||||||
group = Find({ list: $scope.groups, key: 'id', val: data.group_id });
|
$log.debug('Update completed. Refreshing the tree.');
|
||||||
if (data.status === "failed" || data.status === "successful") {
|
$scope.refreshGroups();
|
||||||
if (data.group_id === $scope.selected_group_id || group) {
|
|
||||||
// job completed, fefresh all groups
|
|
||||||
$log.debug('Update completed. Refreshing the tree.');
|
|
||||||
$scope.refreshGroups();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load group on selection
|
// Load group on selection
|
||||||
@@ -1453,5 +1447,5 @@ InventoriesManage.$inject = ['$log', '$scope', '$rootScope', '$location',
|
|||||||
'GroupsDelete', 'Store', 'HostsEdit', 'HostsDelete',
|
'GroupsDelete', 'Store', 'HostsEdit', 'HostsDelete',
|
||||||
'EditInventoryProperties', 'ToggleHostEnabled', 'Stream', 'ShowJobSummary',
|
'EditInventoryProperties', 'ToggleHostEnabled', 'Stream', 'ShowJobSummary',
|
||||||
'InventoryGroupsHelp', 'HelpDialog', 'ViewJob', 'GroupsCopy',
|
'InventoryGroupsHelp', 'HelpDialog', 'ViewJob', 'GroupsCopy',
|
||||||
'HostsCopy', 'Socket'
|
'HostsCopy'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export function JobDetailController ($location, $rootScope, $scope, $compile, $r
|
|||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
var job_id = $routeParams.id,
|
var job_id = $routeParams.id,
|
||||||
event_socket,
|
|
||||||
scope = $scope,
|
scope = $scope,
|
||||||
api_complete = false,
|
api_complete = false,
|
||||||
refresh_count = 0,
|
refresh_count = 0,
|
||||||
@@ -99,12 +98,7 @@ export function JobDetailController ($location, $rootScope, $scope, $compile, $r
|
|||||||
"<p><i class=\"fa fa-circle unreachable-hosts-color\"></i> Unreachable</p>\n" +
|
"<p><i class=\"fa fa-circle unreachable-hosts-color\"></i> Unreachable</p>\n" +
|
||||||
"<p><i class=\"fa fa-circle failed-hosts-color\"></i> Failed</p>\n";
|
"<p><i class=\"fa fa-circle failed-hosts-color\"></i> Failed</p>\n";
|
||||||
function openSocket() {
|
function openSocket() {
|
||||||
event_socket = Socket({
|
$rootScope.event_socket.on("job_events-" + job_id, function(data) {
|
||||||
scope: scope,
|
|
||||||
endpoint: "job_events"
|
|
||||||
});
|
|
||||||
event_socket.init();
|
|
||||||
event_socket.on("job_events-" + job_id, function(data) {
|
|
||||||
if (api_complete && data.id > lastEventId) {
|
if (api_complete && data.id > lastEventId) {
|
||||||
scope.waiting = false;
|
scope.waiting = false;
|
||||||
data.event = data.event_name;
|
data.event = data.event_name;
|
||||||
@@ -117,12 +111,12 @@ export function JobDetailController ($location, $rootScope, $scope, $compile, $r
|
|||||||
if ($rootScope.removeJobStatusChange) {
|
if ($rootScope.removeJobStatusChange) {
|
||||||
$rootScope.removeJobStatusChange();
|
$rootScope.removeJobStatusChange();
|
||||||
}
|
}
|
||||||
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function(e, data) {
|
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange-jobDetails', function(e, data) {
|
||||||
// if we receive a status change event for the current job indicating the job
|
// if we receive a status change event for the current job indicating the job
|
||||||
// is finished, stop event queue processing and reload
|
// is finished, stop event queue processing and reload
|
||||||
if (parseInt(data.unified_job_id, 10) === parseInt(job_id,10)) {
|
if (parseInt(data.unified_job_id, 10) === parseInt(job_id,10)) {
|
||||||
if (data.status === 'failed' || data.status === 'canceled' ||
|
if (data.status === 'failed' || data.status === 'canceled' ||
|
||||||
data.status === 'error' || data.status === 'successful') {
|
data.status === 'error' || data.status === 'successful' || data.status === 'running') {
|
||||||
$scope.liveEventProcessing = false;
|
$scope.liveEventProcessing = false;
|
||||||
if ($rootScope.jobDetailInterval) {
|
if ($rootScope.jobDetailInterval) {
|
||||||
window.clearInterval($rootScope.jobDetailInterval);
|
window.clearInterval($rootScope.jobDetailInterval);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
export function JobStdoutController ($location, $log, $rootScope, $scope, $compile, $routeParams, ClearScope, GetBasePath, Wait, Rest, ProcessErrors, Socket) {
|
export function JobStdoutController ($location, $log, $rootScope, $scope, $compile, $routeParams, ClearScope, GetBasePath, Wait, Rest, ProcessErrors) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -19,8 +19,6 @@ export function JobStdoutController ($location, $log, $rootScope, $scope, $compi
|
|||||||
api_complete = false,
|
api_complete = false,
|
||||||
stdout_url,
|
stdout_url,
|
||||||
current_range,
|
current_range,
|
||||||
event_socket,
|
|
||||||
status_socket,
|
|
||||||
loaded_sections = [],
|
loaded_sections = [],
|
||||||
event_queue = 0,
|
event_queue = 0,
|
||||||
auto_scroll_down=true, // programmatic scroll to bottom
|
auto_scroll_down=true, // programmatic scroll to bottom
|
||||||
@@ -35,37 +33,7 @@ export function JobStdoutController ($location, $log, $rootScope, $scope, $compi
|
|||||||
|
|
||||||
|
|
||||||
function openSockets() {
|
function openSockets() {
|
||||||
status_socket = Socket({
|
$rootScope.event_socket.on("job_events-" + job_id, function() {
|
||||||
scope: $scope,
|
|
||||||
endpoint: "jobs"
|
|
||||||
});
|
|
||||||
status_socket.init();
|
|
||||||
status_socket.on("status_changed", function(data) {
|
|
||||||
if (parseInt(data.unified_job_id, 10) === parseInt(job_id,10) && $scope.job) {
|
|
||||||
$scope.job.status = data.status;
|
|
||||||
if (data.status === 'failed' || data.status === 'canceled' ||
|
|
||||||
data.status === 'error' || data.status === 'successful') {
|
|
||||||
if ($rootScope.jobStdOutInterval) {
|
|
||||||
window.clearInterval($rootScope.jobStdOutInterval);
|
|
||||||
}
|
|
||||||
if (live_event_processing) {
|
|
||||||
if (loaded_sections.length === 0) {
|
|
||||||
$scope.$emit('LoadStdout');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
getNextSection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
live_event_processing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
event_socket = Socket({
|
|
||||||
scope: $scope,
|
|
||||||
endpoint: "job_events"
|
|
||||||
});
|
|
||||||
event_socket.init();
|
|
||||||
event_socket.on("job_events-" + job_id, function() {
|
|
||||||
if (api_complete) {
|
if (api_complete) {
|
||||||
event_queue++;
|
event_queue++;
|
||||||
}
|
}
|
||||||
@@ -73,6 +41,30 @@ export function JobStdoutController ($location, $log, $rootScope, $scope, $compi
|
|||||||
}
|
}
|
||||||
openSockets();
|
openSockets();
|
||||||
|
|
||||||
|
if ($rootScope.removeJobStatusChange) {
|
||||||
|
$rootScope.removeJobStatusChange();
|
||||||
|
}
|
||||||
|
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange-jobStdout', function(e, data) {
|
||||||
|
if (parseInt(data.unified_job_id, 10) === parseInt(job_id,10) && $scope.job) {
|
||||||
|
$scope.job.status = data.status;
|
||||||
|
if (data.status === 'failed' || data.status === 'canceled' ||
|
||||||
|
data.status === 'error' || data.status === 'successful') {
|
||||||
|
if ($rootScope.jobStdOutInterval) {
|
||||||
|
window.clearInterval($rootScope.jobStdOutInterval);
|
||||||
|
}
|
||||||
|
if (live_event_processing) {
|
||||||
|
if (loaded_sections.length === 0) {
|
||||||
|
$scope.$emit('LoadStdout');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getNextSection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
live_event_processing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$rootScope.jobStdOutInterval = setInterval( function() {
|
$rootScope.jobStdOutInterval = setInterval( function() {
|
||||||
if (event_queue > 0) {
|
if (event_queue > 0) {
|
||||||
// events happened since the last check
|
// events happened since the last check
|
||||||
@@ -283,5 +275,4 @@ export function JobStdoutController ($location, $log, $rootScope, $scope, $compi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JobStdoutController.$inject = [ '$location', '$log', '$rootScope', '$scope', '$compile', '$routeParams', 'ClearScope', 'GetBasePath', 'Wait', 'Rest', 'ProcessErrors',
|
JobStdoutController.$inject = [ '$location', '$log', '$rootScope', '$scope', '$compile', '$routeParams', 'ClearScope', 'GetBasePath', 'Wait', 'Rest', 'ProcessErrors'];
|
||||||
'Socket' ];
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
export function JobsListController ($rootScope, $log, $scope, $compile, $routeParams,
|
export function JobsListController ($rootScope, $log, $scope, $compile, $routeParams,
|
||||||
ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadSchedulesScope,
|
ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadSchedulesScope,
|
||||||
LoadJobsScope, AllJobsList, ScheduledJobsList, GetChoices, GetBasePath, Wait, Socket) {
|
LoadJobsScope, AllJobsList, ScheduledJobsList, GetChoices, GetBasePath, Wait) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -24,35 +24,26 @@ export function JobsListController ($rootScope, $log, $scope, $compile, $routePa
|
|||||||
choicesCount = 0,
|
choicesCount = 0,
|
||||||
listCount = 0,
|
listCount = 0,
|
||||||
api_complete = false,
|
api_complete = false,
|
||||||
schedule_socket,
|
|
||||||
job_socket,
|
|
||||||
max_rows;
|
max_rows;
|
||||||
|
|
||||||
function openSockets() {
|
|
||||||
job_socket = Socket({
|
|
||||||
scope: $scope,
|
|
||||||
endpoint: "jobs"
|
|
||||||
});
|
|
||||||
job_socket.init();
|
|
||||||
job_socket.on("status_changed", function() {
|
|
||||||
// if (api_complete) {
|
|
||||||
jobs_scope.refreshJobs();
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
schedule_socket = Socket({
|
|
||||||
scope: $scope,
|
|
||||||
endpoint: "schedules"
|
|
||||||
});
|
|
||||||
schedule_socket.init();
|
|
||||||
schedule_socket.on("schedule_changed", function() {
|
|
||||||
if (api_complete) {
|
|
||||||
scheduled_scope.search('schedule');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
|
if ($rootScope.removeJobStatusChange) {
|
||||||
|
$rootScope.removeJobStatusChange();
|
||||||
|
}
|
||||||
|
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange-jobs', function() {
|
||||||
|
jobs_scope.refreshJobs();
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($rootScope.removeScheduleStatusChange) {
|
||||||
|
$rootScope.removeScheduleStatusChange();
|
||||||
|
}
|
||||||
|
$rootScope.removeScheduleStatusChange = $rootScope.$on('ScheduleStatusChange', function() {
|
||||||
|
if (api_complete) {
|
||||||
|
scheduled_scope.search('schedule');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if ($scope.removeListLoaded) {
|
if ($scope.removeListLoaded) {
|
||||||
$scope.removeListLoaded();
|
$scope.removeListLoaded();
|
||||||
}
|
}
|
||||||
@@ -60,7 +51,6 @@ export function JobsListController ($rootScope, $log, $scope, $compile, $routePa
|
|||||||
listCount++;
|
listCount++;
|
||||||
if (listCount === 2) {
|
if (listCount === 2) {
|
||||||
api_complete = true;
|
api_complete = true;
|
||||||
openSockets();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -193,4 +183,4 @@ export function JobsListController ($rootScope, $log, $scope, $compile, $routePa
|
|||||||
|
|
||||||
JobsListController.$inject = ['$rootScope', '$log', '$scope', '$compile', '$routeParams',
|
JobsListController.$inject = ['$rootScope', '$log', '$scope', '$compile', '$routeParams',
|
||||||
'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadSchedulesScope', 'LoadJobsScope',
|
'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadSchedulesScope', 'LoadJobsScope',
|
||||||
'AllJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'Socket'];
|
'AllJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait'];
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export function PortalController($scope, $compile, $routeParams, $rootScope, $lo
|
|||||||
if ($rootScope.removeJobStatusChange) {
|
if ($rootScope.removeJobStatusChange) {
|
||||||
$rootScope.removeJobStatusChange();
|
$rootScope.removeJobStatusChange();
|
||||||
}
|
}
|
||||||
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function() {
|
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange-portal', function() {
|
||||||
jobs_scope.search('portal_job'); //processEvent(event);
|
jobs_scope.search('portal_job'); //processEvent(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $routeParams,
|
|||||||
if ($rootScope.removeJobStatusChange) {
|
if ($rootScope.removeJobStatusChange) {
|
||||||
$rootScope.removeJobStatusChange();
|
$rootScope.removeJobStatusChange();
|
||||||
}
|
}
|
||||||
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function(e, data) {
|
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange-projects', function(e, data) {
|
||||||
var project;
|
var project;
|
||||||
$log.debug(data);
|
$log.debug(data);
|
||||||
if ($scope.projects) {
|
if ($scope.projects) {
|
||||||
@@ -722,30 +722,6 @@ export function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $rou
|
|||||||
callback: 'choicesReady'
|
callback: 'choicesReady'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle project update status changes
|
|
||||||
if ($rootScope.removeJobStatusChange) {
|
|
||||||
$rootScope.removeJobStatusChange();
|
|
||||||
}
|
|
||||||
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function(e, data) {
|
|
||||||
if ($scope.project_obj && data.project_id === $scope.project_obj.id) {
|
|
||||||
// This is the affected project
|
|
||||||
$log.debug('Received event for project: ' + $scope.project_obj.name);
|
|
||||||
$log.debug('Status changed to: ' + data.status);
|
|
||||||
// Set the status and re-evaluate the update button tooltip and class
|
|
||||||
$scope.project_obj.status = data.status;
|
|
||||||
$scope.scm_update_tooltip = "Start an SCM update";
|
|
||||||
$scope.scm_type_class = "";
|
|
||||||
if (data.status === 'running' || data.status === 'updating') {
|
|
||||||
$scope.scm_update_tooltip = "SCM update currently running";
|
|
||||||
$scope.scm_type_class = "btn-disabled";
|
|
||||||
}
|
|
||||||
if (Empty($scope.project_obj.scm_type)) {
|
|
||||||
$scope.scm_update_tooltip = 'Manual projects do not require an SCM update';
|
|
||||||
$scope.scm_type_class = "btn-disabled";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
$scope.formSave = function () {
|
$scope.formSave = function () {
|
||||||
var fld, i, params;
|
var fld, i, params;
|
||||||
|
|||||||
@@ -80,11 +80,6 @@ export function SocketsController ($scope, $compile, ClearScope, Socket) {
|
|||||||
e.append(html);
|
e.append(html);
|
||||||
$compile(e)(job_events_scope);
|
$compile(e)(job_events_scope);
|
||||||
|
|
||||||
schedules_socket.init();
|
|
||||||
test_socket.init();
|
|
||||||
jobs_socket.init();
|
|
||||||
job_events_socket.init();
|
|
||||||
|
|
||||||
schedules_scope.url = schedules_socket.getUrl();
|
schedules_scope.url = schedules_socket.getUrl();
|
||||||
test_scope.url = test_socket.getUrl();
|
test_scope.url = test_socket.getUrl();
|
||||||
jobs_scope.url = jobs_socket.getUrl();
|
jobs_scope.url = jobs_socket.getUrl();
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function JobStatusGraphData(Rest, getBasePath, processErrors, $rootScope, $q) {
|
|||||||
destroyWatcher: angular.noop,
|
destroyWatcher: angular.noop,
|
||||||
setupWatcher: function(period, jobType) {
|
setupWatcher: function(period, jobType) {
|
||||||
this.destroyWatcher =
|
this.destroyWatcher =
|
||||||
$rootScope.$on('JobStatusChange', function() {
|
$rootScope.$on('JobStatusChange-home', function() {
|
||||||
getData(period, jobType).then(function(result) {
|
getData(period, jobType).then(function(result) {
|
||||||
$rootScope.
|
$rootScope.
|
||||||
$broadcast('DataReceived:JobStatusGraph',
|
$broadcast('DataReceived:JobStatusGraph',
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ angular.module('DashboardJobsWidget', ['RestServices', 'Utilities'])
|
|||||||
e.html(html);
|
e.html(html);
|
||||||
$compile(e)(scope);
|
$compile(e)(scope);
|
||||||
|
|
||||||
$rootScope.$on('JobStatusChange', function() {
|
$rootScope.$on('JobStatusChange-home', function() {
|
||||||
jobs_scope.refreshJobs();
|
jobs_scope.refreshJobs();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ describeModule('DashboardGraphs')
|
|||||||
$rootScope.$on('DataReceived:JobStatusGraph', function(e, data) {
|
$rootScope.$on('DataReceived:JobStatusGraph', function(e, data) {
|
||||||
result.resolve(data);
|
result.resolve(data);
|
||||||
});
|
});
|
||||||
$rootScope.$emit('JobStatusChange');
|
$rootScope.$emit('JobStatusChange-home');
|
||||||
restStub.succeed({ data: expected });
|
restStub.succeed({ data: expected });
|
||||||
restStub.flush();
|
restStub.flush();
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
Reference in New Issue
Block a user