mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Job detail page refactor
Added logic to paint the DOM every 3 seconds. Fingers crossed.
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest,
|
function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest,
|
||||||
ProcessErrors, SelectPlay, SelectTask, Socket, GetElapsed, FilterAllByHostName, DrawGraph, LoadHostSummary, ReloadHostSummaryList,
|
ProcessErrors, SelectPlay, SelectTask, Socket, GetElapsed, FilterAllByHostName, DrawGraph, LoadHostSummary, ReloadHostSummaryList,
|
||||||
JobIsFinished, SetTaskStyles, DigestEvent) {
|
JobIsFinished, SetTaskStyles, DigestEvent, UpdateDOM) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -21,14 +21,9 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
lastEventId = 0;
|
lastEventId = 0;
|
||||||
|
|
||||||
scope.plays = [];
|
scope.plays = [];
|
||||||
scope.playsMap = {};
|
|
||||||
scope.hosts = [];
|
scope.hosts = [];
|
||||||
scope.hostsMap = {};
|
|
||||||
scope.tasks = [];
|
scope.tasks = [];
|
||||||
scope.tasksMap = {};
|
|
||||||
scope.hostResults = [];
|
scope.hostResults = [];
|
||||||
scope.hostResultsMap = {};
|
|
||||||
api_complete = false;
|
|
||||||
|
|
||||||
scope.hostResultsMaxRows = 75;
|
scope.hostResultsMaxRows = 75;
|
||||||
scope.hostSummariesMaxRows = 75;
|
scope.hostSummariesMaxRows = 75;
|
||||||
@@ -123,6 +118,11 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
DrawGraph({ scope: scope, resize: true });
|
DrawGraph({ scope: scope, resize: true });
|
||||||
}
|
}
|
||||||
api_complete = true; //trigger events to start processing
|
api_complete = true; //trigger events to start processing
|
||||||
|
|
||||||
|
$rootScope.jobDetailInterval = setInterval(function() {
|
||||||
|
$log.debug('Updating the DOM...');
|
||||||
|
UpdateDOM({ scope: scope });
|
||||||
|
}, 3000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1053,5 +1053,5 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log,
|
|||||||
|
|
||||||
JobDetailController.$inject = [ '$rootScope', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath',
|
JobDetailController.$inject = [ '$rootScope', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath',
|
||||||
'Wait', 'Rest', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'FilterAllByHostName', 'DrawGraph',
|
'Wait', 'Rest', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'FilterAllByHostName', 'DrawGraph',
|
||||||
'LoadHostSummary', 'ReloadHostSummaryList', 'JobIsFinished', 'SetTaskStyles', 'DigestEvent'
|
'LoadHostSummary', 'ReloadHostSummaryList', 'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
|||||||
status_text = params.status_text,
|
status_text = params.status_text,
|
||||||
play;
|
play;
|
||||||
|
|
||||||
if (scope.jobData.plays[scope.activePlay] !== undefined) {
|
if (scope.jobData.plays[id] !== undefined) {
|
||||||
play = scope.jobData.plays[scope.activePlay];
|
play = scope.jobData.plays[scope.activePlay];
|
||||||
if (failed) {
|
if (failed) {
|
||||||
play.status = 'failed';
|
play.status = 'failed';
|
||||||
@@ -363,7 +363,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
|||||||
no_hosts = params.no_hosts,
|
no_hosts = params.no_hosts,
|
||||||
task;
|
task;
|
||||||
|
|
||||||
if (scope.jobData.plays[scope.activePlay].tasks[scope.activeTask] !== undefined) {
|
if (scope.jobData.plays[scope.activePlay].tasks[id] !== undefined) {
|
||||||
task = scope.jobData.plays[scope.activePlay].tasks[scope.activeTask];
|
task = scope.jobData.plays[scope.activePlay].tasks[scope.activeTask];
|
||||||
if (no_hosts){
|
if (no_hosts){
|
||||||
task.status = 'no-matching-hosts';
|
task.status = 'no-matching-hosts';
|
||||||
@@ -473,7 +473,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
|||||||
name: name,
|
name: name,
|
||||||
created: created,
|
created: created,
|
||||||
msg: msg
|
msg: msg
|
||||||
}
|
};
|
||||||
|
|
||||||
// update the task status bar
|
// update the task status bar
|
||||||
if (scope.jobData.plays[scope.activePlay].tasks[task_id] !== undefined) {
|
if (scope.jobData.plays[scope.activePlay].tasks[task_id] !== undefined) {
|
||||||
@@ -934,6 +934,70 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
.factory('DrawPlays', [ function() {
|
||||||
|
return function(params) {
|
||||||
|
var scope = params.scope,
|
||||||
|
idx = 0,
|
||||||
|
result = [],
|
||||||
|
keys = Object.keys(scope.jobData.plays);
|
||||||
|
keys.reverse();
|
||||||
|
while (idx < keys.length && idx < scope.playsMaxRows) {
|
||||||
|
result.push(scope.jobData.plays[keys[idx]]);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
scope.plays = result;
|
||||||
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
.factory('DrawTasks', [ function() {
|
||||||
|
return function(params) {
|
||||||
|
var scope = params.scope,
|
||||||
|
result = [],
|
||||||
|
idx = 0,
|
||||||
|
keys = Object.keys(scope.jobData.plays[scope.activePlay].tasks);
|
||||||
|
keys.reverse();
|
||||||
|
while (idx < keys.length && idx < scope.tasksMaxRows) {
|
||||||
|
result.push(scope.jobData.plays[scope.activePlay].tasks[keys[idx]]);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
scope.tasks = result;
|
||||||
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
.factory('DrawHostResults', [ function() {
|
||||||
|
return function(params) {
|
||||||
|
var scope = params.scope,
|
||||||
|
result = [],
|
||||||
|
idx = 0,
|
||||||
|
hostResults = scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].hostResults,
|
||||||
|
keys = Object.keys(hostResults);
|
||||||
|
|
||||||
|
keys.sort(function(a,b) {
|
||||||
|
if (hostResults[a].name < hostResults[b].name)
|
||||||
|
return 1;
|
||||||
|
if (hostResults[a].name > hostResults[b].name)
|
||||||
|
return -1;
|
||||||
|
// a must be equal to b
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
while (idx < keys.length && idx < scope.hostResultsMaxRows) {
|
||||||
|
result.push(scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].hostsResults[keys[idx]]);
|
||||||
|
}
|
||||||
|
scope.hostResults = result;
|
||||||
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
.factory('UpdateDOM', ['DrawPlays', 'DrawTasks', 'DrawHostResults', function(DrawPlays, DrawTasks, DrawHostResults) {
|
||||||
|
return function(params) {
|
||||||
|
var scope = params.scope;
|
||||||
|
|
||||||
|
DrawPlays({ scope: scope });
|
||||||
|
DrawTasks({ scope: scope });
|
||||||
|
DrawHostResults({ scope: scope });
|
||||||
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
.factory('FilterAllByHostName', ['Rest', 'GetBasePath', 'ProcessErrors', 'SelectPlay', function(Rest, GetBasePath, ProcessErrors, SelectPlay) {
|
.factory('FilterAllByHostName', ['Rest', 'GetBasePath', 'ProcessErrors', 'SelectPlay', function(Rest, GetBasePath, ProcessErrors, SelectPlay) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
|
|||||||
Reference in New Issue
Block a user