summaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
authormoisseev <moiseev@mezonplus.ru>2022-04-26 20:29:39 +0300
committermoisseev <moiseev@mezonplus.ru>2022-04-26 20:29:39 +0300
commit28d83c3dd1a86e2833db2a7c1a68bc9a95629ffc (patch)
tree5fe6fc118da57eaa64da14ed126751818ff94351 /interface
parent29c1bc04e6d26c4578a6cc8b97d1f4106df5ffa4 (diff)
downloadrspamd-28d83c3dd1a86e2833db2a7c1a68bc9a95629ffc.tar.gz
rspamd-28d83c3dd1a86e2833db2a7c1a68bc9a95629ffc.zip
[WebUI] Learn a random server of "All SERVERS"
Issue: #4157
Diffstat (limited to 'interface')
-rw-r--r--interface/index.html9
-rw-r--r--interface/js/app/rspamd.js5
-rw-r--r--interface/js/app/upload.js13
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()
});
}