From: Alexander Moisseev Date: Wed, 18 Jun 2025 13:56:55 +0000 (+0300) Subject: [WebUI] Add Bayes classifier selector to Learn card X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F5520%2Fhead;p=thirdparty%2Frspamd.git [WebUI] Add Bayes classifier selector to Learn card This enables users to choose a specific Bayes classifier for training from WebUI. --- 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($("