2017-03-02 12:23:23 +02:00
|
|
|
$(document).ready(function() {
|
2017-11-03 21:37:24 +02:00
|
|
|
$('#syncjobLogModal').on('show.bs.modal', function(e) {
|
|
|
|
var syncjob_id = $(e.relatedTarget).data('syncjob-id');
|
|
|
|
$.ajax({
|
|
|
|
url: '/inc/ajax/syncjob_logs.php',
|
|
|
|
data: { id: syncjob_id },
|
|
|
|
dataType: 'text',
|
|
|
|
success: function(data){
|
|
|
|
$(e.currentTarget).find('#logText').text(data);
|
|
|
|
},
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
$(e.currentTarget).find('#logText').text(xhr.responseText);
|
|
|
|
}
|
|
|
|
});
|
2017-03-02 12:23:23 +02:00
|
|
|
});
|
2017-05-17 21:17:00 +02:00
|
|
|
});
|
|
|
|
jQuery(function($){
|
|
|
|
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
|
|
|
var entityMap = {
|
|
|
|
'&': '&',
|
|
|
|
'<': '<',
|
|
|
|
'>': '>',
|
|
|
|
'"': '"',
|
|
|
|
"'": ''',
|
|
|
|
'/': '/',
|
|
|
|
'`': '`',
|
|
|
|
'=': '='
|
|
|
|
};
|
|
|
|
function escapeHtml(string) {
|
|
|
|
return String(string).replace(/[&<>"'`=\/]/g, function (s) {
|
|
|
|
return entityMap[s];
|
|
|
|
});
|
|
|
|
}
|
2017-05-23 09:36:59 +02:00
|
|
|
// http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
|
|
|
|
function validateEmail(email) {
|
|
|
|
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
|
|
return re.test(email);
|
|
|
|
}
|
|
|
|
function unix_time_format(tm) {
|
|
|
|
var date = new Date(tm ? tm * 1000 : 0);
|
|
|
|
return date.toLocaleString();
|
|
|
|
}
|
2017-08-18 22:18:14 +02:00
|
|
|
acl_data = JSON.parse(acl);
|
2018-08-03 20:31:33 +02:00
|
|
|
var last_login = $('.last_login_date').data('time');
|
|
|
|
$('.last_login_date').text(unix_time_format(last_login));
|
2017-08-18 22:18:14 +02:00
|
|
|
|
2017-05-23 09:36:59 +02:00
|
|
|
function draw_tla_table() {
|
|
|
|
ft_tla_table = FooTable.init('#tla_table', {
|
|
|
|
"columns": [
|
|
|
|
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
|
|
|
{"sorted": true,"name":"address","title":lang.alias},
|
|
|
|
{"name":"validity","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.alias_valid_until,"style":{"width":"170px"}},
|
2017-06-06 21:58:48 +02:00
|
|
|
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
2017-05-23 09:36:59 +02:00
|
|
|
],
|
|
|
|
"empty": lang.empty,
|
|
|
|
"rows": $.ajax({
|
|
|
|
dataType: 'json',
|
|
|
|
url: '/api/v1/get/time_limited_aliases',
|
|
|
|
jsonp: false,
|
|
|
|
error: function () {
|
|
|
|
console.log('Cannot draw tla table');
|
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
$.each(data, function (i, item) {
|
2017-08-18 22:18:14 +02:00
|
|
|
if (acl_data.spam_alias === 1) {
|
|
|
|
item.action = '<div class="btn-group">' +
|
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
|
|
|
'<a href="#" data-action="delete_selected" data-id="single-tla" data-api-url="delete/time_limited_alias" data-item="' + encodeURIComponent(item.address) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
2017-08-18 22:18:14 +02:00
|
|
|
'</div>';
|
2018-02-10 23:42:46 +02:00
|
|
|
item.chkbox = '<input type="checkbox" data-id="tla" name="multi_select" value="' + encodeURIComponent(item.address) + '" />';
|
|
|
|
item.address = escapeHtml(item.address);
|
2017-08-18 22:18:14 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
item.chkbox = '<input type="checkbox" disabled />';
|
|
|
|
item.action = '<span>-</span>';
|
|
|
|
}
|
2017-05-23 09:36:59 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
"paging": {
|
|
|
|
"enabled": true,
|
|
|
|
"limit": 5,
|
|
|
|
"size": pagination_size
|
|
|
|
},
|
2019-01-19 09:25:05 +02:00
|
|
|
"state": {"enabled": true},
|
2017-05-23 09:36:59 +02:00
|
|
|
"sorting": {
|
|
|
|
"enabled": true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-05-17 21:17:00 +02:00
|
|
|
function draw_sync_job_table() {
|
2017-05-23 09:36:59 +02:00
|
|
|
ft_syncjob_table = FooTable.init('#sync_job_table', {
|
2017-05-17 21:17:00 +02:00
|
|
|
"columns": [
|
2017-12-31 16:26:11 +02:00
|
|
|
{"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
2017-07-29 10:32:17 +02:00
|
|
|
{"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
2017-05-23 09:36:59 +02:00
|
|
|
{"name":"server_w_port","title":"Server"},
|
2017-11-08 12:07:32 +02:00
|
|
|
{"name":"enc1","title":lang.encryption,"breakpoints":"xs sm"},
|
2017-05-17 21:17:00 +02:00
|
|
|
{"name":"user1","title":lang.username},
|
2017-12-31 16:26:11 +02:00
|
|
|
{"name":"exclude","title":lang.excludes,"breakpoints":"all"},
|
|
|
|
{"name":"mins_interval","title":lang.interval + " (min)","breakpoints":"all"},
|
|
|
|
{"name":"last_run","title":lang.last_run,"breakpoints":"all"},
|
2017-05-17 21:17:00 +02:00
|
|
|
{"name":"log","title":"Log"},
|
2017-11-08 12:07:32 +02:00
|
|
|
{"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active},
|
|
|
|
{"name":"is_running","filterable": false,"style":{"maxWidth":"120px","width":"100px"},"title":lang.status},
|
2017-05-17 21:17:00 +02:00
|
|
|
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
|
|
|
],
|
|
|
|
"empty": lang.empty,
|
|
|
|
"rows": $.ajax({
|
|
|
|
dataType: 'json',
|
2018-02-10 23:42:46 +02:00
|
|
|
url: '/api/v1/get/syncjobs/' + encodeURIComponent(mailcow_cc_username) + '/no_log',
|
2017-05-17 21:17:00 +02:00
|
|
|
jsonp: false,
|
|
|
|
error: function () {
|
|
|
|
console.log('Cannot draw sync job table');
|
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
$.each(data, function (i, item) {
|
2018-02-10 23:42:46 +02:00
|
|
|
item.user1 = escapeHtml(item.user1);
|
|
|
|
item.log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + item.id + '">Open logs</a>'
|
2017-11-08 12:07:32 +02:00
|
|
|
if (!item.exclude > 0) {
|
|
|
|
item.exclude = '-';
|
|
|
|
} else {
|
2018-02-10 23:42:46 +02:00
|
|
|
item.exclude = '<code>' + escapeHtml(item.exclude) + '</code>';
|
2017-11-08 12:07:32 +02:00
|
|
|
}
|
2018-02-10 23:42:46 +02:00
|
|
|
item.server_w_port = escapeHtml(item.user1 + '@' + item.host1 + ':' + item.port1);
|
2017-08-18 22:18:14 +02:00
|
|
|
if (acl_data.syncjobs === 1) {
|
|
|
|
item.action = '<div class="btn-group">' +
|
2018-10-04 14:38:12 +02:00
|
|
|
'<a href="/edit/syncjob/' + item.id + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
[Docker API] Use TLS encryption for communication with "on-the-fly" created key paris (non-exposed)
[Docker API] Create pipe to pass Rspamd UI worker password
[Dovecot] Pull Spamassassin ruleset to be read by Rspamd (MANY THANKS to Peer Heinlein!)
[Dovecot] Garbage collector for deleted maildirs (set keep time via MAILDIR_GC_TIME which defaults to 1440 minutes)
[Web] Flush memcached after mailbox item changes, fixes #1808
[Web] Fix duplicate IDs, fixes #1792
[Compose] Use SQL sockets
[PHP-FPM] Update APCu and Redis libs
[Dovecot] Encrypt maildir with global key pair in crypt-vol-1 (BACKUP!), also fixes #1791
[Web] Fix deletion of spam aliases
[Helper] Add "crypt" to backup script
[Helper] Override file for external SQL socket (not supported!)
[Compose] New images for Rspamd, PHP-FPM, SOGo, Dovecot, Docker API, Watchdog, ACME, Postfix
2018-09-29 22:01:23 +02:00
|
|
|
'<a href="#" data-action="delete_selected" data-id="single-syncjob" data-api-url="delete/syncjob" data-item="' + item.id + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
2017-08-18 22:18:14 +02:00
|
|
|
'</div>';
|
|
|
|
item.chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item.id + '" />';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
item.action = '<span>-</span>';
|
|
|
|
item.chkbox = '<input type="checkbox" disabled />';
|
|
|
|
}
|
2017-11-08 12:07:32 +02:00
|
|
|
if (item.is_running == 1) {
|
|
|
|
item.is_running = '<span id="active-script" class="label label-success">' + lang.running + '</span>';
|
|
|
|
} else {
|
|
|
|
item.is_running = '<span id="inactive-script" class="label label-warning">' + lang.waiting + '</span>';
|
|
|
|
}
|
|
|
|
if (!item.last_run > 0) {
|
|
|
|
item.last_run = lang.waiting;
|
|
|
|
}
|
2017-05-17 21:17:00 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
"paging": {
|
|
|
|
"enabled": true,
|
|
|
|
"limit": 5,
|
|
|
|
"size": pagination_size
|
|
|
|
},
|
2019-01-19 09:25:05 +02:00
|
|
|
"state": {"enabled": true},
|
2017-05-17 21:17:00 +02:00
|
|
|
"sorting": {
|
|
|
|
"enabled": true
|
2019-07-27 18:57:58 +02:00
|
|
|
},
|
|
|
|
"toggleSelector": "table tbody span.footable-toggle"
|
2017-05-17 21:17:00 +02:00
|
|
|
});
|
|
|
|
}
|
2017-05-23 09:36:59 +02:00
|
|
|
function draw_wl_policy_mailbox_table() {
|
|
|
|
ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_mailbox_table', {
|
|
|
|
"columns": [
|
|
|
|
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
|
|
|
{"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
|
|
|
|
{"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
|
|
|
|
{"name":"object","title":"Scope"}
|
|
|
|
],
|
|
|
|
"empty": lang.empty,
|
|
|
|
"rows": $.ajax({
|
|
|
|
dataType: 'json',
|
|
|
|
url: '/api/v1/get/policy_wl_mailbox',
|
|
|
|
jsonp: false,
|
|
|
|
error: function () {
|
|
|
|
console.log('Cannot draw mailbox policy wl table');
|
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
$.each(data, function (i, item) {
|
|
|
|
if (validateEmail(item.object)) {
|
|
|
|
item.chkbox = '<input type="checkbox" data-id="policy_wl_mailbox" name="multi_select" value="' + item.prefid + '" />';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
item.chkbox = '<input type="checkbox" disabled title="' + lang.spamfilter_table_domain_policy + '" />';
|
|
|
|
}
|
2017-08-18 22:18:14 +02:00
|
|
|
if (acl_data.spam_policy === 0) {
|
|
|
|
item.chkbox = '<input type="checkbox" disabled />';
|
|
|
|
}
|
2017-05-23 09:36:59 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
2019-01-19 09:25:05 +02:00
|
|
|
"state": {"enabled": true},
|
2017-05-23 09:36:59 +02:00
|
|
|
"paging": {
|
|
|
|
"enabled": true,
|
|
|
|
"limit": 5,
|
|
|
|
"size": pagination_size
|
|
|
|
},
|
|
|
|
"sorting": {
|
|
|
|
"enabled": true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function draw_bl_policy_mailbox_table() {
|
|
|
|
ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_mailbox_table', {
|
|
|
|
"columns": [
|
|
|
|
{"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
|
|
|
{"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
|
|
|
|
{"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
|
|
|
|
{"name":"object","title":"Scope"}
|
|
|
|
],
|
|
|
|
"empty": lang.empty,
|
|
|
|
"rows": $.ajax({
|
|
|
|
dataType: 'json',
|
|
|
|
url: '/api/v1/get/policy_bl_mailbox',
|
|
|
|
jsonp: false,
|
|
|
|
error: function () {
|
|
|
|
console.log('Cannot draw mailbox policy bl table');
|
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
$.each(data, function (i, item) {
|
|
|
|
if (validateEmail(item.object)) {
|
|
|
|
item.chkbox = '<input type="checkbox" data-id="policy_bl_mailbox" name="multi_select" value="' + item.prefid + '" />';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
item.chkbox = '<input type="checkbox" disabled tooltip="' + lang.spamfilter_table_domain_policy + '" />';
|
|
|
|
}
|
2017-08-18 22:18:14 +02:00
|
|
|
if (acl_data.spam_policy === 0) {
|
|
|
|
item.chkbox = '<input type="checkbox" disabled />';
|
|
|
|
}
|
2017-05-23 09:36:59 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
"paging": {
|
|
|
|
"enabled": true,
|
|
|
|
"limit": 5,
|
|
|
|
"size": pagination_size
|
|
|
|
},
|
2019-01-19 09:25:05 +02:00
|
|
|
"state": {"enabled": true},
|
2017-05-23 09:36:59 +02:00
|
|
|
"sorting": {
|
|
|
|
"enabled": true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-07-27 18:56:51 +02:00
|
|
|
|
|
|
|
$('body').on('click', 'span.footable-toggle', function () {
|
|
|
|
event.stopPropagation();
|
|
|
|
})
|
|
|
|
|
2017-05-17 21:17:00 +02:00
|
|
|
draw_sync_job_table();
|
2017-05-23 09:36:59 +02:00
|
|
|
draw_tla_table();
|
|
|
|
draw_wl_policy_mailbox_table();
|
|
|
|
draw_bl_policy_mailbox_table();
|
2017-11-03 21:37:24 +02:00
|
|
|
|
|
|
|
// Sieve data modal
|
|
|
|
$('#userFilterModal').on('show.bs.modal', function(e) {
|
|
|
|
$('#user_sieve_filter').text(lang.loading);
|
|
|
|
$.ajax({
|
|
|
|
dataType: 'json',
|
2018-02-10 23:42:46 +02:00
|
|
|
url: '/api/v1/get/active-user-sieve/' + encodeURIComponent(mailcow_cc_username),
|
2017-11-03 21:37:24 +02:00
|
|
|
jsonp: false,
|
|
|
|
error: function () {
|
|
|
|
console.log('Cannot get active sieve script');
|
|
|
|
},
|
|
|
|
complete: function (data) {
|
|
|
|
if (data.responseText == '{}') {
|
|
|
|
$('#user_sieve_filter').text(lang.no_active_filter);
|
|
|
|
} else {
|
|
|
|
$('#user_sieve_filter').text(JSON.parse(data.responseText));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
$('#userFilterModal').on('hidden.bs.modal', function () {
|
|
|
|
$('#user_sieve_filter').text(lang.loading);
|
|
|
|
});
|
2017-03-02 12:23:23 +02:00
|
|
|
});
|