2019-02-23 18:59:18 +02:00
$ ( document ) . ready ( function ( ) {
acl _data = JSON . parse ( acl ) ;
2020-02-22 20:23:57 +02:00
// Set paging
2020-01-10 21:49:54 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02:00
}
2021-08-09 08:28:22 +02:00
$ ( '#addSelectDomain' ) . on ( 'change' , function ( ) {
2019-02-23 18:59:18 +02:00
auto _fill _quota ( $ ( '#addSelectDomain' ) . val ( ) ) ;
2021-08-09 08:28:22 +02:00
} ) ;
2019-02-23 18:59:18 +02:00
auto _fill _quota ( $ ( '#addSelectDomain' ) . val ( ) ) ;
2021-08-19 20:27:59 +02:00
2019-02-23 18:59:18 +02: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-09-26 11:23:04 +02:00
$ ( '.dns-modal-body' ) . html ( '<div class="spinner-border" role="status"><span class="visually-hidden">Loading...</span></div>' ) ;
2019-02-23 18:59:18 +02: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 ) ;
}
} ) ;
2023-01-26 00:50:39 +02:00
} ) ;
2022-11-10 17:22:18 +02:00
// @Open Domain add modal
$ ( '#addDomainModal' ) . on ( 'show.bs.modal' , function ( e ) {
$ . ajax ( {
url : '/api/v1/get/domain/template/all' ,
data : { } ,
dataType : 'json' ,
success : async function ( data ) {
2023-01-26 00:50:39 +02:00
$ ( '#domain_templates' ) . find ( 'option' ) . remove ( ) ;
2022-11-10 17:22:18 +02:00
$ ( '#domain_templates' ) . selectpicker ( 'destroy' ) ;
$ ( '#domain_templates' ) . selectpicker ( ) ;
for ( var i = 0 ; i < data . length ; i ++ ) {
if ( data [ i ] . template === "Default" ) {
2023-01-26 00:50:39 +02:00
$ ( '#domain_templates' ) . prepend ( $ ( '<option>' , {
'value' : data [ i ] . id ,
'text' : data [ i ] . template ,
'data-attributes' : JSON . stringify ( data [ i ] . attributes ) ,
'selected' : true
2022-11-10 17:22:18 +02:00
} ) ) ;
setDomainTemplateData ( data [ i ] . attributes ) ;
} else {
2023-01-26 00:50:39 +02:00
$ ( '#domain_templates' ) . append ( $ ( '<option>' , {
'value' : data [ i ] . id ,
'text' : data [ i ] . template ,
'data-attributes' : JSON . stringify ( data [ i ] . attributes ) ,
'selected' : false
2022-11-10 17:22:18 +02:00
} ) ) ;
}
} ;
$ ( '#domain_templates' ) . selectpicker ( "refresh" ) ;
// @selecting template
$ ( '#domain_templates' ) . on ( 'change' , function ( ) {
var selected = $ ( '#domain_templates option:selected' ) ;
var attr = selected . data ( 'attributes' ) ;
setDomainTemplateData ( attr ) ;
} ) ;
} ,
error : function ( xhr , status , error ) {
console . log ( error ) ;
}
} ) ;
} ) ;
// @Open Mailbox add modal
$ ( '#addMailboxModal' ) . on ( 'show.bs.modal' , function ( e ) {
$ . ajax ( {
url : '/api/v1/get/mailbox/template/all' ,
data : { } ,
dataType : 'json' ,
success : async function ( data ) {
2023-01-26 00:50:39 +02:00
$ ( '#mailbox_templates' ) . find ( 'option' ) . remove ( ) ;
2022-11-10 17:22:18 +02:00
$ ( '#mailbox_templates' ) . selectpicker ( 'destroy' ) ;
$ ( '#mailbox_templates' ) . selectpicker ( ) ;
for ( var i = 0 ; i < data . length ; i ++ ) {
if ( data [ i ] . template === "Default" ) {
2023-01-26 00:50:39 +02:00
$ ( '#mailbox_templates' ) . prepend ( $ ( '<option>' , {
'value' : data [ i ] . id ,
'text' : data [ i ] . template ,
'data-attributes' : JSON . stringify ( data [ i ] . attributes ) ,
'selected' : true
2022-11-10 17:22:18 +02:00
} ) ) ;
setMailboxTemplateData ( data [ i ] . attributes ) ;
} else {
2023-01-26 00:50:39 +02:00
$ ( '#mailbox_templates' ) . append ( $ ( '<option>' , {
value : data [ i ] . id ,
text : data [ i ] . template ,
'data-attributes' : JSON . stringify ( data [ i ] . attributes ) ,
'selected' : false
2022-11-10 17:22:18 +02:00
} ) ) ;
}
} ;
$ ( '#mailbox_templates' ) . selectpicker ( "refresh" ) ;
// @selecting template
$ ( '#mailbox_templates' ) . on ( 'change' , function ( ) {
var selected = $ ( '#mailbox_templates option:selected' ) ;
var attr = selected . data ( 'attributes' ) ;
setMailboxTemplateData ( attr ) ;
} ) ;
} ,
error : function ( xhr , status , error ) {
console . log ( error ) ;
}
} ) ;
2019-02-23 18:59:18 +02:00
} ) ;
// 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 13:23:48 +02: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 18:59:18 +02:00
// Validate script data
2020-03-19 13:23:48 +02:00
$ ( ".validate_sieve" ) . click ( function ( event ) {
2019-02-23 18:59:18 +02:00
event . preventDefault ( ) ;
2020-03-19 13:23:48 +02: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 18:59:18 +02:00
$ . ajax ( {
2019-10-29 09:39:57 +02:00
dataType : 'json' ,
2019-02-23 18:59:18 +02: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 13:23:48 +02:00
$ ( validation _button ) . next ( ) . attr ( { "disabled" : false } ) ;
2019-02-23 18:59:18 +02: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 22:17:02 +02: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 18:59:18 +02:00
2022-11-10 17:22:18 +02:00
function setDomainTemplateData ( template ) {
$ ( "#addDomain_max_aliases" ) . val ( template . max _num _aliases _for _domain ) ;
$ ( "#addDomain_max_mailboxes" ) . val ( template . max _num _mboxes _for _domain ) ;
$ ( "#addDomain_mailbox_quota_def" ) . val ( template . def _quota _for _mbox / 1048576 ) ;
$ ( "#addDomain_mailbox_quota_m" ) . val ( template . max _quota _for _mbox / 1048576 ) ;
$ ( "#addDomain_domain_quota_m" ) . val ( template . max _quota _for _domain / 1048576 ) ;
if ( template . gal == 1 ) {
$ ( '#addDomain_gal' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#addDomain_gal' ) . prop ( 'checked' , false ) ;
}
2023-01-26 00:50:39 +02:00
2022-11-10 17:22:18 +02:00
if ( template . active == 1 ) {
$ ( '#addDomain_active' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#addDomain_active' ) . prop ( 'checked' , false ) ;
}
2023-01-26 00:50:39 +02:00
2022-11-10 17:22:18 +02:00
$ ( "#addDomain_rl_value" ) . val ( template . rl _value ) ;
$ ( '#addDomain_rl_frame' ) . selectpicker ( 'val' , template . rl _frame ) ;
$ ( "#dkim_selector" ) . val ( template . dkim _selector ) ;
if ( ! template . key _size )
template . key _size = 2048 ;
$ ( '#key_size' ) . selectpicker ( 'val' , template . key _size . toString ( ) ) ;
2023-01-26 00:50:39 +02:00
2022-11-10 17:22:18 +02:00
if ( template . backupmx == 1 ) {
$ ( '#addDomain_relay_domain' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#addDomain_relay_domain' ) . prop ( 'checked' , false ) ;
}
if ( template . relay _all _recipients == 1 ) {
$ ( '#addDomain_relay_all' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#addDomain_relay_all' ) . prop ( 'checked' , false ) ;
}
if ( template . relay _unknown _only == 1 ) {
$ ( '#addDomain_relay_unknown_only' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#addDomain_relay_unknown_only' ) . prop ( 'checked' , false ) ;
}
2023-01-26 00:50:39 +02:00
2022-11-10 17:22:18 +02:00
// load tags
$ ( '#addDomain_tags' ) . val ( "" ) ;
$ ( $ ( '#addDomain_tags' ) . parent ( ) . find ( ".tag-values" ) [ 0 ] ) . val ( "" ) ;
$ ( '#addDomain_tags' ) . parent ( ) . find ( ".tag-badge" ) . remove ( ) ;
for ( var i = 0 ; i < template . tags . length ; i ++ )
addTag ( $ ( '#addDomain_tags' ) , template . tags [ i ] ) ;
}
function setMailboxTemplateData ( template ) {
$ ( "#addInputQuota" ) . val ( template . quota / 1048576 ) ;
if ( template . quarantine _notification === "never" ) {
$ ( '#quarantine_notification_never' ) . prop ( 'checked' , true ) ;
$ ( '#quarantine_notification_hourly' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_daily' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_weekly' ) . prop ( 'checked' , false ) ;
} else if ( template . quarantine _notification === "hourly" ) {
$ ( '#quarantine_notification_never' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_hourly' ) . prop ( 'checked' , true ) ;
$ ( '#quarantine_notification_daily' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_weekly' ) . prop ( 'checked' , false ) ;
} else if ( template . quarantine _notification === "daily" ) {
$ ( '#quarantine_notification_never' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_hourly' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_daily' ) . prop ( 'checked' , true ) ;
$ ( '#quarantine_notification_weekly' ) . prop ( 'checked' , false ) ;
} else if ( template . quarantine _notification === "weekly" ) {
$ ( '#quarantine_notification_never' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_hourly' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_daily' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_weekly' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#quarantine_notification_never' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_hourly' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_daily' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_notification_weekly' ) . prop ( 'checked' , false ) ;
}
if ( template . quarantine _category === "reject" ) {
$ ( '#quarantine_category_reject' ) . prop ( 'checked' , true ) ;
$ ( '#quarantine_category_add_header' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_category_all' ) . prop ( 'checked' , false ) ;
} else if ( template . quarantine _category === "add_header" ) {
$ ( '#quarantine_category_reject' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_category_add_header' ) . prop ( 'checked' , true ) ;
$ ( '#quarantine_category_all' ) . prop ( 'checked' , false ) ;
} else if ( template . quarantine _category === "all" ) {
$ ( '#quarantine_category_reject' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_category_add_header' ) . prop ( 'checked' , false ) ;
$ ( '#quarantine_category_all' ) . prop ( 'checked' , true ) ;
}
if ( template . tls _enforce _in == 1 ) {
$ ( '#tls_enforce_in' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#tls_enforce_in' ) . prop ( 'checked' , false ) ;
}
if ( template . tls _enforce _out == 1 ) {
$ ( '#tls_enforce_out' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#tls_enforce_out' ) . prop ( 'checked' , false ) ;
}
var protocol _access = [ ] ;
if ( template . imap _access == 1 ) {
protocol _access . push ( "imap" ) ;
}
if ( template . pop3 _access == 1 ) {
protocol _access . push ( "pop3" ) ;
}
if ( template . smtp _access == 1 ) {
protocol _access . push ( "smtp" ) ;
}
if ( template . sieve _access == 1 ) {
protocol _access . push ( "sieve" ) ;
}
$ ( '#protocol_access' ) . selectpicker ( 'val' , protocol _access ) ;
var acl = [ ] ;
if ( template . acl _spam _alias == 1 ) {
acl . push ( "spam_alias" ) ;
}
if ( template . acl _tls _policy == 1 ) {
acl . push ( "tls_policy" ) ;
}
if ( template . acl _spam _score == 1 ) {
acl . push ( "spam_score" ) ;
}
if ( template . acl _spam _policy == 1 ) {
acl . push ( "spam_policy" ) ;
}
if ( template . acl _delimiter _action == 1 ) {
acl . push ( "delimiter_action" ) ;
}
if ( template . acl _syncjobs == 1 ) {
acl . push ( "syncjobs" ) ;
}
if ( template . acl _eas _reset == 1 ) {
acl . push ( "eas_reset" ) ;
}
if ( template . acl _sogo _profile _reset == 1 ) {
acl . push ( "sogo_profile_reset" ) ;
}
if ( template . acl _pushover == 1 ) {
acl . push ( "pushover" ) ;
}
if ( template . acl _quarantine == 1 ) {
acl . push ( "quarantine" ) ;
}
if ( template . acl _quarantine _attachments == 1 ) {
acl . push ( "quarantine_attachments" ) ;
}
if ( template . acl _quarantine _notification == 1 ) {
acl . push ( "quarantine_notification" ) ;
}
if ( template . acl _quarantine _category == 1 ) {
acl . push ( "quarantine_category" ) ;
}
if ( template . acl _app _passwds == 1 ) {
acl . push ( "app_passwds" ) ;
}
$ ( '#user_acl' ) . selectpicker ( 'val' , acl ) ;
$ ( '#rl_value' ) . val ( template . rl _value ) ;
if ( template . rl _frame ) {
$ ( '#rl_frame' ) . selectpicker ( 'val' , template . rl _frame ) ;
}
console . log ( template . active )
if ( template . active ) {
$ ( '#mbox_active' ) . selectpicker ( 'val' , template . active . toString ( ) ) ;
} else {
$ ( '#mbox_active' ) . selectpicker ( 'val' , '' ) ;
}
if ( template . force _pw _update == 1 ) {
$ ( '#force_pw_update' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#force_pw_update' ) . prop ( 'checked' , false ) ;
}
if ( template . sogo _access == 1 ) {
$ ( '#sogo_access' ) . prop ( 'checked' , true ) ;
} else {
$ ( '#sogo_access' ) . prop ( 'checked' , false ) ;
}
2023-01-26 00:50:39 +02:00
2022-11-10 17:22:18 +02:00
// load tags
$ ( '#addMailbox_tags' ) . val ( "" ) ;
$ ( $ ( '#addMailbox_tags' ) . parent ( ) . find ( ".tag-values" ) [ 0 ] ) . val ( "" ) ;
$ ( '#addMailbox_tags' ) . parent ( ) . find ( ".tag-badge" ) . remove ( ) ;
for ( var i = 0 ; i < template . tags . length ; i ++ )
addTag ( $ ( '#addMailbox_tags' ) , template . tags [ i ] ) ;
}
2019-02-23 18:59:18 +02: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" } ) }
2023-01-26 00:50:39 +02:00
2019-02-23 18:59:18 +02:00
$ ( ".refresh_table" ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
var table _name = $ ( this ) . data ( 'table' ) ;
2023-01-26 00:50:39 +02:00
2022-10-11 11:41:06 +02:00
if ( $ . fn . DataTable . isDataTable ( '#' + table _name ) )
$ ( '#' + table _name ) . DataTable ( ) . ajax . reload ( ) ;
2019-02-23 18:59:18 +02: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 ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-16 11:26:49 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-16 11:26:49 +02:00
language : lang _datatables ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#tab-domains' , '#domain_table' ) ;
} ,
2022-05-16 11:26:49 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/domain/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2022-12-09 17:10:10 +02:00
item . domain _name = escapeHtml ( item . domain _name ) ;
2019-02-23 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02:00
if ( role == "admin" ) {
2022-10-11 11:41:06 +02:00
item . action += '<a href="/edit/domain/' + encodeURIComponent ( item . domain _name ) + '" class="btn btn-sm btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-domain" data-api-url="delete/domain" data-item="' + encodeURIComponent ( item . domain _name ) + '" class="btn btn-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'<a href="#dnsInfoModal" class="btn btn-sm btn-info" data-bs-toggle="modal" data-domain="' + encodeURIComponent ( item . domain _name ) + '"><i class="bi bi-globe2"></i> DNS</a></div>' ;
2019-02-23 18:59:18 +02: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 18:59:18 +02: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 12:30:20 +02:00
}
2019-02-23 18:59:18 +02:00
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02:00
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . domain _admins ,
2022-07-01 16:20:39 +02:00
data : 'domain_admins' ,
2022-10-11 11:41:06 +02:00
defaultContent : '' ,
className : 'none'
2019-02-23 18:59:18 +02:00
} ,
2022-11-11 10:22:58 +02:00
{
title : lang . created _on ,
data : 'created' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . last _modified ,
data : 'modified' ,
defaultContent : '' ,
className : 'none'
} ,
2022-06-15 16:34:49 +02:00
{
title : 'Tags' ,
2022-07-01 16:20:39 +02:00
data : 'tags' ,
2022-10-11 11:41:06 +02:00
defaultContent : '' ,
className : 'none'
2022-06-15 16:34:49 +02:00
} ,
{
title : lang . active ,
data : 'active' ,
2022-07-01 16:20:39 +02:00
defaultContent : '' ,
2022-10-11 11:41:06 +02:00
responsivePriority : 6 ,
2022-06-15 16:34:49 +02:00
render : function ( data , type ) {
2023-04-11 23:19:56 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : ( 0 == data ? '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' : 2 == data && '—' ) ;
2022-06-15 16:34:49 +02:00
}
} ,
2022-06-08 12:03:54 +02:00
{
title : lang . action ,
2022-06-08 15:28:45 +02:00
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2022-07-01 16:20:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
2019-02-23 18:59:18 +02:00
} ,
2022-05-16 11:26:49 +02:00
]
2023-01-26 00:50:39 +02:00
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-domains' , '#domain_table' ) ;
} ) ;
2019-02-23 18:59:18 +02:00
}
2022-11-10 17:22:18 +02:00
function draw _templates _domain _table ( ) {
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#templates_domain_table' ) ) {
$ ( '#templates_domain_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#templates_domain_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-11-10 17:22:18 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-11-10 17:22:18 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#tab-templates-domains' , '#templates_domain_table' ) ;
} ,
2022-11-10 17:22:18 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/domain/template/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
item . chkbox = '<input type="checkbox" data-id="domain_template" name="multi_select" value="' + encodeURIComponent ( item . id ) + '" />' ;
item . attributes . def _quota _for _mbox = humanFileSize ( item . attributes . def _quota _for _mbox ) ;
item . attributes . max _quota _for _mbox = humanFileSize ( item . attributes . max _quota _for _mbox ) ;
item . attributes . max _quota _for _domain = humanFileSize ( item . attributes . max _quota _for _domain ) ;
item . template = escapeHtml ( item . template ) ;
if ( item . attributes . rl _frame === "s" ) {
item . attributes . rl _frame = lang _rl . second ;
} else if ( item . attributes . rl _frame === "m" ) {
item . attributes . rl _frame = lang _rl . minute ;
} else if ( item . attributes . rl _frame === "h" ) {
item . attributes . rl _frame = lang _rl . hour ;
} else if ( item . attributes . rl _frame === "d" ) {
item . attributes . rl _frame = lang _rl . day ;
}
item . attributes . rl _value = escapeHtml ( item . attributes . rl _value ) ;
2023-01-26 00:50:39 +02:00
2022-12-12 11:49:00 +02:00
if ( item . template . toLowerCase ( ) == "default" ) {
item . action = '<div class="btn-group">' +
'<a href="/edit/template/' + encodeURIComponent ( item . id ) + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'</div>' ;
}
2023-01-26 00:50:39 +02:00
else {
2022-12-12 11:49:00 +02:00
item . action = '<div class="btn-group">' +
2022-11-10 17:22:18 +02:00
'<a href="/edit/template/' + encodeURIComponent ( 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-template" data-api-url="delete/domain/template" data-item="' + encodeURIComponent ( item . id ) + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'</div>' ;
2022-12-12 11:49:00 +02:00
}
2022-11-10 17:22:18 +02:00
if ( Array . isArray ( item . attributes . tags ) ) {
var tags = '' ;
for ( var i = 0 ; i < item . attributes . tags . length ; i ++ )
tags += '<span class="badge bg-primary tag-badge"><i class="bi bi-tag-fill"></i> ' + escapeHtml ( item . attributes . tags [ i ] ) + '</span>' ;
item . attributes . tags = tags ;
} else {
item . attributes . tags = '' ;
}
} ) ;
return json ;
}
} ,
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : "ID" ,
data : 'id' ,
responsivePriority : 2 ,
defaultContent : ''
} ,
{
title : lang . template ,
data : 'template' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . max _aliases ,
data : 'attributes.max_num_aliases_for_domain' ,
defaultContent : '' ,
} ,
{
title : lang . max _mailboxes ,
data : 'attributes.max_num_mboxes_for_domain' ,
defaultContent : '' ,
} ,
{
title : lang . mailbox _defquota ,
data : 'attributes.def_quota_for_mbox' ,
defaultContent : '' ,
} ,
{
title : lang . max _quota ,
data : 'attributes.max_quota_for_mbox' ,
defaultContent : '' ,
} ,
{
title : lang . domain _quota _total ,
data : 'attributes.max_quota_for_domain' ,
defaultContent : '' ,
} ,
{
title : lang . gal ,
data : 'attributes.gal' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-11 23:42:43 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . backup _mx ,
data : 'attributes.backupmx' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-11 23:42:43 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . relay _all ,
data : 'attributes.relay_all_recipients' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-11 23:42:43 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . relay _unknown ,
data : 'attributes.relay_unknown_only' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-11 23:42:43 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . active ,
data : 'attributes.active' ,
defaultContent : '' ,
responsivePriority : 4 ,
render : function ( data , type ) {
2023-04-11 23:42:43 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : 'rl_frame' ,
data : 'attributes.rl_frame' ,
defaultContent : '' ,
class : 'none' ,
} ,
{
title : 'rl_value' ,
data : 'attributes.rl_value' ,
defaultContent : '' ,
class : 'none' ,
} ,
{
title : lang . dkim _domains _selector ,
data : 'attributes.dkim_selector' ,
defaultContent : '' ,
class : 'none' ,
} ,
{
title : lang . dkim _key _length ,
data : 'attributes.key_size' ,
defaultContent : '' ,
class : 'none' ,
} ,
{
title : 'Tags' ,
data : 'attributes.tags' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 6 ,
defaultContent : ''
} ,
2022-11-10 17:22:18 +02:00
]
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-templates-domains' , '#templates_domain_table' ) ;
} ) ;
2022-11-10 17:22:18 +02:00
}
2019-02-23 18:59:18 +02: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 ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#mailbox_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-16 11:26:49 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-16 11:26:49 +02:00
language : lang _datatables ,
2023-09-03 14:05:12 +02:00
initComplete : function ( settings , json ) {
2023-01-16 16:38:35 +02:00
hideTableExpandCollapseBtn ( '#tab-mailboxes' , '#mailbox_table' ) ;
2023-09-03 14:05:12 +02:00
filterByDomain ( json , 8 , table ) ;
2023-01-16 16:38:35 +02:00
} ,
2022-05-16 11:26:49 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/mailbox/reduced" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2023-01-09 09:04:16 +02:00
item . quota = {
sortBy : item . quota _used ,
value : item . quota
}
item . quota . value = ( item . quota . value == 0 ? "∞" : humanFileSize ( item . quota . value ) ) ;
item . quota . value = humanFileSize ( item . quota _used ) + "/" + item . quota . value ;
2019-02-23 18:59:18 +02:00
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 17:33:50 +02:00
/ *
2019-02-23 18:59:18 +02: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 18:59:18 +02:00
}
2021-03-19 17:33:50 +02:00
* /
2019-02-23 18:59:18 +02: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>' ;
2022-09-27 12:32:14 +02:00
item . sieve _access = '<i class="text-' + ( item . attributes . sieve _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . sieve _access == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
2019-02-23 18:59:18 +02: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 18:41:48 +02: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 18:59:18 +02:00
if ( acl _data . login _as === 1 ) {
2021-08-09 08:28:22 +02:00
2022-09-27 12:32:14 +02:00
item . action = '<div class="btn-group">' +
2022-10-11 11:41:06 +02:00
'<a href="/edit/mailbox/' + encodeURIComponent ( item . username ) + '" class="btn btn-sm btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-mailbox" data-api-url="delete/mailbox" data-item="' + encodeURIComponent ( item . username ) + '" class="btn btn-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'<a href="/index.php?duallogin=' + encodeURIComponent ( item . username ) + '" class="login_as btn btn-sm btn-xs-half btn-success"><i class="bi bi-person-fill"></i> Login</a>' ;
2019-02-23 18:59:18 +02:00
if ( ALLOW _ADMIN _EMAIL _LOGIN ) {
2022-10-11 11:41:06 +02:00
item . action += '<a href="/sogo-auth.php?login=' + encodeURIComponent ( item . username ) + '" class="login_as btn btn-sm btn-xs-half btn-primary" target="_blank"><i class="bi bi-envelope-fill"></i> SOGo</a>' ;
2019-02-23 18:59:18 +02: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 18:59:18 +02:00
'</div>' ;
}
2023-02-16 18:12:03 +02:00
item . in _use = {
sortBy : item . percent _in _use ,
value : '<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" ' +
2023-02-16 18:12:03 +02:00
'style="min-width:2em;width:' + item . percent _in _use + '%">' + item . percent _in _use + '%' + '</div></div>'
} ;
2019-02-23 18:59:18 +02:00
item . username = escapeHtml ( item . username ) ;
2023-01-26 00:50:39 +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
}
2019-02-23 18:59:18 +02:00
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-16 11:26:49 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : lang . username ,
data : 'username' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . domain _quota ,
data : 'quota.value' ,
responsivePriority : 8 ,
defaultContent : '' ,
orderData : 23
} ,
{
title : lang . last _mail _login ,
data : 'last_mail_login' ,
defaultContent : '' ,
responsivePriority : 7 ,
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' ,
defaultContent : ''
} ,
{
title : lang . in _use ,
2023-02-16 18:12:03 +02:00
data : 'in_use.value' ,
2023-01-26 00:50:39 +02:00
defaultContent : '' ,
responsivePriority : 9 ,
2023-02-16 18:12:03 +02:00
className : 'dt-data-w100' ,
orderData : 24
2023-01-26 00:50:39 +02:00
} ,
{
title : lang . fname ,
data : 'name' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . domain ,
data : 'domain' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . tls _enforce _in ,
data : 'tls_enforce_in' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . tls _enforce _out ,
data : 'tls_enforce_out' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : 'SMTP' ,
data : 'smtp_access' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : 'IMAP' ,
data : 'imap_access' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : 'POP3' ,
data : 'pop3_access' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : 'SIEVE' ,
data : 'sieve_access' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . quarantine _notification ,
data : 'quarantine_notification' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . quarantine _category ,
data : 'quarantine_category' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . msg _num ,
data : 'messages' ,
defaultContent : '' ,
responsivePriority : 5
} ,
{
title : lang . created _on ,
data : 'created' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . last _modified ,
data : 'modified' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : 'Tags' ,
data : 'tags' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
responsivePriority : 4 ,
render : function ( data , type ) {
2023-04-11 23:49:50 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : ( 0 == data ? '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' : 2 == data && '—' ) ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 6 ,
defaultContent : ''
} ,
{
title : "" ,
data : 'quota.sortBy' ,
2023-02-16 18:12:03 +02:00
defaultContent : '' ,
className : "d-none"
} ,
{
title : "" ,
data : 'in_use.sortBy' ,
2023-01-26 00:50:39 +02:00
defaultContent : '' ,
className : "d-none"
} ,
2022-05-16 11:26:49 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-mailboxes' , '#mailbox_table' ) ;
} ) ;
2019-02-23 18:59:18 +02:00
}
2022-11-10 17:22:18 +02:00
function draw _templates _mbox _table ( ) {
// just recalc width if instance already exists
if ( $ . fn . DataTable . isDataTable ( '#templates_mbox_table' ) ) {
$ ( '#templates_mbox_table' ) . DataTable ( ) . columns . adjust ( ) . responsive . recalc ( ) ;
return ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#templates_mbox_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-11-10 17:22:18 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-11-10 17:22:18 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#tab-templates-mbox' , '#templates_mbox_table' ) ;
} ,
2022-11-10 17:22:18 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/mailbox/template/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
item . chkbox = '<input type="checkbox" data-id="mailbox_template" name="multi_select" value="' + encodeURIComponent ( item . id ) + '" />' ;
item . template = escapeHtml ( item . template ) ;
if ( item . attributes . rl _frame === "s" ) {
item . attributes . rl _frame = lang _rl . second ;
} else if ( item . attributes . rl _frame === "m" ) {
item . attributes . rl _frame = lang _rl . minute ;
} else if ( item . attributes . rl _frame === "h" ) {
item . attributes . rl _frame = lang _rl . hour ;
} else if ( item . attributes . rl _frame === "d" ) {
item . attributes . rl _frame = lang _rl . day ;
}
item . attributes . rl _value = escapeHtml ( item . attributes . rl _value ) ;
item . attributes . quota = humanFileSize ( item . attributes . quota ) ;
2023-04-12 00:15:16 +02:00
item . attributes . tls _enforce _in = '<i class="text-' + ( item . attributes . tls _enforce _in == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill' ) + '"><span class="sorting-value">' + ( item . attributes . tls _enforce _in == 1 ? '1' : '0' ) + '</span></i>' ;
item . attributes . tls _enforce _out = '<i class="text-' + ( item . attributes . tls _enforce _out == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill' ) + '"><span class="sorting-value">' + ( item . attributes . tls _enforce _out == 1 ? '1' : '0' ) + '</span></i>' ;
item . attributes . pop3 _access = '<i class="text-' + ( item . attributes . pop3 _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . pop3 _access == 1 ? 'check-lg' : 'x-lg' ) + '"><span class="sorting-value">' + ( item . attributes . pop3 _access == 1 ? '1' : '0' ) + '</span></i>' ;
item . attributes . imap _access = '<i class="text-' + ( item . attributes . imap _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . imap _access == 1 ? 'check-lg' : 'x-lg' ) + '"><span class="sorting-value">' + ( item . attributes . imap _access == 1 ? '1' : '0' ) + '</span></i>' ;
item . attributes . smtp _access = '<i class="text-' + ( item . attributes . smtp _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . smtp _access == 1 ? 'check-lg' : 'x-lg' ) + '"><span class="sorting-value">' + ( item . attributes . smtp _access == 1 ? '1' : '0' ) + '</span></i>' ;
item . attributes . sieve _access = '<i class="text-' + ( item . attributes . sieve _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . sieve _access == 1 ? 'check-lg' : 'x-lg' ) + '"><span class="sorting-value">' + ( item . attributes . sieve _access == 1 ? '1' : '0' ) + '</span></i>' ;
item . attributes . sogo _access = '<i class="text-' + ( item . attributes . sogo _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . sogo _access == 1 ? 'check-lg' : 'x-lg' ) + '"><span class="sorting-value">' + ( item . attributes . sogo _access == 1 ? '1' : '0' ) + '</span></i>' ;
2022-11-10 17:22:18 +02:00
if ( item . attributes . quarantine _notification === 'never' ) {
item . attributes . quarantine _notification = lang . never ;
} else if ( item . attributes . quarantine _notification === 'hourly' ) {
item . attributes . quarantine _notification = lang . hourly ;
} else if ( item . attributes . quarantine _notification === 'daily' ) {
item . attributes . quarantine _notification = lang . daily ;
} else if ( item . attributes . quarantine _notification === 'weekly' ) {
item . attributes . quarantine _notification = lang . weekly ;
}
if ( item . attributes . quarantine _category === 'reject' ) {
item . attributes . quarantine _category = '<span class="text-danger">' + lang . q _reject + '</span>' ;
} else if ( item . attributes . quarantine _category === 'add_header' ) {
item . attributes . quarantine _category = '<span class="text-warning">' + lang . q _add _header + '</span>' ;
} else if ( item . attributes . quarantine _category === 'all' ) {
item . attributes . quarantine _category = lang . q _all ;
}
2022-12-12 11:49:00 +02:00
if ( item . template . toLowerCase ( ) == "default" ) {
2023-01-26 00:50:39 +02:00
item . action = '<div class="btn-group">' +
'<a href="/edit/template/' + encodeURIComponent ( item . id ) + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'</div>' ;
2022-12-12 11:49:00 +02:00
}
else {
2023-01-26 00:50:39 +02:00
item . action = '<div class="btn-group">' +
'<a href="/edit/template/' + encodeURIComponent ( 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-template" data-api-url="delete/mailbox/template" data-item="' + encodeURIComponent ( item . id ) + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'</div>' ;
2022-12-12 11:49:00 +02:00
}
2022-11-10 17:22:18 +02:00
if ( Array . isArray ( item . attributes . tags ) ) {
var tags = '' ;
for ( var i = 0 ; i < item . attributes . tags . length ; i ++ )
tags += '<span class="badge bg-primary tag-badge"><i class="bi bi-tag-fill"></i> ' + escapeHtml ( item . attributes . tags [ i ] ) + '</span>' ;
item . attributes . tags = tags ;
} else {
item . attributes . tags = '' ;
}
} ) ;
return json ;
}
} ,
columns : [
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : "ID" ,
data : 'id' ,
responsivePriority : 2 ,
defaultContent : ''
} ,
{
2022-12-12 11:49:00 +02:00
title : lang . template ,
2022-11-10 17:22:18 +02:00
data : 'template' ,
responsivePriority : 3 ,
defaultContent : ''
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : lang . domain _quota ,
data : 'attributes.quota' ,
defaultContent : '' ,
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : lang . tls _enforce _in ,
data : 'attributes.tls_enforce_in' ,
defaultContent : ''
} ,
{
title : lang . tls _enforce _out ,
data : 'attributes.tls_enforce_out' ,
defaultContent : ''
} ,
{
title : 'SMTP' ,
data : 'attributes.smtp_access' ,
defaultContent : '' ,
} ,
{
title : 'IMAP' ,
data : 'attributes.imap_access' ,
defaultContent : '' ,
} ,
{
title : 'POP3' ,
data : 'attributes.pop3_access' ,
defaultContent : '' ,
} ,
{
title : 'SIEVE' ,
data : 'attributes.sieve_access' ,
defaultContent : '' ,
} ,
{
title : 'SOGO' ,
data : 'attributes.sogo_access' ,
defaultContent : '' ,
} ,
{
title : lang . quarantine _notification ,
data : 'attributes.quarantine_notification' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . quarantine _category ,
data : 'attributes.quarantine_category' ,
defaultContent : '' ,
className : 'none'
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : lang . force _pw _update ,
data : 'attributes.force_pw_update' ,
defaultContent : '' ,
class : 'none' ,
render : function ( data , type ) {
return 1 == data ? '<i class="bi bi-check-lg"></i>' : '<i class="bi bi-x-lg"></i>' ;
}
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : "rl_frame" ,
data : 'attributes.rl_frame' ,
defaultContent : '' ,
class : 'none' ,
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : 'rl_value' ,
data : 'attributes.rl_value' ,
defaultContent : '' ,
class : 'none' ,
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : 'Tags' ,
data : 'attributes.tags' ,
defaultContent : '' ,
className : 'none'
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : lang . active ,
data : 'attributes.active' ,
defaultContent : '' ,
responsivePriority : 4 ,
render : function ( data , type ) {
2023-04-12 00:15:16 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : ( 0 == data ? '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' : 2 == data && '—' ) ;
2022-11-10 17:22:18 +02:00
}
2023-01-26 00:50:39 +02:00
} ,
2022-11-10 17:22:18 +02:00
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2022-11-10 17:22:18 +02:00
responsivePriority : 6 ,
defaultContent : ''
} ,
]
} ) ;
2023-01-26 00:50:39 +02:00
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-templates-mbox' , '#templates_mbox_table' ) ;
} ) ;
2022-11-10 17:22:18 +02:00
}
2019-02-23 18:59:18 +02: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 ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#resource_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-16 11:26:49 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-16 11:26:49 +02:00
language : lang _datatables ,
2023-09-03 14:05:12 +02:00
initComplete : function ( settings , json ) {
2023-01-16 16:38:35 +02:00
hideTableExpandCollapseBtn ( '#tab-resources' , '#resource_table' ) ;
2023-09-03 14:05:12 +02:00
filterByDomain ( json , 5 , table ) ;
2023-01-16 16:38:35 +02:00
} ,
2022-05-16 11:26:49 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/resource/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2019-02-23 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02:00
}
2022-06-08 15:31:10 +02:00
item . action = '<div class="btn-group">' +
2022-10-11 11:41:06 +02:00
'<a href="/edit/resource/' + encodeURIComponent ( item . name ) + '" class="btn btn-sm btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-resource" data-api-url="delete/resource" data-item="' + item . name + '" class="btn btn-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 18:59:18 +02: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 18:59:18 +02:00
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-16 11:26:49 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : lang . description ,
data : 'description' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . alias ,
data : 'name' ,
defaultContent : ''
} ,
{
title : lang . kind ,
data : 'kind' ,
defaultContent : ''
} ,
{
title : lang . domain ,
data : 'domain' ,
responsivePriority : 4 ,
defaultContent : ''
} ,
{
title : lang . multiple _bookings ,
data : 'multiple_bookings' ,
defaultContent : ''
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-12 00:17:41 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : ( 0 == data ? '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' : 2 == data && '—' ) ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . action ,
data : 'action' ,
responsivePriority : 5 ,
defaultContent : '' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right'
2023-01-26 00:50:39 +02:00
} ,
2022-05-16 11:26:49 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-resources' , '#resource_table' ) ;
} ) ;
2019-02-23 18:59:18 +02:00
}
function draw _bcc _table ( ) {
2022-07-08 11:31:08 +02:00
$ . get ( "/api/v1/get/bcc-destination-options" , function ( data ) {
2023-05-03 09:59:49 +02:00
var optgroup = "" ;
2022-07-08 11:31:08 +02:00
// Domains
2023-05-03 09:59:49 +02:00
if ( data . domains && data . domains . length > 0 ) {
optgroup = "<optgroup label='" + lang . domains + "'>" ;
$ . each ( data . domains , function ( index , domain ) {
optgroup += "<option value='" + domain + "'>" + domain + "</option>" ;
2022-07-08 11:31:08 +02:00
} ) ;
2023-01-26 00:50:39 +02:00
optgroup += "</optgroup>" ;
2022-07-08 11:31:08 +02:00
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
2023-05-03 09:59:49 +02:00
}
// Alias domains
if ( data . alias _domains && data . alias _domains . length > 0 ) {
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
if ( data . mailboxes && Object . keys ( data . mailboxes ) . length > 0 ) {
$ . each ( data . mailboxes , function ( mailbox , aliases ) {
optgroup = "<optgroup label='" + mailbox + "'>" ;
$ . each ( aliases , function ( index , alias ) {
optgroup += "<option value='" + alias + "'>" + alias + "</option>" ;
} ) ;
optgroup += "</optgroup>" ;
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
} ) ;
}
// Recreate picker
2022-07-08 11:31:08 +02:00
$ ( '#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 ;
}
2023-01-26 00:50:39 +02:00
2023-01-16 16:38:35 +02:00
var table = $ ( '#bcc_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-16 11:26:49 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-16 11:26:49 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-09-03 14:05:12 +02:00
initComplete : function ( settings , json ) {
2023-01-16 16:38:35 +02:00
hideTableExpandCollapseBtn ( '#collapse-tab-bcc' , '#bcc_table' ) ;
2023-09-03 14:05:12 +02:00
filterByDomain ( json , 6 , table ) ;
2023-01-16 16:38:35 +02:00
} ,
2022-05-16 11:26:49 +02:00
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-10-11 11:41:06 +02:00
'<a href="/edit/bcc/' + item . id + '" class="btn btn-sm btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-bcc" data-api-url="delete/bcc" data-item="' + item . id + '" class="btn btn-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02:00
}
} ) ;
2022-05-16 11:26:49 +02:00
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-16 11:26:49 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : 'ID' ,
data : 'id' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . bcc _type ,
data : 'type' ,
defaultContent : ''
} ,
{
title : lang . bcc _local _dest ,
data : 'local_dest' ,
defaultContent : ''
} ,
{
title : lang . bcc _destinations ,
data : 'bcc_dest' ,
defaultContent : ''
} ,
{
title : lang . domain ,
data : 'domain' ,
responsivePriority : 4 ,
defaultContent : ''
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-13 18:10:21 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : ( 0 == data ? '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' : 2 == data && '—' ) ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
} ,
2022-05-16 11:26:49 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#collapse-tab-bcc' , '#bcc_table' ) ;
} ) ;
2019-02-23 18:59:18 +02: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 ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#recipient_map_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-17 14:08:22 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-17 14:08:22 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#collapse-tab-bcc-filters' , '#recipient_map_table' ) ;
} ,
2022-05-17 14:08:22 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/recipient_map/all" ,
dataSrc : function ( json ) {
if ( role !== "admin" ) return null ;
2023-01-26 00:50:39 +02:00
2022-05-17 14:08:22 +02:00
$ . 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-10-11 11:41:06 +02:00
'<a href="/edit/recipient_map/' + item . id + '" class="btn btn-sm 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-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2022-05-17 14:08:22 +02:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="recipient_map" name="multi_select" value="' + item . id + '" />' ;
} ) ;
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : 'ID' ,
data : 'id' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . recipient _map _old ,
data : 'recipient_map_old' ,
defaultContent : ''
} ,
{
title : lang . recipient _map _new ,
data : 'recipient_map_new' ,
defaultContent : '' ,
responsivePriority : 4
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-13 18:10:21 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : 0 == data && '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
} ,
2022-05-17 14:08:22 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-26 00:50:39 +02:00
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#collapse-tab-bcc-filters' , '#recipient_map_table' ) ;
} ) ;
2019-02-23 18:59:18 +02: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 ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#tls_policy_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-17 14:08:22 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-17 14:08:22 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#tab-tls-policy' , '#tls_policy_table' ) ;
} ,
2022-05-17 14:08:22 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/tls-policy-map/all" ,
dataSrc : function ( json ) {
if ( role !== "admin" ) return null ;
2023-01-26 00:50:39 +02:00
2022-05-17 14:08:22 +02:00
$ . 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-10-11 11:41:06 +02:00
'<a href="/edit/tls_policy_map/' + item . id + '" class="btn btn-sm 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-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2022-05-17 14:08:22 +02:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="tls-policy-map" name="multi_select" value="' + item . id + '" />' ;
} ) ;
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : 'ID' ,
data : 'id' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . tls _map _dest ,
data : 'dest' ,
defaultContent : '' ,
responsivePriority : 4
} ,
{
title : lang . tls _map _policy ,
data : 'policy' ,
defaultContent : ''
} ,
{
title : lang . tls _map _parameters ,
data : 'parameters' ,
defaultContent : ''
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-13 18:14:18 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : 0 == data && '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
} ,
2022-05-17 14:08:22 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-26 00:50:39 +02:00
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-tls-policy' , '#tls_policy_table' ) ;
} ) ;
2019-02-23 18:59:18 +02: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 ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#alias_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-17 14:08:22 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-17 14:08:22 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-09-03 14:05:12 +02:00
initComplete : function ( settings , json ) {
2023-01-16 16:38:35 +02:00
hideTableExpandCollapseBtn ( '#tab-mbox-aliases' , '#alias_table' ) ;
2023-09-03 14:05:12 +02:00
filterByDomain ( json , 5 , table ) ;
2023-01-16 16:38:35 +02:00
} ,
2022-05-17 14:08:22 +02:00
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-10-11 11:41:06 +02:00
'<a href="/edit/alias/' + encodeURIComponent ( item . id ) + '" class="btn btn-sm btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-alias" data-api-url="delete/alias" data-item="' + encodeURIComponent ( item . id ) + '" class="btn btn-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 18:59:18 +02: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 03:03:59 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02: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 18:59:18 +02:00
}
} ) ;
2022-05-17 14:08:22 +02:00
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : 'ID' ,
data : 'id' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . alias ,
data : 'address' ,
responsivePriority : 4 ,
defaultContent : ''
} ,
{
title : lang . target _address ,
data : 'goto' ,
defaultContent : ''
} ,
{
title : lang . domain ,
data : 'domain' ,
defaultContent : '' ,
responsivePriority : 5 ,
} ,
{
title : lang . bcc _destinations ,
data : 'bcc_dest' ,
defaultContent : ''
} ,
{
title : lang . sogo _visible ,
data : 'sogo_visible' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-12 00:21:27 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : 0 == data && '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . public _comment ,
data : 'public_comment' ,
defaultContent : ''
} ,
{
title : lang . private _comment ,
data : 'private_comment' ,
defaultContent : ''
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
responsivePriority : 6 ,
render : function ( data , type ) {
2023-04-12 00:21:27 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : 0 == data && '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
} ,
2022-05-17 14:08:22 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-26 00:50:39 +02:00
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-mbox-aliases' , '#alias_table' ) ;
} ) ;
2023-03-20 02:30:06 +02:00
table . on ( 'draw' , function ( ) {
$ ( '#alias_table [data-bs-toggle="tooltip"]' ) . tooltip ( ) ;
} ) ;
2019-02-23 18:59:18 +02: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 ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#aliasdomain_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-17 14:08:22 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-17 14:08:22 +02:00
language : lang _datatables ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#tab-domain-aliases' , '#aliasdomain_table' ) ;
} ,
2022-05-17 14:08:22 +02:00
ajax : {
type : "GET" ,
url : "/api/v1/get/alias-domain/all" ,
dataSrc : function ( json ) {
$ . each ( json , function ( i , item ) {
2022-12-09 17:10:10 +02:00
item . alias _domain = escapeHtml ( item . alias _domain ) ;
2022-06-08 15:31:10 +02:00
item . action = '<div class="btn-group">' +
2022-10-11 11:41:06 +02:00
'<a href="/edit/aliasdomain/' + encodeURIComponent ( item . alias _domain ) + '" class="btn btn-sm btn-xs-third btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<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-sm btn-xs-third btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'<a href="#dnsInfoModal" class="btn btn-sm 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 18:59:18 +02: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 18:59:18 +02:00
} ) ;
2022-05-17 14:08:22 +02:00
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 19:07:01 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : lang . alias ,
data : 'alias_domain' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . target _domain ,
data : 'target_domain' ,
responsivePriority : 4 ,
defaultContent : ''
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-12 00:23:53 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : 0 == data && '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
} ,
2022-05-17 14:08:22 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-domain-aliases' , '#aliasdomain_table' ) ;
} ) ;
2019-02-23 18:59:18 +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 ;
}
2023-01-16 16:38:35 +02:00
var table = $ ( '#sync_job_table' ) . DataTable ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-05-17 14:08:22 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-17 14:08:22 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#tab-syncjobs' , '#sync_job_table' ) ;
} ,
2022-05-17 14:08:22 +02:00
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 18:59:18 +02: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 18:59:18 +02:00
}
2022-12-09 17:10:10 +02:00
item . server _w _port = escapeHtml ( item . user1 ) + '@' + escapeHtml ( item . host1 ) + ':' + escapeHtml ( item . port1 ) ;
2022-06-08 15:31:10 +02:00
item . action = '<div class="btn-group">' +
2022-10-11 11:41:06 +02:00
'<a href="/edit/syncjob/' + item . id + '" class="btn btn-sm btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-syncjob" data-api-url="delete/syncjob" data-item="' + item . id + '" class="btn btn-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 18:59:18 +02: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 18:59:18 +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>' ;
2019-02-23 18:59:18 +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 ] ) {
2023-01-26 00:50:39 +02:00
item . exit _status = lang [ 'syncjob_' + item . exit _status ] ;
2021-09-01 16:29:11 +02:00
} else if ( item . success != '-' ) {
2023-01-26 00:50:39 +02:00
item . exit _status = lang . syncjob _check _log ;
2021-09-01 16:29:11 +02:00
}
item . exit _status = item . success + ' ' + item . exit _status ;
2019-02-23 18:59:18 +02:00
} ) ;
2022-05-17 14:08:22 +02:00
return json ;
2019-02-23 18:59:18 +02:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : 'ID' ,
data : 'id' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : lang . owner ,
data : 'user2' ,
responsivePriority : 4 ,
defaultContent : ''
} ,
{
title : 'Server' ,
data : 'server_w_port' ,
defaultContent : ''
} ,
{
title : lang . last _run ,
data : 'last_run' ,
defaultContent : ''
} ,
{
title : lang . syncjob _last _run _result ,
data : 'exit_status' ,
defaultContent : ''
} ,
{
title : 'Log' ,
data : 'log' ,
defaultContent : ''
} ,
{
title : lang . active ,
data : 'active' ,
defaultContent : '' ,
render : function ( data , type ) {
2023-04-12 00:36:46 +02:00
return 1 == data ? '<i class="bi bi-check-lg"><span class="sorting-value">1</span></i>' : 0 == data && '<i class="bi bi-x-lg"><span class="sorting-value">0</span></i>' ;
2023-01-26 00:50:39 +02:00
}
} ,
{
title : lang . status ,
data : 'is_running' ,
defaultContent : ''
} ,
{
title : lang . excludes ,
data : 'exclude' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . mins _interval ,
data : 'mins_interval' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
} ,
2022-05-17 14:08:22 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-syncjobs' , '#sync_job_table' ) ;
} ) ;
2019-02-23 18:59:18 +02: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 ( {
2023-01-26 00:50:39 +02:00
responsive : true ,
2022-07-08 11:31:08 +02:00
autoWidth : false ,
2022-05-17 14:08:22 +02:00
processing : true ,
serverSide : false ,
2023-01-06 14:45:52 +02:00
stateSave : true ,
2023-01-26 00:50:39 +02:00
pageLength : pagination _size ,
2023-01-06 16:03:04 +02:00
dom : "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" ,
2022-05-17 14:08:22 +02:00
language : lang _datatables ,
2023-01-26 00:50:39 +02:00
order : [ [ 2 , 'desc' ] ] ,
2023-01-16 16:38:35 +02:00
initComplete : function ( ) {
hideTableExpandCollapseBtn ( '#tab-filters' , '#filter_table' ) ;
} ,
2022-05-17 14:08:22 +02:00
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 18:59:18 +02: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 18:59:18 +02:00
}
2022-12-09 17:10:10 +02:00
item . script _desc = escapeHtml ( item . script _desc ) ;
2022-10-11 11:41:06 +02:00
item . script _data = '<pre class="text-break" 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-10-11 11:41:06 +02:00
'<a href="/edit/filter/' + item . id + '" class="btn btn-sm btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-filter" data-api-url="delete/filter" data-item="' + encodeURIComponent ( item . id ) + '" class="btn btn-sm btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-23 18:59:18 +02: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 18:59:18 +02:00
}
2019-07-27 18:57:58 +02:00
} ,
2022-05-17 14:08:22 +02:00
columns : [
2023-01-26 00:50:39 +02:00
{
// placeholder, so checkbox will not block child row toggle
title : '' ,
data : null ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 1
} ,
{
title : '' ,
data : 'chkbox' ,
searchable : false ,
orderable : false ,
defaultContent : '' ,
responsivePriority : 2
} ,
{
title : 'ID' ,
data : 'id' ,
responsivePriority : 2 ,
defaultContent : ''
} ,
{
title : lang . active ,
data : 'active' ,
responsivePriority : 3 ,
defaultContent : ''
} ,
{
title : 'Type' ,
data : 'filter_type' ,
responsivePriority : 4 ,
defaultContent : ''
} ,
{
title : lang . owner ,
data : 'username' ,
defaultContent : ''
} ,
{
title : lang . description ,
data : 'script_desc' ,
defaultContent : ''
} ,
{
title : 'Script' ,
data : 'script_data' ,
defaultContent : '' ,
className : 'none'
} ,
{
title : lang . action ,
data : 'action' ,
2023-01-31 11:37:51 +02:00
className : 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right' ,
2023-01-26 00:50:39 +02:00
responsivePriority : 5 ,
defaultContent : ''
} ,
2022-05-17 14:08:22 +02:00
]
2019-02-23 18:59:18 +02:00
} ) ;
2023-01-16 16:38:35 +02:00
table . on ( 'responsive-resize' , function ( e , datatable , columns ) {
hideTableExpandCollapseBtn ( '#tab-filters' , '#filter_table' ) ;
} ) ;
2019-02-23 18:59:18 +02:00
} ;
2023-01-16 16:38:35 +02:00
function hideTableExpandCollapseBtn ( tab , table ) {
if ( $ ( table ) . hasClass ( 'collapsed' ) )
2023-01-26 00:50:39 +02:00
$ ( tab ) . find ( ".table_collapse_option" ) . show ( ) ;
2023-01-16 16:38:35 +02:00
else
2023-01-26 00:50:39 +02:00
$ ( tab ) . find ( ".table_collapse_option" ) . hide ( ) ;
2023-01-16 16:38:35 +02:00
}
2023-09-03 14:05:12 +02:00
function filterByDomain ( json , column , table ) {
var tableId = $ ( table . table ( ) . container ( ) ) . attr ( 'id' ) ;
// Create the `select` element
var select = $ ( '<select class="btn btn-sm btn-xs-lg btn-light text-start mx-2"><option value="">' + lang . all _domains + '</option></select>' )
. insertBefore (
$ ( '#' + tableId + ' .dataTables_filter > label > input' )
)
. on ( 'change' , function ( ) {
table . column ( column )
. search ( $ ( this ) . val ( ) )
. draw ( ) ;
} ) ;
// get all domains
var domains = [ ] ;
json . forEach ( obj => {
Object . entries ( obj ) . forEach ( ( [ key , value ] ) => {
if ( key === 'domain' ) {
domains . push ( value )
}
} ) ;
} ) ;
// get unique domain list
domains = domains . filter ( function ( value , index , array ) {
return array . indexOf ( value ) === index ;
} ) ;
// add domains to select
domains . forEach ( function ( domain ) {
select . append ( $ ( '<option>' + domain + '</option>' ) ) ;
} ) ;
}
2023-01-26 00:50:39 +02: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 ( ) {
2023-05-03 09:59:49 +02:00
let element _object = document . querySelector ( element ) ;
2022-07-01 16:20:39 +02:00
if ( element _object === null ) return ;
2023-05-03 09:59:49 +02:00
let observer = new IntersectionObserver ( ( entries , observer ) => {
2022-04-27 15:57:53 +02:00
entries . forEach ( entry => {
if ( entry . intersectionRatio > 0 ) {
callback ( element _object ) ;
2023-05-03 09:59:49 +02:00
observer . unobserve ( element _object ) ;
2022-04-27 15:57:53 +02:00
}
} ) ;
2023-05-03 09:59:49 +02:00
} )
observer . observe ( element _object ) ;
2022-04-27 15:57:53 +02:00
} ) ;
}
// Load only if the tab is visible
2022-06-08 11:49:05 +02:00
onVisible ( "[id^=domain_table]" , ( ) => draw _domain _table ( ) ) ;
2022-11-10 17:22:18 +02:00
onVisible ( "[id^=templates_domain_table]" , ( ) => draw _templates _domain _table ( ) ) ;
2022-06-08 11:49:05 +02:00
onVisible ( "[id^=mailbox_table]" , ( ) => draw _mailbox _table ( ) ) ;
2022-11-10 17:22:18 +02:00
onVisible ( "[id^=templates_mbox_table]" , ( ) => draw _templates _mbox _table ( ) ) ;
2022-06-08 11:49:05 +02:00
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
} ) ;