commit cb776ef: [Minor] Refactor displayStatWidgets function

moisseev moiseev at mezonplus.ru
Sun Aug 9 18:28:08 UTC 2020


Author: moisseev
Date: 2020-08-08 18:24:30 +0300
URL: https://github.com/rspamd/rspamd/commit/cb776ef73e9043843480db683392cba4636feb51

[Minor] Refactor displayStatWidgets function

---
 interface/js/app/stats.js | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index 299b02aad..57e16261e 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -56,17 +56,14 @@ define(["jquery", "d3pie"],
         }
 
         function displayStatWidgets(checked_server) {
-            var widgets = $("#statWidgets");
-            $(widgets).empty().hide();
-
             var servers = JSON.parse(sessionStorage.getItem("Credentials"));
             var data = {};
-
             if (servers && servers[checked_server]) {
                 data = servers[checked_server].data;
             }
-            var stat_w = [];
 
+            var stat_w = [];
+            $("#statWidgets").empty().hide();
             $.each(data, function (i, item) {
                 var widgetsOrder = ["scanned", "no action", "greylist", "add header", "rewrite subject", "reject", "learned"];
 
@@ -89,7 +86,7 @@ define(["jquery", "d3pie"],
                     }
                     $('<div class="' + cls + 'float-left px-3"><strong class="d-block mt-2 mb-1 font-weight-bold">' +
                       val + "</strong>" + i + "</div>")
-                        .appendTo(widgets);
+                        .appendTo("#statWidgets");
                 } else if (i === "actions") {
                     $.each(item, function (action, count) {
                         stat_w[widgetsOrder.indexOf(action)] = widget(action, count);
@@ -99,12 +96,13 @@ define(["jquery", "d3pie"],
                 }
             });
             $.each(stat_w, function (i, item) {
-                $(item).appendTo(widgets);
+                $(item).appendTo("#statWidgets");
             });
             $("#statWidgets > div:not(.stat-box)")
                 .wrapAll('<div class="card stat-box text-center bg-light shadow-sm float-right">' +
                   '<div class="widget overflow-hidden p-2 text-capitalize"></div></div>');
             $("#statWidgets").find("div.float-right").appendTo("#statWidgets");
+            $("#statWidgets").show();
 
             $("#clusterTable tbody").empty();
             $("#selSrv").empty();
@@ -144,7 +142,6 @@ define(["jquery", "d3pie"],
                     $('#selSrv [value="' + key + '"]').prop("disabled", true);
                 }
             });
-            $(widgets).show();
         }
 
         function getChart(rspamd, pie, checked_server) {


More information about the Commits mailing list