Add better preset management (#3119)
* add rspamd-presets * add sieveMailbox-presets * adding new translations
This commit is contained in:
32
data/web/js/presets/rspamd.js
Normal file
32
data/web/js/presets/rspamd.js
Normal file
@@ -0,0 +1,32 @@
|
||||
var rspamdPresets = [
|
||||
{
|
||||
description: lang.rsettings_preset_1,
|
||||
codeValue: 'priority = 10;\nauthenticated = yes;\napply "default" {\n symbols_enabled = ["DKIM_SIGNED", "RATELIMITED", "RATELIMIT_UPDATE", "RATELIMIT_CHECK", "DYN_RL_CHECK", "HISTORY_SAVE", "MILTER_HEADERS", "ARC_SIGNED"];\n}'
|
||||
},
|
||||
{
|
||||
description: lang.rsettings_preset_2,
|
||||
codeValue: 'priority = 10;\nrcpt = "/postmaster@.*/";\nwant_spam = yes;'
|
||||
}
|
||||
];
|
||||
|
||||
var rspamd_presetsElem = document.getElementById("rspamd_presets");
|
||||
if (rspamd_presetsElem && rspamdPresets) {
|
||||
rspamd_presetsElem.innerHTML = '';
|
||||
rspamdPresets.forEach(function (item, index) {
|
||||
var elemID = 'rspamd_preset_' + index;
|
||||
rspamd_presetsElem.innerHTML += '<li><a href="#" class="small" id="' + elemID + '">' + lang.rsettings_insert_preset.replace('%s', item.description) + '</a></li>';
|
||||
|
||||
/*
|
||||
we need to define 0-timeout here, to prevent dom not be ready.
|
||||
*/
|
||||
setTimeout(function () {
|
||||
document.getElementById(elemID).addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsDesc').value = item.description;
|
||||
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsContent').value = item.codeValue;
|
||||
return true;
|
||||
});
|
||||
}, 0)
|
||||
|
||||
});
|
||||
}
|
31
data/web/js/presets/sieveMailbox.js
Normal file
31
data/web/js/presets/sieveMailbox.js
Normal file
@@ -0,0 +1,31 @@
|
||||
var sieveMailboxPresets = [
|
||||
{
|
||||
description: lang.sieve_preset_1,
|
||||
codeValue: 'if header :contains "x-attached"\n [".exe",".bat",".js",".com",".cmd",".ini",".dll",".bas",".cpl",".drv",".inf",".sys",".pif",".doc",".docx"] {\n discard;\n stop;\n}'
|
||||
},
|
||||
{
|
||||
description: lang.sieve_preset_2,
|
||||
codeValue: 'require ["envelope", "imap4flags"];\nif envelope "from" "mark@me-read.com"\n{\n setflag "\\\\seen";\n}'
|
||||
}
|
||||
];
|
||||
|
||||
var sieve_presetsElem = document.getElementById("sieve_presets");
|
||||
if (sieve_presetsElem && sieveMailboxPresets) {
|
||||
sieve_presetsElem.innerHTML = '';
|
||||
sieveMailboxPresets.forEach(function (item, index) {
|
||||
var elemID = 'sieve_preset_' + index;
|
||||
sieve_presetsElem.innerHTML += '<li><a href="#" class="small" id="' + elemID + '">' + lang.insert_preset.replace('%s', item.description) + '</a></li>';
|
||||
|
||||
/*
|
||||
we need to define 0-timeout here, to prevent dom not be ready.
|
||||
*/
|
||||
setTimeout(function () {
|
||||
document.getElementById(elemID).addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
document.querySelector('form[data-id=add_filter] #script_desc').value = item.description;
|
||||
document.querySelector('form[data-id=add_filter] #script_data').value = item.codeValue;
|
||||
return true;
|
||||
});
|
||||
}, 0)
|
||||
});
|
||||
}
|
@@ -9,16 +9,6 @@ jQuery(function($){
|
||||
function humanFileSize(i){if(Math.abs(i)<1024)return i+" B";var B=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],e=-1;do{i/=1024,++e}while(Math.abs(i)>=1024&&e<B.length-1);return i.toFixed(1)+" "+B[e]}
|
||||
function hashCode(t){for(var n=0,r=0;r<t.length;r++)n=t.charCodeAt(r)+((n<<5)-n);return n}
|
||||
function intToRGB(t){var n=(16777215&t).toString(16).toUpperCase();return"00000".substring(0,6-n.length)+n}
|
||||
$("#rspamd_preset_1").on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("form[data-id=rsetting]").find("#adminRspamdSettingsDesc").val(lang.rsettings_preset_1);
|
||||
$("form[data-id=rsetting]").find("#adminRspamdSettingsContent").val('priority = 10;\nauthenticated = yes;\napply "default" {\n symbols_enabled = ["DKIM_SIGNED", "RATELIMITED", "RATELIMIT_UPDATE", "RATELIMIT_CHECK", "DYN_RL_CHECK", "HISTORY_SAVE", "MILTER_HEADERS", "ARC_SIGNED"];\n}');
|
||||
});
|
||||
$("#rspamd_preset_2").on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("form[data-id=rsetting]").find("#adminRspamdSettingsDesc").val(lang.rsettings_preset_2);
|
||||
$("form[data-id=rsetting]").find("#adminRspamdSettingsContent").val('priority = 10;\nrcpt = "/postmaster@.*/";\nwant_spam = yes;');
|
||||
});
|
||||
$("#dkim_missing_keys").on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var domains = [];
|
||||
|
Reference in New Issue
Block a user