2019-02-24 00:59:18 +08:00
$ ( document ) . ready ( function ( ) {
acl _data = JSON . parse ( acl ) ;
FooTable . domainFilter = FooTable . Filtering . extend ( {
construct : function ( instance ) {
this . _super ( instance ) ;
2021-07-25 00:51:19 +08:00
this . def = lang . all _domains ;
2019-02-24 00:59:18 +08:00
this . $domain = null ;
} ,
$create : function ( ) {
this . _super ( ) ;
2019-05-16 14:20:21 +08:00
var self = this ;
var domains = [ ] ;
2019-11-11 16:55:15 +08:00
2019-05-16 14:20:21 +08:00
$ . each ( self . ft . rows . all , function ( i , row ) {
2019-05-16 16:15:37 +08:00
if ( ( row . val ( ) . domain != null ) && ( $ . inArray ( row . val ( ) . domain , domains ) === - 1 ) ) domains . push ( row . val ( ) . domain ) ;
2019-05-16 14:20:21 +08:00
} ) ;
2019-11-11 16:55:15 +08:00
2019-02-24 00:59:18 +08:00
$form _grp = $ ( '<div/>' , { 'class' : 'form-group' } )
. append ( $ ( '<label/>' , { 'class' : 'sr-only' , text : 'Domain' } ) )
. prependTo ( self . $form ) ;
self . $domain = $ ( '<select/>' , { 'class' : 'aform-control' } )
. on ( 'change' , { self : self } , self . _onDomainDropdownChanged )
. append ( $ ( '<option/>' , { text : self . def } ) )
. appendTo ( $form _grp ) ;
2019-05-16 14:20:21 +08:00
$ . each ( domains , function ( i , domain ) {
2021-06-30 16:13:29 +08:00
domainname = $ ( $ . parseHTML ( domain ) ) . data ( 'domainname' )
if ( domainname !== undefined ) {
self . $domain . append ( $ ( '<option/>' ) . text ( domainname ) ) ;
} else {
self . $domain . append ( $ ( '<option/>' ) . text ( domain ) ) ;
}
2019-02-24 00:59:18 +08:00
} ) ;
} ,
_onDomainDropdownChanged : function ( e ) {
var self = e . data . self ,
selected = $ ( this ) . val ( ) ;
if ( selected !== self . def ) {
self . addFilter ( 'domain' , selected , [ 'domain' ] ) ;
} else {
self . removeFilter ( 'domain' ) ;
}
self . filter ( ) ;
} ,
draw : function ( ) {
this . _super ( ) ;
var domain = this . find ( 'domain' ) ;
if ( domain instanceof FooTable . Filter ) {
this . $domain . val ( domain . query . val ( ) ) ;
} else {
this . $domain . val ( this . def ) ;
}
$ ( this . $domain ) . closest ( "select" ) . selectpicker ( ) ;
}
} ) ;
2020-02-23 02:23:57 +08:00
// Set paging
2020-02-17 03:08:36 +08:00
$ ( '[data-page-size]' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
2020-02-22 17:12:39 +08:00
var new _size = $ ( this ) . data ( 'page-size' ) ;
var parent _ul = $ ( this ) . closest ( 'ul' ) ;
var table _id = $ ( parent _ul ) . data ( 'table-id' ) ;
FooTable . get ( '#' + table _id ) . pageSize ( new _size ) ;
//$(this).parent().addClass('active').siblings().removeClass('active')
heading = $ ( this ) . parents ( '.panel' ) . find ( '.panel-heading' )
var n _results = $ ( heading ) . children ( '.table-lines' ) . text ( ) . split ( ' / ' ) [ 1 ] ;
$ ( heading ) . children ( '.table-lines' ) . text ( function ( ) {
if ( new _size > n _results ) {
new _size = n _results ;
}
return new _size + ' / ' + n _results ;
} )
2020-02-17 03:08:36 +08:00
} ) ;
2020-01-11 03:49:54 +08:00
// Clone mailbox mass actions
$ ( "div" ) . find ( "[data-actions-header='true'" ) . each ( function ( ) {
$ ( this ) . html ( $ ( this ) . nextAll ( '.mass-actions-mailbox:first' ) . html ( ) ) ;
} ) ;
2019-02-24 00:59:18 +08:00
// Auto-fill domain quota when adding new domain
auto _fill _quota = function ( domain ) {
2020-04-03 14:44:10 +08:00
$ . get ( "/api/v1/get/domain/" + domain , function ( data ) {
2019-02-24 00:59:18 +08:00
var result = $ . parseJSON ( JSON . stringify ( data ) ) ;
2019-07-28 00:56:51 +08:00
def _new _mailbox _quota = ( result . def _new _mailbox _quota / 1048576 ) ;
2019-02-24 00:59:18 +08:00
max _new _mailbox _quota = ( result . max _new _mailbox _quota / 1048576 ) ;
2020-04-03 14:44:10 +08: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-24 00:59:18 +08:00
}
2021-08-09 14:28:22 +08:00
$ ( '#addSelectDomain' ) . on ( 'change' , function ( ) {
2019-02-24 00:59:18 +08:00
auto _fill _quota ( $ ( '#addSelectDomain' ) . val ( ) ) ;
2021-08-09 14:28:22 +08:00
} ) ;
2019-02-24 00:59:18 +08:00
auto _fill _quota ( $ ( '#addSelectDomain' ) . val ( ) ) ;
2021-08-20 02:27:59 +08:00
// Read bcc local dests
// Using ajax to not be a blocking moo
$ . get ( "/api/v1/get/bcc-destination-options" , function ( data ) {
// Domains
var optgroup = "<optgroup label='" + lang . domains + "'>" ;
$ . each ( data . domains , function ( index , domain ) {
optgroup += "<option value='" + domain + "'>" + domain + "</option>"
} ) ;
optgroup += "</optgroup>"
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
// Alias domains
var optgroup = "<optgroup label='" + lang . domain _aliases + "'>" ;
$ . each ( data . alias _domains , function ( index , alias _domain ) {
optgroup += "<option value='" + alias _domain + "'>" + alias _domain + "</option>"
} ) ;
optgroup += "</optgroup>"
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
// Mailboxes and aliases
$ . each ( data . mailboxes , function ( mailbox , aliases ) {
var optgroup = "<optgroup label='" + mailbox + "'>" ;
$ . each ( aliases , function ( index , alias ) {
optgroup += "<option value='" + alias + "'>" + alias + "</option>"
} ) ;
optgroup += "</optgroup>"
$ ( '#bcc-local-dest' ) . append ( optgroup ) ;
} ) ;
// Finish
$ ( '#bcc-local-dest' ) . find ( 'option:selected' ) . remove ( ) ;
$ ( '#bcc-local-dest' ) . selectpicker ( 'refresh' ) ;
} ) ;
2019-02-24 00:59:18 +08: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' ) ;
2021-05-26 20:02:27 +08:00
$ ( '.dns-modal-body' ) . html ( '<center><i class="bi bi-arrow-repeat icon-spin"></i></center>' ) ;
2019-02-24 00:59:18 +08:00
$ . ajax ( {
url : '/inc/ajax/dns_diagnostics.php' ,
data : { domain : domain } ,
dataType : 'text' ,
success : function ( data ) {
$ ( '.dns-modal-body' ) . html ( data ) ;
} ,
error : function ( xhr , status , error ) {
$ ( '.dns-modal-body' ) . html ( xhr . responseText ) ;
}
} ) ;
} ) ;
// Sieve data modal
$ ( '#sieveDataModal' ) . on ( 'show.bs.modal' , function ( e ) {
var sieveScript = $ ( e . relatedTarget ) . data ( 'sieve-script' ) ;
$ ( e . currentTarget ) . find ( '#sieveDataText' ) . html ( '<pre style="font-size:14px;line-height:1.1">' + sieveScript + '</pre>' ) ;
} ) ;
// Disable submit button on script change
2021-08-09 14:28:22 +08:00
$ ( '.textarea-code' ) . on ( 'keyup' , function ( ) {
2020-03-19 19:23:48 +08:00
// Disable all "save" buttons, could be a "related button only" function, todo
$ ( '.add_sieve_script' ) . attr ( { "disabled" : true } ) ;
2021-08-09 14:28:22 +08:00
} ) ;
2019-02-24 00:59:18 +08:00
// Validate script data
2020-03-19 19:23:48 +08:00
$ ( ".validate_sieve" ) . click ( function ( event ) {
2019-02-24 00:59:18 +08:00
event . preventDefault ( ) ;
2020-03-19 19:23:48 +08: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-24 00:59:18 +08:00
$ . ajax ( {
2019-10-29 15:39:57 +08:00
dataType : 'json' ,
2019-02-24 00:59:18 +08: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 19:23:48 +08:00
$ ( validation _button ) . next ( ) . attr ( { "disabled" : false } ) ;
2019-02-24 00:59:18 +08: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-24 04:17:02 +08: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-24 00:59:18 +08:00
} ) ;
jQuery ( function ( $ ) {
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
var entityMap = { "&" : "&" , "<" : "<" , ">" : ">" , '"' : """ , "'" : "'" , "/" : "/" , "`" : "`" , "=" : "=" } ;
function escapeHtml ( n ) { return String ( n ) . replace ( /[&<>"'`=\/]/g , function ( n ) { return entityMap [ n ] } ) }
// 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 ] }
2021-05-23 19:18:52 +08:00
function unix _time _format ( i ) { return "" == i ? '<i class="bi bi-x-lg"></i>' : new Date ( i ? 1e3 * i : 0 ) . toLocaleDateString ( void 0 , { year : "numeric" , month : "2-digit" , day : "2-digit" , hour : "2-digit" , minute : "2-digit" , second : "2-digit" } ) }
2019-02-24 00:59:18 +08:00
$ ( ".refresh_table" ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
var table _name = $ ( this ) . data ( 'table' ) ;
$ ( '#' + table _name ) . find ( "tr.footable-empty" ) . remove ( ) ;
draw _table = $ ( this ) . data ( 'draw' ) ;
eval ( draw _table + '()' ) ;
} ) ;
function table _mailbox _ready ( ft , name ) {
if ( is _dual ) {
$ ( '.login_as' ) . data ( "toggle" , "tooltip" )
. attr ( "disabled" , true )
. removeAttr ( "href" )
. attr ( "title" , "Dual login cannot be used twice" )
. tooltip ( ) ;
2019-05-06 02:59:59 +08:00
}
$ ( '.refresh_table' ) . prop ( "disabled" , false ) ;
2019-10-11 14:51:40 +08:00
heading = ft . $el . parents ( '.panel' ) . find ( '.panel-heading' )
2019-02-24 00:59:18 +08:00
var ft _paging = ft . use ( FooTable . Paging )
$ ( heading ) . children ( '.table-lines' ) . text ( function ( ) {
2020-02-22 17:12:39 +08:00
var total _rows = ft _paging . totalRows ;
var size = ft _paging . size ;
if ( size > total _rows ) {
size = total _rows ;
}
return size + ' / ' + total _rows ;
2019-02-24 00:59:18 +08:00
} )
}
function draw _domain _table ( ) {
ft _domain _table = FooTable . init ( '#domain_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2019-02-24 00:59:18 +08:00
{ "sorted" : true , "name" : "domain_name" , "title" : lang . domain , "style" : { "width" : "250px" } } ,
{ "name" : "aliases" , "title" : lang . aliases , "breakpoints" : "xs sm" } ,
{ "name" : "mailboxes" , "title" : lang . mailboxes } ,
{ "name" : "quota" , "style" : { "whiteSpace" : "nowrap" } , "title" : lang . domain _quota , "formatter" : function ( value ) {
res = value . split ( "/" ) ;
return humanFileSize ( res [ 0 ] ) + " / " + humanFileSize ( res [ 1 ] ) ;
} ,
"sortValue" : function ( value ) {
res = value . split ( "/" ) ;
return Number ( res [ 0 ] ) ;
2020-04-14 02:34:39 +08:00
} } ,
{ "name" : "stats" , "sortable" : false , "style" : { "whiteSpace" : "nowrap" } , "title" : lang . stats , "formatter" : function ( value ) {
2020-04-06 14:52:27 +08:00
res = value . split ( "/" ) ;
2021-05-22 18:13:37 +08:00
return '<i class="bi bi-files"></i> ' + res [ 0 ] + ' / ' + humanFileSize ( res [ 1 ] ) ;
2020-04-14 02:34:39 +08:00
} } ,
2019-07-28 00:56:51 +08:00
{ "name" : "def_quota_for_mbox" , "title" : lang . mailbox _defquota , "breakpoints" : "xs sm md" , "style" : { "width" : "125px" } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "max_quota_for_mbox" , "title" : lang . mailbox _quota , "breakpoints" : "xs sm" , "style" : { "width" : "125px" } } ,
2021-08-09 14:28:22 +08:00
{ "name" : "rl" , "title" : "RL" , "breakpoints" : "xs sm md lg" , "style" : { "min-width" : "100px" , "width" : "100px" } } ,
{ "name" : "backupmx" , "filterable" : false , "style" : { "min-width" : "120px" , "width" : "120px" } , "title" : lang . backup _mx , "breakpoints" : "xs sm md lg" , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
2019-11-11 16:55:15 +08:00
{ "name" : "domain_admins" , "title" : lang . domain _admins , "style" : { "word-break" : "break-all" , "min-width" : "200px" } , "breakpoints" : "xs sm md lg" , "filterable" : ( role == "admin" ) , "visible" : ( role == "admin" ) } ,
2021-08-09 14:28:22 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "240px" , "width" : "240px" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm md" }
2019-02-24 00:59:18 +08:00
] ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/domain/all' ,
jsonp : false ,
error : function ( data ) {
console . log ( 'Cannot draw domain table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
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 14:52:27 +08:00
item . quota = item . quota _used _in _domain + "/" + item . max _quota _for _domain + "/" + item . bytes _total ;
item . stats = item . msgs _total + "/" + item . bytes _total ;
2019-02-24 00:59:18 +08:00
if ( ! item . rl ) {
item . rl = '∞' ;
} else {
item . rl = $ . map ( item . rl , function ( e ) {
return e ;
} ) . join ( '/1' ) ;
}
2019-07-28 00:56:51 +08:00
item . def _quota _for _mbox = humanFileSize ( item . def _quota _for _mbox ) ;
2019-02-24 00:59:18 +08: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 ) + '" />' ;
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' ;
2019-02-24 00:59:18 +08:00
if ( role == "admin" ) {
2021-07-09 14:21:09 +08:00
item . action += '<a href="/edit/domain/' + encodeURIComponent ( item . domain _name ) + '" class="btn btn-xs btn-xs-third btn-default"><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-xs btn-xs-third btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'<a href="#dnsInfoModal" class="btn btn-xs btn-xs-third btn-info" data-toggle="modal" data-domain="' + encodeURIComponent ( item . domain _name ) + '"><i class="bi bi-globe2"></i> DNS</a></div>' ;
2019-02-24 00:59:18 +08:00
}
else {
2021-07-09 14:21:09 +08:00
item . action += '<a href="/edit/domain/' + encodeURIComponent ( item . domain _name ) + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#dnsInfoModal" class="btn btn-xs btn-xs-half btn-info" data-toggle="modal" data-domain="' + encodeURIComponent ( item . domain _name ) + '"><i class="bi bi-globe2"></i> DNS</a></div>' ;
2019-02-24 00:59:18 +08:00
}
2021-08-09 14:28:22 +08:00
2020-09-18 01:49:15 +08:00
if ( item . backupmx == 1 ) {
if ( item . relay _unknown _only == 1 ) {
2020-04-05 17:35:35 +08:00
item . domain _name = '<div class="label label-info">Relay Non-Local</div> ' + item . domain _name ;
2020-09-18 01:49:15 +08:00
} else if ( item . relay _all _recipients == 1 ) {
2020-04-05 17:35:35 +08:00
item . domain _name = '<div class="label label-info">Relay All</div> ' + item . domain _name ;
} else {
item . domain _name = '<div class="label label-info">Relay</div> ' + item . domain _name ;
}
2020-02-18 18:30:20 +08:00
}
2019-02-24 00:59:18 +08:00
} ) ;
}
} ) ,
"empty" : lang . empty ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'domain_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'domain_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 01:07:01 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _mailbox _table ( ) {
ft _mailbox _table = FooTable . init ( '#mailbox_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2019-02-24 00:59:18 +08:00
{ "sorted" : true , "name" : "username" , "style" : { "word-break" : "break-all" , "min-width" : "120px" } , "title" : lang . username } ,
2019-05-06 02:49:13 +08:00
{ "name" : "name" , "title" : lang . fname , "style" : { "word-break" : "break-all" , "min-width" : "120px" } , "breakpoints" : "xs sm md lg" } ,
{ "name" : "domain" , "title" : lang . domain , "breakpoints" : "xs sm md lg" } ,
2019-02-24 00:59:18 +08:00
{ "name" : "quota" , "style" : { "whiteSpace" : "nowrap" } , "title" : lang . domain _quota , "formatter" : function ( value ) {
res = value . split ( "/" ) ;
2019-03-31 21:49:18 +08:00
var of _q = ( res [ 1 ] == 0 ? "∞" : humanFileSize ( res [ 1 ] ) ) ;
return humanFileSize ( res [ 0 ] ) + " / " + of _q ;
2019-02-24 00:59:18 +08:00
} ,
"sortValue" : function ( value ) {
res = value . split ( "/" ) ;
return Number ( res [ 0 ] ) ;
} ,
} ,
2021-03-19 23:33:50 +08:00
/* {"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"all"}, */
2019-02-24 00:59:18 +08:00
{ "name" : "tls_enforce_in" , "filterable" : false , "title" : lang . tls _enforce _in , "breakpoints" : "all" } ,
{ "name" : "tls_enforce_out" , "filterable" : false , "title" : lang . tls _enforce _out , "breakpoints" : "all" } ,
2020-09-18 21:53:01 +08:00
{ "name" : "smtp_access" , "filterable" : false , "title" : "SMTP" , "breakpoints" : "all" } ,
{ "name" : "imap_access" , "filterable" : false , "title" : "IMAP" , "breakpoints" : "all" } ,
{ "name" : "pop3_access" , "filterable" : false , "title" : "POP3" , "breakpoints" : "all" } ,
2020-04-14 02:34:39 +08:00
{ "name" : "last_mail_login" , "breakpoints" : "xs sm" , "title" : lang . last _mail _login , "style" : { "width" : "170px" } ,
"sortValue" : function ( value ) {
res = value . split ( "/" ) ;
return Math . max ( res [ 0 ] , res [ 1 ] ) ;
} ,
"formatter" : function ( value ) {
res = value . split ( "/" ) ;
2020-10-17 16:15:30 +08:00
return '<div class="label label-last-login">IMAP @ ' + unix _time _format ( Number ( res [ 0 ] ) ) + '</div><br>' +
2021-08-09 14:28:22 +08:00
'<div class="label label-last-login">POP3 @ ' + unix _time _format ( Number ( res [ 1 ] ) ) + '</div><br>' +
2020-10-17 16:15:30 +08:00
'<div class="label label-last-login">SMTP @ ' + unix _time _format ( Number ( res [ 2 ] ) ) + '</div>' ;
2020-04-14 02:34:39 +08:00
} } ,
2021-06-09 13:19:57 +08:00
{ "name" : "last_pw_change" , "filterable" : false , "title" : lang . last _pw _change , "breakpoints" : "all" } ,
2019-02-24 00:59:18 +08:00
{ "name" : "quarantine_notification" , "filterable" : false , "title" : lang . quarantine _notification , "breakpoints" : "all" } ,
2020-11-29 00:41:48 +08:00
{ "name" : "quarantine_category" , "filterable" : false , "title" : lang . quarantine _category , "breakpoints" : "all" } ,
2019-02-24 00:59:18 +08:00
{ "name" : "in_use" , "filterable" : false , "type" : "html" , "title" : lang . in _use , "sortValue" : function ( value ) {
2020-04-06 14:52:27 +08:00
return Number ( $ ( value ) . find ( ".progress-bar-mailbox" ) . attr ( 'aria-valuenow' ) ) ;
2019-02-24 00:59:18 +08:00
} ,
} ,
{ "name" : "messages" , "filterable" : false , "title" : lang . msg _num , "breakpoints" : "xs sm md" } ,
2021-03-19 23:33:50 +08:00
/* {"name":"rl","title":"RL","breakpoints":"all","style":{"width":"125px"}}, */
2021-08-09 14:28:22 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : ( 0 == value ? '<i class="bi bi-x-lg"></i>' : 2 == value && '—' ) ; } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "min-width" : "290px" , "text-align" : "right" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm md" }
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
2021-03-19 23:33:50 +08:00
url : '/api/v1/get/mailbox/reduced' ,
2019-02-24 00:59:18 +08:00
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw mailbox table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
item . quota = item . quota _used + "/" + item . quota ;
item . max _quota _for _mbox = humanFileSize ( item . max _quota _for _mbox ) ;
2020-09-15 17:02:53 +08:00
item . last _mail _login = item . last _imap _login + '/' + item . last _pop3 _login + '/' + item . last _smtp _login ;
2021-03-19 23:33:50 +08:00
/ *
2019-02-24 00:59:18 +08:00
if ( ! item . rl ) {
item . rl = '∞' ;
} else {
item . rl = $ . map ( item . rl , function ( e ) {
return e ;
} ) . join ( '/1' ) ;
2019-08-25 22:02:58 +08:00
if ( item . rl _scope === 'domain' ) {
2021-05-22 18:13:37 +08:00
item . rl = '<i class="bi bi-arrow-return-right"></i> ' + item . rl + ' (via ' + item . domain + ')' ;
2019-08-25 22:02:58 +08:00
}
2019-02-24 00:59:18 +08:00
}
2021-03-19 23:33:50 +08:00
* /
2019-02-24 00:59:18 +08:00
item . chkbox = '<input type="checkbox" data-id="mailbox" name="multi_select" value="' + encodeURIComponent ( item . username ) + '" />' ;
2021-06-09 13:19:57 +08: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 18:13:37 +08:00
item . tls _enforce _in = '<i class="text-' + ( item . attributes . tls _enforce _in == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill' ) + '"></i>' ;
item . tls _enforce _out = '<i class="text-' + ( item . attributes . tls _enforce _out == 1 ? 'success bi bi-lock-fill' : 'danger bi bi-unlock-fill' ) + '"></i>' ;
item . pop3 _access = '<i class="text-' + ( item . attributes . pop3 _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . pop3 _access == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
item . imap _access = '<i class="text-' + ( item . attributes . imap _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . imap _access == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
item . smtp _access = '<i class="text-' + ( item . attributes . smtp _access == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . attributes . smtp _access == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
2019-02-24 00:59:18 +08: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-29 00:41:48 +08: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-24 00:59:18 +08:00
if ( acl _data . login _as === 1 ) {
2021-08-09 14:28:22 +08:00
var btnSize = 'btn-xs-third' ;
if ( ALLOW _ADMIN _EMAIL _LOGIN ) btnSize = 'btn-xs-quart' ;
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/mailbox/' + encodeURIComponent ( item . username ) + '" class="btn btn-xs ' + btnSize + ' btn-default"><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-xs ' + btnSize + ' btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'<a href="/index.php?duallogin=' + encodeURIComponent ( item . username ) + '" class="login_as btn btn-xs ' + btnSize + ' btn-success"><i class="bi bi-person-fill"></i> Login</a>' ;
2019-02-24 00:59:18 +08:00
if ( ALLOW _ADMIN _EMAIL _LOGIN ) {
2021-07-09 14:21:09 +08:00
item . action += '<a href="/sogo-auth.php?login=' + encodeURIComponent ( item . username ) + '" class="login_as btn btn-xs ' + btnSize + ' btn-primary" target="_blank"><i class="bi bi-envelope-fill"></i> SOGo</a>' ;
2019-02-24 00:59:18 +08:00
}
item . action += '</div>' ;
}
else {
item . action = '<div class="btn-group">' +
2021-07-09 14:21:09 +08:00
'<a href="/edit/mailbox/' + encodeURIComponent ( item . username ) + '" class="btn btn-xs btn-xs-half btn-default"><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-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08:00
'</div>' ;
}
item . in _use = '<div class="progress">' +
2020-04-06 14:52:27 +08:00
'<div class="progress-bar-mailbox progress-bar progress-bar-' + item . percent _class + '" role="progressbar" aria-valuenow="' + item . percent _in _use + '" aria-valuemin="0" aria-valuemax="100" ' +
2019-02-24 00:59:18 +08:00
'style="min-width:2em;width:' + item . percent _in _use + '%">' + item . percent _in _use + '%' + '</div></div>' ;
item . username = escapeHtml ( item . username ) ;
} ) ;
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
//"container": "#tab-mailboxes.panel",
"placeholder" : lang . filter _table
} ,
"components" : {
"filtering" : FooTable . domainFilter
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'mailbox_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'mailbox_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 00:57:58 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _resource _table ( ) {
ft _resource _table = FooTable . init ( '#resource_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2019-02-24 00:59:18 +08:00
{ "sorted" : true , "name" : "description" , "title" : lang . description , "style" : { "width" : "250px" } } ,
2019-06-09 22:49:17 +08:00
{ "name" : "name" , "title" : lang . alias } ,
2019-02-24 00:59:18 +08:00
{ "name" : "kind" , "title" : lang . kind } ,
{ "name" : "domain" , "title" : lang . domain , "breakpoints" : "xs sm" } ,
2021-08-09 14:28:22 +08:00
{ "name" : "multiple_bookings" , "filterable" : false , "style" : { "min-width" : "150px" , "width" : "140px" } , "title" : lang . multiple _bookings , "breakpoints" : "xs sm" } ,
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "180px" , "width" : "180px" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/resource/all' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw resource table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
if ( item . multiple _bookings == '0' ) {
item . multiple _bookings = '<span id="active-script" class="label label-success">' + lang . booking _0 _short + '</span>' ;
} else if ( item . multiple _bookings == '-1' ) {
item . multiple _bookings = '<span id="active-script" class="label label-warning">' + lang . booking _lt0 _short + '</span>' ;
} else {
item . multiple _bookings = '<span id="active-script" class="label label-danger">' + lang . booking _custom _short + ' (' + item . multiple _bookings + ')</span>' ;
}
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/resource/' + encodeURIComponent ( item . name ) + '" class="btn btn-xs btn-xs-half btn-default"><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-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="resource" name="multi_select" value="' + encodeURIComponent ( item . name ) + '" />' ;
item . name = escapeHtml ( item . name ) ;
} ) ;
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"components" : {
"filtering" : FooTable . domainFilter
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'resource_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'resource_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 01:07:01 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _bcc _table ( ) {
ft _bcc _table = FooTable . init ( '#bcc_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2021-06-03 14:00:59 +08:00
{ "sorted" : true , "name" : "id" , "title" : "ID" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "type" , "title" : lang . bcc _type } ,
{ "name" : "local_dest" , "title" : lang . bcc _local _dest } ,
{ "name" : "bcc_dest" , "title" : lang . bcc _destinations } ,
{ "name" : "domain" , "title" : lang . domain , "breakpoints" : "xs sm" } ,
2021-06-03 14:00:59 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "180px" , "width" : "180px" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/bcc/all' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw bcc table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/bcc/' + item . id + '" class="btn btn-xs btn-xs-half btn-default"><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-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08: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' ) {
2021-07-25 00:51:19 +08:00
item . type = '<span id="active-script" class="label label-success">' + lang . bcc _sender _map + '</span>' ;
2019-02-24 00:59:18 +08:00
} else {
2021-07-25 00:51:19 +08:00
item . type = '<span id="inactive-script" class="label label-warning">' + lang . bcc _rcpt _map + '</span>' ;
2019-02-24 00:59:18 +08:00
}
} ) ;
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'bcc_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'bcc_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 01:07:01 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _recipient _map _table ( ) {
ft _recipient _map _table = FooTable . init ( '#recipient_map_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2021-08-09 14:28:22 +08:00
{ "sorted" : true , "name" : "id" , "title" : "ID" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "recipient_map_old" , "title" : lang . recipient _map _old } ,
{ "name" : "recipient_map_new" , "title" : lang . recipient _map _new } ,
2021-08-09 14:28:22 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "180px" , "width" : "180px" } , "type" : "html" , "title" : ( role == "admin" ? lang . action : "" ) , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/recipient_map/all' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw recipient map table' ) ;
} ,
success : function ( data ) {
if ( role == "admin" ) {
$ . each ( data , function ( i , item ) {
item . recipient _map _old = escapeHtml ( item . recipient _map _old ) ;
item . recipient _map _new = escapeHtml ( item . recipient _map _new ) ;
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/recipient_map/' + item . id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-recipient_map" data-api-url="delete/recipient_map" data-item="' + item . id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="recipient_map" name="multi_select" value="' + item . id + '" />' ;
} ) ;
}
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'recipient_map_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'recipient_map_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 01:07:01 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _tls _policy _table ( ) {
ft _tls _policy _table = FooTable . init ( '#tls_policy_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2021-08-09 14:28:22 +08:00
{ "sorted" : true , "name" : "id" , "title" : "ID" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "dest" , "title" : lang . tls _map _dest } ,
{ "name" : "policy" , "title" : lang . tls _map _policy } ,
{ "name" : "parameters" , "title" : lang . tls _map _parameters } ,
2021-08-09 14:28:22 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "180px" , "width" : "180px" } , "type" : "html" , "title" : ( role == "admin" ? lang . action : "" ) , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/tls-policy-map/all' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw tls policy map table' ) ;
} ,
success : function ( data ) {
if ( role == "admin" ) {
$ . each ( data , 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>' ;
}
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/tls_policy_map/' + item . id + '" class="btn btn-xs btn-xs-half btn-default"><i class="bi bi-pencil-fill"></i> ' + lang . edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-tls-policy-map" data-api-url="delete/tls-policy-map" data-item="' + item . id + '" class="btn btn-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="tls-policy-map" name="multi_select" value="' + item . id + '" />' ;
} ) ;
}
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'tls_policy_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'tls_policy_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 01:07:01 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _alias _table ( ) {
ft _alias _table = FooTable . init ( '#alias_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2021-08-09 14:28:22 +08:00
{ "name" : "id" , "title" : "ID" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } } ,
2019-02-24 00:59:18 +08:00
{ "sorted" : true , "name" : "address" , "title" : lang . alias , "style" : { "width" : "250px" } } ,
{ "name" : "goto" , "title" : lang . target _address } ,
{ "name" : "domain" , "title" : lang . domain , "breakpoints" : "xs sm" } ,
{ "name" : "public_comment" , "title" : lang . public _comment , "breakpoints" : "all" } ,
{ "name" : "private_comment" , "title" : lang . private _comment , "breakpoints" : "all" } ,
2021-05-23 19:18:52 +08:00
{ "name" : "sogo_visible" , "title" : lang . sogo _visible , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } , "breakpoints" : "all" } ,
2021-08-09 14:28:22 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "180px" , "width" : "180px" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/alias/all' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw alias table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/alias/' + encodeURIComponent ( item . id ) + '" class="btn btn-xs btn-xs-half btn-default"><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-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08: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 09:03:59 +08: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-24 00:59:18 +08:00
if ( item . is _catch _all == 1 ) {
2021-07-25 00:51:19 +08:00
item . address = '<div class="label label-default">' + lang . catch _all + '</div> ' + escapeHtml ( item . address ) ;
2019-02-24 00:59:18 +08:00
}
else {
item . address = escapeHtml ( item . address ) ;
}
if ( item . goto == "null@localhost" ) {
2021-05-26 20:02:27 +08:00
item . goto = '⤷ <i class="bi bi-trash" style="font-size:12px"></i>' ;
2019-02-24 00:59:18 +08:00
}
else if ( item . goto == "spam@localhost" ) {
2021-07-25 00:51:19 +08:00
item . goto = '<span class="label label-danger">' + lang . goto _spam + '</span>' ;
2019-02-24 00:59:18 +08:00
}
else if ( item . goto == "ham@localhost" ) {
2021-07-25 00:51:19 +08:00
item . goto = '<span class="label label-success">' + lang . goto _ham + '</span>' ;
2019-02-24 00:59:18 +08:00
}
if ( item . in _primary _domain !== "" ) {
2021-06-30 16:13:29 +08:00
item . domain = '<i data-domainname="' + item . domain + '" class="bi bi-info-circle-fill alias-domain-info text-info" data-toggle="tooltip" title="' + lang . target _domain + ': ' + item . in _primary _domain + '"></i> ' + item . domain ;
2019-02-24 00:59:18 +08:00
}
} ) ;
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"components" : {
"filtering" : FooTable . domainFilter
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'alias_table' ) ;
2021-05-30 22:07:57 +08:00
$ ( '.alias-domain-info' ) . tooltip ( ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'alias_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 00:57:58 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _aliasdomain _table ( ) {
ft _aliasdomain _table = FooTable . init ( '#aliasdomain_table' , {
"columns" : [
2021-05-24 05:09:37 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
2019-02-24 00:59:18 +08:00
{ "sorted" : true , "name" : "alias_domain" , "title" : lang . alias , "style" : { "width" : "250px" } } ,
2019-09-02 17:11:41 +08:00
{ "name" : "target_domain" , "title" : lang . target _domain , "type" : "html" } ,
2021-08-09 14:28:22 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "250px" , "width" : "250px" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/alias-domain/all' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw alias domain table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/aliasdomain/' + encodeURIComponent ( item . alias _domain ) + '" class="btn btn-xs btn-xs-third btn-default"><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-xs btn-xs-third btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
'<a href="#dnsInfoModal" class="btn btn-xs btn-xs-third btn-info" data-toggle="modal" data-domain="' + encodeURIComponent ( item . alias _domain ) + '"><i class="bi bi-globe2"></i> DNS</a></div>' +
2019-02-24 00:59:18 +08:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="alias-domain" name="multi_select" value="' + encodeURIComponent ( item . alias _domain ) + '" />' ;
2019-09-02 17:11:41 +08:00
if ( item . parent _is _backupmx == '1' ) {
item . target _domain = '<span><a href="/edit/domain/' + item . target _domain + '">' + item . target _domain + '</a> <div class="label label-warning">' + lang . alias _domain _backupmx + '</div></span>' ;
} else {
item . target _domain = '<span><a href="/edit/domain/' + item . target _domain + '">' + item . target _domain + '</a></span>' ;
}
2019-02-24 00:59:18 +08:00
} ) ;
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'aliasdomain_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'aliasdomain_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 01:07:01 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _sync _job _table ( ) {
ft _syncjob _table = FooTable . init ( '#sync_job_table' , {
"columns" : [
2021-08-09 14:28:22 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
{ "sorted" : true , "name" : "id" , "title" : "ID" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "user2" , "title" : lang . owner } ,
2019-05-09 17:30:14 +08:00
{ "name" : "server_w_port" , "title" : "Server" , "breakpoints" : "xs sm md" , "style" : { "word-break" : "break-all" } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "exclude" , "title" : lang . excludes , "breakpoints" : "all" } ,
{ "name" : "mins_interval" , "title" : lang . mins _interval , "breakpoints" : "all" } ,
2019-05-09 17:30:14 +08:00
{ "name" : "last_run" , "title" : lang . last _run , "breakpoints" : "xs sm md" } ,
2021-09-01 22:29:11 +08:00
{ "name" : "exit_status" , "filterable" : false , "title" : lang . syncjob _last _run _result } ,
2019-02-24 00:59:18 +08:00
{ "name" : "log" , "title" : "Log" } ,
2021-08-09 14:28:22 +08:00
{ "name" : "active" , "filterable" : false , "style" : { "min-width" : "70px" , "width" : "70px" } , "title" : lang . active , "formatter" : function ( value ) { return 1 == value ? '<i class="bi bi-check-lg"></i>' : 0 == value && '<i class="bi bi-x-lg"></i>' ; } } ,
{ "name" : "is_running" , "filterable" : false , "style" : { "min-width" : "120px" , "width" : "100px" } , "title" : lang . status } ,
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "180px" , "width" : "180px" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/syncjobs/all/no_log' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw sync job table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
2021-07-07 12:39:29 +08:00
item . log = '<a href="#syncjobLogModal" data-toggle="modal" data-syncjob-id="' + encodeURIComponent ( item . id ) + '">' + lang . open _logs + '</a>'
2019-02-24 00:59:18 +08:00
item . user2 = escapeHtml ( item . user2 ) ;
if ( ! item . exclude > 0 ) {
item . exclude = '-' ;
} else {
item . exclude = '<code>' + item . exclude + '</code>' ;
}
item . server _w _port = escapeHtml ( item . user1 ) + '@' + item . host1 + ':' + item . port1 ;
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/syncjob/' + item . id + '" class="btn btn-xs btn-xs-half btn-default"><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-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="syncjob" name="multi_select" value="' + item . id + '" />' ;
if ( item . is _running == 1 ) {
item . is _running = '<span id="active-script" class="label label-success">' + lang . running + '</span>' ;
} else {
item . is _running = '<span id="inactive-script" class="label label-warning">' + lang . waiting + '</span>' ;
}
if ( ! item . last _run > 0 ) {
item . last _run = lang . waiting ;
}
2021-09-01 22:29:11 +08:00
if ( item . success == null ) {
item . success = '-' ;
item . exit _status = '' ;
} else {
item . success = '<i class="text-' + ( item . success == 1 ? 'success' : 'danger' ) + ' bi bi-' + ( item . success == 1 ? 'check-lg' : 'x-lg' ) + '"></i>' ;
}
if ( lang [ 'syncjob_' + item . exit _status ] ) {
item . exit _status = lang [ 'syncjob_' + item . exit _status ] ;
} else if ( item . success != '-' ) {
item . exit _status = lang . syncjob _check _log ;
}
item . exit _status = item . success + ' ' + item . exit _status ;
2019-02-24 00:59:18 +08:00
} ) ;
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'sync_job_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'sync_job_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 00:57:58 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
}
function draw _filter _table ( ) {
ft _filter _table = FooTable . init ( '#filter_table' , {
"columns" : [
2021-08-09 14:28:22 +08:00
{ "name" : "chkbox" , "title" : "" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } , "filterable" : false , "sortable" : false , "type" : "html" } ,
{ "name" : "id" , "title" : "ID" , "style" : { "min-width" : "60px" , "width" : "60px" , "text-align" : "center" } } ,
{ "name" : "active" , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : lang . active } ,
{ "name" : "filter_type" , "style" : { "min-width" : "80px" , "width" : "80px" } , "title" : "Type" } ,
{ "sorted" : true , "name" : "username" , "title" : lang . owner , "style" : { "min-width" : "550px" , "width" : "350px" } } ,
2019-02-24 00:59:18 +08:00
{ "name" : "script_desc" , "title" : lang . description , "breakpoints" : "xs" } ,
{ "name" : "script_data" , "title" : "Script" , "breakpoints" : "all" } ,
2021-08-09 14:28:22 +08:00
{ "name" : "action" , "filterable" : false , "sortable" : false , "style" : { "text-align" : "right" , "min-width" : "180px" , "width" : "180px" } , "type" : "html" , "title" : lang . action , "breakpoints" : "xs sm" }
2019-02-24 00:59:18 +08:00
] ,
"empty" : lang . empty ,
"rows" : $ . ajax ( {
dataType : 'json' ,
url : '/api/v1/get/filters/all' ,
jsonp : false ,
error : function ( ) {
console . log ( 'Cannot draw filter table' ) ;
} ,
success : function ( data ) {
$ . each ( data , function ( i , item ) {
2020-09-18 01:49:15 +08:00
if ( item . active == 1 ) {
2019-02-24 00:59:18 +08:00
item . active = '<span id="active-script" class="label label-success">' + lang . active + '</span>' ;
} else {
item . active = '<span id="inactive-script" class="label label-warning">' + lang . inactive + '</span>' ;
}
item . script _data = '<pre style="margin:0px">' + escapeHtml ( item . script _data ) + '</pre>'
item . filter _type = '<div class="label label-default">' + item . filter _type . charAt ( 0 ) . toUpperCase ( ) + item . filter _type . slice ( 1 ) . toLowerCase ( ) + '</div>'
2021-07-09 14:21:09 +08:00
item . action = '<div class="btn-group footable-actions">' +
'<a href="/edit/filter/' + item . id + '" class="btn btn-xs btn-xs-half btn-default"><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-xs btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang . remove + '</a>' +
2019-02-24 00:59:18 +08:00
'</div>' ;
item . chkbox = '<input type="checkbox" data-id="filter_item" name="multi_select" value="' + item . id + '" />'
} ) ;
}
} ) ,
"paging" : {
"enabled" : true ,
"limit" : 5 ,
"size" : pagination _size
} ,
"state" : {
"enabled" : true
} ,
"filtering" : {
"enabled" : true ,
2019-09-02 17:11:41 +08:00
"delay" : 1200 ,
2019-02-24 00:59:18 +08:00
"position" : "left" ,
"connectors" : false ,
"placeholder" : lang . filter _table
} ,
"sorting" : {
"enabled" : true
} ,
"on" : {
2019-05-06 02:59:59 +08:00
"destroy.ft.table" : function ( e , ft ) {
$ ( '.refresh_table' ) . attr ( 'disabled' , 'true' ) ;
} ,
2019-02-24 00:59:18 +08:00
"ready.ft.table" : function ( e , ft ) {
table _mailbox _ready ( ft , 'filter_table' ) ;
2019-05-06 02:44:29 +08:00
} ,
"after.ft.filtering" : function ( e , ft ) {
table _mailbox _ready ( ft , 'filter_table' ) ;
2019-02-24 00:59:18 +08:00
}
2019-07-28 00:57:58 +08:00
} ,
"toggleSelector" : "table tbody span.footable-toggle"
2019-02-24 00:59:18 +08:00
} ) ;
} ;
2019-07-28 00:56:51 +08:00
$ ( 'body' ) . on ( 'click' , 'span.footable-toggle' , function ( ) {
event . stopPropagation ( ) ;
} )
2019-02-24 00:59:18 +08:00
draw _domain _table ( ) ;
draw _mailbox _table ( ) ;
draw _resource _table ( ) ;
draw _alias _table ( ) ;
draw _aliasdomain _table ( ) ;
draw _sync _job _table ( ) ;
draw _filter _table ( ) ;
draw _bcc _table ( ) ;
draw _recipient _map _table ( ) ;
draw _tls _policy _table ( ) ;
2019-10-04 14:44:31 +08:00
} ) ;