aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-10-16 08:27:33 +0100
committerGitHub <noreply@github.com>2023-10-16 08:27:33 +0100
commit508fe8a626e649233fcbe57e829a78f23ceb364c (patch)
treeddd3e3ab00c6c6940cbfa9de2528e112f0c90281
parentd6abbee4d1bb09ca4c8811968207dcdc6619a2e9 (diff)
parentc290eece13a1f9f1f816789f5e02bb9c0cf34d82 (diff)
downloadrspamd-508fe8a626e649233fcbe57e829a78f23ceb364c.tar.gz
rspamd-508fe8a626e649233fcbe57e829a78f23ceb364c.zip
Merge pull request #4645 from moisseev/webui
[WebUI] Add control to invert action filter
-rw-r--r--.eslintrc.json1
-rw-r--r--interface/js/app/rspamd.js45
2 files changed, 28 insertions, 18 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index 714c80f7c..f0856b782 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -49,6 +49,7 @@
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"prefer-destructuring": "off",
+ "prefer-named-capture-group": "off",
"prefer-object-has-own": "off",
"prefer-spread": "off",
"prefer-template": "off",
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index 67b60d973..59a4a4d17 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -792,13 +792,29 @@ function ($, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_config,
},
$create: function () {
this._super();
- var self = this, $form_grp = $("<div/>", {
- class: "form-group"
+ const self = this, $form_grp = $("<div/>", {
+ class: "form-group d-inline-flex align-items-center"
}).append($("<label/>", {
class: "sr-only",
text: "Action"
})).prependTo(self.$form);
+ $("<div/>", {
+ class: "form-check form-check-inline",
+ title: "Invert action match."
+ }).append(
+ self.$not = $("<input/>", {
+ type: "checkbox",
+ class: "form-check-input",
+ id: "not_" + table
+ }).on("change", {self: self}, self._onStatusDropdownChanged),
+ $("<label/>", {
+ class: "form-check-label",
+ for: "not_" + table,
+ text: "not"
+ })
+ ).appendTo($form_grp);
+
self.$action = $("<select/>", {
class: "form-select"
}).on("change", {
@@ -813,30 +829,23 @@ function ($, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_config,
});
},
_onStatusDropdownChanged: function (e) {
- var self = e.data.self, selected = $(this).val();
+ const self = e.data.self;
+ const selected = self.$action.val();
if (selected !== self.def) {
+ const not = self.$not.is(":checked");
+ let query = null;
+
if (selected === "reject") {
- self.addFilter("action", "reject -soft", ["action"]);
+ query = not ? "-reject OR soft" : "reject -soft";
} else {
- self.addFilter("action", selected, ["action"]);
+ query = not ? selected.replace(/(\b\w+\b)/g, "-$1") : selected;
}
+
+ self.addFilter("action", query, ["action"]);
} else {
self.removeFilter("action");
}
self.filter();
- },
- draw: function () {
- this._super();
- var action = this.find("action");
- if (action instanceof FooTable.Filter) {
- if (action.query.val() === "reject -soft") {
- this.$action.val("reject");
- } else {
- this.$action.val(action.query.val());
- }
- } else {
- this.$action.val(this.def);
- }
}
});
/* eslint-enable consistent-this, no-underscore-dangle, one-var-declaration-per-line */