Job details page re-refactor continues...

Started adding logic to support parallel processing of plays/tasks. Fixed summary host lit not loading when there is no active play and/or active task.
Now using jobs/N/job_host_summaries.host_name when building host summary list.
This commit is contained in:
Chris Houseknecht 2014-07-11 16:11:22 -04:00
parent 4b34401ca9
commit 20e2ba0d6d
2 changed files with 23 additions and 30 deletions

View File

@ -149,8 +149,8 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
.success(function(data) {
data.results.forEach(function(event) {
var name;
if (event.summary_fields.host && event.summary_fields.host.name) {
name = event.summary_fields.host.name;
if (event.host_name) {
name = event.host_name;
}
else {
name = "<deleted host>";
@ -236,8 +236,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
});
}
else {
scope.jobData.hostSummaries = {};
scope.$emit('InitialLoadComplete');
scope.$emit('LoadHostSummaries');
}
});
@ -322,9 +321,9 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
task: play.tasks[event.id]
});
});
//if (scope.activeTask) {
// scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active';
//}
if (scope.activeTask) {
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active';
}
scope.$emit('LoadHosts');
})
.error(function(data) {
@ -333,8 +332,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
});
}
else {
scope.jobData.hostSummaries = {};
scope.$emit('InitialLoadComplete');
scope.$emit('LoadHostSummaries');
}
});
@ -425,7 +423,6 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
scope.jobData.plays[scope.activePlay].playActiveClass = 'active';
}
scope.$emit('LoadTasks', events_url);
//scope.$emit('FixPlaysScroll');
})
.error( function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
@ -850,8 +847,8 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
var url = scope.job.url + 'job_plays/?id__gt=' + scope.plays[scope.plays.length - 1].id;
url += (scope.search_play_name) ? '&play__icontains=' + scope.search_play_name : '';
url += (scope.search_play_status === 'failed') ? '&failed=true' : '';
url += + '&page_size=' + scope.playsMaxRows + '&order_by=id';
url += '&page_size=' + scope.playsMaxRows + '&order_by=id';
$('#playsMoreRows').fadeIn();
Rest.setUrl(url);
Rest.get()
.success( function(data) {
@ -902,6 +899,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
scope.plays[scope.plays.length - 1].hostCount = ok + changed + failed + skipped;
});
$('#playsMoreRows').fadeOut(400);
})
.error( function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
@ -914,7 +912,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
// check for more tasks when user scrolls to bottom of task list...
if ((!scope.liveEventProcessing) && scope.activePlay && scope.tasks.length) {
var url = scope.job.url + 'job_tasks/?event_id=' + scope.activePlay;
url += (scope.search_task_name) ? '&name__icontains=' + scope.search_task_name : '';
url += (scope.search_task_name) ? '&task__icontains=' + scope.search_task_name : '';
url += (scope.search_task_status === 'failed') ? '&failed=true' : '';
url += '&id__gt=' + scope.tasks[scope.tasks.length - 1].id + '&page_size=' + scope.tasksMaxRows + '&order_by=id';
$('#tasksMoreRows').fadeIn();
@ -1056,8 +1054,8 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
.success(function(data) {
data.results.forEach(function(row) {
var name;
if (event.summary_fields.host && event.summary_fields.host.name) {
name = event.summary_fields.host.name;
if (event.host_name) {
name = event.host_name;
}
else {
name = "<deleted host>";

View File

@ -46,8 +46,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return function(params) {
var scope = params.scope,
event = params.event,
status, status_text;
event = params.event;
$log.debug('processing event: ' + event.id);
@ -216,7 +215,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
if (scope.jobData.plays[key].taskCount > 0) {
activeList.push(key);
}
};
}
//find the most recent play in the list of 'active' plays
if (scope.activeList.length > 0) {
@ -275,9 +274,10 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
if (scope.jobData.plays[scope.activePlay].tasks[key].reportedHosts > 0 || scope.jobData.plays[scope.activePlay].tasks[key].status === 'no-matching-hosts') {
activeList.push(key);
}
};
}
if (scope.activeList.length > 0) {
newActiveTask = scope.jobData.plays[scope.activePlay].tasks[scope.acitveList[scope.activeList.length - 1]].id
newActiveTask = scope.jobData.plays[scope.activePlay].tasks[scope.acitveList[scope.activeList.length - 1]].id;
if (scope.activeTask && newActiveTask !== scope.activeTask) {
if (scope.activeTask && scope.jobData.plays[scope.activePlay].tasks[scope.activeTask] !== undefined) {
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = '';
@ -647,9 +647,6 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
});
});
if (scope.liveEventProcessing) {
}
// set the active task
SelectPlay({
scope: scope,
@ -701,7 +698,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
if (scope.activePlay) {
url = scope.job.url + 'job_tasks/?event_id=' + scope.activePlay;
url += (scope.search_task_name) ? '&name__icontains=' + scope.search_task_name : '';
url += (scope.search_task_name) ? '&task__icontains=' + scope.search_task_name : '';
url += (scope.search_task_status === 'failed') ? '&failed=true' : '';
url += '&page_size=' + scope.tasksMaxRows + '&order_by=id';
@ -926,8 +923,8 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
.success(function(data) {
data.results.forEach(function(event) {
var name;
if (event.summary_fields.host && event.summary_fields.host.name) {
name = event.summary_fields.host.name;
if (event.host_name) {
name = event.host_name;
}
else {
name = "<deleted host>";
@ -1228,11 +1225,9 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
idx = 0,
hostSummaries,
key,
keys;
if (scope.activePlay && scope.activeTask) {
keys = Object.keys(scope.jobData.hostSummaries);
if (keys.length > 0) {
hostSummaries = JSON.parse(JSON.stringify(scope.jobData.hostSummaries));
if (scope.search_host_summary_name) {
for (key in hostSummaries) {
if (hostSummaries[key].name.indexOf(scope.search_host_summary_name) > 0) {