mirror of
https://github.com/ziirish/burp-ui.git
synced 2026-05-21 06:45:24 -06:00
fix: wrong behavior of the live monitor view
This commit is contained in:
parent
bc99d6de4b
commit
9459aef1ed
8 changed files with 60 additions and 31 deletions
|
|
@ -109,6 +109,8 @@ var notif = function(type, message, timeout) {
|
|||
i = '<i class="fa fa-fw fa-exclamation-circle" aria-hidden="true"></i> ';
|
||||
break;
|
||||
case NOTIF_INFO:
|
||||
t = 'info';
|
||||
i = '<i class="fa fa-fw fa-info-circle" aria-hidden="true"></i> ';
|
||||
default:
|
||||
t = 'info';
|
||||
i = '<i class="fa fa-fw fa-info-circle" aria-hidden="true"></i> ';
|
||||
|
|
@ -131,6 +133,9 @@ var anim = function(elem, timeout) {
|
|||
};
|
||||
|
||||
var errorsHandler = function(json) {
|
||||
if (!json) {
|
||||
return false;
|
||||
}
|
||||
if ('notif' in json) {
|
||||
message = json.notif;
|
||||
} else if ('message' in json) {
|
||||
|
|
@ -429,7 +434,7 @@ var cancel_refresh = function() {
|
|||
auto_refresh = undefined;
|
||||
}
|
||||
}
|
||||
var auto_refresh_function = function() {
|
||||
var auto_refresh_function = function(oneshot) {
|
||||
{% if clients -%}
|
||||
_clients();
|
||||
{% endif -%}
|
||||
|
|
@ -439,8 +444,10 @@ var auto_refresh_function = function() {
|
|||
{% if servers and overview -%}
|
||||
_servers();
|
||||
{% endif -%}
|
||||
cancel_refresh()
|
||||
schedule_refresh();
|
||||
if (!oneshot) {
|
||||
cancel_refresh()
|
||||
schedule_refresh();
|
||||
}
|
||||
};
|
||||
{% endif -%}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ var __icons = {
|
|||
|
||||
{{ macros.timestamp_filter() }}
|
||||
|
||||
var __init_complete = false;
|
||||
var _client_table = $('#table-client').DataTable( {
|
||||
{{ macros.translate_datatable() }}
|
||||
{{ macros.get_page_length() }}
|
||||
|
|
@ -97,6 +98,9 @@ var _client_table = $('#table-client').DataTable( {
|
|||
rowCallback: function( row, data ) {
|
||||
row.className += ' clickable';
|
||||
},
|
||||
initComplete: function ( settings, json ) {
|
||||
__init_complete = true;
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
data: null,
|
||||
|
|
@ -156,6 +160,9 @@ var _client_table = $('#table-client').DataTable( {
|
|||
var first = true;
|
||||
|
||||
var _client = function() {
|
||||
if (!__init_complete) {
|
||||
return;
|
||||
}
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
|
|
@ -255,7 +262,9 @@ var refresh_status = function( is_running ) {
|
|||
}, {{ config.LIVEREFRESH * 1000 }});
|
||||
} else {
|
||||
_cache_id = new Date().getTime();
|
||||
auto_refresh_function();
|
||||
if (__init_complete && is_running) {
|
||||
auto_refresh_function(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (_get_running) {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ var _cache_id = _EXTRA;
|
|||
|
||||
{{ macros.timestamp_filter() }}
|
||||
|
||||
var __init_complete = false;
|
||||
var _clients_table = $('#table-clients').DataTable( {
|
||||
{{ macros.translate_datatable() }}
|
||||
{{ macros.get_page_length() }}
|
||||
|
|
@ -98,6 +99,9 @@ var _clients_table = $('#table-clients').DataTable( {
|
|||
}
|
||||
row.className += ' clickable';
|
||||
},
|
||||
initComplete: function( settings, json ) {
|
||||
__init_complete = true;
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
data: 'name',
|
||||
|
|
@ -176,6 +180,9 @@ var _clients_table = $('#table-clients').DataTable( {
|
|||
var first = true;
|
||||
|
||||
var _clients = function() {
|
||||
if (!__init_complete) {
|
||||
return;
|
||||
}
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
|
|
@ -253,7 +260,9 @@ var refresh_status = function( is_running ) {
|
|||
}, {{ config.LIVEREFRESH * 1000 }});
|
||||
} else {
|
||||
_cache_id = new Date().getTime();
|
||||
auto_refresh_function();
|
||||
if (__init_complete && is_running) {
|
||||
auto_refresh_function(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ app.controller('LiveCtrl', function($scope, $http, $timeout) {
|
|||
}
|
||||
};
|
||||
|
||||
var last_status = 404;
|
||||
$scope.load = function() {
|
||||
$http.get(counters, { headers: { 'X-From-UI': true } })
|
||||
.then(function(response) {
|
||||
|
|
@ -60,23 +61,26 @@ app.controller('LiveCtrl', function($scope, $http, $timeout) {
|
|||
$scope.clients = [];
|
||||
$scope.clients.push(data);
|
||||
}
|
||||
if (status === 404) {
|
||||
if ($scope.clients.length == 0) {
|
||||
var message = "{{ _('No more backup running') }}";
|
||||
$scope.stopTimer();
|
||||
notif(NOTIF_INFO, "{{ _('Backup complete. Will redirect you in 5 seconds') }}");
|
||||
$timeout(function() {
|
||||
$http.post('{{ url_for("api.alert") }}', {'message': message}, { headers: { 'X-From-UI': true } })
|
||||
.then(function(response2) {
|
||||
document.location = '{{ url_for("view.home") }}';
|
||||
}, 5000);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if ($scope.clients.length == 0) {
|
||||
$http.post('{{ url_for("api.alert") }}', {'message': "{{ _('No more backup running') }}"}, { headers: { 'X-From-UI': true } });
|
||||
document.location = '{{ url_for("view.home") }}';
|
||||
}
|
||||
last_status = response.status;
|
||||
timer = $timeout($scope.load, {{ config.LIVEREFRESH * 1000 }});
|
||||
}, function(response) {
|
||||
var data = response.data;
|
||||
$scope.stopTimer();
|
||||
errorsHandler(data);
|
||||
if (response.status === 404 && response.status !== last_status) {
|
||||
$scope.stopTimer();
|
||||
notif(NOTIF_INFO, "{{ _('Backup complete') }}");
|
||||
} else {
|
||||
errorsHandler(data);
|
||||
}
|
||||
notif(NOTIF_INFO, "{{ _('Will redirect you in 5 seconds') }}");
|
||||
$timeout(function() {
|
||||
document.location = '{{ url_for("view.home") }}';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
{% include "notifications.html" %}
|
||||
<div class="main">
|
||||
<ul class="breadcrumb" style="margin-bottom: 5px;">
|
||||
<li><a href="{{ url_for('view.home') }}">{{ _('Home') }}</a></li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue