const ui = {};
function saveSymbols(action, id, server) {
+ $("#save-alert button").attr("disabled", true);
+
const inputs = $("#" + id + ' :input[data-role="numerictextbox"]');
const url = action;
const values = [];
rspamd.query(url, {
success: function () {
+ $("#save-alert").addClass("d-none");
rspamd.alertMessage("alert-modal alert-success", "Symbols successfully saved");
},
+ complete: () => $("#save-alert button").removeAttr("disabled", true),
errorMessage: "Save symbols error",
method: "POST",
params: {
const lookup = {};
const freqs = [];
const distinct_groups = [];
- const selected_server = rspamd.getSelector("selSrv");
data.forEach((group) => {
group.rules.forEach((item) => {
lookup[item.group] = 1;
distinct_groups.push(item.group);
}
- item.save =
- '<button data-save="' + selected_server + '" title="Save changes to the selected server" ' +
- 'type="button" class="btn btn-primary btn-sm mb-disabled">Save</button> ' +
- '<button data-save="All SERVERS" title="Save changes to all servers" ' +
- 'type="button" class="btn btn-primary btn-sm mb-disabled">Save in cluster</button>';
items.push(item);
});
});
}
// @get symbols into modal form
ui.getSymbols = function (checked_server) {
+ $("#save-alert").addClass("d-none");
rspamd.query("symbols", {
success: function (json) {
const [{data}] = json;
style: {"font-size": "11px"},
sortValue: function (value) { return Number(value).toFixed(2); }},
{name: "time", title: "Avg. time", breakpoints: "xs sm", style: {"font-size": "11px"}},
- {name: "save", title: "Save", style: {"font-size": "11px"}},
],
rows: items[0],
paging: {
server: (checked_server === "All SERVERS") ? "local" : checked_server
});
$("#symbolsTable")
- .off("click", ":button")
- .on("click", ":button", function () {
- const value = $(this).data("save");
- if (!value) return;
- saveSymbols("./savesymbols", "symbolsTable", value);
- })
.on("input", ".scorebar", ({target}) => {
const t = $(target);
t.removeClass("scorebar-ham scorebar-spam");
} else if (target.value > 0) {
t.addClass("scorebar-spam");
}
+ $("#save-alert").removeClass("d-none");
});
+ $("#save-alert button")
+ .off("click")
+ .on("click", ({target}) => saveSymbols("./savesymbols", "symbolsTable", $(target).data("save")));
};
$("#updateSymbols").on("click", (e) => {
e.preventDefault();
+ $("#save-alert").addClass("d-none");
const checked_server = rspamd.getSelector("selSrv");
rspamd.query("symbols", {
success: function (data) {