mirror of
https://github.com/ansible/awx.git
synced 2026-05-21 07:47:44 -02:30
Fixes issue with sockets and XHR requests for backgrounded tabs
adjusts toggling based on API setting and doesn't toggle for job stdout page
This commit is contained in:
@@ -8,7 +8,8 @@ export default
|
|||||||
['$rootScope', '$location', '$log','$state', '$q', 'i18n',
|
['$rootScope', '$location', '$log','$state', '$q', 'i18n',
|
||||||
function ($rootScope, $location, $log, $state, $q, i18n) {
|
function ($rootScope, $location, $log, $state, $q, i18n) {
|
||||||
var needsResubscribing = false,
|
var needsResubscribing = false,
|
||||||
socketPromise = $q.defer();
|
socketPromise = $q.defer(),
|
||||||
|
needsRefreshAfterBlur;
|
||||||
return {
|
return {
|
||||||
init: function() {
|
init: function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
@@ -24,6 +25,26 @@ export default
|
|||||||
}
|
}
|
||||||
url = `${protocol}://${host}/websocket/`;
|
url = `${protocol}://${host}/websocket/`;
|
||||||
|
|
||||||
|
// only toggle background tabbed sockets if the
|
||||||
|
// UI_LIVE_UPDATES_ENABLED flag is true in the settings file
|
||||||
|
if(window.liveUpdates){
|
||||||
|
document.addEventListener('visibilitychange', function() {
|
||||||
|
$log.debug(document.visibilityState);
|
||||||
|
if(document.visibilityState === 'hidden'){
|
||||||
|
window.liveUpdates = false;
|
||||||
|
}
|
||||||
|
else if(document.visibilityState === 'visible'){
|
||||||
|
window.liveUpdates = true;
|
||||||
|
if(needsRefreshAfterBlur){
|
||||||
|
$state.go('.', null, {reload: true});
|
||||||
|
needsRefreshAfterBlur = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$rootScope.sessionTimer || ($rootScope.sessionTimer && !$rootScope.sessionTimer.isExpired())) {
|
if (!$rootScope.sessionTimer || ($rootScope.sessionTimer && !$rootScope.sessionTimer.isExpired())) {
|
||||||
|
|
||||||
$log.debug('Socket connecting to: ' + url);
|
$log.debug('Socket connecting to: ' + url);
|
||||||
@@ -75,6 +96,13 @@ export default
|
|||||||
$log.debug('Received From Server: ' + e.data);
|
$log.debug('Received From Server: ' + e.data);
|
||||||
|
|
||||||
var data = JSON.parse(e.data), str = "";
|
var data = JSON.parse(e.data), str = "";
|
||||||
|
|
||||||
|
if(!window.liveUpdates && data.group_name !== "control" && $state.current.name !== "jobResult"){
|
||||||
|
$log.debug('Message from server dropped: ' + e.data);
|
||||||
|
needsRefreshAfterBlur = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(data.group_name==="jobs" && !('status' in data)){
|
if(data.group_name==="jobs" && !('status' in data)){
|
||||||
// we know that this must have been a
|
// we know that this must have been a
|
||||||
// summary complete message b/c status is missing.
|
// summary complete message b/c status is missing.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<link rel="shortcut icon" href="{{ STATIC_URL }}assets/favicon.ico?v={{version}}" />
|
<link rel="shortcut icon" href="{{ STATIC_URL }}assets/favicon.ico?v={{version}}" />
|
||||||
<script>
|
<script>
|
||||||
var $basePath = "{{ STATIC_URL }}";
|
var $basePath = "{{ STATIC_URL }}";
|
||||||
var $liveUpdates = "{{ UI_LIVE_UPDATES_ENABLED }}";
|
window.liveUpdates = "{{ UI_LIVE_UPDATES_ENABLED }}" === "False" ? false : true;
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ STATIC_URL }}app.vendor.js?v={{version}}"></script>
|
<script src="{{ STATIC_URL }}app.vendor.js?v={{version}}"></script>
|
||||||
<script src="{{ STATIC_URL }}app.js?v={{version}}"></script>
|
<script src="{{ STATIC_URL }}app.js?v={{version}}"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user