aboutsummaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-01-28 23:42:27 +0600
committerGitHub <noreply@github.com>2024-01-28 23:42:27 +0600
commita06f4c1439fda74bc221812a3ecbfba0a285dffd (patch)
treeb2819e59ddf767ecbc2a0b2faca6fc2dbd61b08a /interface
parent4adcf12295934fa5d64b4867ebd67e8dba325ae1 (diff)
parentf44458b19aae42fd58e6faca3af15b1b9b7d3833 (diff)
downloadrspamd-a06f4c1439fda74bc221812a3ecbfba0a285dffd.tar.gz
rspamd-a06f4c1439fda74bc221812a3ecbfba0a285dffd.zip
Merge pull request #4796 from moisseev/webui
[Minor] Move server selection logic to common.js
Diffstat (limited to 'interface')
-rw-r--r--interface/js/app/common.js5
-rw-r--r--interface/js/app/config.js11
-rw-r--r--interface/js/app/rspamd.js6
-rw-r--r--interface/js/app/selectors.js11
-rw-r--r--interface/js/app/symbols.js7
-rw-r--r--interface/js/app/upload.js9
6 files changed, 21 insertions, 28 deletions
diff --git a/interface/js/app/common.js b/interface/js/app/common.js
index ea6102f60..0364ed0e9 100644
--- a/interface/js/app/common.js
+++ b/interface/js/app/common.js
@@ -138,6 +138,11 @@ define(["jquery", "nprogress"],
return e.options[e.selectedIndex].value;
};
+ ui.getServer = function () {
+ const checked_server = ui.getSelector("selSrv");
+ return (checked_server === "All SERVERS") ? "local" : checked_server;
+ };
+
/**
* @param {string} url - A string containing the URL to which the request is sent
* @param {Object} [options] - A set of key/value pairs that configure the Ajax request. All settings are optional.
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 6be107555..d7b43dfdb 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -29,7 +29,7 @@ define(["jquery", "app/common"],
"use strict";
const ui = {};
- ui.getActions = function getActions(checked_server) {
+ ui.getActions = function getActions() {
common.query("actions", {
success: function (data) {
$("#actionsFormField").empty();
@@ -57,7 +57,7 @@ define(["jquery", "app/common"],
$("#actionsFormField").html(
items.map((e) => e.html).join(""));
},
- server: (checked_server === "All SERVERS") ? "local" : checked_server
+ server: common.getServer()
});
};
@@ -109,7 +109,7 @@ define(["jquery", "app/common"],
}
};
- ui.getMaps = function (checked_server) {
+ ui.getMaps = function () {
const $listmaps = $("#listMaps");
$listmaps.closest(".card").hide();
common.query("maps", {
@@ -135,7 +135,7 @@ define(["jquery", "app/common"],
$tbody.appendTo($listmaps);
$listmaps.closest(".card").show();
},
- server: (checked_server === "All SERVERS") ? "local" : checked_server
+ server: common.getServer()
});
};
@@ -158,7 +158,6 @@ define(["jquery", "app/common"],
// Modal form for maps
$(document).on("click", "[data-bs-toggle=\"modal\"]", function () {
- const checked_server = common.getSelector("selSrv");
const item = $(this).data("item");
common.query("getmap", {
headers: {
@@ -197,7 +196,7 @@ define(["jquery", "app/common"],
$("#modalDialog").modal("show");
},
errorMessage: "Cannot receive maps data",
- server: (checked_server === "All SERVERS") ? "local" : checked_server
+ server: common.getServer()
});
return false;
});
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index 938f048e7..fb5c268c9 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -168,12 +168,12 @@ define(["jquery", "app/common", "stickytabs", "visibility",
break;
case "#configuration_nav":
require(["app/config"], (module) => {
- module.getActions(checked_server);
- module.getMaps(checked_server);
+ module.getActions();
+ module.getMaps();
});
break;
case "#symbols_nav":
- require(["app/symbols"], (module) => module.getSymbols(checked_server));
+ require(["app/symbols"], (module) => module.getSymbols());
break;
case "#scan_nav":
require(["app/upload"]);
diff --git a/interface/js/app/selectors.js b/interface/js/app/selectors.js
index 53240d838..c2b8b27e5 100644
--- a/interface/js/app/selectors.js
+++ b/interface/js/app/selectors.js
@@ -10,11 +10,6 @@ define(["jquery", "app/common"],
));
}
- function get_server() {
- const checked_server = common.getSelector("selSrv");
- return (checked_server === "All SERVERS") ? "local" : checked_server;
- }
-
function checkMsg(data) {
const selector = $("#selectorsSelArea").val();
common.query("plugins/selectors/check_message?selector=" + encodeURIComponent(selector), {
@@ -30,7 +25,7 @@ define(["jquery", "app/common"],
common.alertMessage("alert-error", "Unexpected error processing message");
}
},
- server: get_server()
+ server: common.getServer()
});
}
@@ -50,7 +45,7 @@ define(["jquery", "app/common"],
toggle_form_group_class("valid", "invalid");
}
},
- server: get_server()
+ server: common.getServer()
});
} else {
$("#selectorsSelArea").removeClass("is-valid is-invalid");
@@ -76,7 +71,7 @@ define(["jquery", "app/common"],
const json = neighbours_status[0].data;
build_table_from_json(json, "#selectorsTable-" + list);
},
- server: get_server()
+ server: common.getServer()
});
}
diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js
index 1e3fb5de7..2d8f359fc 100644
--- a/interface/js/app/symbols.js
+++ b/interface/js/app/symbols.js
@@ -122,7 +122,7 @@ define(["jquery", "app/common", "footable"],
return [items, distinct_groups];
}
// @get symbols into modal form
- ui.getSymbols = function (checked_server) {
+ ui.getSymbols = function () {
clear_altered();
common.query("symbols", {
success: function (json) {
@@ -220,7 +220,7 @@ define(["jquery", "app/common", "footable"],
}
});
},
- server: (checked_server === "All SERVERS") ? "local" : checked_server
+ server: common.getServer()
});
};
@@ -228,13 +228,12 @@ define(["jquery", "app/common", "footable"],
$("#updateSymbols").on("click", (e) => {
e.preventDefault();
clear_altered();
- const checked_server = common.getSelector("selSrv");
common.query("symbols", {
success: function (data) {
const [items] = process_symbols_data(data[0].data);
common.tables.symbols.rows.load(items);
},
- server: (checked_server === "All SERVERS") ? "local" : checked_server
+ server: common.getServer()
});
});
diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js
index 546f5cc84..1cde1d470 100644
--- a/interface/js/app/upload.js
+++ b/interface/js/app/upload.js
@@ -73,11 +73,6 @@ define(["jquery", "app/common", "app/libft"],
});
}
- function get_server() {
- const checked_server = common.getSelector("selSrv");
- return (checked_server === "All SERVERS") ? "local" : checked_server;
- }
-
// @upload text
function scanText(data, headers) {
common.query("checkv2", {
@@ -136,7 +131,7 @@ define(["jquery", "app/common", "app/libft"],
common.alertMessage("alert-error", "Cannot tokenize message: no text data");
}
},
- server: get_server()
+ server: common.getServer()
});
}
@@ -168,7 +163,7 @@ define(["jquery", "app/common", "app/libft"],
common.alertMessage("alert-error", "Unexpected error processing message");
}
},
- server: get_server()
+ server: common.getServer()
});
}