mirror of
https://github.com/ziirish/burp-ui.git
synced 2026-05-21 06:45:24 -06:00
add: notification system
This commit is contained in:
parent
c6fa1b4911
commit
b05912386e
15 changed files with 163 additions and 23 deletions
|
|
@ -101,8 +101,8 @@ def client_tree(name=None, backup=None):
|
|||
try:
|
||||
j = bui.cli.get_tree(name, backup, root)
|
||||
except BUIserverException, e:
|
||||
err = [str(e)]
|
||||
return jsonify(errors=err)
|
||||
err = [[2, str(e)]]
|
||||
return jsonify(notif=err)
|
||||
return jsonify(results=j)
|
||||
|
||||
@app.route('/api/clients-report.json')
|
||||
|
|
@ -114,8 +114,8 @@ def clients_report_json():
|
|||
try:
|
||||
clients = bui.cli.get_all_clients()
|
||||
except BUIserverException, e:
|
||||
err = [str(e)]
|
||||
return jsonify(errors=err)
|
||||
err = [[2, str(e)]]
|
||||
return jsonify(notif=err)
|
||||
cl = []
|
||||
ba = []
|
||||
for c in clients:
|
||||
|
|
@ -138,21 +138,21 @@ def client_stat_json(name=None, backup=None):
|
|||
"""
|
||||
j = []
|
||||
if not name:
|
||||
err = ['No client defined']
|
||||
return jsonify(errors=err)
|
||||
err = [[1, 'No client defined']]
|
||||
return jsonify(notif=err)
|
||||
if backup:
|
||||
try:
|
||||
f = bui.cli.status('c:{0}:b:{1}:f:log.gz\n'.format(name, backup))
|
||||
except BUIserverException, e:
|
||||
err = [str(e)]
|
||||
return jsonify(errors=err)
|
||||
err = [[2, str(e)]]
|
||||
return jsonify(notif=err)
|
||||
j = bui.cli.parse_backup_log(f, backup)
|
||||
else:
|
||||
try:
|
||||
cl = bui.cli.get_client(name)
|
||||
except BUIserverException, e:
|
||||
err = [str(e)]
|
||||
return jsonify(errors=err)
|
||||
err = [[2, str(e)]]
|
||||
return jsonify(notif=err)
|
||||
for c in cl:
|
||||
f = bui.cli.status('c:{0}:b:{1}:f:log.gz\n'.format(name, c['number']))
|
||||
j.append(bui.cli.parse_backup_log(f, c['number']))
|
||||
|
|
@ -166,8 +166,8 @@ def client_json(name=None):
|
|||
try:
|
||||
j = bui.cli.get_client(name)
|
||||
except BUIserverException, e:
|
||||
err = [str(e)]
|
||||
return jsonify(errors=err)
|
||||
err = [[2, str(e)]]
|
||||
return jsonify(notif=err)
|
||||
return jsonify(results=j)
|
||||
|
||||
@app.route('/api/clients.json')
|
||||
|
|
@ -178,8 +178,8 @@ def clients():
|
|||
try:
|
||||
j = bui.cli.get_all_clients()
|
||||
except BUIserverException, e:
|
||||
err = [str(e)]
|
||||
return jsonify(errors=err)
|
||||
err = [[2, str(e)]]
|
||||
return jsonify(notif=err)
|
||||
return jsonify(results=j)
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -203,3 +203,16 @@ svg text {
|
|||
animation: blink 1s step-start 0s infinite;
|
||||
-webkit-animation: blink 1s step-start 0s infinite;
|
||||
}
|
||||
|
||||
/* centered columns styles */
|
||||
.row-centered {
|
||||
text-align:center;
|
||||
}
|
||||
.col-centered {
|
||||
display:inline-block;
|
||||
float:none;
|
||||
/* reset the text-align */
|
||||
text-align:left;
|
||||
/* inline-block space fix */
|
||||
margin-right:-4px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
|
||||
<div id="bui-notifications">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{% include "small_topbar.html" %}
|
||||
<ul class="breadcrumb" style="margin-bottom: 5px;">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
|
||||
<div id="bui-notifications">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{% include "small_topbar.html" %}
|
||||
<ul class="breadcrumb" style="margin-bottom: 5px;">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
|
||||
<div id="bui-notifications">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{% include "small_topbar.html" %}
|
||||
<ul class="breadcrumb" style="margin-bottom: 5px;">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
|
||||
<div id="bui-notifications">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{% include "small_topbar.html" %}
|
||||
<ul class="breadcrumb" style="margin-bottom: 5px;">
|
||||
|
|
@ -22,7 +26,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<div class="alert alert-dismissable alert-danger" id="client-alert" style="display: none;">
|
||||
<strong>Sorry!</strong> There are no backups for this client.
|
||||
<span class="glyphicon glyphicon-exclamation-sign"></span> <strong>Sorry!</strong> There are no backups for this client.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
|
||||
<div id="bui-notifications">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{% include "small_topbar.html" %}
|
||||
<ul class="breadcrumb" style="margin-bottom: 5px;">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2">
|
||||
<div id="bui-notifications">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{% include "small_topbar.html" %}
|
||||
<ul class="breadcrumb" style="margin-bottom: 5px;">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,36 @@
|
|||
var pad = function (num, size) {
|
||||
var pad = function(num, size) {
|
||||
var s = "0000000" + num;
|
||||
return s.substr(s.length-size);
|
||||
}
|
||||
};
|
||||
|
||||
var notif = function(type, message) {
|
||||
var t = '';
|
||||
switch(type) {
|
||||
case 0:
|
||||
t = 'success';
|
||||
i = '<span class="glyphicon glyphicon-ok-sign"></span> ';
|
||||
break;
|
||||
case 1:
|
||||
t = 'warning';
|
||||
i = '<span class="glyphicon glyphicon-question-sign"></span> ';
|
||||
break;
|
||||
case 2:
|
||||
t = 'danger';
|
||||
i = '<span class="glyphicon glyphicon-exclamation-sign"></span> ';
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
t = 'info';
|
||||
i = '<span class="glyphicon glyphicon-info-sign"></span> ';
|
||||
break;
|
||||
}
|
||||
e = $('<div class="alert alert-dismissable alert-'+t+'">'+
|
||||
'<button type="button" class="close" data-dismiss="alert">×</button>'+
|
||||
i+message+
|
||||
'</div>');
|
||||
$('#bui-notifications').append(e).show();
|
||||
e.animate({opacity:1}, 5000, 'linear', function() { e.animate({opacity:0}, 2000, 'linear', function() {e.remove(); }); });
|
||||
};
|
||||
|
||||
{% if not login %}
|
||||
var _check_running = function() {
|
||||
|
|
@ -26,7 +55,10 @@ var _clients_bh = new Bloodhound({
|
|||
prefetch: {
|
||||
url: '{{ url_for("clients") }}',
|
||||
filter: function(list) {
|
||||
return list.results;
|
||||
if (list.results) {
|
||||
return list.results;
|
||||
}
|
||||
return new Array();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -71,11 +103,19 @@ var _async_ajax = function(b) {
|
|||
$.ajaxSetup({
|
||||
async: b
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(function() {
|
||||
_async_ajax(false);
|
||||
|
||||
/***
|
||||
* Show the notifications
|
||||
*/
|
||||
$('#bui-notifications > div').each(function() {
|
||||
e = $(this);
|
||||
e.animate({opacity:1}, 5000, 'linear', function() { e.animate({opacity:0}, 2000, 'linear', function() {e.remove(); }); });
|
||||
});
|
||||
|
||||
/***
|
||||
* Action on the 'refresh' button
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,6 +38,19 @@ var _client = function() {
|
|||
$.getJSON(url, function(d) {
|
||||
var _fields = [ 'dir', 'files', 'hardlink', 'softlink' ];
|
||||
j = d.results;
|
||||
if (!j) {
|
||||
if (d.notif) {
|
||||
$.each(d.notif, function(i, n) {
|
||||
notif(n[0], n[1]);
|
||||
});
|
||||
}
|
||||
$('.mycharts').each(function() {
|
||||
$(this).parent().hide();
|
||||
});
|
||||
}
|
||||
$('.mycharts').each(function() {
|
||||
$(this).parent().show();
|
||||
});
|
||||
$.each(_charts, function(k, l) {
|
||||
data = [];
|
||||
$.each(_fields, function(i, c) {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@
|
|||
source: function() {
|
||||
r = [];
|
||||
$.getJSON('{{ url_for("client_tree", name=cname, backup=nbackup) }}', function(data) {
|
||||
if (!data.results) {
|
||||
if (data.notif) {
|
||||
$.each(data.notif, function(i, n) {
|
||||
notif(n[0], n[1]);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
$.each(data.results, function(j, c) {
|
||||
l = (c.type === "d");
|
||||
f = (c.type === "d");
|
||||
|
|
@ -73,6 +81,14 @@
|
|||
p = node.key;
|
||||
if (p !== "/") p += '/';
|
||||
$.getJSON('{{ url_for("client_tree", name=cname, backup=nbackup) }}?root='+p, function(data) {
|
||||
if (!data.results) {
|
||||
if (data.notif) {
|
||||
$.each(data.notif, function(i, n) {
|
||||
notif(n[0], n[1]);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
$.each(data.results, function(j, c) {
|
||||
l = (c.type === "d");
|
||||
f = (c.type === "d");
|
||||
|
|
|
|||
|
|
@ -84,6 +84,20 @@ var _client = function() {
|
|||
size = [];
|
||||
duration = [];
|
||||
push = false;
|
||||
if (!d.results) {
|
||||
if (d.notif) {
|
||||
$.each(d.notif, function(i, n) {
|
||||
notif(n[0], n[1]);
|
||||
});
|
||||
}
|
||||
$('.mycharts').each(function() {
|
||||
$(this).parent().hide();
|
||||
});
|
||||
return;
|
||||
}
|
||||
$('.mycharts').each(function() {
|
||||
$(this).parent().show();
|
||||
});
|
||||
$.each(d.results, function(a, j) {
|
||||
if (j[c] !== undefined) {
|
||||
val = parseFloat(j[c][l]);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ var _client = function() {
|
|||
if (!data.results) {
|
||||
$('#table-client').hide();
|
||||
$('#client-alert').show();
|
||||
if (data.notif) {
|
||||
$.each(data.notif, function(i, n) {
|
||||
notif(n[0], n[1]);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data.results.length == 0) {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,20 @@ var _clients = function() {
|
|||
backups = {};
|
||||
windows = 0;
|
||||
nonwin = 0;
|
||||
if (!d.results) {
|
||||
if (d.notif) {
|
||||
$.each(d.notif, function(i, n) {
|
||||
notif(n[0], n[1]);
|
||||
});
|
||||
}
|
||||
$('.mycharts').each(function() {
|
||||
$(this).parent().hide();
|
||||
});
|
||||
return;
|
||||
}
|
||||
$('.mycharts').each(function() {
|
||||
$(this).parent().show();
|
||||
});
|
||||
$.each(d.results[0]['clients'], function(k, c) {
|
||||
if (c.stats.windows) {
|
||||
windows++;
|
||||
|
|
|
|||
|
|
@ -36,11 +36,12 @@ var _clients = function() {
|
|||
url = '{{ url_for("clients") }}';
|
||||
$.getJSON(url, function(data) {
|
||||
$('#table-clients > tbody:last').empty();
|
||||
if (!data.resuts && data.errors) {
|
||||
alert(data.errors[0]);
|
||||
return;
|
||||
}
|
||||
if (!data.results) {
|
||||
if (data.notif) {
|
||||
$.each(data.notif, function(i, n) {
|
||||
notif(n[0], n[1]);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
$.each(data.results, function(j, c) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue