]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Add symbols order selector to history
authorAlexander Moisseev <moiseev@mezonplus.ru>
Thu, 5 Apr 2018 15:03:38 +0000 (18:03 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Thu, 5 Apr 2018 17:26:50 +0000 (20:26 +0300)
interface/css/rspamd.css
interface/index.html
interface/js/app/history.js

index 3af8baad737ab293a77808d6856ffca03b3aff9d..c52e133c173c366910038259e6c9b270be23adc1 100644 (file)
@@ -160,6 +160,13 @@ input.action-scores {
     padding-right: 20px;
 }
 
+#selSymOrder {
+    height: auto;
+}
+.widget-title-form label {
+    font-weight: normal;
+}
+
 .btn-upload-trigger {
        position:relative;
        z-index:1;
@@ -281,8 +288,7 @@ td.maps-cell {
        margin:0 0 0 36px;
        }
 .widget-title .buttons {
-       float:left;
-       margin:2px 2px 0 0;
+       padding:2px 2px 0 0;
        }
 .widget-title .label {
        padding:3px 5px 2px;
index 85794a49db68cdbc9a0cee73fcb7d952d316d439..8cb21794f08d43de9c4c436d468bc42f3be9ba59 100644 (file)
 
                                <div class="widget-box">
                                        <div class="widget-title">
-                                               <div class="buttons pull-right">
+                                               <form role="form" class="form-inline pull-right buttons">
+                                                       <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="name">Name</option>
+                                                               </select>
+                                                       </div>
                                                        <button class="btn btn-danger btn-sm" id="resetHistory">
                                                                <i class="glyphicon glyphicon-remove-circle"></i> Reset
                                                        </button>
                                                        <button class="btn btn-info btn-sm" id="updateHistory">
                                                                <i class="glyphicon glyphicon-refresh"></i> Update
                                                        </button>
-                                               </div>
+                                               </form>
                                                <span class="icon"><i class="glyphicon glyphicon-eye-open"></i></span>
                                                <h5>History</h5>
                                        </div>
index af0a2a80e9bbcc046dc52c06ad137bc513e6ec46..fba1dd58f7c16cd21423a10cc11ac36d0b12b57e 100644 (file)
@@ -116,6 +116,18 @@ function($, _, Humanize) {
     function process_history_v2(data) {
         var items = [];
 
+        function getSelector(id) {
+            var e = document.getElementById(id);
+            return e.options[e.selectedIndex].value;
+        }
+        var compare = (getSelector("selSymOrder") === "score")
+            ? function (e1, e2) {
+                return Math.abs(e1.score) < Math.abs(e2.score);
+            }
+            : function (e1, e2) {
+                return e1.name.localeCompare(e2.name);
+            };
+
         $.each(data.rows,
           function (i, item) {
 
@@ -141,9 +153,7 @@ function($, _, Humanize) {
                 map(function(key) {
                     return item.symbols[key];
                 }).
-                sort(function(e1, e2) {
-                    return Math.abs(e1.score) < Math.abs(e2.score);
-                }).
+                sort(compare).
                 map(function(e) { return e.str; }).
                 join("<br>\n");
             item.time = {
@@ -605,6 +615,9 @@ function($, _, Humanize) {
             e.preventDefault();
             interface.getHistory(rspamd, tables, neighbours, checked_server);
         });
+        $("#selSymOrder").change(function() {
+            interface.getHistory(rspamd, tables, neighbours, checked_server);
+        });
 
         // @reset history log
         $('#resetHistory').off('click');