mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Job stdout sockets and menu title
Added monitoring and restart of the socket connections on the stdout page. Added a title to the main nav that displays when the menu collapses.
This commit is contained in:
@@ -442,13 +442,23 @@ angular.module('Tower', [
|
|||||||
|
|
||||||
function activateTab() {
|
function activateTab() {
|
||||||
// Make the correct tab active
|
// Make the correct tab active
|
||||||
var base = $location.path().replace(/^\//, '').split('/')[0];
|
var base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
urlDepth = $location.path().replace(/^\//, '').split('/').length;
|
||||||
|
|
||||||
if (base === '') {
|
if (base === '') {
|
||||||
base = 'home';
|
base = 'home';
|
||||||
} else {
|
} else {
|
||||||
//base.replace(/\_/g, ' ');
|
//base.replace(/\_/g, ' ');
|
||||||
base = (base === 'job_events' || base === 'job_host_summaries') ? 'jobs' : base;
|
base = (base === 'job_events' || base === 'job_host_summaries') ? 'jobs' : base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (urlDepth === 1 && base !== 'home') {
|
||||||
|
$('#ansible-list-title').html('<strong>' + base.replace(/\_/,' ') + '</strong>');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#ansible-list-title').empty();
|
||||||
|
}
|
||||||
|
|
||||||
$('#ansible-main-menu li').each(function() {
|
$('#ansible-main-menu li').each(function() {
|
||||||
$(this).removeClass('active');
|
$(this).removeClass('active');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,44 +25,65 @@ function JobStdoutController ($log, $rootScope, $scope, $compile, $routeParams,
|
|||||||
page_size = 500,
|
page_size = 500,
|
||||||
lastScrollTop = 0,
|
lastScrollTop = 0,
|
||||||
st,
|
st,
|
||||||
direction;
|
direction,
|
||||||
|
checkCount = 0;;
|
||||||
|
|
||||||
status_socket = Socket({
|
|
||||||
scope: $scope,
|
function openSockets() {
|
||||||
endpoint: "jobs"
|
status_socket = Socket({
|
||||||
});
|
scope: $scope,
|
||||||
status_socket.init();
|
endpoint: "jobs"
|
||||||
status_socket.on("status_changed", function(data) {
|
});
|
||||||
if (parseInt(data.unified_job_id, 10) === parseInt(job_id,10) && $scope.job) {
|
status_socket.init();
|
||||||
$scope.job.status = data.status;
|
status_socket.on("status_changed", function(data) {
|
||||||
if (data.status === 'failed' || data.status === 'canceled' ||
|
if (parseInt(data.unified_job_id, 10) === parseInt(job_id,10) && $scope.job) {
|
||||||
data.status === 'error' || data.status === 'successful') {
|
$scope.job.status = data.status;
|
||||||
if ($rootScope.jobStdOutInterval) {
|
if (data.status === 'failed' || data.status === 'canceled' ||
|
||||||
window.clearInterval($rootScope.jobStdOutInterval);
|
data.status === 'error' || data.status === 'successful') {
|
||||||
}
|
if ($rootScope.jobStdOutInterval) {
|
||||||
if (live_event_processing) {
|
window.clearInterval($rootScope.jobStdOutInterval);
|
||||||
if (loaded_sections.length === 0) {
|
|
||||||
$scope.$emit('LoadStdout');
|
|
||||||
}
|
}
|
||||||
else {
|
if (live_event_processing) {
|
||||||
getNextSection();
|
if (loaded_sections.length === 0) {
|
||||||
|
$scope.$emit('LoadStdout');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getNextSection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
live_event_processing = false;
|
||||||
}
|
}
|
||||||
live_event_processing = false;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
event_socket = Socket({
|
||||||
|
scope: $scope,
|
||||||
|
endpoint: "job_events"
|
||||||
|
});
|
||||||
|
event_socket.init();
|
||||||
|
event_socket.on("job_events-" + job_id, function() {
|
||||||
|
if (api_complete) {
|
||||||
|
event_queue++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
openSockets();
|
||||||
|
|
||||||
event_socket = Socket({
|
$rootScope.checkSocketConnectionInterval = setInterval(function() {
|
||||||
scope: $scope,
|
if (status_socket.checkStatus() === 'error' || checkCount > 2) {
|
||||||
endpoint: "job_events"
|
// there's an error or we're stuck in a 'connecting' state. attempt to reconnect
|
||||||
});
|
$log.debug('stdout page: initializing and restarting socket connections');
|
||||||
event_socket.init();
|
status_socket = null;
|
||||||
event_socket.on("job_events-" + job_id, function() {
|
event_socket = null;
|
||||||
if (api_complete) {
|
openSockets();
|
||||||
event_queue++;
|
checkCount = 0;
|
||||||
}
|
}
|
||||||
});
|
else if (status_socket.checkStatus() === 'connecting') {
|
||||||
|
checkCount++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
checkCount = 0;
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
$rootScope.jobStdOutInterval = setInterval( function() {
|
$rootScope.jobStdOutInterval = setInterval( function() {
|
||||||
if (event_queue > 0) {
|
if (event_queue > 0) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function JobsListController ($rootScope, $log, $scope, $compile, $routeParams, C
|
|||||||
api_complete = false,
|
api_complete = false,
|
||||||
schedule_socket,
|
schedule_socket,
|
||||||
job_socket,
|
job_socket,
|
||||||
max_rows, checkCount;
|
max_rows, checkCount=0;
|
||||||
|
|
||||||
function openSockets() {
|
function openSockets() {
|
||||||
job_socket = Socket({
|
job_socket = Socket({
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ html {
|
|||||||
body {
|
body {
|
||||||
font-family: 'Open Sans', sans-serif;
|
font-family: 'Open Sans', sans-serif;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
padding-top: 60px;
|
padding-top: 75px;
|
||||||
color: @black;
|
color: @black;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +46,10 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ansible-list-title {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#content-container {
|
#content-container {
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
}
|
}
|
||||||
@@ -73,6 +77,14 @@ body {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ansible-list-title {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
left: 10px;
|
||||||
|
color: @black;
|
||||||
|
text-transform:capitalize;
|
||||||
|
}
|
||||||
#account-menu {
|
#account-menu {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
<link rel="stylesheet" href="{{ STATIC_URL }}lib/codemirror/lib/codemirror.css" />
|
<link rel="stylesheet" href="{{ STATIC_URL }}lib/codemirror/lib/codemirror.css" />
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}lib/codemirror/theme/elegant.css" />
|
<link rel="stylesheet" href="{{ STATIC_URL }}lib/codemirror/theme/elegant.css" />
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}lib/codemirror/addon/lint/lint.css" />
|
<link rel="stylesheet" href="{{ STATIC_URL }}lib/codemirror/addon/lint/lint.css" />
|
||||||
<!-- link rel="stylesheet" href="{{ STATIC_URL }}lib/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css" -->
|
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}lib/novus-nvd3/nv.d3.css" type="text/css">
|
<link rel="stylesheet" href="{{ STATIC_URL }}lib/novus-nvd3/nv.d3.css" type="text/css">
|
||||||
|
|
||||||
{% if settings.USE_MINIFIED_JS %}
|
{% if settings.USE_MINIFIED_JS %}
|
||||||
@@ -199,10 +198,11 @@
|
|||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="#home"><img id="ansible-brand-logo" src="{{ STATIC_URL }}img/tower2-logominimal.png" /></a>
|
<a class="navbar-brand" href="#home"><img id="ansible-brand-logo" src="{{ STATIC_URL }}img/tower2-logominimal.png" /></a>
|
||||||
|
<div id="ansible-list-title"></div> <!-- title to show on list pages when menu collapses. value set in app.js -->
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-collapse collapse" id="main-navbar-collapse">
|
<div class="navbar-collapse collapse" id="main-navbar-collapse">
|
||||||
<ul class="nav navbar-nav" id="ansible-main-menu">
|
<ul class="nav navbar-nav" id="ansible-main-menu">
|
||||||
<!--<li id="home" class="active"><a href="#home" id="main_home_link" >Home</a></li>-->
|
<!-- <li id="home" class="active"><a href="#home" id="main_home_link" >Home</a></li> -->
|
||||||
<li id="organizations"><a href="#organizations" id="main_organizations_link">Organizations</a></li>
|
<li id="organizations"><a href="#organizations" id="main_organizations_link">Organizations</a></li>
|
||||||
<li id="users"><a href="#users" id="main_users_link">Users</a></li>
|
<li id="users"><a href="#users" id="main_users_link">Users</a></li>
|
||||||
<li id="teams"><a href="#teams" id="main_teams_link">Teams</a></li>
|
<li id="teams"><a href="#teams" id="main_teams_link">Teams</a></li>
|
||||||
|
|||||||
Reference in New Issue
Block a user