diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-10-25 18:51:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 18:51:25 +0100 |
commit | b48547358dfc8aed59c7c69b1718595c41f65c43 (patch) | |
tree | 134aac69080076f5bdcea948eb25d381705e0302 | |
parent | 6b81b812a7a34ad7201b7df214bb543d089d7919 (diff) | |
parent | 95664f9855b13f001d25df60171d71309cdd6738 (diff) | |
download | rspamd-b48547358dfc8aed59c7c69b1718595c41f65c43.tar.gz rspamd-b48547358dfc8aed59c7c69b1718595c41f65c43.zip |
Merge pull request #4661 from moisseev/webui
[WebUI] Fix history table vanishing
-rw-r--r-- | .eslintrc.json | 2 | ||||
-rw-r--r-- | interface/js/app/rspamd.js | 27 |
2 files changed, 20 insertions, 9 deletions
diff --git a/.eslintrc.json b/.eslintrc.json index f0856b782..a2d754d5d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -28,7 +28,7 @@ "line-comment-position": "off", "logical-assignment-operators": ["error", "never"], "max-params": ["warn", 6], - "max-statements": ["warn", 44], + "max-statements": ["warn", 50], "max-statements-per-line": ["error", { "max": 2 }], "multiline-comment-style": "off", "multiline-ternary": ["error", "always-multiline"], diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 59a4a4d17..eca4a7dfe 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -59,6 +59,8 @@ function ($, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_config, var neighbours = []; // list of clusters var checked_server = "All SERVERS"; var timer_id = []; + let pageSizeTimerId = null; + let pageSizeInvocationCounter = 0; var locale = (localStorage.getItem("selected_locale") === "custom") ? localStorage.getItem("custom_locale") : null; var selData = null; // Graph's dataset selector state @@ -261,15 +263,26 @@ function ($, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_config, sessionStorage.setItem("Password", password); } - function set_page_size(table, page_size, callback) { + function set_page_size(table, page_size, changeTablePageSize) { var n = parseInt(page_size, 10); // HTML Input elements return string representing a number - if (n !== ui.page_size[table] && n > 0) { + if (n > 0) { ui.page_size[table] = n; - if (callback) { - return callback(n); + + if (changeTablePageSize && + $("#historyTable_" + table + " tbody").is(":parent")) { // Table is not empty + + clearTimeout(pageSizeTimerId); + const t = FooTable.get("#historyTable_" + table); + if (t) { + pageSizeInvocationCounter = 0; + // Wait for input finish + pageSizeTimerId = setTimeout(() => t.pageSize(n), 1000); + } else if (++pageSizeInvocationCounter < 10) { + // Wait for FooTable instance ready + pageSizeTimerId = setTimeout(() => set_page_size(table, n, true), 1000); + } } } - return null; } function sort_symbols(o, compare_function) { @@ -753,9 +766,7 @@ function ($, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_config, var order = this.value; change_symbols_order(order); }); - $("#" + table + "_page_size").change(function () { - set_page_size(table, this.value, function (n) { tables[table].pageSize(n); }); - }); + $("#" + table + "_page_size").change((e) => set_page_size(table, e.target.value, true)); $(document).on("click", ".btn-sym-order-" + table + " input", function () { var order = this.value; $("#selSymOrder_" + table).val(order); |