2021-06-22 07:17:55 +02:00
|
|
|
// Base64 functions
|
|
|
|
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(r){var t,e,o,a,h,n,c,d="",C=0;for(r=Base64._utf8_encode(r);C<r.length;)a=(t=r.charCodeAt(C++))>>2,h=(3&t)<<4|(e=r.charCodeAt(C++))>>4,n=(15&e)<<2|(o=r.charCodeAt(C++))>>6,c=63&o,isNaN(e)?n=c=64:isNaN(o)&&(c=64),d=d+this._keyStr.charAt(a)+this._keyStr.charAt(h)+this._keyStr.charAt(n)+this._keyStr.charAt(c);return d},decode:function(r){var t,e,o,a,h,n,c="",d=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");d<r.length;)t=this._keyStr.indexOf(r.charAt(d++))<<2|(a=this._keyStr.indexOf(r.charAt(d++)))>>4,e=(15&a)<<4|(h=this._keyStr.indexOf(r.charAt(d++)))>>2,o=(3&h)<<6|(n=this._keyStr.indexOf(r.charAt(d++))),c+=String.fromCharCode(t),64!=h&&(c+=String.fromCharCode(e)),64!=n&&(c+=String.fromCharCode(o));return c=Base64._utf8_decode(c)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e<r.length;e++){var o=r.charCodeAt(e);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t},_utf8_decode:function(r){for(var t="",e=0,o=c1=c2=0;e<r.length;)(o=r.charCodeAt(e))<128?(t+=String.fromCharCode(o),e++):o>191&&o<224?(c2=r.charCodeAt(e+1),t+=String.fromCharCode((31&o)<<6|63&c2),e+=2):(c2=r.charCodeAt(e+1),c3=r.charCodeAt(e+2),t+=String.fromCharCode((15&o)<<12|(63&c2)<<6|63&c3),e+=3);return t}};
|
2017-03-02 12:23:23 +02:00
|
|
|
$(document).ready(function() {
|
2021-05-21 12:48:19 +02:00
|
|
|
// Spam score slider
|
|
|
|
var spam_slider = $('#spam_score')[0];
|
2021-08-04 12:41:01 +02:00
|
|
|
if (typeof spam_slider !== 'undefined') {
|
|
|
|
noUiSlider.create(spam_slider, {
|
|
|
|
start: user_spam_score,
|
|
|
|
connect: [true, true, true],
|
|
|
|
range: {
|
|
|
|
'min': [0], //stepsize is 50.000
|
|
|
|
'50%': [10],
|
|
|
|
'70%': [20, 5],
|
|
|
|
'80%': [50, 10],
|
|
|
|
'90%': [100, 100],
|
|
|
|
'95%': [1000, 1000],
|
|
|
|
'max': [5000]
|
|
|
|
},
|
|
|
|
});
|
|
|
|
var connect = spam_slider.querySelectorAll('.noUi-connect');
|
|
|
|
var classes = ['c-1-color', 'c-2-color', 'c-3-color'];
|
|
|
|
for (var i = 0; i < connect.length; i++) {
|
|
|
|
connect[i].classList.add(classes[i]);
|
|
|
|
}
|
|
|
|
spam_slider.noUiSlider.on('update', function (values, handle) {
|
|
|
|
$('.spam-ham-score').text('< ' + Math.round(values[0] * 10) / 10);
|
|
|
|
$('.spam-spam-score').text(Math.round(values[0] * 10) / 10 + ' - ' + Math.round(values[1] * 10) / 10);
|
|
|
|
$('.spam-reject-score').text('> ' + Math.round(values[1] * 10) / 10);
|
|
|
|
$('#spam_score_value').val((Math.round(values[0] * 10) / 10) + ',' + (Math.round(values[1] * 10) / 10));
|
|
|
|
});
|
2021-05-21 12:48:19 +02:00
|
|
|
}
|
|
|
|
// syncjobLogModal
|
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
|
|
|
});
|
2020-04-17 16:56:28 +02:00
|
|
|
$(".arrow-toggle").on('click', function(e) { e.preventDefault(); $(this).find('.arrow').toggleClass("animation"); });
|
2020-04-18 10:15:03 +02:00
|
|
|
$("#pushover_delete").click(function() { return confirm(lang.delete_ays); });
|
2021-06-04 14:29:39 +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);
|
2020-04-10 21:00:46 +02:00
|
|
|
return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
2017-05-23 09:36:59 +02:00
|
|
|
}
|
2017-08-18 22:18:14 +02:00
|
|
|
acl_data = JSON.parse(acl);
|
2021-06-04 14:29:39 +02:00
|
|
|
|
2021-06-09 07:19:57 +02:00
|
|
|
$('.clear-last-logins').on('click', function () {if (confirm(lang.delete_ays)) {last_logins('reset');}})
|
|
|
|
$(".login-history").on('click', function(e) {e.preventDefault(); last_logins('get', $(this).data('days'));$(this).addClass('active').siblings().removeClass('active');});
|
2021-06-04 14:29:39 +02:00
|
|
|
|
2021-10-30 16:56:04 +02:00
|
|
|
function last_logins(action, days = 7) {
|
2021-06-04 14:29:39 +02:00
|
|
|
if (action == 'get') {
|
2021-06-09 07:19:57 +02:00
|
|
|
$('.last-login').html('<i class="bi bi-hourglass"></i>' + lang.waiting);
|
2021-06-04 14:29:39 +02:00
|
|
|
$.ajax({
|
|
|
|
dataType: 'json',
|
2021-06-09 07:19:57 +02:00
|
|
|
url: '/api/v1/get/last-login/' + encodeURIComponent(mailcow_cc_username) + '/' + days,
|
2021-06-04 14:29:39 +02:00
|
|
|
jsonp: false,
|
|
|
|
error: function () {
|
|
|
|
console.log('error reading last logins');
|
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
$('.last-login').html();
|
|
|
|
if (data.ui.time) {
|
|
|
|
$('.last-login').html('<i class="bi bi-person-fill"></i> ' + lang.last_ui_login + ': ' + unix_time_format(data.ui.time));
|
|
|
|
} else {
|
|
|
|
$('.last-login').text(lang.no_last_login);
|
|
|
|
}
|
|
|
|
if (data.sasl) {
|
|
|
|
$('.last-login').append('<ul class="list-group">');
|
|
|
|
$.each(data.sasl, function (i, item) {
|
|
|
|
var datetime = new Date(item.datetime.replace(/-/g, "/"));
|
|
|
|
var local_datetime = datetime.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
2022-06-15 16:34:49 +02:00
|
|
|
var service = '<div class="badge fs-6 bg-secondary">' + item.service.toUpperCase() + '</div>';
|
2021-10-30 16:56:04 +02:00
|
|
|
var app_password = item.app_password ? ' <a href="/edit/app-passwd/' + item.app_password + '"><i class="bi bi-app-indicator"></i> ' + escapeHtml(item.app_password_name || "App") + '</a>' : '';
|
2021-10-30 16:51:26 +02:00
|
|
|
var real_rip = item.real_rip.startsWith("Web") ? item.real_rip : '<a href="https://bgp.he.net/ip/' + item.real_rip + '" target="_blank">' + item.real_rip + "</a>";
|
|
|
|
var ip_location = item.location ? ' <span class="flag-icon flag-icon-' + item.location.toLowerCase() + '"></span>' : '';
|
|
|
|
var ip_data = real_rip + ip_location + app_password;
|
2021-06-08 13:16:10 +02:00
|
|
|
$(".last-login").append('<li class="list-group-item">' + local_datetime + " " + service + " " + lang.from + " " + ip_data + "</li>");
|
2021-06-04 14:29:39 +02:00
|
|
|
})
|
|
|
|
$('.last-login').append('</ul>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else if (action == 'reset') {
|
|
|
|
$.ajax({
|
|
|
|
dataType: 'json',
|
|
|
|
url: '/api/v1/get/reset-last-login/' + encodeURIComponent(mailcow_cc_username),
|
|
|
|
jsonp: false,
|
|
|
|
error: function () {
|
|
|
|
console.log('cannot reset last logins');
|
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
last_logins('get');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2017-08-18 22:18:14 +02:00
|
|
|
|
2017-05-23 09:36:59 +02:00
|
|
|
function draw_tla_table() {
|
2022-07-08 11:31:08 +02:00
|
|
|
// just recalc width if instance already exists
|
|
|
|
if ($.fn.DataTable.isDataTable('#tla_table') ) {
|
|
|
|
$('#tla_table').DataTable().columns.adjust().responsive.recalc();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:45:36 +02:00
|
|
|
$('#tla_table').DataTable({
|
|
|
|
processing: true,
|
|
|
|
serverSide: false,
|
|
|
|
language: lang_datatables,
|
|
|
|
ajax: {
|
|
|
|
type: "GET",
|
|
|
|
url: "/api/v1/get/time_limited_aliases",
|
|
|
|
dataSrc: function(data){
|
|
|
|
console.log(data);
|
2017-05-23 09:36:59 +02:00
|
|
|
$.each(data, function (i, item) {
|
2017-08-18 22:18:14 +02:00
|
|
|
if (acl_data.spam_alias === 1) {
|
2022-06-08 15:31:10 +02:00
|
|
|
item.action = '<div class="btn-group">' +
|
2021-05-26 14:02:27 +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"><i class="bi bi-trash"></i> ' + 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
|
|
|
});
|
2022-06-03 15:45:36 +02:00
|
|
|
|
|
|
|
return data;
|
2017-05-23 09:36:59 +02:00
|
|
|
}
|
|
|
|
},
|
2022-06-03 15:45:36 +02:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
// placeholder, so checkbox will not block child row toggle
|
|
|
|
title: '',
|
|
|
|
data: null,
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '',
|
2022-06-08 12:03:54 +02:00
|
|
|
data: 'chkbox',
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.alias,
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'address',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.alias_valid_until,
|
|
|
|
data: 'validity',
|
2022-07-01 16:20:39 +02:00
|
|
|
defaultContent: '',
|
2022-06-03 15:45:36 +02:00
|
|
|
render: function (data, type) {
|
|
|
|
var date = new Date(data ? data * 1000 : 0);
|
|
|
|
return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
|
|
|
}
|
|
|
|
},
|
2022-07-08 11:31:08 +02:00
|
|
|
{
|
|
|
|
title: lang.created_on,
|
|
|
|
data: 'created',
|
|
|
|
defaultContent: '',
|
|
|
|
render: function (data, type) {
|
|
|
|
var date = new Date(data.replace(/-/g, "/"));
|
|
|
|
return date.toLocaleDateString(undefined, {year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit"});
|
|
|
|
}
|
|
|
|
},
|
2022-06-03 15:45:36 +02:00
|
|
|
{
|
|
|
|
title: lang.action,
|
2022-06-08 15:28:45 +02:00
|
|
|
data: 'action',
|
2022-07-01 16:20:39 +02:00
|
|
|
className: 'text-md-end dt-sm-head-hidden dt-body-right',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
}
|
|
|
|
]
|
2017-05-23 09:36:59 +02:00
|
|
|
});
|
|
|
|
}
|
2017-05-17 21:17:00 +02:00
|
|
|
function draw_sync_job_table() {
|
2022-07-08 11:31:08 +02:00
|
|
|
// just recalc width if instance already exists
|
|
|
|
if ($.fn.DataTable.isDataTable('#sync_job_table') ) {
|
|
|
|
$('#sync_job_table').DataTable().columns.adjust().responsive.recalc();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:45:36 +02:00
|
|
|
$('#sync_job_table').DataTable({
|
|
|
|
processing: true,
|
|
|
|
serverSide: false,
|
|
|
|
language: lang_datatables,
|
|
|
|
ajax: {
|
|
|
|
type: "GET",
|
2018-02-10 23:42:46 +02:00
|
|
|
url: '/api/v1/get/syncjobs/' + encodeURIComponent(mailcow_cc_username) + '/no_log',
|
2022-06-03 15:45:36 +02:00
|
|
|
dataSrc: function(data){
|
|
|
|
console.log(data);
|
2017-05-17 21:17:00 +02:00
|
|
|
$.each(data, function (i, item) {
|
2018-02-10 23:42:46 +02:00
|
|
|
item.user1 = escapeHtml(item.user1);
|
2022-04-01 08:25:47 +02:00
|
|
|
item.log = '<a href="#syncjobLogModal" data-bs-toggle="modal" data-syncjob-id="' + item.id + '">' + lang.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) {
|
2022-06-08 15:31:10 +02:00
|
|
|
item.action = '<div class="btn-group">' +
|
2022-04-01 08:25:47 +02:00
|
|
|
'<a href="/edit/syncjob/' + item.id + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +
|
2021-07-09 08:21:09 +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-xs-half btn-danger"><i class="bi bi-trash"></i> ' + 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) {
|
2022-06-15 16:34:49 +02:00
|
|
|
item.is_running = '<span id="active-script" class="badge fs-6 bg-success">' + lang.running + '</span>';
|
2017-11-08 12:07:32 +02:00
|
|
|
} else {
|
2022-06-15 16:34:49 +02:00
|
|
|
item.is_running = '<span id="inactive-script" class="badge fs-6 bg-warning">' + lang.waiting + '</span>';
|
2017-11-08 12:07:32 +02:00
|
|
|
}
|
|
|
|
if (!item.last_run > 0) {
|
|
|
|
item.last_run = lang.waiting;
|
|
|
|
}
|
2021-09-01 16:29:11 +02:00
|
|
|
if (item.success == null) {
|
|
|
|
item.success = '-';
|
|
|
|
item.exit_status = '';
|
|
|
|
} else {
|
|
|
|
item.success = '<i class="text-' + (item.success == 1 ? 'success' : 'danger') + ' bi bi-' + (item.success == 1 ? 'check-lg' : 'x-lg') + '"></i>';
|
|
|
|
}
|
|
|
|
if (lang['syncjob_'+item.exit_status]) {
|
|
|
|
item.exit_status = lang['syncjob_'+item.exit_status];
|
|
|
|
} else if (item.success != '-') {
|
|
|
|
item.exit_status = lang.syncjob_check_log;
|
|
|
|
}
|
|
|
|
item.exit_status = item.success + ' ' + item.exit_status;
|
2017-05-17 21:17:00 +02:00
|
|
|
});
|
2022-06-03 15:45:36 +02:00
|
|
|
|
|
|
|
return data;
|
2017-05-17 21:17:00 +02:00
|
|
|
}
|
2019-07-27 18:57:58 +02:00
|
|
|
},
|
2022-06-03 15:45:36 +02:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
// placeholder, so checkbox will not block child row toggle
|
|
|
|
title: '',
|
|
|
|
data: null,
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
2022-10-11 11:41:06 +02:00
|
|
|
defaultContent: '',
|
|
|
|
responsivePriority: 1
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '',
|
2022-06-08 12:03:54 +02:00
|
|
|
data: 'chkbox',
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
2022-10-11 11:41:06 +02:00
|
|
|
defaultContent: '',
|
|
|
|
responsivePriority: 2
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'ID',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'id',
|
2022-07-08 11:31:08 +02:00
|
|
|
defaultContent: '',
|
|
|
|
responsivePriority: 3
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Server',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'server_w_port',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.username,
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'user1',
|
2022-10-11 11:41:06 +02:00
|
|
|
defaultContent: '',
|
|
|
|
responsivePriority: 3
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.last_run,
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'last_run',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.syncjob_last_run_result,
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'exit_status',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Log',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'log',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.active,
|
|
|
|
data: 'active',
|
2022-07-01 16:20:39 +02:00
|
|
|
defaultContent: '',
|
2022-06-03 15:45:36 +02:00
|
|
|
render: function (data, type) {
|
|
|
|
return 1==data?'<i class="bi bi-check-lg"></i>':0==data&&'<i class="bi bi-x-lg"></i>'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.status,
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'is_running',
|
2022-07-08 11:31:08 +02:00
|
|
|
defaultContent: '',
|
2022-10-11 11:41:06 +02:00
|
|
|
responsivePriority: 5
|
2022-07-08 11:31:08 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.encryption,
|
|
|
|
data: 'enc1',
|
|
|
|
defaultContent: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.excludes,
|
|
|
|
data: 'exclude',
|
|
|
|
defaultContent: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.interval + " (min)",
|
|
|
|
data: 'mins_interval',
|
2022-07-01 16:20:39 +02:00
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.action,
|
2022-06-08 15:28:45 +02:00
|
|
|
data: 'action',
|
2022-07-01 16:20:39 +02:00
|
|
|
className: 'text-md-end dt-sm-head-hidden dt-body-right',
|
2022-07-08 11:31:08 +02:00
|
|
|
defaultContent: '',
|
|
|
|
responsivePriority: 5
|
2022-06-03 15:45:36 +02:00
|
|
|
}
|
|
|
|
]
|
2017-05-17 21:17:00 +02:00
|
|
|
});
|
|
|
|
}
|
2019-12-02 12:02:19 +02:00
|
|
|
function draw_app_passwd_table() {
|
2022-07-08 11:31:08 +02:00
|
|
|
// just recalc width if instance already exists
|
|
|
|
if ($.fn.DataTable.isDataTable('#app_passwd_table') ) {
|
|
|
|
$('#app_passwd_table').DataTable().columns.adjust().responsive.recalc();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:45:36 +02:00
|
|
|
$('#app_passwd_table').DataTable({
|
|
|
|
processing: true,
|
|
|
|
serverSide: false,
|
|
|
|
language: lang_datatables,
|
|
|
|
ajax: {
|
|
|
|
type: "GET",
|
2019-12-02 12:02:19 +02:00
|
|
|
url: '/api/v1/get/app-passwd/all',
|
2022-06-03 15:45:36 +02:00
|
|
|
dataSrc: function(data){
|
|
|
|
console.log(data);
|
2019-12-02 12:02:19 +02:00
|
|
|
$.each(data, function (i, item) {
|
2021-10-28 21:57:19 +02:00
|
|
|
item.name = escapeHtml(item.name)
|
|
|
|
item.protocols = []
|
|
|
|
if (item.imap_access == 1) { item.protocols.push("<code>IMAP</code>"); }
|
|
|
|
if (item.smtp_access == 1) { item.protocols.push("<code>SMTP</code>"); }
|
|
|
|
if (item.eas_access == 1) { item.protocols.push("<code>EAS/ActiveSync</code>"); }
|
2021-10-29 06:15:10 +02:00
|
|
|
if (item.dav_access == 1) { item.protocols.push("<code>DAV</code>"); }
|
|
|
|
if (item.pop3_access == 1) { item.protocols.push("<code>POP3</code>"); }
|
|
|
|
if (item.sieve_access == 1) { item.protocols.push("<code>Sieve</code>"); }
|
2021-10-28 21:57:19 +02:00
|
|
|
item.protocols = item.protocols.join(" ")
|
2019-12-02 12:02:19 +02:00
|
|
|
if (acl_data.app_passwds === 1) {
|
2022-06-08 15:31:10 +02:00
|
|
|
item.action = '<div class="btn-group">' +
|
2022-04-01 08:25:47 +02:00
|
|
|
'<a href="/edit/app-passwd/' + item.id + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +
|
2021-07-09 08:21:09 +02:00
|
|
|
'<a href="#" data-action="delete_selected" data-id="single-apppasswd" data-api-url="delete/app-passwd" data-item="' + item.id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
|
2019-12-02 12:02:19 +02:00
|
|
|
'</div>';
|
|
|
|
item.chkbox = '<input type="checkbox" data-id="apppasswd" name="multi_select" value="' + item.id + '" />';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
item.action = '<span>-</span>';
|
|
|
|
item.chkbox = '<input type="checkbox" disabled />';
|
|
|
|
}
|
|
|
|
});
|
2022-06-03 15:45:36 +02:00
|
|
|
|
|
|
|
return data;
|
2019-12-02 12:02:19 +02:00
|
|
|
}
|
|
|
|
},
|
2022-06-03 15:45:36 +02:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
// placeholder, so checkbox will not block child row toggle
|
|
|
|
title: '',
|
|
|
|
data: null,
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '',
|
2022-06-08 12:03:54 +02:00
|
|
|
data: 'chkbox',
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'ID',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'id',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.app_name,
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'name',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.allowed_protocols,
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'protocols',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.active,
|
|
|
|
data: 'active',
|
2022-07-01 16:20:39 +02:00
|
|
|
defaultContent: '',
|
2022-06-03 15:45:36 +02:00
|
|
|
render: function (data, type) {
|
|
|
|
return 1==data?'<i class="bi bi-check-lg"></i>':0==data&&'<i class="bi bi-x-lg"></i>'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.action,
|
2022-06-08 15:28:45 +02:00
|
|
|
data: 'action',
|
2022-07-01 16:20:39 +02:00
|
|
|
className: 'text-md-end dt-sm-head-hidden dt-body-right',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
}
|
|
|
|
]
|
2019-12-02 12:02:19 +02:00
|
|
|
});
|
|
|
|
}
|
2017-05-23 09:36:59 +02:00
|
|
|
function draw_wl_policy_mailbox_table() {
|
2022-07-08 11:31:08 +02:00
|
|
|
// just recalc width if instance already exists
|
|
|
|
if ($.fn.DataTable.isDataTable('#wl_policy_mailbox_table') ) {
|
|
|
|
$('#wl_policy_mailbox_table').DataTable().columns.adjust().responsive.recalc();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:45:36 +02:00
|
|
|
$('#wl_policy_mailbox_table').DataTable({
|
|
|
|
processing: true,
|
|
|
|
serverSide: false,
|
|
|
|
language: lang_datatables,
|
|
|
|
ajax: {
|
|
|
|
type: "GET",
|
2017-05-23 09:36:59 +02:00
|
|
|
url: '/api/v1/get/policy_wl_mailbox',
|
2022-06-03 15:45:36 +02:00
|
|
|
dataSrc: function(data){
|
|
|
|
console.log(data);
|
2017-05-23 09:36:59 +02:00
|
|
|
$.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
|
|
|
});
|
2022-06-03 15:45:36 +02:00
|
|
|
|
|
|
|
return data;
|
2017-05-23 09:36:59 +02:00
|
|
|
}
|
|
|
|
},
|
2022-06-03 15:45:36 +02:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
// placeholder, so checkbox will not block child row toggle
|
|
|
|
title: '',
|
|
|
|
data: null,
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '',
|
2022-06-08 12:03:54 +02:00
|
|
|
data: 'chkbox',
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'ID',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'prefid',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.spamfilter_table_rule,
|
2022-07-08 11:31:08 +02:00
|
|
|
data: 'value',
|
2022-07-01 16:20:39 +02:00
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title:'Scope',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'object',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
}
|
|
|
|
]
|
2017-05-23 09:36:59 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
function draw_bl_policy_mailbox_table() {
|
2022-07-08 11:31:08 +02:00
|
|
|
// just recalc width if instance already exists
|
|
|
|
if ($.fn.DataTable.isDataTable('#bl_policy_mailbox_table') ) {
|
|
|
|
$('#bl_policy_mailbox_table').DataTable().columns.adjust().responsive.recalc();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:45:36 +02:00
|
|
|
$('#bl_policy_mailbox_table').DataTable({
|
|
|
|
processing: true,
|
|
|
|
serverSide: false,
|
|
|
|
language: lang_datatables,
|
|
|
|
ajax: {
|
|
|
|
type: "GET",
|
2017-05-23 09:36:59 +02:00
|
|
|
url: '/api/v1/get/policy_bl_mailbox',
|
2022-06-03 15:45:36 +02:00
|
|
|
dataSrc: function(data){
|
|
|
|
console.log(data);
|
2017-05-23 09:36:59 +02:00
|
|
|
$.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
|
|
|
});
|
2022-06-03 15:45:36 +02:00
|
|
|
|
|
|
|
return data;
|
2017-05-23 09:36:59 +02:00
|
|
|
}
|
|
|
|
},
|
2022-06-03 15:45:36 +02:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
// placeholder, so checkbox will not block child row toggle
|
|
|
|
title: '',
|
|
|
|
data: null,
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '',
|
2022-06-08 12:03:54 +02:00
|
|
|
data: 'chkbox',
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'ID',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'prefid',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: lang.spamfilter_table_rule,
|
2022-07-08 11:31:08 +02:00
|
|
|
data: 'value',
|
2022-07-01 16:20:39 +02:00
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title:'Scope',
|
2022-07-01 16:20:39 +02:00
|
|
|
data: 'object',
|
|
|
|
defaultContent: ''
|
2022-06-03 15:45:36 +02:00
|
|
|
}
|
|
|
|
]
|
2017-05-23 09:36:59 +02:00
|
|
|
});
|
|
|
|
}
|
2019-07-27 18:56:51 +02:00
|
|
|
|
2020-11-17 14:38:28 +02:00
|
|
|
// FIDO2 friendly name modal
|
|
|
|
$('#fido2ChangeFn').on('show.bs.modal', function (e) {
|
|
|
|
rename_link = $(e.relatedTarget)
|
|
|
|
if (rename_link != null) {
|
|
|
|
$('#fido2_cid').val(rename_link.data('cid'));
|
|
|
|
$('#fido2_subject_desc').text(Base64.decode(rename_link.data('subject')));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
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);
|
|
|
|
});
|
2022-06-03 15:45:36 +02:00
|
|
|
|
|
|
|
// detect element visibility changes
|
|
|
|
function onVisible(element, callback) {
|
2022-07-01 16:20:39 +02:00
|
|
|
$(document).ready(function() {
|
|
|
|
element_object = document.querySelector(element);
|
|
|
|
if (element_object === null) return;
|
|
|
|
|
2022-06-03 15:45:36 +02:00
|
|
|
new IntersectionObserver((entries, observer) => {
|
|
|
|
entries.forEach(entry => {
|
|
|
|
if(entry.intersectionRatio > 0) {
|
|
|
|
callback(element_object);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}).observe(element_object);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load only if the tab is visible
|
2022-06-08 11:49:05 +02:00
|
|
|
onVisible("[id^=tla_table]", () => draw_tla_table());
|
|
|
|
onVisible("[id^=bl_policy_mailbox_table]", () => draw_bl_policy_mailbox_table());
|
|
|
|
onVisible("[id^=wl_policy_mailbox_table]", () => draw_wl_policy_mailbox_table());
|
|
|
|
onVisible("[id^=sync_job_table]", () => draw_sync_job_table());
|
|
|
|
onVisible("[id^=app_passwd_table]", () => draw_app_passwd_table());
|
2022-06-03 15:45:36 +02:00
|
|
|
last_logins('get');
|
2021-06-15 11:40:39 +02:00
|
|
|
});
|