mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
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:
parent
a7c0c362c3
commit
a565c72f9f
@ -322,9 +322,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) {
|
||||
|
||||
@ -24,6 +24,10 @@ angular.module('EventsViewerFormDefinition', [])
|
||||
label: 'Host',
|
||||
section: 'Event'
|
||||
},
|
||||
role: {
|
||||
label: 'Role',
|
||||
section: 'Event'
|
||||
},
|
||||
play: {
|
||||
label: 'Play',
|
||||
type: 'text',
|
||||
@ -33,8 +37,12 @@ angular.module('EventsViewerFormDefinition', [])
|
||||
label: 'Task',
|
||||
section: 'Event'
|
||||
},
|
||||
role: {
|
||||
label: 'Role',
|
||||
module_name: {
|
||||
label: 'Module',
|
||||
section: 'Event'
|
||||
},
|
||||
module_args: {
|
||||
label: 'Arguments',
|
||||
section: 'Event'
|
||||
},
|
||||
rc: {
|
||||
@ -60,14 +68,6 @@ angular.module('EventsViewerFormDefinition', [])
|
||||
delta: {
|
||||
label: 'Elapsed',
|
||||
section: 'Timing'
|
||||
},
|
||||
module_name: {
|
||||
label: 'Name',
|
||||
section: 'Module'
|
||||
},
|
||||
module_args: {
|
||||
label: 'Arguments',
|
||||
section: 'Module'
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -40,9 +40,9 @@
|
||||
angular.module('JobDetailHelper', ['Utilities', 'RestServices', 'ModalDialog'])
|
||||
|
||||
.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,
|
||||
UpdateTaskStatus, DrawGraph, LoadHostSummary, JobIsFinished, AddNewTask) {
|
||||
UpdateTaskStatus, DrawGraph, LoadHostSummary, JobIsFinished, AddNewTask, AddNewPlay) {
|
||||
return function(params) {
|
||||
|
||||
var scope = params.scope,
|
||||
@ -60,27 +60,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
||||
break;
|
||||
|
||||
case 'playbook_on_play_start':
|
||||
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
|
||||
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';
|
||||
AddNewPlay({ scope: scope, event: event });
|
||||
break;
|
||||
|
||||
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) {
|
||||
var scope = params.scope,
|
||||
event = params.event,
|
||||
status, status_text;
|
||||
status, status_text, activeList, newActivePlay, key;
|
||||
|
||||
status = (event.failed) ? 'failed' : (event.changed) ? 'changed' : 'successful';
|
||||
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,
|
||||
play_id: event.parent,
|
||||
name: event.event_display,
|
||||
name: event.task,
|
||||
status: status,
|
||||
status_text: 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;
|
||||
}
|
||||
|
||||
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 = {};
|
||||
//find the most recent task in the list of 'active' tasks
|
||||
activeList = [];
|
||||
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({
|
||||
scope: scope,
|
||||
@ -257,10 +295,6 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
||||
changed: event.changed,
|
||||
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.taskCount++;
|
||||
play.status_tip = "Event ID: " + play.id + "<br />Status: " + play.status_text;
|
||||
play.finished = modified;
|
||||
play.elapsed = GetElapsed({
|
||||
@ -612,6 +647,9 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge
|
||||
});
|
||||
});
|
||||
|
||||
if (scope.liveEventProcessing) {
|
||||
|
||||
}
|
||||
// set the active task
|
||||
SelectPlay({
|
||||
scope: scope,
|
||||
|
||||
@ -154,7 +154,7 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
||||
msg += 'Please contact your system administrator.';
|
||||
}
|
||||
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')) {
|
||||
$rootScope.sessionTimer.expireSession();
|
||||
$location.url('/login');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user