]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Add control to invert action filter 4645/head
authormoisseev <moiseev@mezonplus.ru>
Sun, 15 Oct 2023 16:58:20 +0000 (19:58 +0300)
committermoisseev <moiseev@mezonplus.ru>
Sun, 15 Oct 2023 16:58:20 +0000 (19:58 +0300)
to scan results and history tables

Issue: #4098

.eslintrc.json
interface/js/app/rspamd.js

index 714c80f7cf4ede307dfc0bb671e765c41eea9096..f0856b782b45b47da98a01394ddf9feba35afd2d 100644 (file)
@@ -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",
index 763579ca670ba38fac30b218732ff0490c364f27..59a4a4d1721027f1b33c190be31d43e71463cf6d 100644 (file)
@@ -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,13 +829,19 @@ 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");
                 }