2019-02-23 17:59:18 +01:00
$ ( document ) . ready ( function ( ) {
acl _data = JSON . parse ( acl ) ;
2022-05-16 11:26:49 +02:00
// FooTable.domainFilter = FooTable.Filtering.extend({
// construct: function(instance){
// this._super(instance);
// this.def = lang.all_domains;
// this.$domain = null;
// },
// $create: function(){
// this._super();
// var self = this;
// var domains = [];
2019-11-11 09:55:15 +01:00
2022-05-16 11:26:49 +02:00
// $.each(self.ft.rows.all, function(i, row){
// if((row.val().domain != null) && ($.inArray(row.val().domain, domains) === -1)) domains.push(row.val().domain);
// });
2019-11-11 09:55:15 +01:00
2022-05-16 11:26:49 +02:00
// $form_grp = $('<div/>', {'class': 'form-group'})
// .append($('<label/>', {'class': 'sr-only', text: 'Domain'}))
// .prependTo(self.$form);
// self.$domain = $('<select/>', { 'class': 'aform-control' })
// .on('change', {self: self}, self._onDomainDropdownChanged)
// .append($('<option/>', {text: self.def}))
// .appendTo($form_grp);
2019-02-23 17:59:18 +01:00
2022-05-16 11:26:49 +02:00
// $.each(domains, function(i, domain){
// domainname = $($.parseHTML(domain)).data('domainname')
// if (domainname !== undefined) {
// self.$domain.append($('<option/>').text(domainname));
// } else {
// self.$domain.append($('<option/>').text(domain));
// }
// });
// },
// _onDomainDropdownChanged: function(e){
// var self = e.data.self,
// selected = $(this).val();
// if (selected !== self.def){
// self.addFilter('domain', selected, ['domain']);
// } else {
// self.removeFilter('domain');
// }
// self.filter();
// },
// draw: function(){
// this._super();
// var domain = this.find('domain');
// if (domain instanceof FooTable.Filter){
// this.$domain.val(domain.query.val());
// } else {
// this.$domain.val(this.def);
// }
// $(this.$domain).closest("select").selectpicker();
// }
// });
2020-02-22 19:23:57 +01:00
// Set paging
2020-01-10 20:49:54 +01:00
// Clone mailbox mass actions
$ ( "div" ) . find ( "[data-actions-header='true'" ) . each ( function ( ) {
$ ( this ) . html ( $ ( this ) . nextAll ( '.mass-actions-mailbox:first' ) . html ( ) ) ;
} ) ;
2019-02-23 17:59:18 +01:00
// Auto-fill domain quota when adding new domain
auto _fill _quota = function ( domain ) {
2020-04-03 08:44:10 +02:00
$ . get ( "/api/v1/get/domain/" + domain , function ( data ) {
2019-02-23 17:59:18 +01:00
var result = $ . parseJSON ( JSON . stringify ( data ) ) ;
2019-07-27 18:56:51 +02:00
def _new _mailbox _quota = ( result . def _new _mailbox _quota / 1048576 ) ;
2019-02-23 17:59:18 +01:00
max _new _mailbox _quota = ( result . max _new _mailbox _quota / 1048576 ) ;
2020-04-03 08:44:10 +02:00
if ( max _new _mailbox _quota != '0' ) {
$ ( '.addInputQuotaExhausted' ) . hide ( ) ;
$ ( "#quotaBadge" ) . html ( 'max. ' + max _new _mailbox _quota + ' MiB' ) ;
$ ( '#addInputQuota' ) . attr ( { "disabled" : false , "value" : "" , "type" : "number" , "max" : max _new _mailbox _quota } ) ;
$ ( '#addInputQuota' ) . val ( def _new _mailbox _quota ) ;
}
else {
$ ( '.addInputQuotaExhausted' ) . show ( ) ;
$ ( "#quotaBadge" ) . html ( 'max. ' + max _new _mailbox _quota + ' MiB' ) ;
$ ( '#addInputQuota' ) . attr ( { "disabled" : true , "value" : "" , "type" : "text" , "value" : "n/a" } ) ;
$ ( '#addInputQuota' ) . val ( max _new _mailbox _quota ) ;
}
} ) ;
2019-02-23 17:59:18 +01:00
}
2021-08-09 08:28:22 +02:00
$ ( '#addSelectDomain' ) . on ( 'change' , function ( ) {
2019-02-23 17:59:18 +01:00
auto _fill _quota ( $ ( '#addSelectDomain' ) . val ( ) ) ;
2021-08-09 08:28:22 +02:00
} ) ;
2019-02-23 17:59:18 +01:00
auto _fill _quota ( $ ( '#addSelectDomain' ) . val ( ) ) ;
2021-08-19 20:27:59 +02:00
2019-02-23 17:59:18 +01:00
$ ( ".goto_checkbox" ) . click ( function ( event ) {
$ ( "form[data-id='add_alias'] .goto_checkbox" ) . not ( this ) . prop ( 'checked' , false ) ;
if ( $ ( "form[data-id='add_alias'] .goto_checkbox:checked" ) . length > 0 ) {
$ ( '#textarea_alias_goto' ) . prop ( 'disabled' , true ) ;
}
else {
$ ( "#textarea_alias_goto" ) . removeAttr ( 'disabled' ) ;
}
} ) ;
$ ( '#addAliasModal' ) . on ( 'show.bs.modal' , function ( e ) {
if ( $ ( "form[data-id='add_alias'] .goto_checkbox:checked" ) . length > 0 ) {
$ ( '#textarea_alias_goto' ) . prop ( 'disabled' , true ) ;
}
else {
$ ( "#textarea_alias_goto" ) . removeAttr ( 'disabled' ) ;
}
} ) ;
// Log modal
$ ( '#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 ) ;
}
} ) ;
} ) ;
// Log modal
$ ( '#dnsInfoModal' ) . on ( 'show.bs.modal' , function ( e ) {
var domain = $ ( e . relatedTarget ) . data ( 'domain' ) ;
2022-04-14 10:22:06 +02:00
$ ( '.dns-modal-body' ) . html ( '<div class="spinner-border text-secondary" role="status"><span class="visually-hidden">Loading...</span></div>' ) ;
2019-02-23 17:59:18 +01:00
$ . ajax ( {
url : '/inc/ajax/dns_diagnostics.php' ,
data : { domain : domain } ,
dataType : 'text' ,
success : function ( data ) {
$ ( '.dns-modal-body' ) . html ( data ) ;
} ,
error : function ( xhr , status , error ) {
$ ( '.dns-modal-body' ) . html ( xhr . responseText ) ;
}
} ) ;
} ) ;
// Sieve data modal
$ ( '#sieveDataModal' ) . on ( 'show.bs.modal' , function ( e ) {
var sieveScript = $ ( e . relatedTarget ) . data ( 'sieve-script' ) ;
$ ( e . currentTarget ) . find ( '#sieveDataText' ) . html ( '<pre style="font-size:14px;line-height:1.1">' + sieveScript + '</pre>' ) ;
} ) ;
// Disable submit button on script change
2021-08-09 08:28:22 +02:00
$ ( '.textarea-code' ) . on ( 'keyup' , function ( ) {
2020-03-19 12:23:48 +01:00
// Disable all "save" buttons, could be a "related button only" function, todo
$ ( '.add_sieve_script' ) . attr ( { "disabled" : true } ) ;
2021-08-09 08:28:22 +02:00
} ) ;
2019-02-23 17:59:18 +01:00
// Validate script data
2020-03-19 12:23:48 +01:00
$ ( ".validate_sieve" ) . click ( function ( event ) {
2019-02-23 17:59:18 +01:00
event . preventDefault ( ) ;
2020-03-19 12:23:48 +01:00
var validation _button = $ ( this ) ;
// Get script_data textarea content from form the button was clicked in
var script = $ ( 'textarea[name="script_data"]' , $ ( this ) . parents ( 'form:first' ) ) . val ( ) ;
2019-02-23 17:59:18 +01:00
$ . ajax ( {
2019-10-29 08:39:57 +01:00
dataType : 'json' ,
2019-02-23 17:59:18 +01:00
url : "/inc/ajax/sieve_validation.php" ,
type : "get" ,
data : { script : script } ,
complete : function ( data ) {
var response = ( data . responseText ) ;
response _obj = JSON . parse ( response ) ;
if ( response _obj . type == "success" ) {
2020-03-19 12:23:48 +01:00
$ ( validation _button ) . next ( ) . attr ( { "disabled" : false } ) ;
2019-02-23 17:59:18 +01:00
}
mailcow _alert _box ( response _obj . msg , response _obj . type ) ;
} ,
} ) ;
} ) ;
// $(document).on('DOMNodeInserted', '#prefilter_table', function () {
// $("#active-script").closest('td').css('background-color','#b0f0a0');
// $("#inactive-script").closest('td').css('background-color','#b0f0a0');
// });
2019-03-23 21:17:02 +01:00
$ ( '#addResourceModal' ) . on ( 'shown.bs.modal' , function ( ) {
$ ( "#multiple_bookings" ) . val ( $ ( "#multiple_bookings_select" ) . val ( ) ) ;
if ( $ ( "#multiple_bookings" ) . val ( ) == "custom" ) {
$ ( "#multiple_bookings_custom_div" ) . show ( ) ;
$ ( "#multiple_bookings" ) . val ( $ ( "#multiple_bookings_custom" ) . val ( ) ) ;
}
} )
$ ( "#multiple_bookings_select" ) . change ( function ( ) {
$ ( "#multiple_bookings" ) . val ( $ ( "#multiple_bookings_select" ) . val ( ) ) ;
if ( $ ( "#multiple_bookings" ) . val ( ) == "custom" ) {
$ ( "#multiple_bookings_custom_div" ) . show ( ) ;
}
else {
$ ( "#multiple_bookings_custom_div" ) . hide ( ) ;
}
} ) ;
$ ( "#multiple_bookings_custom" ) . bind ( "change keypress keyup blur" , function ( ) {
$ ( "#multiple_bookings" ) . val ( $ ( "#multiple_bookings_custom" ) . val ( ) ) ;
} ) ;
2019-02-23 17:59:18 +01:00
} ) ;
jQuery ( function ( $ ) {
// http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
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 ] }
2022-07-08 11:31:08 +02:00
function unix _time _format ( i ) { return "" == i ? '<i class="bi bi-x"></i>' : new Date ( i ? 1e3 * i : 0 ) . toLocaleDateString ( void 0 , { year : "numeric" , month : "2-digit" , day : "2-digit" , hour : "2-digit" , minute : "2-digit" , second : "2-digit" } ) }
2019-02-23 17:59:18 +01:00
$ ( ".refresh_table" ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
var table _name = $ ( this ) . data ( 'table' ) ;
2022-05-17 14:08:22 +02:00
$ ( '#' + table _name ) . DataTable ( ) . ajax . reload ( ) ;
2019-02-23 17:59:18 +01:00
} ) ;
function draw _domain _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#domain_table' ) ) {
$ ( '#domain_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
var table = $ ( '#domain_table' ) . DataTable ( {
2022-05-16 11:26:49 +02:00
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/domain/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2019-02-23 17:59:18 +01:00
item . aliases = item . aliases _in _domain + " / " + item . max _num _aliases _for _domain ;
item . mailboxes = item . mboxes _in _domain + " / " + item . max _num _mboxes _for _domain ;
2020-04-06 08:52:27 +02:00
item . quota = item . quota _used _in _domain + "/" + item . max _quota _for _domain + "/" + item . bytes _total ;
item . stats = item . msgs _total + "/" + item . bytes _total ;
2022-05-16 11:26:49 +02:00
if ( ! item . rl ) item . rl = '∞' ;
else {
2019-02-23 17:59:18 +01:00
item . rl = $ . map ( item . rl , function ( e ) {
return e ;
} ) . join ( '/1' ) ;
}
2022-05-16 11:26:49 +02:00
2019-07-27 18:56:51 +02:00
item . def _quota _for _mbox = humanFileSize ( item . def _quota _for _mbox ) ;
2019-02-23 17:59:18 +01:00
item . max _quota _for _mbox = humanFileSize ( item . max _quota _for _mbox ) ;
item . chkbox = '<input type="checkbox" data-id="domain" name="multi_select" value="' + encodeURIComponent ( item . domain _name ) + '" />' ;
2022-06-08 15:31:10 +02:00
item . action = '<div class="btn-group">' ;
2019-02-23 17:59:18 +01:00
if ( role == "admin" ) {
2022-04-01 08:25:47 +02:00
item . action += '<a href="/edit/domain/' + encodeURIComponent ( item . domain _name ) + '" class="btn btn-xs btn-xs-third 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-domain" data-api-url="delete/domain" data-item="' + encodeURIComponent ( item . domain _name ) + '" class="btn btn-xs btn-xs-third btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2022-05-16 11:26:49 +02:00
'<a href="#dnsInfoModal" class="btn btn-xs btn-xs-third btn-info" data-bs-toggle="modal" data-domain="' + encodeURIComponent ( item . domain _name ) + '"><i class="bi bi-globe2"></i> DNS</a></div>' ;
2019-02-23 17:59:18 +01:00
}
else {
2022-04-01 08:25:47 +02:00
item . action += '<a href="/edit/domain/' + encodeURIComponent ( item . domain _name ) + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#dnsInfoModal" class="btn btn-xs btn-xs-half btn-info" data-bs-toggle="modal" data-domain="' + encodeURIComponent ( item . domain _name ) + '"><i class="bi bi-globe2"></i> DNS</a></div>' ;
2019-02-23 17:59:18 +01:00
}
2021-08-09 08:28:22 +02:00
2022-05-05 08:25:01 +02:00
if ( Array . isArray ( item . tags ) ) {
var tags = '' ;
for ( var i = 0 ; i < item . tags . length ; i ++ )
2022-06-15 16:34:49 +02:00
tags += '<span class="badge bg-primary tag-badge"><i class="bi bi-tag-fill"></i> ' + escapeHtml ( item . tags [ i ] ) + '</span>' ;
2022-05-05 08:25:01 +02:00
item . tags = tags ;
2022-06-15 16:34:49 +02:00
} else {
item . tags = '' ;
2022-05-05 08:25:01 +02:00
}
2020-09-17 19:49:15 +02:00
if ( item . backupmx == 1 ) {
if ( item . relay _unknown _only == 1 ) {
2022-06-15 16:34:49 +02:00
item . domain _name = '<div class="badge fs-6 bg-info">Relay Non-Local</div> ' + item . domain _name ;
2020-09-17 19:49:15 +02:00
} else if ( item . relay _all _recipients == 1 ) {
2022-06-15 16:34:49 +02:00
item . domain _name = '<div class="badge fs-6 bg-info">Relay All</div> ' + item . domain _name ;
2020-04-05 11:35:35 +02:00
} else {
2022-06-15 16:34:49 +02:00
item . domain _name = '<div class="badge fs-6 bg-info">Relay</div> ' + item . domain _name ;
2020-04-05 11:35:35 +02:00
}
2020-02-18 11:30:20 +01:00
}
2019-02-23 17:59:18 +01:00
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
} ,
2022-05-16 11:26:49 +02:00
columns : [
2022-06-08 12:03:54 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2019-05-05 20:59:59 +02:00
} ,
2022-06-08 12:03:54 +02:00
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2019-05-05 20:44:29 +02:00
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . domain ,
2022-06-08 16:21:15 +02:00
data : 'domain_name' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-06-08 12:03:54 +02:00
} ,
{
title : lang . aliases ,
2022-07-08 11:31:08 +02:00
data : 'aliases' ,
2022-07-01 16:20:39 +02:00
defaultContent : ''
2022-06-08 12:03:54 +02:00
} ,
{
title : lang . mailboxes ,
2022-07-08 11:31:08 +02:00
data : 'mailboxes' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2019-02-23 17:59:18 +01:00
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . domain _quota ,
data : 'quota' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-06-08 12:03:54 +02:00
render : function ( data , type ) {
data = data . split ( "/" ) ;
return humanFileSize ( data [ 0 ] ) + " / " + humanFileSize ( data [ 1 ] ) ;
}
} ,
{
title : lang . stats ,
data : 'stats' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-06-08 12:03:54 +02:00
render : function ( data , type ) {
data = data . split ( "/" ) ;
return '<i class="bi bi-files"></i> ' + data [ 0 ] + ' / ' + humanFileSize ( data [ 1 ] ) ;
}
2019-02-23 17:59:18 +01:00
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . mailbox _defquota ,
2022-07-01 16:20:39 +02:00
data : 'def_quota_for_mbox' ,
defaultContent : ''
2019-02-23 17:59:18 +01:00
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . mailbox _quota ,
2022-07-01 16:20:39 +02:00
data : 'max_quota_for_mbox' ,
defaultContent : ''
2020-04-13 20:34:39 +02:00
} ,
2022-06-08 12:03:54 +02:00
{
title : 'RL' ,
2022-07-01 16:20:39 +02:00
data : 'rl' ,
defaultContent : ''
2022-06-08 12:03:54 +02:00
} ,
{
title : lang . backup _mx ,
data : 'backupmx' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-06-08 12:03:54 +02:00
redner : function ( data , type ) {
return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ;
}
2019-02-23 17:59:18 +01:00
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . domain _admins ,
2022-07-01 16:20:39 +02:00
data : 'domain_admins' ,
defaultContent : ''
2019-02-23 17:59:18 +01:00
} ,
2022-06-15 16:34:49 +02:00
{
title : 'Tags' ,
2022-07-01 16:20:39 +02:00
data : 'tags' ,
defaultContent : ''
2022-06-15 16:34:49 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-07-08 11:31:08 +02:00
responsivePriority : 5 ,
2022-06-15 16:34:49 +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>' : 2 == data && '—' ) ;
}
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2019-02-23 17:59:18 +01:00
} ,
2022-05-16 11:26:49 +02:00
]
2022-07-08 11:31:08 +02:00
} ) ;
2019-02-23 17:59:18 +01:00
}
function draw _mailbox _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#mailbox_table' ) ) {
$ ( '#mailbox_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2022-05-16 11:26:49 +02:00
$ ( '#mailbox_table' ) . DataTable ( {
2022-05-19 21:29:01 +02:00
responsive : true ,
2022-05-16 11:26:49 +02:00
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/mailbox/reduced" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2019-02-23 17:59:18 +01:00
item . quota = item . quota _used + "/" + item . quota ;
item . max _quota _for _mbox = humanFileSize ( item . max _quota _for _mbox ) ;
2020-09-15 11:02:53 +02:00
item . last _mail _login = item . last _imap _login + '/' + item . last _pop3 _login + '/' + item . last _smtp _login ;
2021-03-19 16:33:50 +01:00
/ *
2019-02-23 17:59:18 +01:00
if ( ! item . rl ) {
item . rl = '∞' ;
} else {
item . rl = $ . map ( item . rl , function ( e ) {
return e ;
} ) . join ( '/1' ) ;
2019-08-25 16:02:58 +02:00
if ( item . rl _scope === 'domain' ) {
2021-05-22 12:13:37 +02:00
item . rl = '<i class="bi bi-arrow-return-right"></i> ' + item . rl + ' (via ' + item . domain + ')' ;
2019-08-25 16:02:58 +02:00
}
2019-02-23 17:59:18 +01:00
}
2021-03-19 16:33:50 +01:00
* /
2019-02-23 17:59:18 +01:00
item . chkbox = '<input type="checkbox" data-id="mailbox" name="multi_select" value="' + encodeURIComponent ( item . username ) + '" />' ;
2021-06-09 07:19:57 +02:00
if ( item . attributes . passwd _update != '0' ) {
var last _pw _change = new Date ( item . attributes . passwd _update . replace ( /-/g , "/" ) ) ;
item . last _pw _change = last _pw _change . toLocaleDateString ( undefined , { year : "numeric" , month : "2-digit" , day : "2-digit" , hour : "2-digit" , minute : "2-digit" , second : "2-digit" } ) ;
} else {
item . last _pw _change = '-' ;
}
2021-05-22 12:13:37 +02:00
item . tls _enforce _in = '<i class="text-' + ( item . attributes . tls _enforce _in == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill' ) + '"></i>' ;
item . tls _enforce _out = '<i class="text-' + ( item . attributes . tls _enforce _out == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill' ) + '"></i>' ;
item . pop3 _access = '<i class="text-' + ( item . attributes . pop3 _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . pop3 _access == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
item . imap _access = '<i class="text-' + ( item . attributes . imap _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . imap _access == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
item . smtp _access = '<i class="text-' + ( item . attributes . smtp _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . smtp _access == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
2019-02-23 17:59:18 +01:00
if ( item . attributes . quarantine _notification === 'never' ) {
item . quarantine _notification = lang . never ;
} else if ( item . attributes . quarantine _notification === 'hourly' ) {
item . quarantine _notification = lang . hourly ;
} else if ( item . attributes . quarantine _notification === 'daily' ) {
item . quarantine _notification = lang . daily ;
} else if ( item . attributes . quarantine _notification === 'weekly' ) {
item . quarantine _notification = lang . weekly ;
}
2020-11-28 17:41:48 +01:00
if ( item . attributes . quarantine _category === 'reject' ) {
item . quarantine _category = '<span class="text-danger">' + lang . q _reject + '</span>' ;
} else if ( item . attributes . quarantine _category === 'add_header' ) {
item . quarantine _category = '<span class="text-warning">' + lang . q _add _header + '</span>' ;
} else if ( item . attributes . quarantine _category === 'all' ) {
item . quarantine _category = lang . q _all ;
}
2019-02-23 17:59:18 +01:00
if ( acl _data . login _as === 1 ) {
2021-08-09 08:28:22 +02:00
var btnSize = 'btn-xs-third' ;
if ( ALLOW _ADMIN _EMAIL _LOGIN ) btnSize = 'btn-xs-quart' ;
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/mailbox/' + encodeURIComponent ( item . username ) + '" class="btn btn-xs ' + btnSize + ' 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-mailbox" data-api-url="delete/mailbox" data-item="' + encodeURIComponent ( item . username ) + '" class="btn btn-xs ' + btnSize + ' btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'<a href="/index.php?duallogin=' + encodeURIComponent ( item . username ) + '" class="login_as btn btn-xs ' + btnSize + ' btn-success"><i class="bi bi-person-fill"></i> Login</a>' ;
2019-02-23 17:59:18 +01:00
if ( ALLOW _ADMIN _EMAIL _LOGIN ) {
2021-07-09 08:21:09 +02:00
item . action += '<a href="/sogo-auth.php?login=' + encodeURIComponent ( item . username ) + '" class="login_as btn btn-xs ' + btnSize + ' btn-primary" target="_blank"><i class="bi bi-envelope-fill"></i> SOGo</a>' ;
2019-02-23 17:59:18 +01:00
}
item . action += '</div>' ;
}
else {
item . action = '<div class="btn-group">' +
2022-04-01 08:25:47 +02:00
'<a href="/edit/mailbox/' + encodeURIComponent ( item . username ) + '" 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-mailbox" data-api-url="delete/mailbox" data-item="' + encodeURIComponent ( item . username ) + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 17:59:18 +01:00
'</div>' ;
}
item . in _use = '<div class="progress">' +
2020-04-06 08:52:27 +02:00
'<div class="progress-bar-mailbox progress-bar progress-bar-' + item . percent _class + '" role="progressbar" aria-valuenow="' + item . percent _in _use + '" aria-valuemin="0" aria-valuemax="100" ' +
2019-02-23 17:59:18 +01:00
'style="min-width:2em;width:' + item . percent _in _use + '%">' + item . percent _in _use + '%' + '</div></div>' ;
item . username = escapeHtml ( item . username ) ;
2022-05-05 08:25:01 +02:00
if ( Array . isArray ( item . tags ) ) {
var tags = '' ;
for ( var i = 0 ; i < item . tags . length ; i ++ )
2022-06-15 16:34:49 +02:00
tags += '<span class="badge bg-primary tag-badge"><i class="bi bi-tag-fill"></i> ' + escapeHtml ( item . tags [ i ] ) + '</span>' ;
2022-05-05 08:25:01 +02:00
item . tags = tags ;
2022-06-15 16:34:49 +02:00
} else {
item . tags = '' ;
2022-05-05 08:25:01 +02:00
}
2019-02-23 17:59:18 +01:00
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-16 11:26:49 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-16 11:26:49 +02:00
{
title : lang . username ,
2022-06-08 16:21:15 +02:00
data : 'username' ,
2022-07-08 11:31:08 +02:00
responsivePriority : 1 ,
defaultContent : ''
} ,
{
title : lang . domain _quota ,
data : 'quota' ,
responsivePriority : 2 ,
defaultContent : '' ,
render : function ( data , type ) {
data = data . split ( "/" ) ;
var of _q = ( data [ 1 ] == 0 ? "∞" : humanFileSize ( data [ 1 ] ) ) ;
return humanFileSize ( data [ 0 ] ) + " / " + of _q ;
}
} ,
{
title : lang . last _mail _login ,
data : 'last_mail_login' ,
defaultContent : '' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
2022-07-08 11:31:08 +02:00
render : function ( data , type ) {
res = data . split ( "/" ) ;
return '<div class="badge bg-info mb-2">IMAP @ ' + unix _time _format ( Number ( res [ 0 ] ) ) + '</div><br>' +
'<div class="badge bg-info mb-2">POP3 @ ' + unix _time _format ( Number ( res [ 1 ] ) ) + '</div><br>' +
'<div class="badge bg-info">SMTP @ ' + unix _time _format ( Number ( res [ 2 ] ) ) + '</div>' ;
}
} ,
{
title : lang . last _pw _change ,
data : 'last_pw_change' ,
2022-07-01 16:20:39 +02:00
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
2022-07-08 11:31:08 +02:00
{
title : lang . in _use ,
data : 'in_use' ,
defaultContent : '' ,
responsivePriority : 4
} ,
2022-05-16 11:26:49 +02:00
{
title : lang . fname ,
2022-07-01 16:20:39 +02:00
data : 'name' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . domain ,
2022-07-01 16:20:39 +02:00
data : 'domain' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . tls _enforce _in ,
2022-07-01 16:20:39 +02:00
data : 'tls_enforce_in' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . tls _enforce _out ,
2022-07-01 16:20:39 +02:00
data : 'tls_enforce_out' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : 'SMTP' ,
2022-07-01 16:20:39 +02:00
data : 'smtp_access' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : 'IMAP' ,
2022-07-01 16:20:39 +02:00
data : 'imap_access' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : 'POP3' ,
2022-07-01 16:20:39 +02:00
data : 'pop3_access' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . quarantine _notification ,
2022-07-01 16:20:39 +02:00
data : 'quarantine_notification' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . quarantine _category ,
2022-07-01 16:20:39 +02:00
data : 'quarantine_category' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . msg _num ,
2022-07-01 16:20:39 +02:00
data : 'messages' ,
2022-07-08 11:31:08 +02:00
defaultContent : '' ,
responsivePriority : 5
2022-05-16 11:26:49 +02:00
} ,
2022-06-15 16:34:49 +02:00
{
title : 'Tags' ,
2022-07-01 16:20:39 +02:00
data : 'tags' ,
defaultContent : ''
2022-06-15 16:34:49 +02:00
} ,
2022-05-16 11:26:49 +02:00
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-07-08 11:31:08 +02:00
responsivePriority : 6 ,
2022-05-16 11:26:49 +02:00
render : function ( data , type ) {
2022-05-19 21:29:01 +02:00
return 1 == data ? '<i class="bi bi-check-lg"></i>' : ( 0 == data ? '<i class="bi bi-x-lg"></i>' : 2 == data && '—' ) ;
2022-05-16 11:26:49 +02:00
}
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
}
function draw _resource _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#resource_table' ) ) {
$ ( '#resource_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2022-05-16 11:26:49 +02:00
$ ( '#resource_table' ) . DataTable ( {
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/resource/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2019-02-23 17:59:18 +01:00
if ( item . multiple _bookings == '0' ) {
2022-06-15 16:34:49 +02:00
item . multiple _bookings = '<span id="active-script" class="badge fs-6 bg-success">' + lang . booking _0 _short + '</span>' ;
2019-02-23 17:59:18 +01:00
} else if ( item . multiple _bookings == '-1' ) {
2022-06-15 16:34:49 +02:00
item . multiple _bookings = '<span id="active-script" class="badge fs-6 bg-warning">' + lang . booking _lt0 _short + '</span>' ;
2019-02-23 17:59:18 +01:00
} else {
2022-06-15 16:34:49 +02:00
item . multiple _bookings = '<span id="active-script" class="badge fs-6 bg-danger">' + lang . booking _custom _short + ' (' + item . multiple _bookings + ')</span>' ;
2019-02-23 17:59:18 +01:00
}
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/resource/' + encodeURIComponent ( item . name ) + '" 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-resource" data-api-url="delete/resource" data-item="' + item . name + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 17:59:18 +01:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="resource" name="multi_select" value="' + encodeURIComponent ( item . name ) + '" />' ;
item . name = escapeHtml ( item . name ) ;
2022-06-03 14:37:56 +02:00
item . description = escapeHtml ( item . description ) ;
2019-02-23 17:59:18 +01:00
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-16 11:26:49 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-16 11:26:49 +02:00
{
title : lang . description ,
2022-06-08 16:21:15 +02:00
data : 'description' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . alias ,
2022-07-01 16:20:39 +02:00
data : 'name' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . kind ,
2022-07-01 16:20:39 +02:00
data : 'kind' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . domain ,
2022-06-08 16:21:15 +02:00
data : 'domain' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . multiple _bookings ,
2022-07-01 16:20:39 +02:00
data : 'multiple_bookings' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-05-16 11:26:49 +02:00
render : function ( data , type ) {
2022-05-20 12:03:12 +02:00
return 1 == data ? '<i class="bi bi-check-lg"></i>' : ( 0 == data ? '<i class="bi bi-x-lg"></i>' : 2 == data && '—' ) ;
2022-05-16 11:26:49 +02:00
}
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
}
function draw _bcc _table ( ) {
2022-07-08 11:31:08 +02:00
$ . get ( "/api/v1/get/bcc-destination-options" , function ( data ) {
// Domains
var optgroup = "<optgroup label='" + lang . domains + "'>" ;
$ . each ( data . domains , function ( index , domain ) {
optgroup += "<option value='" + domain + "'>" + domain + "</option>"
} ) ;
optgroup += "</optgroup>"
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
// Alias domains
var optgroup = "<optgroup label='" + lang . domain _aliases + "'>" ;
$ . each ( data . alias _domains , function ( index , alias _domain ) {
optgroup += "<option value='" + alias _domain + "'>" + alias _domain + "</option>"
} ) ;
optgroup += "</optgroup>"
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
// Mailboxes and aliases
$ . each ( data . mailboxes , function ( mailbox , aliases ) {
var optgroup = "<optgroup label='" + mailbox + "'>" ;
$ . each ( aliases , function ( index , alias ) {
optgroup += "<option value='" + alias + "'>" + alias + "</option>"
} ) ;
optgroup += "</optgroup>"
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
} ) ;
// Finish
$ ( '#bcc-local-dest' ) . selectpicker ( 'refresh' ) ;
} ) ;
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#bcc_table' ) ) {
$ ( '#bcc_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2022-05-16 11:26:49 +02:00
$ ( '#bcc_table' ) . DataTable ( {
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/bcc/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
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/bcc/' + 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-bcc" data-api-url="delete/bcc" data-item="' + item . id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 17:59:18 +01:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="bcc" name="multi_select" value="' + item . id + '" />' ;
item . local _dest = escapeHtml ( item . local _dest ) ;
item . bcc _dest = escapeHtml ( item . bcc _dest ) ;
if ( item . type == 'sender' ) {
2022-06-15 16:34:49 +02:00
item . type = '<span id="active-script" class="badge fs-6 bg-success">' + lang . bcc _sender _map + '</span>' ;
2019-02-23 17:59:18 +01:00
} else {
2022-06-15 16:34:49 +02:00
item . type = '<span id="inactive-script" class="badge fs-6 bg-warning">' + lang . bcc _rcpt _map + '</span>' ;
2019-02-23 17:59:18 +01:00
}
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-16 11:26:49 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-16 11:26:49 +02:00
{
2022-05-17 14:08:22 +02:00
title : 'ID' ,
2022-06-08 16:21:15 +02:00
data : 'id' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . bcc _type ,
2022-07-01 16:20:39 +02:00
data : 'type' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . bcc _local _dest ,
2022-07-01 16:20:39 +02:00
data : 'local_dest' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . bcc _destinations ,
2022-07-01 16:20:39 +02:00
data : 'bcc_dest' ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . domain ,
2022-06-08 16:21:15 +02:00
data : 'domain' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-05-16 11:26:49 +02:00
render : function ( data , type ) {
2022-05-20 12:03:12 +02:00
return 1 == data ? '<i class="bi bi-check-lg"></i>' : ( 0 == data ? '<i class="bi bi-x-lg"></i>' : 2 == data && '—' ) ;
2022-05-16 11:26:49 +02:00
}
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-16 11:26:49 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
}
function draw _recipient _map _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#recipient_map_table' ) ) {
$ ( '#recipient_map_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2022-05-17 14:08:22 +02:00
$ ( '#recipient_map_table' ) . DataTable ( {
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/recipient_map/all" ,
dataSrc : function ( json ) {
if ( role !== "admin" ) return null ;
$ . each ( json , function ( i , item ) {
item . recipient _map _old = escapeHtml ( item . recipient _map _old ) ;
item . recipient _map _new = escapeHtml ( item . recipient _map _new ) ;
2022-06-08 15:31:10 +02:00
item . action = '<div class="btn-group">' +
2022-05-17 14:08:22 +02:00
'<a href="/edit/recipient_map/' + item . id + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-recipient_map" data-api-url="delete/recipient_map" data-item="' + item . id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="recipient_map" name="multi_select" value="' + item . id + '" />' ;
} ) ;
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
{
title : 'ID' ,
2022-06-08 16:21:15 +02:00
data : 'id' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . recipient _map _old ,
2022-07-01 16:20:39 +02:00
data : 'recipient_map_old' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . recipient _map _new ,
2022-07-01 16:20:39 +02:00
data : 'recipient_map_new' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-05-17 14:08:22 +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-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
}
function draw _tls _policy _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#tls_policy_table' ) ) {
$ ( '#tls_policy_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2022-05-17 14:08:22 +02:00
$ ( '#tls_policy_table' ) . DataTable ( {
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/tls-policy-map/all" ,
dataSrc : function ( json ) {
if ( role !== "admin" ) return null ;
$ . each ( json , function ( i , item ) {
item . dest = escapeHtml ( item . dest ) ;
item . policy = '<b>' + escapeHtml ( item . policy ) + '</b>' ;
if ( item . parameters == '' ) {
item . parameters = '<code>-</code>' ;
} else {
item . parameters = '<code>' + escapeHtml ( item . parameters ) + '</code>' ;
}
2022-06-08 15:31:10 +02:00
item . action = '<div class="btn-group">' +
2022-05-17 14:08:22 +02:00
'<a href="/edit/tls_policy_map/' + item . id + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-tls-policy-map" data-api-url="delete/tls-policy-map" data-item="' + item . id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="tls-policy-map" name="multi_select" value="' + item . id + '" />' ;
} ) ;
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
{
title : 'ID' ,
2022-06-08 16:21:15 +02:00
data : 'id' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . tls _map _dest ,
2022-07-01 16:20:39 +02:00
data : 'dest' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . tls _map _policy ,
2022-07-01 16:20:39 +02:00
data : 'policy' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . tls _map _parameters ,
2022-07-01 16:20:39 +02:00
data : 'parameters' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . domain ,
2022-06-08 16:21:15 +02:00
data : 'domain' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-05-17 14:08:22 +02:00
render : function ( data , type ) {
2022-05-20 12:03:12 +02:00
return 1 == data ? '<i class="bi bi-check-lg"></i>' : 0 == data && '<i class="bi bi-x-lg"></i>' ;
2022-05-17 14:08:22 +02:00
}
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
}
function draw _alias _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#alias_table' ) ) {
$ ( '#alias_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2022-05-17 14:08:22 +02:00
$ ( '#alias_table' ) . DataTable ( {
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/alias/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
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/alias/' + encodeURIComponent ( 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-alias" data-api-url="delete/alias" data-item="' + encodeURIComponent ( item . id ) + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 17:59:18 +01:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="alias" name="multi_select" value="' + encodeURIComponent ( item . id ) + '" />' ;
item . goto = escapeHtml ( item . goto . replace ( /,/g , " " ) ) ;
2019-03-18 02:03:59 +01:00
if ( item . public _comment !== null ) {
item . public _comment = escapeHtml ( item . public _comment ) ;
}
else {
item . public _comment = '-' ;
}
if ( item . private _comment !== null ) {
item . private _comment = escapeHtml ( item . private _comment ) ;
}
else {
item . private _comment = '-' ;
}
2019-02-23 17:59:18 +01:00
if ( item . is _catch _all == 1 ) {
2022-06-15 16:34:49 +02:00
item . address = '<div class="badge fs-6 bg-secondary">' + lang . catch _all + '</div> ' + escapeHtml ( item . address ) ;
2019-02-23 17:59:18 +01:00
}
else {
item . address = escapeHtml ( item . address ) ;
}
if ( item . goto == "null@localhost" ) {
2021-05-26 14:02:27 +02:00
item . goto = '⤷ <i class="bi bi-trash" style="font-size:12px"></i>' ;
2019-02-23 17:59:18 +01:00
}
else if ( item . goto == "spam@localhost" ) {
2022-06-15 16:34:49 +02:00
item . goto = '<span class="badge fs-6 bg-danger">' + lang . goto _spam + '</span>' ;
2019-02-23 17:59:18 +01:00
}
else if ( item . goto == "ham@localhost" ) {
2022-06-15 16:34:49 +02:00
item . goto = '<span class="badge fs-6 bg-success">' + lang . goto _ham + '</span>' ;
2019-02-23 17:59:18 +01:00
}
if ( item . in _primary _domain !== "" ) {
2022-04-01 08:25:47 +02:00
item . domain = '<i data-domainname="' + item . domain + '" class="bi bi-info-circle-fill alias-domain-info text-info" data-bs-toggle="tooltip" title="' + lang . target _domain + ': ' + item . in _primary _domain + '"></i> ' + item . domain ;
2019-02-23 17:59:18 +01:00
}
} ) ;
2022-05-17 14:08:22 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
{
title : 'ID' ,
2022-06-08 16:21:15 +02:00
data : 'id' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . alias ,
2022-06-08 16:21:15 +02:00
data : 'address' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . target _address ,
2022-07-01 16:20:39 +02:00
data : 'goto' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
2022-07-08 11:31:08 +02:00
{
title : lang . domain ,
data : 'domain' ,
defaultContent : '' ,
responsivePriority : 5 ,
} ,
2022-05-17 14:08:22 +02:00
{
title : lang . bcc _destinations ,
2022-07-01 16:20:39 +02:00
data : 'bcc_dest' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
2022-07-08 11:31:08 +02:00
title : lang . sogo _visible ,
data : 'sogo_visible' ,
defaultContent : '' ,
render : function ( data , type ) {
return 1 == data ? '<i class="bi bi-check-lg"></i>' : 0 == data && '<i class="bi bi-x-lg"></i>' ;
}
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . public _comment ,
2022-07-01 16:20:39 +02:00
data : 'public_comment' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . private _comment ,
2022-07-01 16:20:39 +02:00
data : 'private_comment' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-07-08 11:31:08 +02:00
responsivePriority : 6 ,
2022-05-17 14:08:22 +02:00
render : function ( data , type ) {
2022-05-20 12:03:12 +02:00
return 1 == data ? '<i class="bi bi-check-lg"></i>' : 0 == data && '<i class="bi bi-x-lg"></i>' ;
2022-05-17 14:08:22 +02:00
}
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
}
function draw _aliasdomain _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#aliasdomain_table' ) ) {
$ ( '#aliasdomain_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2022-05-17 14:08:22 +02:00
$ ( '#aliasdomain_table' ) . DataTable ( {
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/alias-domain/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
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/aliasdomain/' + encodeURIComponent ( item . alias _domain ) + '" class="btn btn-xs btn-xs-third 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-alias-domain" data-api-url="delete/alias-domain" data-item="' + encodeURIComponent ( item . alias _domain ) + '" class="btn btn-xs btn-xs-third btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2022-04-01 08:25:47 +02:00
'<a href="#dnsInfoModal" class="btn btn-xs btn-xs-third btn-info" data-bs-toggle="modal" data-domain="' + encodeURIComponent ( item . alias _domain ) + '"><i class="bi bi-globe2"></i> DNS</a></div>' +
2019-02-23 17:59:18 +01:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="alias-domain" name="multi_select" value="' + encodeURIComponent ( item . alias _domain ) + '" />' ;
2019-09-02 11:11:41 +02:00
if ( item . parent _is _backupmx == '1' ) {
2022-06-15 16:34:49 +02:00
item . target _domain = '<span><a href="/edit/domain/' + item . target _domain + '">' + item . target _domain + '</a> <div class="badge fs-6 bg-warning">' + lang . alias _domain _backupmx + '</div></span>' ;
2019-09-02 11:11:41 +02:00
} else {
item . target _domain = '<span><a href="/edit/domain/' + item . target _domain + '">' + item . target _domain + '</a></span>' ;
}
2019-02-23 17:59:18 +01:00
} ) ;
2022-05-17 14:08:22 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
{
title : lang . alias ,
2022-06-08 16:21:15 +02:00
data : 'alias_domain' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . target _domain ,
2022-06-08 16:21:15 +02:00
data : 'target_domain' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-05-17 14:08:22 +02:00
render : function ( data , type ) {
2022-05-20 12:03:12 +02:00
return 1 == data ? '<i class="bi bi-check-lg"></i>' : 0 == data && '<i class="bi bi-x-lg"></i>' ;
2022-05-17 14:08:22 +02:00
}
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
]
2019-02-23 17:59:18 +01: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-05-17 14:08:22 +02:00
$ ( '#sync_job_table' ) . DataTable ( {
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/syncjobs/all/no_log" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2022-04-01 08:25:47 +02:00
item . log = '<a href="#syncjobLogModal" data-bs-toggle="modal" data-syncjob-id="' + encodeURIComponent ( item . id ) + '">' + lang . open _logs + '</a>'
2019-02-23 17:59:18 +01:00
item . user2 = escapeHtml ( item . user2 ) ;
if ( ! item . exclude > 0 ) {
item . exclude = '-' ;
} else {
2022-06-03 14:37:56 +02:00
item . exclude = '<code>' + escapeHtml ( item . exclude ) + '</code>' ;
2019-02-23 17:59:18 +01:00
}
item . server _w _port = escapeHtml ( item . user1 ) + '@' + item . host1 + ':' + item . port1 ;
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>' +
2019-02-23 17:59:18 +01:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item . id + '" />' ;
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>' ;
2019-02-23 17:59:18 +01: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>' ;
2019-02-23 17:59:18 +01: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 ;
2019-02-23 17:59:18 +01:00
} ) ;
2022-05-17 14:08:22 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
{
title : 'ID' ,
2022-06-08 16:21:15 +02:00
data : 'id' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 3 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . owner ,
2022-06-08 16:21:15 +02:00
data : 'user2' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : 'Server' ,
2022-07-01 16:20:39 +02:00
data : 'server_w_port' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . last _run ,
2022-07-01 16:20:39 +02:00
data : 'last_run' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . syncjob _last _run _result ,
2022-07-01 16:20:39 +02:00
data : 'exit_status' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
2022-07-08 11:31:08 +02:00
title : 'Log' ,
data : 'log' ,
2022-07-01 16:20:39 +02:00
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-05-17 14:08:22 +02:00
render : function ( data , type ) {
2022-05-20 12:03:12 +02:00
return 1 == data ? '<i class="bi bi-check-lg"></i>' : 0 == data && '<i class="bi bi-x-lg"></i>' ;
2022-05-17 14:08:22 +02:00
}
} ,
{
2022-07-08 11:31:08 +02:00
title : lang . status ,
data : 'is_running' ,
defaultContent : ''
} ,
{
title : lang . excludes ,
data : 'exclude' ,
defaultContent : ''
} ,
{
title : lang . mins _interval ,
data : 'mins_interval' ,
2022-07-01 16:20:39 +02:00
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
}
function draw _filter _table ( ) {
2022-07-08 11:31:08 +02:00
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#filter_table' ) ) {
$ ( '#filter_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
var table = $ ( '#filter_table' ) . DataTable ( {
autoWidth : false ,
2022-05-17 14:08:22 +02:00
processing : true ,
serverSide : false ,
language : lang _datatables ,
ajax : {
type : "GET" ,
url : "/api/v1/get/filters/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2020-09-17 19:49:15 +02:00
if ( item . active == 1 ) {
2022-06-15 16:34:49 +02:00
item . active = '<span id="active-script" class="badge fs-6 bg-success">' + lang . active + '</span>' ;
2019-02-23 17:59:18 +01:00
} else {
2022-06-15 16:34:49 +02:00
item . active = '<span id="inactive-script" class="badge fs-6 bg-warning">' + lang . inactive + '</span>' ;
2019-02-23 17:59:18 +01:00
}
item . script _data = '<pre style="margin:0px">' + escapeHtml ( item . script _data ) + '</pre>'
2022-06-15 16:34:49 +02:00
item . filter _type = '<div class="badge fs-6 bg-secondary">' + item . filter _type . charAt ( 0 ) . toUpperCase ( ) + item . filter _type . slice ( 1 ) . toLowerCase ( ) + '</div>'
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/filter/' + 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-filter" data-api-url="delete/filter" data-item="' + encodeURIComponent ( item . id ) + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 17:59:18 +01:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="filter_item" name="multi_select" value="' + item . id + '" />'
} ) ;
2022-05-17 14:08:22 +02:00
return json ;
2019-02-23 17:59:18 +01:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2022-05-19 21:29:01 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 1
2022-05-19 21:29:01 +02:00
} ,
{
title : '' ,
2022-06-08 12:03:54 +02:00
data : 'chkbox' ,
searchable : false ,
orderable : false ,
2022-06-08 16:21:15 +02:00
defaultContent : '' ,
responsivePriority : 2
2022-05-19 21:29:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
{
title : 'ID' ,
2022-06-08 16:21:15 +02:00
data : 'id' ,
2022-07-08 11:31:08 +02:00
responsivePriority : 2 ,
2022-07-01 16:20:39 +02:00
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . active ,
2022-07-01 16:20:39 +02:00
data : 'active' ,
2022-07-08 11:31:08 +02:00
responsivePriority : 3 ,
2022-07-01 16:20:39 +02:00
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
2022-06-08 16:21:15 +02:00
title : 'Type' ,
data : 'filter_type' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 4 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . owner ,
2022-07-01 16:20:39 +02:00
data : 'username' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . description ,
2022-07-01 16:20:39 +02:00
data : 'script_desc' ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
{
title : 'Script' ,
2022-07-01 16:20:39 +02:00
data : 'script_data' ,
2022-07-08 11:31:08 +02:00
defaultContent : '' ,
className : 'none'
2022-05-17 14:08:22 +02:00
} ,
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2022-06-08 16:21:15 +02:00
className : 'text-md-end dt-sm-head-hidden dt-body-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2022-05-17 14:08:22 +02:00
} ,
]
2019-02-23 17:59:18 +01:00
} ) ;
} ;
2022-04-27 15:57:53 +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-04-27 15:57:53 +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^=domain_table]" , ( ) => draw _domain _table ( ) ) ;
onVisible ( "[id^=mailbox_table]" , ( ) => draw _mailbox _table ( ) ) ;
onVisible ( "[id^=resource_table]" , ( ) => draw _resource _table ( ) ) ;
onVisible ( "[id^=alias_table]" , ( ) => draw _alias _table ( ) ) ;
onVisible ( "[id^=aliasdomain_table]" , ( ) => draw _aliasdomain _table ( ) ) ;
onVisible ( "[id^=sync_job_table]" , ( ) => draw _sync _job _table ( ) ) ;
onVisible ( "[id^=filter_table]" , ( ) => draw _filter _table ( ) ) ;
onVisible ( "[id^=bcc_table]" , ( ) => draw _bcc _table ( ) ) ;
onVisible ( "[id^=recipient_map_table]" , ( ) => draw _recipient _map _table ( ) ) ;
onVisible ( "[id^=tls_policy_table]" , ( ) => draw _tls _policy _table ( ) ) ;
2019-10-04 08:44:31 +02:00
} ) ;