From 84a4ffcb43e4cc79dcf22538326c9ccdc514418f Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 10 Jan 2018 17:35:52 +0100 Subject: [PATCH] js tweaks --- burpui/templates/client-browse.html | 2 +- burpui/templates/gerard.js | 176 +++++++++++++-------------- burpui/templates/js/client-browse.js | 11 +- burpui/templates/js/client.js | 1 + burpui/templates/js/clients.js | 1 + burpui/templates/js/servers.js | 3 +- burpui/templates/js/user.js | 3 +- burpui/templates/layout.html | 1 + burpui/templates/macros.html | 2 +- 9 files changed, 107 insertions(+), 93 deletions(-) diff --git a/burpui/templates/client-browse.html b/burpui/templates/client-browse.html index c58c5a07..bcdcb8de 100644 --- a/burpui/templates/client-browse.html +++ b/burpui/templates/client-browse.html @@ -10,7 +10,7 @@
  • {{ _('%(client)s overview', client=cname) }}
  • {{ _('Backup n°%(number)s overview', number=mypad(nbackup)) }}
  • {% else -%} -
  • Home
  • +
  • {{ _('Home') }}
  • {{ _('%(client)s overview', client=cname) }}
  • {{ _('Backup n°%(number)s overview', number=mypad(nbackup)) }}
  • {% endif -%} diff --git a/burpui/templates/gerard.js b/burpui/templates/gerard.js index 502adf20..cefdffa5 100644 --- a/burpui/templates/gerard.js +++ b/burpui/templates/gerard.js @@ -171,36 +171,36 @@ var myFail = function(xhr, stat, err) { notif(NOTIF_ERROR, msg); }; -{% if config.WITH_CELERY %} +{% if config.WITH_CELERY -%} {% set api_running_backup = "api.async_running_backup" %} -{% else %} +{% else -%} {% set api_running_backup = "api.running_backup" %} -{% endif %} -{% if not login %} +{% endif -%} +{% if not login -%} var _last_running_status = undefined; var _last_call = 0; var _check_running = function() { - {% if server %} + {% if server -%} var url = '{{ url_for(api_running_backup, server=server) }}'; - {% else %} + {% else -%} var url = '{{ url_for(api_running_backup) }}'; - {% endif %} + {% endif -%} var now = Date.now(); if ((now - _last_call) < 5*1000) { return; } _last_call = now; $.getJSON(url, function(data) { - {% if clients and overview %} + {% if clients and overview -%} if (_last_running_status != data.running) { $( document ).trigger('refreshClientsStatesEvent', data.running); } - {% endif %} - {% if client and overview %} + {% endif -%} + {% if client and overview -%} if (_last_running_status != data.running) { $( document ).trigger('refreshClientStatusEvent', data.running); } - {% endif %} + {% endif -%} if (data.running) { $('#toblink').addClass('blink'); } else { @@ -209,9 +209,9 @@ var _check_running = function() { _last_running_status = data.running; }); }; -{% endif %} +{% endif -%} -{% if not login %} +{% if not login -%} var substringMatcher = function(objs) { return function findMatches(q, cb) { @@ -237,7 +237,7 @@ var substringMatcher = function(objs) { var _clients_all = []; - {% if config.STANDALONE %} + {% if config.STANDALONE -%} $.get("{{ url_for('api.clients_all') }}") .done(function (data) { @@ -259,13 +259,13 @@ $.get("{{ url_for('api.clients_all') }}") }); - {% else %} + {% else -%} - {% for srv in config.SERVERS %} + {% for srv in config.SERVERS -%} var _clients_{{ srv|regex_replace("[^a-z0-9_]", "_") }} = []; - {% endfor %} + {% endfor -%} $.get("{{ url_for('api.clients_all') }}") .done(function (data) { @@ -279,7 +279,7 @@ $.get("{{ url_for('api.clients_all') }}") $('#input-client').typeahead({ highlight: true }, - {% for srv in config.SERVERS %} + {% for srv in config.SERVERS -%} { name: '{{ srv }}', displayKey: 'name', @@ -287,74 +287,74 @@ $('#input-client').typeahead({ templates: { header: '

    {{ srv }}

    ' } - {% if loop.last %} + {% if loop.last -%} } - {% else %} + {% else -%} }, - {% endif %} - {% endfor %} + {% endif -%} + {% endfor -%} ).on('typeahead:selected', function(obj, datum) { window.location = '{{ url_for("view.client") }}?name='+datum.name+'&serverName='+datum.agent; }); - {% endif %} -{% endif %} + {% endif -%} +{% endif -%} -{% if servers and overview %} +{% if servers and overview -%} {% include "js/servers.js" %} -{% endif %} +{% endif -%} -{% if servers and report %} +{% if servers and report -%} {% include "js/servers-report.js" %} -{% endif %} +{% endif -%} -{% if clients and overview %} +{% if clients and overview -%} {% include "js/clients.js" %} -{% endif %} +{% endif -%} -{% if clients and report %} +{% if clients and report -%} {% include "js/clients-report.js" %} -{% endif %} +{% endif -%} -{% if client and overview %} +{% if client and overview -%} {% include "js/client.js" %} -{% set is_client_func = True %} -{% endif %} +{% set is_client_func = True -%} +{% endif -%} -{% if backup and report and client %} +{% if backup and report and client -%} {% include "js/backup-report.js" %} -{% set is_client_func = True %} -{% endif %} +{% set is_client_func = True -%} +{% endif -%} -{% if not backup and report and client %} +{% if not backup and report and client -%} {% include "js/client-report.js" %} -{% set is_client_func = True %} -{% endif %} +{% set is_client_func = True -%} +{% endif -%} -{% if live %} +{% if live -%} {% include "js/live-monitor.js" %} -{% endif %} +{% endif -%} -{% if settings %} +{% if settings -%} {% include "js/settings.js" %} -{% endif %} +{% endif -%} -{% if about %} +{% if about -%} {% include "js/about.js" %} -{% endif %} +{% endif -%} -{% if calendar %} +{% if calendar -%} {% include "js/calendar.js" %} -{% endif %} +{% endif -%} -{% if tree %} +{% if tree -%} {% include "js/client-browse.js" %} -{% endif %} +{% endif -%} -{% if me %} +{% if me -%} {% include "js/user.js" %} -{% endif %} +{% endif -%} var _fit_menu = function() { size = $(window).width(); @@ -400,21 +400,21 @@ $(function() { */ $('#refresh').on('click', function(e) { e.preventDefault(); - {% if clients %} + {% if clients -%} _clients(); - {% endif %} - {% if client and is_client_func %} + {% endif -%} + {% if client and is_client_func -%} _client(); - {% endif %} - {% if not login %} + {% endif -%} + {% if not login -%} _check_running(); - {% endif %} - {% if servers %} + {% endif -%} + {% if servers -%} _servers(); - {% endif %} - {% if me %} + {% endif -%} + {% if me -%} _sessions(); - {% endif %} + {% endif -%} }); /*** @@ -443,53 +443,53 @@ $(function() { /*** * initialize our page if needed */ - {% if not login %} + {% if not login -%} _check_running(); - {% endif %} - {% if clients %} + {% endif -%} + {% if clients -%} _clients(); - {% endif %} - {% if client and is_client_func %} + {% endif -%} + {% if client and is_client_func -%} _client(); - {% endif %} - {% if servers %} + {% endif -%} + {% if servers -%} _servers(); - {% endif %} - {% if me %} + {% endif -%} + {% if me -%} _sessions(); - {% endif %} + {% endif -%} - {% if not report and not login %} + {% if not report and not login -%} /*** * auto-refresh our page if needed */ - {% set autorefresh = config.REFRESH %} + {% set autorefresh = config.REFRESH -%} var auto_refresh = setInterval(function() { - {% if clients %} + {% if clients -%} _clients(); - {% endif %} - {% if client and not settings %} + {% endif -%} + {% if client and not settings -%} _client(); - {% endif %} - {% if servers and overview %} + {% endif -%} + {% if servers and overview -%} _servers(); - {% endif %} + {% endif -%} return; }, {{ autorefresh * 1000 }}); - {% endif %} + {% endif -%} - {% if not login %} - {% if not config.WS_AVAILABLE or not config.WITH_CELERY %} + {% if not login -%} + {% if not config.WS_AVAILABLE or not config.WITH_CELERY -%} /*** * Javascript Loop */ var refresh_running = setInterval(function () { _check_running(); }, {{ config.LIVEREFRESH * 1000 }}); - {% endif %} - {% endif %} + {% endif -%} + {% endif -%} }); -{% if not login and config.WS_AVAILABLE %} +{% if not login and config.WS_AVAILABLE -%} {% include "js/websocket.js" %} -{% endif %} +{% endif -%} diff --git a/burpui/templates/js/client-browse.js b/burpui/templates/js/client-browse.js index 1b8a9952..b99e1d59 100644 --- a/burpui/templates/js/client-browse.js +++ b/burpui/templates/js/client-browse.js @@ -43,6 +43,7 @@ $( document ).ready(function() { selectMode: 3, extensions: ["glyph", "table", "gridnav", "filter"], glyph: { + preset: "bootstrap3", map: { doc: "glyphicon glyphicon-file", docOpen: "glyphicon glyphicon-file", @@ -62,6 +63,14 @@ $( document ).ready(function() { loading: "glyphicon glyphicon-refresh glyphicon-spin" } }, + persist: { + expandLazy: false, + overrideSource: false, + store: "cookie", + cookie: { + path: '{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}', + }, + }, source: function() { {% if edit and edit.found -%} url = '{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server, root=edit.roots, recursive=True, selected=True) }}'; @@ -81,7 +90,7 @@ $( document ).ready(function() { p = node.key; if (p !== "/") p += '/'; p = encodeURIComponent(p); - data.result = { url: '{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}?root='+p, debugDelay: 500 }; + data.result = $.getJSON('{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}?root='+p); }, loadChildren: function(event, data) { // This is a hack to select all children of a selected node after diff --git a/burpui/templates/js/client.js b/burpui/templates/js/client.js index 1ac66bc5..0e95bc42 100644 --- a/burpui/templates/js/client.js +++ b/burpui/templates/js/client.js @@ -62,6 +62,7 @@ var _client_table = $('#table-client').DataTable( { {{ macros.translate_datatable() }} {{ macros.get_page_length() }} responsive: true, + processing: true, ajax: { url: '{{ url_for("api.client_stats", name=cname, server=server) }}', headers: { 'X-From-UI': true }, diff --git a/burpui/templates/js/clients.js b/burpui/templates/js/clients.js index 4b784ab4..9681c22e 100644 --- a/burpui/templates/js/clients.js +++ b/burpui/templates/js/clients.js @@ -59,6 +59,7 @@ var _clients_table = $('#table-clients').DataTable( { {{ macros.translate_datatable() }} {{ macros.get_page_length() }} responsive: true, + processing: true, ajax: { url: '{{ url_for("api.clients_stats", server=server) }}', dataSrc: function (data) { diff --git a/burpui/templates/js/servers.js b/burpui/templates/js/servers.js index 1b9c8f2e..739c9645 100644 --- a/burpui/templates/js/servers.js +++ b/burpui/templates/js/servers.js @@ -13,6 +13,7 @@ var _servers_table = $('#table-servers').DataTable( { {{ macros.translate_datatable() }} {{ macros.get_page_length() }} responsive: true, + processing: true, ajax: { url: '{{ url_for("api.servers_stats") }}', dataSrc: function (data) { @@ -20,7 +21,7 @@ var _servers_table = $('#table-servers').DataTable( { }, error: myFail, }, - destroy: true, + rowId: 'name', rowCallback: function( row, data ) { if (!data.alive) { row.className += ' danger'; diff --git a/burpui/templates/js/user.js b/burpui/templates/js/user.js index 50ae1915..0db4a23c 100644 --- a/burpui/templates/js/user.js +++ b/burpui/templates/js/user.js @@ -167,6 +167,7 @@ var _sessions_table = $('#table-sessions').DataTable( { {{ macros.translate_datatable() }} {{ macros.get_page_length() }} responsive: true, + processing: true, select: { style: 'os', }, @@ -237,7 +238,7 @@ var _sessions_table = $('#table-sessions').DataTable( { } ], order: [[1, 'desc']], - destroy: true, + rowId: 'uuid', columns: [ { data: 'ip' }, { diff --git a/burpui/templates/layout.html b/burpui/templates/layout.html index cc599a22..84b5c8b7 100644 --- a/burpui/templates/layout.html +++ b/burpui/templates/layout.html @@ -103,6 +103,7 @@ {% if tree -%} + {# -#} diff --git a/burpui/templates/macros.html b/burpui/templates/macros.html index 9869de41..b9062da9 100644 --- a/burpui/templates/macros.html +++ b/burpui/templates/macros.html @@ -123,7 +123,7 @@ $(document).ready(function() { select: { rows: { _: '{{ _("You have selected %%d rows") }}', - 0: '{{ _("Click a row to select it (hold ctrl to select several)") }}', + 0: '
    {{ _("Click a row to select it (hold ctrl to select several)") }}', 1: '{{ _("You have selected 1 row") }}' }, },