From a492727ffcefcc4ae7c6b1790da04a1b61aaa5f1 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Wed, 18 Jun 2025 16:56:55 +0300 Subject: [PATCH] [WebUI] Add Bayes classifier selector to Learn card This enables users to choose a specific Bayes classifier for training from WebUI. --- interface/index.html | 9 ++++++--- interface/js/app/rspamd.js | 2 ++ interface/js/app/upload.js | 18 +++++++++++++++++- src/controller.c | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/interface/index.html b/interface/index.html index b176d65273..61487ce295 100644 --- a/interface/index.html +++ b/interface/index.html @@ -479,9 +479,12 @@

Learn Bayesian classifier:

-
- - +
+ +
+ + +
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 6d047d6f66..da4e9bccfe 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -236,6 +236,8 @@ define(["jquery", "app/common", "stickytabs", "visibility", complete: function () { ajaxSetup(localStorage.getItem("ajax_timeout")); + if (require.defined("app/upload")) require(["app/upload"], (module) => module.getClassifiers()); + if (common.read_only) { $(".ro-disable").attr("disabled", true); $(".ro-hide").hide(); diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js index a5d30b59ef..0960ebf25b 100644 --- a/interface/js/app/upload.js +++ b/interface/js/app/upload.js @@ -217,7 +217,10 @@ define(["jquery", "app/common", "app/libft"], getFuzzyHashes(data); } else { let headers = {}; - if (source === "fuzzyadd") { + if (source === "learnham" || source === "learnspam") { + const classifier = $("#classifier").val(); + if (classifier) headers = {classifier: classifier}; + } else if (source === "fuzzyadd") { headers = { flag: $("#fuzzyFlagText").val(), weight: $("#fuzzyWeightText").val() @@ -296,5 +299,18 @@ define(["jquery", "app/common", "app/libft"], common.fileUtils.setupFileHandling("#scanMsgSource", "#formFile", fileSet, enable_disable_scan_btn, multiple_files_cb); + ui.getClassifiers = function () { + if (!common.read_only) { + const sel = $("#classifier").empty().append($("