Session Expired -job detail page

For reasons yet to be determined the status field on job_tasks and possibly job_plays may contain 'Token is expired' rather than a numeric return code (i.e. 400, 401, 403, etc.). Changed process_errors to look for this condition and trigger session timeout behavior.
This commit is contained in:
Chris Houseknecht
2014-07-11 14:48:01 -04:00
parent a7c0c362c3
commit a565c72f9f
4 changed files with 88 additions and 50 deletions

View File

@@ -322,9 +322,9 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
task: play.tasks[event.id] task: play.tasks[event.id]
}); });
}); });
if (scope.activeTask) { //if (scope.activeTask) {
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active'; // scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active';
} //}
scope.$emit('LoadHosts'); scope.$emit('LoadHosts');
}) })
.error(function(data) { .error(function(data) {

View File

@@ -24,6 +24,10 @@ angular.module('EventsViewerFormDefinition', [])
label: 'Host', label: 'Host',
section: 'Event' section: 'Event'
}, },
role: {
label: 'Role',
section: 'Event'
},
play: { play: {
label: 'Play', label: 'Play',
type: 'text', type: 'text',
@@ -33,8 +37,12 @@ angular.module('EventsViewerFormDefinition', [])
label: 'Task', label: 'Task',
section: 'Event' section: 'Event'
}, },
role: { module_name: {
label: 'Role', label: 'Module',
section: 'Event'
},
module_args: {
label: 'Arguments',
section: 'Event' section: 'Event'
}, },
rc: { rc: {
@@ -60,14 +68,6 @@ angular.module('EventsViewerFormDefinition', [])
delta: { delta: {
label: 'Elapsed', label: 'Elapsed',
section: 'Timing' section: 'Timing'
},
module_name: {
label: 'Name',
section: 'Module'
},
module_args: {
label: 'Arguments',
section: 'Module'
} }
} }
}); });

View File

@@ -40,9 +40,9 @@
angular.module('JobDetailHelper', ['Utilities', 'RestServices', 'ModalDialog']) angular.module('JobDetailHelper', ['Utilities', 'RestServices', 'ModalDialog'])
.factory('DigestEvent', ['$rootScope', '$log', 'UpdatePlayStatus', 'UpdateHostStatus', 'AddHostResult', .factory('DigestEvent', ['$rootScope', '$log', 'UpdatePlayStatus', 'UpdateHostStatus', 'AddHostResult',
'GetElapsed', 'UpdateTaskStatus', 'DrawGraph', 'LoadHostSummary', 'JobIsFinished', 'AddNewTask', 'GetElapsed', 'UpdateTaskStatus', 'DrawGraph', 'LoadHostSummary', 'JobIsFinished', 'AddNewTask', 'AddNewPlay',
function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, GetElapsed, function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, GetElapsed,
UpdateTaskStatus, DrawGraph, LoadHostSummary, JobIsFinished, AddNewTask) { UpdateTaskStatus, DrawGraph, LoadHostSummary, JobIsFinished, AddNewTask, AddNewPlay) {
return function(params) { return function(params) {
var scope = params.scope, var scope = params.scope,
@@ -60,27 +60,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
break; break;
case 'playbook_on_play_start': case 'playbook_on_play_start':
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful'; AddNewPlay({ scope: scope, event: event });
status_text = (event.failed) ? 'Failed' : (event.changed) ? 'Changed' : 'OK';
scope.jobData.plays[event.id] = {
id: event.id,
name: event.play,
created: event.created,
status: status,
status_text: status_text,
elapsed: '00:00:00',
hostCount: 0,
fistTask: null,
unreachableCount: 0,
status_tip: "Event ID: " + event.id + "<br />Status: " + status_text,
tasks: {}
};
if (scope.activePlay) {
scope.jobData.plays[scope.activePlay].tasks = {};
scope.jobData.plays[scope.activePlay].playActiveClass = '';
}
scope.activePlay = event.id;
scope.jobData.plays[scope.activePlay].playActiveClass = 'active';
break; break;
case 'playbook_on_setup': case 'playbook_on_setup':
@@ -206,19 +186,65 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
}; };
}]) }])
.factory('AddNewTask', ['DrawGraph', 'UpdatePlayStatus', function(DrawGraph, UpdatePlayStatus) { .factory('AddNewPlay', [ function() {
return function(params) { return function(params) {
var scope = params.scope, var scope = params.scope,
event = params.event, event = params.event,
status, status_text; status, status_text, activeList, newActivePlay, key;
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful'; status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
status_text = (event.failed) ? 'Failed' : (event.changed) ? 'Changed' : 'OK'; status_text = (event.failed) ? 'Failed' : (event.changed) ? 'Changed' : 'OK';
scope.jobData.plays[scope.activePlay].tasks[event.id] = { scope.jobData.plays[event.id] = {
id: event.id,
name: event.play,
created: event.created,
status: status,
status_text: status_text,
elapsed: '00:00:00',
hostCount: 0,
taskCount: 0,
fistTask: null,
unreachableCount: 0,
status_tip: "Event ID: " + event.id + "<br />Status: " + status_text,
tasks: {}
};
//find the most recent task in the list of 'active' tasks
activeList = [];
for (key in scope.jobData.play) {
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) {
newActivePlay = scope.plays[scope.activeList[scope.activeList.length - 1]].id;
if (scope.activePlay && newActivePlay !== scope.activePlay) {
scope.jobData.plays[scope.activePlay].tasks = {};
scope.jobData.plays[scope.activePlay].playActiveClass = '';
}
scope.activePlay = newActivePlay;
scope.jobData.plays[scope.activePlay].playActiveClass = 'active';
}
};
}])
.factory('AddNewTask', ['DrawGraph', 'UpdatePlayStatus', function(DrawGraph, UpdatePlayStatus) {
return function(params) {
var scope = params.scope,
event = params.event,
status, status_text,
activeList, newActiveTask, key;
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
status_text = (event.failed) ? 'Failed' : (event.changed) ? 'Changed' : 'OK';
scope.jobData.plays[event.parent].tasks[event.id] = {
id: event.id, id: event.id,
play_id: event.parent, play_id: event.parent,
name: event.event_display, name: event.task,
status: status, status: status,
status_text: status_text, status_text: status_text,
status_tip: "Event ID: " + event.id + "<br />Status: " + status_text, status_tip: "Event ID: " + event.id + "<br />Status: " + status_text,
@@ -243,12 +269,24 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
scope.jobData.plays[scope.activePlay].firstTask = event.id; scope.jobData.plays[scope.activePlay].firstTask = event.id;
} }
if (scope.activeTask && scope.jobData.plays[scope.activePlay].tasks[scope.activeTask] !== undefined) { //find the most recent task in the list of 'active' tasks
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = ''; activeList = [];
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].hostResults = {}; for (key in scope.jobData.plays[scope.activePlay].tasks) {
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
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 = '';
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].hostResults = {};
}
}
scope.activeTask = newActiveTask;
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active';
} }
scope.activeTask = event.id;
scope.jobData.plays[scope.activePlay].tasks[scope.activeTask].taskActiveClass = 'active';
UpdatePlayStatus({ UpdatePlayStatus({
scope: scope, scope: scope,
@@ -257,10 +295,6 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
changed: event.changed, changed: event.changed,
modified: event.modified modified: event.modified
}); });
/*if (scope.host_summary.total > 0) {
DrawGraph({ scope: scope, resize: true });
}*/
}; };
}]) }])
@@ -318,6 +352,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
play.status_text = (changed) ? 'Changed' : (failed) ? 'Failed' : 'OK'; play.status_text = (changed) ? 'Changed' : (failed) ? 'Failed' : 'OK';
} }
} }
play.taskCount++;
play.status_tip = "Event ID: " + play.id + "<br />Status: " + play.status_text; play.status_tip = "Event ID: " + play.id + "<br />Status: " + play.status_text;
play.finished = modified; play.finished = modified;
play.elapsed = GetElapsed({ play.elapsed = GetElapsed({
@@ -612,6 +647,9 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
}); });
}); });
if (scope.liveEventProcessing) {
}
// set the active task // set the active task
SelectPlay({ SelectPlay({
scope: scope, scope: scope,

View File

@@ -154,7 +154,7 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
msg += 'Please contact your system administrator.'; msg += 'Please contact your system administrator.';
} }
Alert(defaultMsg.hdr, msg); Alert(defaultMsg.hdr, msg);
} else if ((status === 401 && data.detail && data.detail === 'Token is expired') || } else if ((status === 'Token is expired') || (status === 401 && data.detail && data.detail === 'Token is expired') ||
(status === 401 && data.detail && data.detail === 'Invalid token')) { (status === 401 && data.detail && data.detail === 'Invalid token')) {
$rootScope.sessionTimer.expireSession(); $rootScope.sessionTimer.expireSession();
$location.url('/login'); $location.url('/login');