Mailboxes datatable - server side processing
Signed-off-by: Kristian Feldsam <feldsam@gmail.com>
This commit is contained in:
parent
3e194c7906
commit
28cec99699
@ -869,7 +869,7 @@ jQuery(function($){
|
|||||||
var table = $('#mailbox_table').DataTable({
|
var table = $('#mailbox_table').DataTable({
|
||||||
responsive: true,
|
responsive: true,
|
||||||
processing: true,
|
processing: true,
|
||||||
serverSide: false,
|
serverSide: true,
|
||||||
stateSave: true,
|
stateSave: true,
|
||||||
pageLength: pagination_size,
|
pageLength: pagination_size,
|
||||||
dom: "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
|
dom: "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" +
|
||||||
@ -878,13 +878,12 @@ jQuery(function($){
|
|||||||
language: lang_datatables,
|
language: lang_datatables,
|
||||||
initComplete: function(settings, json){
|
initComplete: function(settings, json){
|
||||||
hideTableExpandCollapseBtn('#tab-mailboxes', '#mailbox_table');
|
hideTableExpandCollapseBtn('#tab-mailboxes', '#mailbox_table');
|
||||||
filterByDomain(json, 8, table);
|
|
||||||
},
|
},
|
||||||
ajax: {
|
ajax: {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/api/v1/get/mailbox/reduced",
|
url: "/api/v1/get/mailbox/datatables",
|
||||||
dataSrc: function(json){
|
dataSrc: function(json){
|
||||||
$.each(json, function (i, item) {
|
$.each(json.data, function (i, item) {
|
||||||
item.quota = {
|
item.quota = {
|
||||||
sortBy: item.quota_used,
|
sortBy: item.quota_used,
|
||||||
value: item.quota
|
value: item.quota
|
||||||
@ -970,7 +969,7 @@ jQuery(function($){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return json;
|
return json.data;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
@ -1000,13 +999,15 @@ jQuery(function($){
|
|||||||
{
|
{
|
||||||
title: lang.domain_quota,
|
title: lang.domain_quota,
|
||||||
data: 'quota.value',
|
data: 'quota.value',
|
||||||
|
searchable: false,
|
||||||
responsivePriority: 8,
|
responsivePriority: 8,
|
||||||
defaultContent: '',
|
defaultContent: ''
|
||||||
orderData: 23
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: lang.last_mail_login,
|
title: lang.last_mail_login,
|
||||||
data: 'last_mail_login',
|
data: 'last_mail_login',
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
defaultContent: '',
|
defaultContent: '',
|
||||||
responsivePriority: 7,
|
responsivePriority: 7,
|
||||||
render: function (data, type) {
|
render: function (data, type) {
|
||||||
@ -1019,11 +1020,15 @@ jQuery(function($){
|
|||||||
{
|
{
|
||||||
title: lang.last_pw_change,
|
title: lang.last_pw_change,
|
||||||
data: 'last_pw_change',
|
data: 'last_pw_change',
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
defaultContent: ''
|
defaultContent: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: lang.in_use,
|
title: lang.in_use,
|
||||||
data: 'in_use.value',
|
data: 'in_use.value',
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
defaultContent: '',
|
defaultContent: '',
|
||||||
responsivePriority: 9,
|
responsivePriority: 9,
|
||||||
className: 'dt-data-w100',
|
className: 'dt-data-w100',
|
||||||
@ -1092,6 +1097,8 @@ jQuery(function($){
|
|||||||
{
|
{
|
||||||
title: lang.msg_num,
|
title: lang.msg_num,
|
||||||
data: 'messages',
|
data: 'messages',
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
defaultContent: '',
|
defaultContent: '',
|
||||||
responsivePriority: 5
|
responsivePriority: 5
|
||||||
},
|
},
|
||||||
@ -1116,6 +1123,8 @@ jQuery(function($){
|
|||||||
{
|
{
|
||||||
title: lang.active,
|
title: lang.active,
|
||||||
data: 'active',
|
data: 'active',
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
defaultContent: '',
|
defaultContent: '',
|
||||||
responsivePriority: 4,
|
responsivePriority: 4,
|
||||||
render: function (data, type) {
|
render: function (data, type) {
|
||||||
@ -1125,22 +1134,12 @@ jQuery(function($){
|
|||||||
{
|
{
|
||||||
title: lang.action,
|
title: lang.action,
|
||||||
data: 'action',
|
data: 'action',
|
||||||
|
searchable: false,
|
||||||
|
orderable: false,
|
||||||
className: 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right',
|
className: 'dt-sm-head-hidden dt-data-w100 dtr-col-md dt-text-right',
|
||||||
responsivePriority: 6,
|
responsivePriority: 6,
|
||||||
defaultContent: ''
|
defaultContent: ''
|
||||||
},
|
}
|
||||||
{
|
|
||||||
title: "",
|
|
||||||
data: 'quota.sortBy',
|
|
||||||
defaultContent: '',
|
|
||||||
className: "d-none"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "",
|
|
||||||
data: 'in_use.sortBy',
|
|
||||||
defaultContent: '',
|
|
||||||
className: "d-none"
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1046,6 +1046,39 @@ if (isset($_GET['query'])) {
|
|||||||
break;
|
break;
|
||||||
case "mailbox":
|
case "mailbox":
|
||||||
switch ($object) {
|
switch ($object) {
|
||||||
|
case "datatables":
|
||||||
|
$table = ['mailbox', 'm'];
|
||||||
|
$primaryKey = 'username';
|
||||||
|
$columns = [
|
||||||
|
['db' => 'username', 'dt' => 2],
|
||||||
|
['db' => 'quota', 'dt' => 3],
|
||||||
|
];
|
||||||
|
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/lib/ssp.class.php';
|
||||||
|
global $pdo;
|
||||||
|
if($_SESSION['mailcow_cc_role'] === 'admin') {
|
||||||
|
$data = SSP::complex($_GET, $pdo, $table, $primaryKey, $columns, null, "(`m`.`kind` = '' OR `m`.`kind` = NULL)");
|
||||||
|
} elseif ($_SESSION['mailcow_cc_role'] === 'domainadmin') {
|
||||||
|
$data = SSP::complex($_GET, $pdo, $table, $primaryKey, $columns,
|
||||||
|
'INNER JOIN domain_admins as da ON da.domain = m.domain',
|
||||||
|
[
|
||||||
|
'condition' => "(`m`.`kind` = '' OR `m`.`kind` = NULL) AND `da`.`active` = 1 AND `da`.`username` = :username",
|
||||||
|
'bindings' => ['username' => $_SESSION['mailcow_cc_username']]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['data'])) {
|
||||||
|
$mailboxData = [];
|
||||||
|
foreach ($data['data'] as $mailbox) {
|
||||||
|
if ($details = mailbox('get', 'mailbox_details', $mailbox[2])) {
|
||||||
|
$mailboxData[] = $details;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['data'] = $mailboxData;
|
||||||
|
}
|
||||||
|
|
||||||
|
process_get_return($data);
|
||||||
|
break;
|
||||||
case "all":
|
case "all":
|
||||||
case "reduced":
|
case "reduced":
|
||||||
$tags = null;
|
$tags = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user