diff --git a/data/web/js/build/014-mailcow.js b/data/web/js/build/014-mailcow.js index 3ca0b6af..cdde60e7 100644 --- a/data/web/js/build/014-mailcow.js +++ b/data/web/js/build/014-mailcow.js @@ -252,4 +252,9 @@ $(document).ready(function() { }) }); }) + + // Jquery Datatables, enable responsive plugin + $.extend($.fn.dataTable.defaults, { + responsive: true + }); }); diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js index d7f85021..f98a004a 100644 --- a/data/web/js/site/admin.js +++ b/data/web/js/site/admin.js @@ -71,33 +71,90 @@ jQuery(function($){ }) } function draw_domain_admins() { - ft_domainadmins = FooTable.init('#domainadminstable', { - "columns": [ - {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, - {"sorted": true,"name":"username","title":lang.username,"style":{"width":"250px"}}, - {"name":"selected_domains","title":lang.admin_domains,"breakpoints":"xs sm"}, - {"name":"tfa_active","title":"TFA", "filterable": false,"style":{"maxWidth":"80px","width":"80px"},"formatter": function(value){return 1==value?'':0==value&&'';}}, - {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active,"formatter": function(value){return 1==value?'':0==value&&'';}}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"250px","width":"250px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "rows": $.ajax({ - dataType: 'json', - url: '/api/v1/get/domain-admin/all', - jsonp: false, - error: function () { - console.log('Cannot draw domain admin table'); - }, - success: function (data) { - return process_table_data(data, 'domainadminstable'); + $('#domainadminstable').DataTable({ + processing: true, + serverSide: false, + language: lang_datatables, + ajax: { + type: "GET", + url: "/api/v1/get/domain-admin/all", + dataSrc: function(json){ + console.log(json); + return json; } - }), - "empty": lang.empty, - "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, - "state": {"enabled": true}, - "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, - "sorting": {"enabled": true}, - "toggleSelector": "table tbody span.footable-toggle" + }, + columns: [ + { + title: lang.username, + data: 'username', + }, + { + title: "TFA", + data: 'tfa_active', + render: function (data, type) { + if(data == 1) return ''; + else return '' + } + }, + { + title: lang.admin_domains, + data: 'tfa_active', + render: function (data, type) { + return data; + } + }, + { + title: lang.active, + data: 'active', + render: function (data, type) { + if(data == 1) return ''; + else return '' + } + }, + { + title: lang.action, + data: null, + render: function (data, type) { + return `
+ + Bearbeiten + + + Entfernen + +
`; + } + }, + ] }); + + // ft_domainadmins = FooTable.init('#domainadminstable', { + // "columns": [ + // {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, + // {"sorted": true,"name":"username","title":lang.username,"style":{"width":"250px"}}, + // {"name":"selected_domains","title":lang.admin_domains,"breakpoints":"xs sm"}, + // {"name":"tfa_active","title":"TFA", "filterable": false,"style":{"maxWidth":"80px","width":"80px"},"formatter": function(value){return 1==value?'':0==value&&'';}}, + // {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active,"formatter": function(value){return 1==value?'':0==value&&'';}}, + // {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"250px","width":"250px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} + // ], + // "rows": $.ajax({ + // dataType: 'json', + // url: '/api/v1/get/domain-admin/all', + // jsonp: false, + // error: function () { + // console.log('Cannot draw domain admin table'); + // }, + // success: function (data) { + // return process_table_data(data, 'domainadminstable'); + // } + // }), + // "empty": lang.empty, + // "paging": {"enabled": true,"limit": 5,"size": log_pagination_size}, + // "state": {"enabled": true}, + // "filtering": {"enabled": true,"delay": 1200,"position": "left","connectors": false,"placeholder": lang.filter_table}, + // "sorting": {"enabled": true}, + // "toggleSelector": "table tbody span.footable-toggle" + // }); } function draw_oauth2_clients() { ft_oauth2clientstable = FooTable.init('#oauth2clientstable', { @@ -127,10 +184,6 @@ jQuery(function($){ }); } function draw_admins() { - $.extend( $.fn.dataTable.defaults, { - responsive: true - }); - $('#adminstable').DataTable({ processing: true, serverSide: false, @@ -179,6 +232,7 @@ jQuery(function($){ }, ] }); + // ft_admins = FooTable.init('#adminstable', { // "columns": [ // {"name":"chkbox","title":"","style":{"maxWidth":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, @@ -414,7 +468,7 @@ jQuery(function($){ return data }; // // Initial table drawings - // draw_domain_admins(); + draw_domain_admins(); draw_admins(); // draw_fwd_hosts(); // draw_relayhosts(); diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index e12a5a21..7b0841aa 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -1,58 +1,58 @@ $(document).ready(function() { acl_data = JSON.parse(acl); - FooTable.domainFilter = FooTable.Filtering.extend({ - construct: function(instance){ - this._super(instance); - this.def = lang.all_domains; - this.$domain = null; - }, - $create: function(){ - this._super(); - var self = this; - var domains = []; + // FooTable.domainFilter = FooTable.Filtering.extend({ + // construct: function(instance){ + // this._super(instance); + // this.def = lang.all_domains; + // this.$domain = null; + // }, + // $create: function(){ + // this._super(); + // var self = this; + // var domains = []; - $.each(self.ft.rows.all, function(i, row){ - if((row.val().domain != null) && ($.inArray(row.val().domain, domains) === -1)) domains.push(row.val().domain); - }); + // $.each(self.ft.rows.all, function(i, row){ + // if((row.val().domain != null) && ($.inArray(row.val().domain, domains) === -1)) domains.push(row.val().domain); + // }); - $form_grp = $('
', {'class': 'form-group'}) - .append($('
'; + ' DNS'; } else { item.action += ' ' + lang.edit + '' + @@ -340,97 +312,90 @@ jQuery(function($){ } } }); - } - }), - "empty": lang.empty, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "state": { - "enabled": true - }, - "filtering": { - "enabled": true, - "delay": 1200, - "position": "left", - "connectors": false, - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true - }, - "on": { - "destroy.ft.table": function(e, ft){ - $('.refresh_table').attr('disabled', 'true'); - }, - "ready.ft.table": function(e, ft){ - table_mailbox_ready(ft, 'domain_table'); - }, - "after.ft.filtering": function(e, ft){ - table_mailbox_ready(ft, 'domain_table'); + + console.log(json); + return json; } }, - "toggleSelector": "table tbody span.footable-toggle" + columns: [ + { + title: lang.domain, + data: 'domain_name' + }, + { + title: lang.aliases, + data: 'aliases_in_domain' + }, + { + title: lang.mailboxes, + data: 'mboxes_in_domain' + }, + { + title: lang.domain_quota, + data: 'quota', + render: function (data, type) { + data = data.split("/"); + return humanFileSize(data[0]) + " / " + humanFileSize(data[1]); + } + }, + { + title: lang.stats, + data: 'stats', + render: function (data, type) { + data = data.split("/"); + return ' ' + data[0] + ' / ' + humanFileSize(data[1]); + } + }, + { + title: lang.mailbox_defquota, + data: 'def_quota_for_mbox' + }, + { + title: lang.mailbox_quota, + data: 'max_quota_for_mbox' + }, + { + title: 'RL', + data: 'rl' + }, + { + title: lang.backup_mx, + data: 'backupmx', + redner: function (data, type){ + return 1==value ? '' : 0==value && ''; + } + }, + { + title: lang.domain_admins, + data: 'domain_admins' + }, + { + title: lang.action, + data: null, + render: function (data, type) { + return `
+ + Bearbeiten + + + Entfernen + +
`; + } + }, + ] }); } function draw_mailbox_table() { - ft_mailbox_table = FooTable.init('#mailbox_table', { - "columns": [ - {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, - {"sorted": true,"name":"username","style":{"word-break":"break-all","min-width":"120px"},"title":lang.username}, - {"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"}, - {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota,"formatter": function(value){ - res = value.split("/"); - var of_q = (res[1] == 0 ? "∞" : humanFileSize(res[1])); - return humanFileSize(res[0]) + " / " + of_q; - }, - "sortValue": function(value){ - res = value.split("/"); - return Number(res[0]); - }, - }, - /* {"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"all"}, */ - {"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"}, - {"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"}, - {"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("/"); - return '
IMAP @ ' + unix_time_format(Number(res[0])) + '

' + - '
POP3 @ ' + unix_time_format(Number(res[1])) + '

' + - '
SMTP @ ' + unix_time_format(Number(res[2])) + '
'; - }}, - {"name":"last_pw_change","filterable": false,"title":lang.last_pw_change,"breakpoints":"all"}, - {"name":"quarantine_notification","filterable": false,"title":lang.quarantine_notification,"breakpoints":"all"}, - {"name":"quarantine_category","filterable": false,"title":lang.quarantine_category,"breakpoints":"all"}, - {"name":"in_use","filterable": false,"type":"html","title":lang.in_use,"sortValue": function(value){ - return Number($(value).find(".progress-bar-mailbox").attr('aria-valuenow')); - }, - }, - {"name":"messages","filterable": false,"title":lang.msg_num,"breakpoints":"xs sm md"}, - /* {"name":"rl","title":"RL","breakpoints":"all","style":{"width":"125px"}}, */ - {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"title":lang.active,"formatter": function(value){return 1==value?'':(0==value?'':2==value&&'—');}}, - {"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', - url: '/api/v1/get/mailbox/reduced', - jsonp: false, - error: function () { - console.log('Cannot draw mailbox table'); - }, - success: function (data) { - $.each(data, function (i, item) { + $('#mailbox_table').DataTable({ + processing: true, + serverSide: false, + language: lang_datatables, + ajax: { + type: "GET", + url: "/api/v1/get/mailbox/reduced", + dataSrc: function(json){ + $.each(json, function (i, item) { item.quota = item.quota_used + "/" + item.quota; item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox); item.last_mail_login = item.last_imap_login + '/' + item.last_pop3_login + '/' + item.last_smtp_login; @@ -498,66 +463,111 @@ jQuery(function($){ 'style="min-width:2em;width:' + item.percent_in_use + '%">' + item.percent_in_use + '%' + ''; item.username = escapeHtml(item.username); }); - } - }), - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "state": { - "enabled": true - }, - "filtering": { - "enabled": true, - "delay": 1200, - "position": "left", - "connectors": false, - //"container": "#tab-mailboxes.panel", - "placeholder": lang.filter_table - }, - "components": { - "filtering": FooTable.domainFilter - }, - "sorting": { - "enabled": true - }, - "on": { - "destroy.ft.table": function(e, ft){ - $('.refresh_table').attr('disabled', 'true'); - }, - "ready.ft.table": function(e, ft){ - table_mailbox_ready(ft, 'mailbox_table'); - }, - "after.ft.filtering": function(e, ft){ - table_mailbox_ready(ft, 'mailbox_table'); + + console.log(json); + return json; } }, - "toggleSelector": "table tbody span.footable-toggle" + columns: [ + { + title: lang.username, + data: 'username' + }, + { + title: lang.fname, + data: 'name' + }, + { + title: lang.domain, + data: 'domain' + }, + { + title: lang.domain_quota, + data: 'quota', + render: function (data, type) { + data = data.split("/"); + var of_q = (data[1] == 0 ? "∞" : humanFileSize(data[1])); + return humanFileSize(data[0]) + " / " + of_q; + } + }, + { + title: lang.tls_enforce_in, + data: 'tls_enforce_in' + }, + { + title: lang.tls_enforce_out, + data: 'tls_enforce_out' + }, + { + title: 'SMTP', + data: 'smtp_access' + }, + { + title: 'IMAP', + data: 'imap_access' + }, + { + title: 'POP3', + data: 'pop3_access' + }, + { + title: lang.last_mail_login, + data: 'last_mail_login' + }, + { + title: lang.last_pw_change, + data: 'last_pw_change' + }, + { + title: lang.quarantine_notification, + data: 'quarantine_notification' + }, + { + title: lang.quarantine_category, + data: 'quarantine_category' + }, + { + title: lang.in_use, + data: 'in_use' + }, + { + title: lang.msg_num, + data: 'messages' + }, + { + title: lang.active, + data: 'active', + render: function (data, type) { + return 1==value?'':(0==value?'':2==value&&'—'); + } + }, + { + title: lang.action, + data: null, + render: function (data, type) { + return `
+ + Bearbeiten + + + Entfernen + +
`; + } + }, + ] }); } function draw_resource_table() { - ft_resource_table = FooTable.init('#resource_table', { - "columns": [ - {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, - {"sorted": true,"name":"description","title":lang.description,"style":{"width":"250px"}}, - {"name":"name","title":lang.alias}, - {"name":"kind","title":lang.kind}, - {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, - {"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?'':0==value&&'';}}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "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) { + $('#resource_table').DataTable({ + processing: true, + serverSide: false, + language: lang_datatables, + ajax: { + type: "GET", + url: "/api/v1/get/resource/all", + dataSrc: function(json){ + $.each(json, function (i, item) { if (item.multiple_bookings == '0') { item.multiple_bookings = '' + lang.booking_0_short + ''; } else if (item.multiple_bookings == '-1') { @@ -572,65 +582,66 @@ jQuery(function($){ item.chkbox = ''; item.name = escapeHtml(item.name); }); - } - }), - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "state": { - "enabled": true - }, - "filtering": { - "enabled": true, - "delay": 1200, - "position": "left", - "connectors": false, - "placeholder": lang.filter_table - }, - "components": { - "filtering": FooTable.domainFilter - }, - "sorting": { - "enabled": true - }, - "on": { - "destroy.ft.table": function(e, ft){ - $('.refresh_table').attr('disabled', 'true'); - }, - "ready.ft.table": function(e, ft){ - table_mailbox_ready(ft, 'resource_table'); - }, - "after.ft.filtering": function(e, ft){ - table_mailbox_ready(ft, 'resource_table'); + + console.log(json); + return json; } }, - "toggleSelector": "table tbody span.footable-toggle" + columns: [ + { + title: lang.description, + data: 'description' + }, + { + title: lang.alias, + data: 'name' + }, + { + title: lang.kind, + data: 'kind' + }, + { + title: lang.domain, + data: 'domain' + }, + { + title: lang.multiple_bookings, + data: 'multiple_bookings' + }, + { + title: lang.active, + data: 'active', + render: function (data, type) { + return 1==value?'':(0==value?'':2==value&&'—'); + } + }, + { + title: lang.action, + data: null, + render: function (data, type) { + return `
+ + Bearbeiten + + + Entfernen + +
`; + } + }, + ] }); } function draw_bcc_table() { - ft_bcc_table = FooTable.init('#bcc_table', { - "columns": [ - {"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"}, - {"sorted": true,"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}}, - {"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"}, - {"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"title":lang.active,"formatter": function(value){return 1==value?'':0==value&&'';}}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "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) { + $('#bcc_table').DataTable({ + processing: true, + serverSide: false, + language: lang_datatables, + ajax: { + type: "GET", + url: "/api/v1/get/bcc/all", + dataSrc: function(json){ + $.each(json, function (i, item) { item.action = '
' + ' ' + lang.edit + '' + ' ' + lang.remove + '' + @@ -644,38 +655,54 @@ jQuery(function($){ item.type = '' + lang.bcc_rcpt_map + ''; } }); - } - }), - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "state": { - "enabled": true - }, - "filtering": { - "enabled": true, - "delay": 1200, - "position": "left", - "connectors": false, - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true - }, - "on": { - "destroy.ft.table": function(e, ft){ - $('.refresh_table').attr('disabled', 'true'); - }, - "ready.ft.table": function(e, ft){ - table_mailbox_ready(ft, 'bcc_table'); - }, - "after.ft.filtering": function(e, ft){ - table_mailbox_ready(ft, 'bcc_table'); + + console.log(json); + return json; } }, - "toggleSelector": "table tbody span.footable-toggle" + columns: [ + { + title: "ID", + data: 'id' + }, + { + title: lang.bcc_type, + data: 'type' + }, + { + title: lang.bcc_local_dest, + data: 'local_dest' + }, + { + title: lang.bcc_destinations, + data: 'bcc_dest' + }, + { + title: lang.domain, + data: 'domain' + }, + { + title: lang.active, + data: 'active', + render: function (data, type) { + return 1==value?'':(0==value?'':2==value&&'—'); + } + }, + { + title: lang.action, + data: null, + render: function (data, type) { + return `
+ + Bearbeiten + + + Entfernen + +
`; + } + }, + ] }); } function draw_recipient_map_table() { @@ -1150,12 +1177,12 @@ jQuery(function($){ draw_domain_table(); draw_mailbox_table(); draw_resource_table(); - draw_alias_table(); - draw_aliasdomain_table(); - draw_sync_job_table(); - draw_filter_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(); + // draw_recipient_map_table(); + // draw_tls_policy_table(); }); diff --git a/data/web/mailbox.php b/data/web/mailbox.php index 489ac429..a8abd7ca 100644 --- a/data/web/mailbox.php +++ b/data/web/mailbox.php @@ -40,6 +40,7 @@ $template_data = [ 'domains' => $domains, 'mailboxes' => $mailboxes, 'lang_mailbox' => json_encode($lang['mailbox']), + 'lang_datatables' => json_encode($lang['datatables']), ]; require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; diff --git a/data/web/templates/admin/tab-config-admins.twig b/data/web/templates/admin/tab-config-admins.twig index 16f7321d..8f2c62a8 100644 --- a/data/web/templates/admin/tab-config-admins.twig +++ b/data/web/templates/admin/tab-config-admins.twig @@ -225,9 +225,8 @@
{{ lang.admin.domain_admins }}
-
-
-
+ +
{{ lang.mailbox.toggle_all }} diff --git a/data/web/templates/mailbox.twig b/data/web/templates/mailbox.twig index 62c24bb4..cba189d7 100644 --- a/data/web/templates/mailbox.twig +++ b/data/web/templates/mailbox.twig @@ -47,6 +47,7 @@