]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] History: add sorting by symbol score value 2548/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 28 Sep 2018 09:48:19 +0000 (12:48 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 28 Sep 2018 09:48:19 +0000 (12:48 +0300)
interface/index.html
interface/js/app/history.js

index 6eebef1d4fcb8e22a52ef2bf47feb0af260c842d..1cf363b96eb0ffe3d76b41e24eb5380ea7cbf187 100644 (file)
                                                        <div class="form-group widget-title-form">
                                                                <label for="selSymOrder">Symbols order:</label>
                                                                <select id="selSymOrder" class="form-control">
-                                                                       <option value="score" selected>Score</option>
+                                                                       <option value="magnitude" selected>Score magnitude</option>
+                                                                       <option value="score">Score value</option>
                                                                        <option value="name">Name</option>
                                                                </select>
                                                        </div>
index f82925b2656bb8f7fc5941837065012a8d8b40d7..3d1983b236651ed33b6f13c08b66e7ba8ee41554 100644 (file)
@@ -113,7 +113,7 @@ define(["jquery", "footable", "humanize"],
         }
 
         function process_history_v2(data) {
-        // Display no more than rcpt_lim recipients
+            // Display no more than rcpt_lim recipients
             var rcpt_lim = 3;
             var items = [];
 
@@ -121,13 +121,23 @@ define(["jquery", "footable", "humanize"],
                 var e = document.getElementById(id);
                 return e.options[e.selectedIndex].value;
             }
-            var compare = (getSelector("selSymOrder") === "score")
-                ? function (e1, e2) {
-                    return Math.abs(e2.score) - Math.abs(e1.score);
-                }
-                : function (e1, e2) {
-                    return e1.name.localeCompare(e2.name);
-                };
+            var compare = null;
+            switch (getSelector("selSymOrder")) {
+                case "score":
+                    compare = function (e1, e2) {
+                        return e2.score - e1.score;
+                    };
+                    break;
+                case "name":
+                    compare = function (e1, e2) {
+                        return e1.name.localeCompare(e2.name);
+                    };
+                    break;
+                default:
+                    compare = function (e1, e2) {
+                        return Math.abs(e2.score) - Math.abs(e1.score);
+                    };
+            }
 
             $("#selSymOrder, label[for='selSymOrder']").show();