diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-15 13:28:17 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-15 13:28:17 +0300 |
commit | f4bc21ab86764a41875118805b4a91e699c23e19 (patch) | |
tree | 7f73b7f93f6929ae8b39bf9c9bbec51fa1365a72 /interface | |
parent | 28403d98158bc8fd75dd3b80443dcb65999671a5 (diff) | |
download | rspamd-f4bc21ab86764a41875118805b4a91e699c23e19.tar.gz rspamd-f4bc21ab86764a41875118805b4a91e699c23e19.zip |
[WebUI] Fix disabling and hiding controls on page reload
Diffstat (limited to 'interface')
-rw-r--r-- | interface/index.html | 2 | ||||
-rw-r--r-- | interface/js/app/rspamd.js | 42 | ||||
-rw-r--r-- | interface/js/app/stats.js | 1 |
3 files changed, 15 insertions, 30 deletions
diff --git a/interface/index.html b/interface/index.html index 1b3677646..a10af453f 100644 --- a/interface/index.html +++ b/interface/index.html @@ -30,7 +30,7 @@ <li role="presentation"><a id="configuration_nav" aria-controls="configuration" role="tab" href="#configuration" data-toggle="tab">Configuration</a></li> <li role="presentation"><a id="symbols_nav" aria-controls="symbols" role="tab" href="#symbols" data-toggle="tab">Symbols</a></li> - <li role="presentation"><a id="learning_nav" aria-controls="learning" role="tab" href="#learning" data-toggle="tab">Learning</a></li> + <li role="presentation"><a id="learning_nav" aria-controls="learning" role="tab" href="#learning" data-toggle="tab" style="display: none;">Learning</a></li> <li role="presentation"><a id="scan_nav" aria-controls="scan" role="tab" href="#scan" data-toggle="tab">Scan</a></li> <li role="presentation"><a id="history_nav" aria-controls="history" role="tab" href="#history" data-toggle="tab">History</a></li> </ul> diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 70f6fbfd5..06d9a46f9 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -35,10 +35,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, var tables = {}; var neighbours = []; // list of clusters var checked_server = "All SERVERS"; - var ui = { - read_only: false, - }; - + var ui = {}; var timer_id = []; var selData; // Graph's dataset selector state @@ -158,7 +155,18 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, } function displayUI() { - // @toggle auth and main + // In many browsers local storage can only store string. + // So when we store the boolean true or false, it actually stores the strings "true" or "false". + ui.read_only = sessionStorage.getItem("read_only") === "true"; + if (ui.read_only) { + $("#learning_nav").hide(); + $("#resetHistory").attr("disabled", true); + $("#errors-history").hide(); + } else { + $("#learning_nav").show(); + $("#resetHistory").removeAttr("disabled", true); + } + var buttons = $("#navBar .pull-right"); $("#mainUI").show(); $("#progress").show(); @@ -294,18 +302,6 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, ui.connect = function () { if (isLogged()) { - var data = JSON.parse(sessionStorage.getItem("Credentials")); - - if (data && data[checked_server].read_only) { - ui.read_only = true; - $("#learning_nav").hide(); - $("#resetHistory").attr("disabled", true); - $("#errors-history").hide(); - } else { - ui.read_only = false; - $("#learning_nav").show(); - $("#resetHistory").removeAttr("disabled", true); - } displayUI(); return; } @@ -341,17 +337,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, if (json.auth === "failed") { // Is actually never returned by Rspamd } else { - if (json.read_only) { - ui.read_only = true; - $("#learning_nav").hide(); - $("#resetHistory").attr("disabled", true); - $("#errors-history").hide(); - } else { - ui.read_only = false; - $("#learning_nav").show(); - $("#resetHistory").removeAttr("disabled", true); - } - + sessionStorage.setItem("read_only", json.read_only); saveCredentials(password); $(dialog).hide(); $(backdrop).hide(); diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index e40206266..ea8edfd8a 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -184,7 +184,6 @@ define(["jquery", "d3pie", "humanize"], soft_reject: 0, scanned: 0, learned: 0, - read_only: neighbours_status[0].data.read_only, config_id: "" }; var status_count = 0; |