Job detail page re-refactor

Wired up new search fields
This commit is contained in:
Chris Houseknecht 2014-07-09 15:26:04 -04:00
parent 62ecffad0e
commit e3cea8ff25
3 changed files with 371 additions and 264 deletions

View File

@ -8,8 +8,8 @@
'use strict';
function JobDetailController ($location, $rootScope, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest,
ProcessErrors, SelectPlay, SelectTask, Socket, GetElapsed, FilterAllByHostName, DrawGraph, LoadHostSummary, ReloadHostSummaryList,
JobIsFinished, SetTaskStyles, DigestEvent, UpdateDOM, EventViewer, DeleteJob, PlaybookRun, HostEventsViewer) {
ProcessErrors, SelectPlay, SelectTask, Socket, GetElapsed, DrawGraph, LoadHostSummary, ReloadHostSummaryList, JobIsFinished, SetTaskStyles, DigestEvent,
UpdateDOM, EventViewer, DeleteJob, PlaybookRun, HostEventsViewer, LoadPlays, LoadTasks, LoadHosts) {
ClearScope();
@ -32,14 +32,19 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
scope.liveEventProcessing = true; // control play/pause state of event processing
scope.search_all_tasks = [];
scope.search_all_plays = [];
scope.job_status = {};
scope.job_id = job_id;
scope.auto_scroll = false;
scope.searchTaskHostsEnabled = true;
scope.searchSummaryHostsEnabled = true;
scope.searchAllHostsEnabled = true;
scope.searchPlaysEnabled = true;
scope.searchTasksEnabled = true;
scope.searchHostsEnabled = true;
scope.searchHostSummaryEnabled = true;
scope.search_play_status = 'all';
scope.search_task_status = 'all';
scope.search_host_status = 'all';
scope.search_host_summary_status = 'all';
scope.haltEventQueue = false;
scope.processing = false;
scope.lessStatus = true;
@ -676,57 +681,120 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
scope.lessStatus = (scope.lessStatus) ? false : true;
};
scope.searchAllByHost = function() {
if (scope.search_all_hosts_name) {
FilterAllByHostName({
scope: scope,
host: scope.search_all_hosts_name
scope.filterPlayStatus = function() {
scope.search_play_status = (scope.search_play_status === 'all') ? 'failed' : 'all';
if (!scope.liveEventProcessing) {
LoadPlays({
scope: scope
});
scope.searchAllHostsEnabled = false;
}
else {
scope.search_all_tasks = [];
scope.search_all_plays = [];
scope.searchAllHostsEnabled = true;
SelectPlay({
scope: scope,
id: (scope.plays.length > 0) ? scope.plays[0].id : null
});
}
ReloadHostSummaryList({
scope: scope
});
};
scope.allHostNameKeyPress = function(e) {
if (e.keyCode === 13) {
scope.searchAllByHost();
}
};
scope.filterByStatus = function(choice) {
var nxtPlay;
if (choice === 'Failed') {
scope.searchAllStatus = 'failed';
nxtPlay = null;
scope.plays.every(function(play) {
if (play.status === 'failed') {
nxtPlay = play.id;
return false;
}
return true;
});
scope.searchPlays = function() {
if (scope.search_play_name) {
scope.searchPlaysEnabled = false;
}
else {
scope.searchAllStatus = '';
nxtPlay = (scope.plays.length > 0) ? scope.plays[0].id : null;
scope.searchPlaysEnabled = true;
}
if (!scope.liveEventProcessing) {
SelectPlay({
scope: scope,
id: nxtPlay
LoadPlays({
scope: scope
});
}
};
scope.searchPlaysKeyPress = function(e) {
if (e.keyCode === 13) {
scope.searchPlays();
e.stopPropagation();
}
};
scope.searchTasks = function() {
if (scope.search_task_name) {
scope.searchTasksEnabled = false;
}
else {
scope.searchTasksEnabled = true;
}
if (!scope.liveEventProcessing) {
LoadTasks({
scope: scope
});
}
};
scope.searchTasksKeyPress = function(e) {
if (e.keyCode === 13) {
scope.searchTasks();
e.stopPropagation();
}
};
scope.searchHosts = function() {
if (scope.search_host_name) {
scope.searchHostsEnabled = false;
}
else {
scope.searchHostsEnabled = true;
}
if (!scope.liveEventProcessing) {
LoadHosts({
scope: scope
});
}
};
scope.searchHostsKeyPress = function(e) {
if (e.keyCode === 13) {
scope.searchHosts();
e.stopPropagation();
}
};
scope.searchHostSummary = function() {
if (scope.search_host_summary_name) {
scope.searchHostSummaryEnabled = false;
}
else {
scope.searchHostSummaryEnabled = true;
}
if (!scope.liveEventProcessing) {
ReloadHostSummaryList({
scope: scope
});
}
};
scope.searchHostSummaryKeyPress = function(e) {
if (e.keyCode === 13) {
scope.searchHostSummary();
e.stopPropagation();
}
};
scope.filterTaskStatus = function() {
scope.search_task_status = (scope.search_task_status === 'all') ? 'failed' : 'all';
if (!scope.liveEventProcessing) {
LoadTasks({
scope: scope
});
}
};
scope.filterHostStatus = function() {
scope.search_host_status = (scope.search_host_status === 'all') ? 'failed' : 'all';
if (!scope.liveEventProcessing) {
LoadHosts({
scope: scope
});
}
};
scope.filterHostSummaryStatus = function() {
scope.search_host_summary_status = (scope.search_host_summary_status === 'all') ? 'failed' : 'all';
if (!scope.liveEventProcessing) {
ReloadHostSummaryList({
scope: scope
});
@ -772,8 +840,10 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
// check for more plays when user scrolls to bottom of play list...
if ((!scope.liveEventProcessing) && scope.plays.length) {
var url = scope.job.url + 'job_plays/?';
url += '&id__gt=' + scope.plays[scope.plays.length - 1].id + '&page_size=' + scope.playsMaxRows + '&order_by=id';
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';
Rest.setUrl(url);
Rest.get()
@ -837,8 +907,8 @@ 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_all_tasks.length > 0) ? '&id__in=' + scope.search_all_tasks.join() : '';
url += (scope.searchAllStatus === 'failed') ? '&failed=true' : '';
url += (scope.search_task_name) ? '&name__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();
Rest.setUrl(url);
@ -910,8 +980,8 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
// check for more hosts when user scrolls to bottom of host results list...
if ((!scope.liveEventProcessing) && scope.activeTask && scope.hostResults.length) {
var url = GetBasePath('jobs') + job_id + '/job_events/?parent=' + scope.activeTask + '&';
url += (scope.search_all_hosts_name) ? 'host__name__icontains=' + scope.search_all_hosts_name + '&' : '';
url += (scope.searchAllStatus === 'failed') ? 'failed=true&' : '';
url += (scope.search_host_name) ? 'host__name__icontains=' + scope.search_host_name + '&' : '';
url += (scope.search_host_status === 'failed') ? '&failed=true' : '';
url += 'host__name__gt=' + scope.hostResults[scope.hostResults.length - 1].name + '&page_size=' +
scope.hostResultsMaxRows + '&order_by=host__name';
$('#hostResultsMoreRows').fadeIn();
@ -970,8 +1040,8 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
// check for more hosts when user scrolls to bottom of host summaries list...
if ((!scope.liveEventProcessing) && scope.hosts) {
var url = GetBasePath('jobs') + job_id + '/job_host_summaries/?';
url += (scope.search_all_hosts_name) ? 'host__name__icontains=' + scope.search_all_hosts_name + '&' : '';
url += (scope.searchAllStatus === 'failed') ? 'failed=true&' : '';
url += (scope.search_host_summary_name) ? 'host__name__icontains=' + scope.search_host_summary_name + '&' : '';
url += (scope.search_host_summary_status === 'failed') ? 'failed=true&' : '';
url += 'host__name__gt=' + scope.hosts[scope.hosts.length - 1].name + '&page_size=' + scope.hostSummariesMaxRows + '&order_by=host__name';
$('#hostSummariesMoreRows').fadeIn();
Rest.setUrl(url);
@ -1017,6 +1087,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
}
JobDetailController.$inject = [ '$location', '$rootScope', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath',
'Wait', 'Rest', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'FilterAllByHostName', 'DrawGraph', 'LoadHostSummary', 'ReloadHostSummaryList',
'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'EventViewer', 'DeleteJob', 'PlaybookRun', 'HostEventsViewer'
'Wait', 'Rest', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'DrawGraph', 'LoadHostSummary', 'ReloadHostSummaryList',
'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'EventViewer', 'DeleteJob', 'PlaybookRun', 'HostEventsViewer', 'LoadPlays', 'LoadTasks',
'LoadHosts'
];

View File

@ -555,21 +555,83 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
};
}])
.factory('LoadPlays', ['Rest', 'ProcessErrors', 'GetElapsed', 'SelectPlay', 'JobIsFinished',
function(Rest, ProcessErrors, GetElapsed, SelectPlay, JobIsFinished) {
return function(params) {
var scope = params.scope,
callback = params.callback,
url;
scope.plays = [];
url = scope.job.url + 'job_plays/?page_size=' + scope.playsMaxRows + '&order_by=id';
url += (scope.search_play_name) ? '&play__icontains=' + scope.search_play_name : '';
url += (scope.search_play_status === 'failed') ? '&failed=true' : '';
Rest.setUrl(url);
Rest.get()
.success(function(data) {
data.results.forEach(function(event, idx) {
var status, status_text, start, end, elapsed;
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
status_text = (event.failed) ? 'Failed' : (event.changed) ? 'Changed' : 'OK';
start = event.started;
if (idx < data.length - 1) {
// end date = starting date of the next event
end = data[idx + 1].started;
}
else if (JobIsFinished(scope)) {
// this is the last play and the job already finished
end = scope.job_status.finished;
}
if (end) {
elapsed = GetElapsed({
start: start,
end: end
});
}
else {
elapsed = '00:00:00';
}
scope.plays.push({
id: event.id,
name: event.play,
created: start,
finished: end,
status: status,
status_text: status_text,
status_tip: "Event ID: " + event.id + "<br />Status: " + status_text,
elapsed: elapsed,
hostCount: 0,
fistTask: null,
playActiveClass: '',
unreachableCount: (event.unreachable_count) ? event.unreachable_count : 0,
});
});
// set the active task
SelectPlay({
scope: scope,
id: (scope.plays.length > 0) ? scope.plays[0].id : null,
callback: callback
});
})
.error(function(data) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
};
}])
// Call SelectPlay whenever the the activePlay needs to change
.factory('SelectPlay', ['SelectTask', 'LoadTasks', function(SelectTask, LoadTasks) {
return function(params) {
var scope = params.scope,
id = params.id,
callback = params.callback,
clear = false;
// Determine if the tasks and hostResults arrays should be initialized
if (scope.search_all_hosts_name || scope.searchAllStatus === 'failed') {
clear = true;
}
else {
clear = (scope.activePlay === id) ? false : true; //are we moving to a new play?
}
callback = params.callback;
scope.activePlay = id;
scope.plays.forEach(function(play, idx) {
@ -581,14 +643,10 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
}
});
setTimeout(function() {
scope.$apply(function() {
LoadTasks({
scope: scope,
callback: callback,
clear: true
});
});
LoadTasks({
scope: scope,
callback: callback,
clear: true
});
};
@ -598,18 +656,15 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return function(params) {
var scope = params.scope,
callback = params.callback,
clear = params.clear,
url;
if (clear) {
scope.tasks = [];
scope.tasksMap = {};
}
scope.tasks = [];
scope.tasksMap = {};
if (scope.activePlay) {
url = scope.job.url + 'job_tasks/?event_id=' + scope.activePlay;
url += (scope.search_all_tasks.length > 0) ? '&id__in=' + scope.search_all_tasks.join() : '';
url += (scope.searchAllStatus === 'failed') ? '&failed=true' : '';
url += (scope.search_task_name) ? '&name__icontains=' + scope.search_task_name : '';
url += (scope.search_task_status === 'failed') ? '&failed=true' : '';
url += '&page_size=' + scope.tasksMaxRows + '&order_by=id';
Rest.setUrl(url);
@ -618,11 +673,6 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
data.results.forEach(function(event, idx) {
var end, elapsed, status, status_text;
//if (!scope.plays[scope.playsMap[scope.activePlay]].firstTask) {
// scope.plays[scope.playsMap[scope.activePlay]].firstTask = event.id;
// scope.plays[scope.playsMap[scope.activePlay]].hostCount = (event.host_count) ? event.host_count : 0;
//}
if (idx < data.length - 1) {
// end date = starting date of the next event
end = data[idx + 1].created;
@ -684,7 +734,6 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
callback: callback
});
//$('#tasks-table-detail').mCustomScrollbar("update");
})
.error(function(data) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
@ -707,15 +756,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return function(params) {
var scope = params.scope,
id = params.id,
callback = params.callback,
clear=false;
if (scope.search_all_hosts_name || scope.searchAllStatus === 'failed') {
clear = true;
}
else {
clear = (scope.activeTask === id) ? false : true;
}
callback = params.callback;
scope.activeTask = id;
scope.tasks.forEach(function(task, idx) {
@ -740,19 +781,16 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return function(params) {
var scope = params.scope,
callback = params.callback,
clear = params.clear,
url;
if (clear) {
scope.hostResults = [];
scope.hostResultsMap = {};
}
scope.hostResults = [];
scope.hostResultsMap = {};
if (scope.activeTask) {
// If we have a selected task, then get the list of hosts
url = scope.job.related.job_events + '?parent=' + scope.activeTask + '&';
url += (scope.search_all_hosts_name) ? 'host__name__icontains=' + scope.search_all_hosts_name + '&' : '';
url += (scope.searchAllStatus === 'failed') ? 'failed=true&' : '';
url += (scope.search_host_name) ? 'host__name__icontains=' + scope.search_host_name + '&' : '';
url += (scope.search_host_status === 'failed') ? 'failed=true&' : '';
url += 'event__icontains=runner&page_size=' + scope.hostResultsMaxRows + '&order_by=host__name';
Rest.setUrl(url);
Rest.get()
@ -798,7 +836,6 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
if (callback) {
scope.$emit(callback);
}
//$('#hosts-table-detail').mCustomScrollbar("update");
})
.error(function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
@ -822,8 +859,8 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
url;
url = scope.job.related.job_host_summaries + '?';
url += (scope.search_all_hosts_name) ? 'host__name__icontains=' + scope.search_all_hosts_name + '&': '';
url += (scope.searchAllStatus === 'failed') ? 'failed=true&' : '';
url += (scope.search_host_summary_name) ? 'host__name__icontains=' + scope.search_host_summary_name + '&': '';
url += (scope.search_host_summary_status === 'failed') ? 'failed=true&' : '';
url += '&page_size=' + scope.hostSummariesMaxRows + '&order_by=host__name';
scope.hosts = [];
@ -952,7 +989,10 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
result = [],
newKeys = [],
plays = JSON.parse(JSON.stringify(scope.jobData.plays)),
keys = Object.keys(plays);
filteredListA = [],
filteredListB = [],
key,
keys;
function listSort(a,b) {
if (parseInt(a,10) < parseInt(b,10))
@ -962,6 +1002,29 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return 0;
}
if (scope.search_play_name) {
for (key in plays) {
if (plays[key].name.indexOf(scope.search_play_name) > 0) {
filteredListA[key] = plays[key];
}
}
}
else {
filteredListA = plays;
}
if (scope.search_play_status === 'failed') {
for (key in filteredListA) {
if (filteredListA[key].status === 'failed') {
filteredListB[key] = plays[key];
}
}
}
else {
filteredListB = filteredListA;
}
keys = Object.keys(filteredListB);
keys.sort(function(a,b) { return listSort(a,b); }).reverse();
for (idx=0; idx < scope.playsMaxRows && idx < keys.length; idx++) {
newKeys.push(keys[idx]);
@ -969,7 +1032,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
newKeys.sort(function(a,b) { return listSort(a,b); });
idx = 0;
while (idx < newKeys.length) {
result.push(plays[newKeys[idx]]);
result.push(filteredListB[newKeys[idx]]);
idx++;
}
scope.plays = result;
@ -983,7 +1046,9 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return function(params) {
var scope = params.scope,
result = [],
idx, keys, newKeys, tasks;
filteredListA = [],
filteredListB = [],
idx, key, keys, newKeys, tasks;
function listSort(a,b) {
if (parseInt(a,10) < parseInt(b,10))
@ -994,8 +1059,32 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
}
if (scope.activePlay) {
tasks = JSON.parse(JSON.stringify(scope.jobData.plays[scope.activePlay].tasks));
keys = Object.keys(tasks);
if (scope.search_task_name) {
for (key in tasks) {
if (tasks[key].name.indexOf(scope.search_task_name) > 0) {
filteredListA[key] = tasks[key];
}
}
}
else {
filteredListA = tasks;
}
if (scope.search_task_status === 'failed') {
for (key in filteredListA) {
if (filteredListA[key].status === 'failed') {
filteredListB[key] = tasks[key];
}
}
}
else {
filteredListB = filteredListA;
}
keys = Object.keys(filteredListB);
keys.sort(function(a,b) { return listSort(a,b); }).reverse();
newKeys = [];
for (idx=0; result.length < scope.tasksMaxRows && idx < keys.length; idx++) {
@ -1004,7 +1093,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
newKeys.sort(function(a,b) { return listSort(a,b); });
idx = 0;
while (idx < newKeys.length) {
result.push(tasks[newKeys[idx]]);
result.push(filteredListB[newKeys[idx]]);
idx++;
}
}
@ -1020,30 +1109,50 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return function(params) {
var scope = params.scope,
result = [],
filteredListA = [],
filteredListB = [],
idx = 0,
hostResults,
key,
keys;
if (scope.activePlay && scope.activeTask) {
hostResults = JSON.parse(JSON.stringify(scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].hostResults));
keys = Object.keys(hostResults);
if (scope.search_host_name) {
for (key in hostResults) {
if (hostResults[key].name.indexOf(scope.search_host_name) > 0) {
filteredListA[key] = hostResults[key];
}
}
}
else {
filteredListA = hostResults;
}
if (scope.search_host_status === 'failed') {
for (key in filteredListA) {
if (filteredListA[key].status === 'failed') {
filteredListB[key] = filteredListA[key];
}
}
}
else {
filteredListB = filteredListA;
}
keys = Object.keys(filteredListB);
keys.sort(function(a,b) {
if (hostResults[a].name > hostResults[b].name)
if (filteredListB[a].name > filteredListB[b].name)
return -1;
if (hostResults[a].name < hostResults[b].name)
if (filteredListB[a].name < filteredListB[b].name)
return 1;
// a must be equal to b
return 0;
});
while (idx < keys.length && result.length < scope.hostResultsMaxRows) {
if (scope.searchAllStatus === 'failed') {
if (hostResults[keys[idx]].status === 'failed') {
result.unshift(hostResults[keys[idx]]);
}
}
else {
result.unshift(hostResults[keys[idx]]);
}
result.unshift(filteredListB[keys[idx]]);
idx++;
}
}
@ -1058,43 +1167,58 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
return function(params) {
var scope = params.scope,
result = [],
filteredListA = [],
filteredListB = [],
idx = 0,
hostSummaries,
key,
keys;
if (scope.activePlay && scope.activeTask) {
hostSummaries = JSON.parse(JSON.stringify(scope.jobData.hostSummaries));
keys = Object.keys(hostSummaries);
if (scope.search_host_summary_name) {
for (key in hostSummaries) {
if (hostSummaries[key].name.indexOf(scope.search_host_summary_name) > 0) {
filteredListA[key] = hostSummaries[key];
}
}
}
else {
filteredListA = hostSummaries;
}
if (scope.search_host_summary_status === 'failed') {
for (key in filteredListA) {
if (filteredListA[key].status === 'failed') {
filteredListB[key] = filteredListA[key];
}
}
}
else {
filteredListB = filteredListA;
}
keys = Object.keys(filteredListB);
keys.sort(function(a,b) {
if (hostSummaries[a].name > hostSummaries[b].name)
if (filteredListB[a].name > filteredListB[b].name)
return 1;
if (hostSummaries[a].name < hostSummaries[b].name)
if (filteredListB[a].name < filteredListB[b].name)
return -1;
// a must be equal to b
return 0;
});
while (idx < keys.length && result.length < scope.hostSummariesMaxRows) {
if (scope.searchAllStatus === 'failed') {
if (hostSummaries[keys[idx]].status === 'failed') {
result.push(hostSummaries[keys[idx]]);
}
}
else {
result.push(hostSummaries[keys[idx]]);
}
result.push(filteredListB[keys[idx]]);
idx++;
}
}
scope.hosts = result;
if (scope.liveEventProcessing) {
scope.$emit('FixHostSummariesScroll');
}
};
}])
.factory('UpdateDOM', ['DrawPlays', 'DrawTasks', 'DrawHostResults', 'DrawHostSummaries', 'DrawGraph',
function(DrawPlays, DrawTasks, DrawHostResults, DrawHostSummaries, DrawGraph) {
return function(params) {
@ -1109,91 +1233,4 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
DrawGraph({ scope: scope, resize: true });
}
};
}])
.factory('FilterAllByHostName', ['Rest', 'GetBasePath', 'ProcessErrors', 'SelectPlay', function(Rest, GetBasePath, ProcessErrors, SelectPlay) {
return function(params) {
var scope = params.scope,
host = params.host,
newActivePlay,
url = scope.job.related.job_events + '?event__icontains=runner&host_name__icontains=' + host + '&parent__isnull=false';
scope.search_all_tasks = [];
scope.search_all_plays = [];
if (scope.removeAllPlaysReady) {
scope.removeAllPlaysReady();
}
scope.removeAllPlaysReady = scope.$on('AllPlaysReady', function() {
if (scope.activePlay) {
setTimeout(function() {
SelectPlay({
scope: scope,
id: newActivePlay
});
}, 500);
}
else {
scope.tasks = [];
scope.hostResults = [];
}
});
if (scope.removeAllTasksReady) {
scope.removeAllTasksReady();
}
scope.removeAllTasksReady = scope.$on('AllTasksReady', function() {
if (scope.search_all_tasks.length > 0) {
url = scope.job.related.job_events + '?id__in=' + scope.search_all_tasks.join();
Rest.setUrl(url);
Rest.get()
.success(function(data) {
if (data.count > 0) {
data.results.forEach(function(row) {
if (row.parent && scope.search_all_plays.indexOf(row.parent) < 0) {
scope.search_all_plays.push(row.parent);
}
});
if (scope.search_all_plays.length > 0) {
scope.search_all_plays.sort();
newActivePlay = scope.search_all_plays[0];
}
else {
newActivePlay = null;
}
}
scope.$emit('AllPlaysReady');
})
.error(function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
}
else {
newActivePlay = null;
scope.search_all_plays.push(0);
scope.$emit('AllPlaysReady');
}
});
Rest.setUrl(url);
Rest.get()
.success(function(data) {
if (data.count > 0) {
data.results.forEach(function(row) {
if (scope.search_all_tasks.indexOf(row.parent) < 0) {
scope.search_all_tasks.push(row.parent);
}
});
if (scope.search_all_tasks.length > 0) {
scope.search_all_tasks.sort();
}
}
scope.$emit('AllTasksReady');
})
.error(function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
};
}]);

View File

@ -15,26 +15,26 @@
<div class="job_well">
<div class="row">
<div class="col-md-12 text-right">
<a href="/#/jobs/{{ job_id }}/stdout" id="view-stdout-button" target="_blank" type="button" class="btn btn-primary btn-xs" aw-tool-tip="View standard out. Opens in new tab or window." data-placement="top"><i class="fa fa-lg fa-external-link"></i></a>
<a href="" ng-click="deleteJob()" id="cancel-job-button" ng-show="job_status.status == 'running'" type="button" class="btn btn-primary btn-xs" aw-tool-tip="Cancel" data-placement="top"><i class="fa fa-lg fa-minus-circle"></i></a>
<a href="" ng-click="deleteJob()" id="delete-job-button" ng-show="job_status.status != 'running'" type="button" class="btn btn-primary btn-xs" aw-tool-tip="Delete" data-placement="top"><i class="fa fa-lg fa-trash-o"></i></a>
<a href="" ng-click="relaunchJob()" id="relaunch-job-button" type="button" class="btn btn-primary btn-xs" aw-tool-tip="Relaunch using the same parameters" data-placement="top"><i class="fa fa-lg fa-rocket"></i></a>
<button type="button" id="summary-button" class="btn btn-primary btn-xs" ng-click="toggleSummary()" aw-tool-tip="View summary" data-placement="top"><i class="fa fa-lg fa-arrow-circle-left fa-lg"></i></button>
<a href="/#/jobs/{{ job_id }}/stdout" id="view-stdout-button" target="_blank" type="button" class="btn btn-primary btn-xs" aw-tool-tip="View standard out. Opens in new tab or window." data-placement="top"><i class="fa fa-external-link"></i></a>
<a href="" ng-click="deleteJob()" id="cancel-job-button" ng-show="job_status.status == 'running'" type="button" class="btn btn-primary btn-xs" aw-tool-tip="Cancel" data-placement="top"><i class="fa fa-minus-circle"></i></a>
<a href="" ng-click="deleteJob()" id="delete-job-button" ng-show="job_status.status != 'running'" type="button" class="btn btn-primary btn-xs" aw-tool-tip="Delete" data-placement="top"><i class="fa fa-trash-o"></i></a>
<a href="" ng-click="relaunchJob()" id="relaunch-job-button" type="button" class="btn btn-primary btn-xs" aw-tool-tip="Relaunch using the same parameters" data-placement="top"><i class="fa fa-rocket"></i></a>
<button type="button" id="summary-button" class="btn btn-primary btn-xs" ng-click="toggleSummary()" aw-tool-tip="View summary" data-placement="top"><i class="fa fa-arrow-circle-left"></i></button>
</div>
</div>
<div class="form-horizontal" role="form" id="job-status-form">
<div class="form-group">
<label class="col-lg-1 col-md-2 col-sm-2 col-xs-3 control-label">Status</label>
<div class="col-lg-11 col-md-10 col-sm-10 col-xs-9">
<label class="col-lg-2 col-md-2 col-sm-2 col-xs-3 control-label">Status</label>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-9">
<i class="fa icon-job-{{ job_status.status }}"></i> {{ job_status.status }} {{ job_status.explanation }}
</div>
</div>
<div class="form-group">
<label class="col-lg-1 col-md-2 col-sm-2 col-xs-3 control-label">Started</label>
<div class="col-lg-11 col-md-10 col-sm-10 col-xs-9">
<label class="col-lg-2 col-md-2 col-sm-2 col-xs-3 control-label">Started</label>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-9">
<div ng-show="job_status.started" id="started-time">{{ job_status.started | date:'MM/dd/yy HH:mm:ss' }}</div>
<div ng-show="job_status.finished" id="finished-time">Finished &nbsp;{{ job_status.finished | date:'MM/dd/yy HH:mm:ss' }}</div>
<div ng-show="job_status.finished" id="elapsed-time">Elapsed &nbsp;{{ job_status.elapsed }}</div>
@ -42,22 +42,22 @@
</div>
<div class="form-group" ng-show="!lessStatus">
<label class="col-lg-1 col-md-2 col-sm-2 col-xs-3 control-label">Template</label>
<div class="col-lg-11 col-md-10 col-sm-10 col-xs-9">
<label class="col-lg-2 col-md-2 col-sm-2 col-xs-3 control-label">Template</label>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-9">
<a href="{{ job_template_url }}" aw-tool-tip="Edit the job template" data-placement="top">{{ job_template_name }}</a>
</div>
</div>
<div class="form-group" ng-show="!lessStatus">
<label class="col-lg-1 col-md-2 col-sm-2 col-xs-3 control-label">Project</label>
<div class="col-lg-11 col-md-10 col-sm-10 col-xs-9">
<label class="col-lg-2 col-md-2 col-sm-2 col-xs-3 control-label">Project</label>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-9">
<a href="{{ project_url }}" aw-tool-tip="Edit the project" data-placement="top">{{ project_name }}</a>
</div>
</div>
<div class="form-group" ng-show="!lessStatus">
<label class="col-lg-1 col-md-2 col-sm-2 col-xs-3 control-label">Inventory</label>
<div class="col-lg-11 col-md-10 col-sm-10 col-xs-9">
<label class="col-lg-2 col-md-2 col-sm-2 col-xs-3 control-label">Inventory</label>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-9">
<a href="{{ inventory_url }}" aw-tool-tip="Edit the inventory" data-placement="top">{{ inventory_name }}</a>
</div>
</div>
@ -79,7 +79,7 @@
<div class="row title-row">
<div class="col-lg-1 col-md-2 col-sm-2 title">Plays</div>
<div class="col-lg-11 col-md-10 col-sm-10" style="text-align:right;">
<form id="play-search-form" class="search-form form-inline">
<div id="play-search-form" class="search-form form-inline">
<div class="form-group">
<label>Search</label>
<div class="search-name" style="display:inline-block; position:relative;">
@ -93,12 +93,12 @@
</div>
<div class="form-group">
<label>Status</label>
<div class="btn-group" aw-toggle-button data-after-toggle="filterByStatus">
<div class="btn-group" aw-toggle-button data-after-toggle="filterPlayStatus">
<button class="btn btn-xs btn-primary active">All</button>
<button class="btn btn-xs btn-default">Failed</button>
</div>
</div>
</form>
</div>
</div>
</div>
@ -111,8 +111,7 @@
</div>
<div id="plays-table-detail" class="table-detail" lr-infinite-scroll="playsScrollDown"
scroll-threshold="10" time-threshold="500">
<div class="row cursor-pointer" ng-repeat="play in playList = (plays | FilterById : search_all_plays | FilterFailedEvents : liveEventProcessing : searchAllStatus) track by $index"
ng-class="play.playActiveClass" ng-click="selectPlay(play.id)">
<div class="row cursor-pointer" ng-repeat="play in plays" ng-class="play.playActiveClass" ng-click="selectPlay(play.id, $event)">
<div class="col-lg-1 col-md-1 col-sm-2 hidden-xs">{{ play.created | date: 'HH:mm:ss' }}</div>
<div class="col-lg-1 col-md-1 hidden-sm hidden-xs" aw-tool-tip="Completed at {{ play.finished | date:'HH:mm:ss' }}"
data-placement="top">{{ play.elapsed }}
@ -136,7 +135,7 @@
<div class="row title-row">
<div class="col-lg-1 col-md-2 col-sm-2 title">Tasks</div>
<div class="col-lg-11 col-md-10 col-sm-10" style="text-align:right;">
<form id="task-search-form" class="search-form form-inline">
<div id="task-search-form" class="search-form form-inline">
<div class="form-group">
<label>Search</label>
<div class="search-name" style="display:inline-block; position:relative;">
@ -150,12 +149,12 @@
</div>
<div class="form-group">
<label>Status</label>
<div class="btn-group" aw-toggle-button data-after-toggle="filterByStatus">
<div class="btn-group" aw-toggle-button data-after-toggle="filterTaskStatus">
<button class="btn btn-xs btn-primary active">All</button>
<button class="btn btn-xs btn-default">Failed</button>
</div>
</div>
</form>
</div>
</div>
</div>
@ -170,7 +169,7 @@
<div id="tasks-table-detail" class="table-detail" lr-infinite-scroll="tasksScrollDown"
scroll-threshold="10" time-threshold="500">
<div class="row cursor-pointer"
ng-repeat="task in taskList = (tasks | FilterById : search_all_tasks | FilterFailedEvents : liveEventProcessing : searchAllStatus) track by $index"
ng-repeat="task in taskList = (tasks) track by $index"
ng-class="task.taskActiveClass" ng-click="selectTask(task.id)">
<div class="col-lg-1 col-md-1 col-sm-2 hidden-xs">{{ task.created | date: 'HH:mm:ss' }}</div>
<div class="col-lg-1 col-md-1 hidden-sm hidden-xs" aw-tool-tip="Completed at {{ task.finished | date:'HH:mm:ss' }}"
@ -198,7 +197,7 @@
<div class="row title-row">
<div class="col-lg-1 col-md-2 col-sm-2 title">Hosts</div>
<div class="col-lg-11 col-md-10 col-sm-10" style="text-align:right;">
<form id="host-search-form" class="search-form form-inline">
<div id="host-search-form" class="search-form form-inline">
<div class="form-group">
<label>Search</label>
<div class="search-name" style="display:inline-block; position:relative;">
@ -212,18 +211,18 @@
</div>
<div class="form-group">
<label>Status</label>
<div class="btn-group" aw-toggle-button data-after-toggle="filterByStatus">
<div class="btn-group" aw-toggle-button data-after-toggle="filterHostStatus">
<button class="btn btn-xs btn-primary active">All</button>
<button class="btn btn-xs btn-default">Failed</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div id="hosts-table-detail" class="table-detail" lr-infinite-scroll="hostResultsScrollDown" scroll-threshold="10" time-threshold="500">
<div id="hosts-table-detail-inner">
<div class="row cursor-pointer" ng-repeat="result in results = (hostResults | filter:{ status : searchAllStatus}) track by $index" ng-click="viewHostResults(result.id)">
<div class="row cursor-pointer" ng-repeat="result in results = (hostResults) track by $index" ng-click="viewHostResults(result.id)">
<div class="col-lg-7 col-md-7 col-sm-7 col-xs-7 status-column">
<a href="" aw-tool-tip="Event ID: {{ result.id }}<br \>Status: {{ result.status_text }}. Click for details" data-placement="top"><i ng-show="result.status_text != 'Unreachable'" class="fa icon-job-{{ result.status }}"></i><i ng-show="result.status_text == 'Unreachable'" class="fa icon-job-unreachable"></i> {{ result.name }}</a>
</div>
@ -250,7 +249,7 @@
<div class="job_well">
<div id="summary-well-top-section">
<div id="hide-summary-button" style="display: hidden;">
<a href="" class="btn btn-xs btn-primary" ng-click="toggleSummary('hide')" aw-tool-tip="Hide summary" data-placement="top"><i class="fa fa-arrow-circle-right fa-lg"></i></a>
<a href="" class="btn btn-xs btn-primary" ng-click="toggleSummary('hide')" aw-tool-tip="Hide summary" data-placement="top"><i class="fa fa-arrow-circle-right"></i></a>
</div>
<div id="hosts-summary-section" class="section job_summary">
@ -258,26 +257,26 @@
<div class="row title-row">
<div class="col-lg-1 col-md-2 col-sm-2 title">Summary</div>
<div class="col-lg-10 col-md-8 col-sm-8" style="text-align:right;">
<form id="task-search-form" class="search-form form-inline">
<div id="task-search-form" class="search-form form-inline">
<div class="form-group">
<label>Search</label>
<div class="search-name" style="display:inline-block; position:relative;">
<input type="text" class="input-xs form-control" id="search_taks_name" ng-model="search_task_name"
placeholder="Task Name" ng-keypress="searchTasksKeyPress($event)" >
<input type="text" class="input-xs form-control" id="search_host_summary_name" ng-model="search_host_summary_name"
placeholder="Host Name" ng-keypress="searchHostSummaryKeyPress($event)" >
<div id="search-all-input-icons">
<a class="search-icon" ng-show="searchTasksEnabled" ng-click="searchTasks()"><i class="fa fa-search"></i></a>
<a class="search-icon" ng-show="!searchTasksEnabled" ng-click="search_task_name=''; searchTasks()"><i class="fa fa-times"></i></a>
<a class="search-icon" ng-show="searchHostSummaryEnabled" ng-click="searchHostSummary()"><i class="fa fa-search"></i></a>
<a class="search-icon" ng-show="!searchHostSummaryEnabled" ng-click="search_host_summary_name=''; searchHostSummary()"><i class="fa fa-times"></i></a>
</div>
</div>
</div>
<div class="form-group">
<label>Status</label>
<div class="btn-group" aw-toggle-button data-after-toggle="filterByStatus">
<div class="btn-group" aw-toggle-button data-after-toggle="filterHostSummaryStatus">
<button class="btn btn-xs btn-primary active">All</button>
<button class="btn btn-xs btn-default">Failed</button>
</div>
</div>
</form>
</div>
</div>
</div>
@ -295,7 +294,7 @@
</div>
</div>
<div id="hosts-summary-table" class="table-detail" lr-infinite-scroll="hostSummariesScrollDown" scroll-threshold="10" time-threshold="500">
<div class="row" ng-repeat="host in summaryList = (hosts | filter:{ status : searchAllStatus}) track by $index" id="{{ host.id }}">
<div class="row" ng-repeat="host in summaryList = (hosts) track by $index" id="{{ host.id }}">
<div class="name col-lg-6 col-md-6 col-sm-6 col-xs-6">
<a href="" ng-click="hostEventsViewer(host.id, host.name)" aw-tool-tip="View all events for this host"
data-placement="top">{{ host.name }}</a>