]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Learn a random server of "All SERVERS" 4160/head
authormoisseev <moiseev@mezonplus.ru>
Tue, 26 Apr 2022 17:29:39 +0000 (20:29 +0300)
committermoisseev <moiseev@mezonplus.ru>
Tue, 26 Apr 2022 17:29:39 +0000 (20:29 +0300)
Issue: #4157

interface/index.html
interface/js/app/rspamd.js
interface/js/app/upload.js

index 8124044af71561c827186586c08a787eaabaa283..c7f57cc1a2d4f5d6d14a1c433fd5afacebfd719c 100644 (file)
                                        </div>
                                </div>
                                <div class="card ro-hide" style="display: none;">
-                                       <div class="card-header text-secondary py-2">
+                                       <div class="card-header text-secondary py-1 d-flex">
                                                <span class="icon mr-3"><i class="fas fa-graduation-cap"></i></span>
                                                <span class="h6 font-weight-bolder my-2">Learn Rspamd</span>
+                                               <div id="learnServers" class="form-inline card-header-form input-group-sm align-self-center ml-auto mr-1">
+                                                       <label for="selLearnServers">Learn servers:</label>
+                                                       <select id="selLearnServers" class="form-control ml-1">
+                                                               <option value="random" selected>random</option>
+                                                               <option value="all">all</option>
+                                                       </select>
+                                               </div>
                                        </div>
                                        <div class="card-body">
                                                <div class="row">
index b440022e43d6f4ec5441e33370e1f1bd2022c461..66b1766c92a1c750346cd4154327dc60e4f8c34b 100644 (file)
@@ -548,6 +548,11 @@ function ($, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_config,
         $("#selSrv").change(function () {
             checked_server = this.value;
             $("#selSrv [value=\"" + checked_server + "\"]").prop("checked", true);
+            if (checked_server === "All SERVERS") {
+                $("#learnServers").show();
+            } else {
+                $("#learnServers").hide();
+            }
             tabClick("#" + $("#navBar > ul > .nav-item > .nav-link.active").attr("id"));
         });
 
index 3e95c217116e7112350a9c5616db4ea00aedb5da..cef5c596e870e8ebaa27d541c7f584ee598516ac 100644 (file)
@@ -43,6 +43,16 @@ define(["jquery"],
             } else if (source === "scan") {
                 url = "checkv2";
             }
+
+            function server() {
+                if (rspamd.getSelector("selSrv") === "All SERVERS" &&
+                    rspamd.getSelector("selLearnServers") === "random") {
+                    const servers = $("#selSrv option").slice(1).map(function (_, o) { return o.value; });
+                    return servers[Math.floor(Math.random() * servers.length)];
+                }
+                return null;
+            }
+
             rspamd.query(url, {
                 data: data,
                 params: {
@@ -56,7 +66,8 @@ define(["jquery"],
                     if (jqXHR.status !== 200) {
                         rspamd.alertMessage("alert-info", jqXHR.statusText);
                     }
-                }
+                },
+                server: server()
             });
         }