commit 28d83c3: [WebUI] Learn a random server of "All SERVERS"
moisseev
moiseev at mezonplus.ru
Tue Apr 26 19:07:03 UTC 2022
Author: moisseev
Date: 2022-04-26 20:29:39 +0300
URL: https://github.com/rspamd/rspamd/commit/28d83c3dd1a86e2833db2a7c1a68bc9a95629ffc (refs/pull/4160/head)
[WebUI] Learn a random server of "All SERVERS"
Issue: #4157
---
interface/index.html | 9 ++++++++-
interface/js/app/rspamd.js | 5 +++++
interface/js/app/upload.js | 13 ++++++++++++-
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/interface/index.html b/interface/index.html
index 8124044af..c7f57cc1a 100644
--- a/interface/index.html
+++ b/interface/index.html
@@ -412,9 +412,16 @@
</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">
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index b440022e4..66b1766c9 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -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"));
});
diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js
index 3e95c2171..cef5c596e 100644
--- a/interface/js/app/upload.js
+++ b/interface/js/app/upload.js
@@ -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()
});
}
More information about the Commits
mailing list