fix: make sure to refresh cache when leaving a page while there is a running backup

parent 29557082
Pipeline #1412 failed with stages
in 3 minutes and 38 seconds
......@@ -117,7 +117,7 @@ class Counters(Resource):
self.abort(403, "Not allowed to view '{}' counters".format(client))
running = bui.client.is_one_backup_running()
if isinstance(running, dict):
if server and client not in bui.client.running[server]:
if server and client not in running[server]:
self.abort(404, "'{}' not found in the list of running clients for '{}'".format(client, server))
else:
found = False
......@@ -375,29 +375,52 @@ class About(Resource):
def get(self, server=None):
"""Returns various informations about Burp-UI"""
args = self.parser.parse_args()
r = {}
res = {}
server = server or args['serverName']
r['version'] = api.version
r['release'] = api.release
r['api'] = url_for('api.doc')
r['burp'] = []
res['version'] = api.version
res['release'] = api.release
res['api'] = url_for('api.doc')
res['burp'] = []
cli = bui.client.get_client_version(server)
srv = bui.client.get_server_version(server)
multi = {}
if isinstance(cli, dict):
for (name, v) in iteritems(cli):
multi[name] = {'client': v}
for (name, val) in iteritems(cli):
multi[name] = {'client': val}
if isinstance(srv, dict):
for (name, v) in iteritems(srv):
multi[name]['server'] = v
for (name, val) in iteritems(srv):
multi[name]['server'] = val
if not multi:
r['burp'].append({'client': cli, 'server': srv})
res['burp'].append({'client': cli, 'server': srv})
else:
for (name, v) in iteritems(multi):
a = v
a.update({'name': name})
r['burp'].append(a)
return r
for (name, val) in iteritems(multi):
tmp = val
tmp.update({'name': name})
res['burp'].append(tmp)
return res
@ns.route('/ping', endpoint='ping')
class Ping(Resource):
"""The :class:`burpui.api.misc.Ping` resource allows you to ping the API.
It is actually a Dummy endpoint that does nothing"""
# Login not required on this view
login_required = False
ping_fields = ns.model('Ping', {
'alive': fields.Boolean(required=True, description="API alive?"),
})
@ns.marshal_list_with(ping_fields, code=200, description='Success')
@ns.doc(
responses={
200: 'Success',
403: 'Insufficient permissions',
},
)
def get(self):
"""Tells if the API is alive"""
return {'alive': True}
@ns.route('/history',
......
......@@ -11,6 +11,7 @@ import re
import math
import uuid
from six import iteritems
from flask import request, render_template, redirect, url_for, abort, \
flash, Blueprint, session, current_app, g
from flask_login import login_user, login_required, logout_user, current_user
......
......@@ -504,7 +504,16 @@ $(function() {
return;
}
if (!$(this).closest('table').hasClass('collapsed')) {
window.location = $(this).find('a').attr('href');
var $that = $(this);
var callback = function() {
window.location = $that.find('a').attr('href');
};
if (typeof __refresh_running !== "undefined") {
_cache_id = new Date().getTime();
$.getJSON('{{ url_for("api.ping") }}', callback);
} else {
callback();
}
}
});
$( document ).on('click', 'td.child', function(e) {
......@@ -514,7 +523,23 @@ $(function() {
}
$before = $(this).parent().prev();
if ($before.hasClass('clickable')) {
window.location = $before.find('a').attr('href');
var callback = function() {
window.location = $before.find('a').attr('href');
};
if (typeof __refresh_running !== "undefined") {
_cache_id = new Date().getTime();
$.getJSON('{{ url_for("api.ping") }}', callback);
} else {
callback();
}
}
});
$( document ).on('click', 'a', function(e) {
if (typeof __refresh_running !== "undefined") {
e.preventDefault();
var target = this.href;
_cache_id = new Date().getTime();
$.getJSON('{{ url_for("api.ping") }}', function() { window.location = target; });
}
});
......
......@@ -255,6 +255,7 @@ var refresh_status = function( is_running ) {
var _inner_callback_setup = function() {
if (__refresh_running) {
clearTimeout(__refresh_running);
__refresh_running = undefined;
}
if (_client_running) {
__refresh_running = setTimeout(function() {
......
......@@ -254,6 +254,7 @@ var refresh_status = function( is_running ) {
if (_clients_running.length > 0) {
if (__refresh_running) {
clearTimeout(__refresh_running);
__refresh_running = undefined;
}
__refresh_running = setTimeout(function() {
refresh_status(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment