mirror of
https://github.com/ziirish/burp-ui.git
synced 2026-05-15 14:16:08 -06:00
show labels on client stats view
This commit is contained in:
parent
93c224ff5c
commit
24f15509f4
3 changed files with 24 additions and 6 deletions
|
|
@ -1048,21 +1048,22 @@ class ClientLabels(Resource):
|
|||
return {'labels': labels}
|
||||
|
||||
@staticmethod
|
||||
def _get_labels(client, server):
|
||||
def _get_labels(client, server=None):
|
||||
key = 'labels-{}-{}'.format(client, server)
|
||||
ret = cache.cache.get(key)
|
||||
if ret is not None:
|
||||
return ret
|
||||
labels = bui.client.get_client_labels(client, agent=server)
|
||||
ret = []
|
||||
ignore = re.compile('|'.join(bui.ignore_labels)) if bui.ignore_labels else None
|
||||
reformat = [(re.compile(regex), replace) for regex, replace in bui.format_labels] if bui.format_labels else []
|
||||
for label in labels:
|
||||
if bui.ignore_labels and \
|
||||
re.search('|'.join(bui.ignore_labels), label):
|
||||
ignore.search(label):
|
||||
continue
|
||||
tmp_label = label
|
||||
if bui.format_labels:
|
||||
for regex, replace in bui.format_labels:
|
||||
tmp_label = re.sub(regex, replace, tmp_label)
|
||||
for regex, replace in reformat:
|
||||
tmp_label = regex.sub(replace, tmp_label)
|
||||
ret.append(tmp_label)
|
||||
cache.cache.set(key, ret, 1800)
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -17,7 +17,15 @@
|
|||
{% if current_user and current_user.is_authenticated and (current_user.is_admin or current_user.is_moderator) -%}
|
||||
{% set extra_features = True %}
|
||||
{% endif -%}
|
||||
<h1 class="page-header">{{ cname }} {% if extra_features %}<a href="{{ url_for("view.cli_settings", server=server, client=cname) }}" class="btn btn-info" title="{{ _('edit') }}"><i class="fa fa-pencil" aria-hidden="true"></i></a>{% endif %}</h1>
|
||||
<div class="row page-header">
|
||||
<div class="col-md-4">
|
||||
<h1>{{ cname }} {% if extra_features %}<a href="{{ url_for("view.cli_settings", server=server, client=cname) }}" class="btn btn-info" title="{{ _('edit') }}"><i class="fa fa-pencil" aria-hidden="true"></i></a>{% endif %}</h1>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="pull-right" id="client-labels">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="sub-header">{{ _('Backups') }} <span id="running-status" class="label pull-right"></span></h2>
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -213,10 +213,12 @@ var refresh_status = function( is_running ) {
|
|||
{% endif %}
|
||||
var url = '{{ url_for(api_running_clients, client=cname, server=server) }}';
|
||||
var client_status_url = '{{ url_for("api.client_running_status", name=cname, server=server) }}';
|
||||
var client_labels_url = '{{ url_for("api.client_labels", name=cname, server=server) }}';
|
||||
var _get_running = undefined;
|
||||
var _get_status = undefined;
|
||||
var _client_running = false;
|
||||
var _span = $('#running-status');
|
||||
var _labels = $('#client-labels');
|
||||
var _inner_format_status = function(status) {
|
||||
var _content = '<i class="'+__icons[status.state]+'" aria-hidden="true"></i> ';
|
||||
if (status.state == '{{ _("running") }}') {
|
||||
|
|
@ -242,6 +244,13 @@ var refresh_status = function( is_running ) {
|
|||
_span.addClass(__status[_status.state]);
|
||||
});
|
||||
};
|
||||
$.getJSON(client_labels_url, function(labels) {
|
||||
var _labels_span = '';
|
||||
_.forEach(labels, function(label) {
|
||||
_labels_span += '<span class="label label-info">' + label + '</span> ';
|
||||
});
|
||||
_labels.html(_labels_span);
|
||||
});
|
||||
if (is_running) {
|
||||
_get_running = $.getJSON(url, function(running) {
|
||||
if (_.indexOf(running, '{{ cname }}') != -1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue