[Web] show fold/unfold action if child rows exists

This commit is contained in:
FreddleSpl0it
2023-01-16 15:38:35 +01:00
parent 099db33e44
commit 8782304e8d
16 changed files with 339 additions and 143 deletions

View File

@@ -118,7 +118,7 @@ jQuery(function($){
return;
}
$('#autodiscover_log').DataTable({
var table = $('#autodiscover_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -128,6 +128,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-autodiscover-logs', '#autodiscover_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/autodiscover/100",
@@ -172,6 +175,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-autodiscover-logs', '#autodiscover_log');
});
}
function draw_postfix_logs() {
// just recalc width if instance already exists
@@ -180,7 +187,7 @@ jQuery(function($){
return;
}
$('#postfix_log').DataTable({
var table = $('#postfix_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -190,6 +197,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-postfix-logs', '#postfix_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/postfix",
@@ -219,6 +229,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-postfix-logs', '#postfix_log');
});
}
function draw_watchdog_logs() {
// just recalc width if instance already exists
@@ -227,7 +241,7 @@ jQuery(function($){
return;
}
$('#watchdog_log').DataTable({
var table = $('#watchdog_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -237,6 +251,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-watchdog-logs', '#watchdog_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/watchdog",
@@ -270,6 +287,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-watchdog-logs', '#watchdog_log');
});
}
function draw_api_logs() {
// just recalc width if instance already exists
@@ -278,7 +299,7 @@ jQuery(function($){
return;
}
$('#api_log').DataTable({
var table = $('#api_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -288,6 +309,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-api-logs', '#api_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/api",
@@ -328,6 +352,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-api-logs', '#api_log');
});
}
function draw_rl_logs() {
// just recalc width if instance already exists
@@ -336,7 +364,7 @@ jQuery(function($){
return;
}
$('#rl_log').DataTable({
var table = $('#rl_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -346,6 +374,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-rl-logs', '#rl_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/ratelimited",
@@ -424,6 +455,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-rl-logs', '#rl_log');
});
}
function draw_ui_logs() {
// just recalc width if instance already exists
@@ -432,7 +467,7 @@ jQuery(function($){
return;
}
$('#ui_logs').DataTable({
var table = $('#ui_logs').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -442,6 +477,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-ui-logs', '#ui_logs');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/ui",
@@ -500,6 +538,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-ui-logs', '#ui_log');
});
}
function draw_sasl_logs() {
// just recalc width if instance already exists
@@ -508,7 +550,7 @@ jQuery(function($){
return;
}
$('#sasl_logs').DataTable({
var table = $('#sasl_logs').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -518,6 +560,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-sasl-logs', '#sasl_logs');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/sasl",
@@ -553,6 +598,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-sasl-logs', '#sasl_logs');
});
}
function draw_acme_logs() {
// just recalc width if instance already exists
@@ -561,7 +610,7 @@ jQuery(function($){
return;
}
$('#acme_log').DataTable({
var table = $('#acme_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -571,6 +620,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-acme-logs', '#acme_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/acme",
@@ -595,6 +647,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-acme-logs', '#acme_log');
});
}
function draw_netfilter_logs() {
// just recalc width if instance already exists
@@ -603,7 +659,7 @@ jQuery(function($){
return;
}
$('#netfilter_log').DataTable({
var table = $('#netfilter_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -613,6 +669,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-netfilter-logs', '#netfilter_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/netfilter",
@@ -642,6 +701,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-netfilter-logs', '#netfilter_log');
});
}
function draw_sogo_logs() {
// just recalc width if instance already exists
@@ -650,7 +713,7 @@ jQuery(function($){
return;
}
$('#sogo_log').DataTable({
var table = $('#sogo_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -660,6 +723,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-sogo-logs', '#sogo_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/sogo",
@@ -689,6 +755,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-sogo-logs', '#sogo_log');
});
}
function draw_dovecot_logs() {
// just recalc width if instance already exists
@@ -697,7 +767,7 @@ jQuery(function($){
return;
}
$('#dovecot_log').DataTable({
var table = $('#dovecot_log').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -707,6 +777,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-dovecot-logs', '#dovecot_log');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/dovecot",
@@ -736,6 +809,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-dovecot-logs', '#dovecot_log');
});
}
function rspamd_pie_graph() {
$.ajax({
@@ -805,7 +882,7 @@ jQuery(function($){
return;
}
$('#rspamd_history').DataTable({
var table = $('#rspamd_history').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -815,6 +892,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[0, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-rspamd-logs', '#rspamd_history');
},
ajax: {
type: "GET",
url: "/api/v1/get/logs/rspamd-history",
@@ -903,6 +983,10 @@ jQuery(function($){
}
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-rspamd-history', '#rspamd_history');
});
}
function process_table_data(data, table) {
if (table == 'rspamd_history') {
@@ -1098,6 +1182,12 @@ jQuery(function($){
});
}
})
function hideTableExpandCollapseBtn(tab, table){
if ($(table).hasClass('collapsed'))
$(tab).find(".table_collapse_option").show();
else
$(tab).find(".table_collapse_option").hide();
}
// detect element visibility changes
function onVisible(element, callback) {

View File

@@ -441,6 +441,9 @@ jQuery(function($){
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
initComplete: function(){
hideTableExpandCollapseBtn('#tab-domains', '#domain_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/domain/all",
@@ -614,7 +617,11 @@ jQuery(function($){
defaultContent: ''
},
]
});
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-domains', '#domain_table');
});
}
function draw_templates_domain_table() {
// just recalc width if instance already exists
@@ -623,7 +630,7 @@ jQuery(function($){
return;
}
$('#templates_domain_table').DataTable({
var table = $('#templates_domain_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -633,6 +640,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-templates-domains', '#templates_domain_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/domain/template/all",
@@ -817,6 +827,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-templates-domains', '#templates_domain_table');
});
}
function draw_mailbox_table() {
// just recalc width if instance already exists
@@ -825,7 +839,7 @@ jQuery(function($){
return;
}
$('#mailbox_table').DataTable({
var table = $('#mailbox_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -834,6 +848,9 @@ jQuery(function($){
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
initComplete: function(){
hideTableExpandCollapseBtn('#tab-mailboxes', '#mailbox_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/mailbox/reduced",
@@ -1088,6 +1105,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-mailboxes', '#mailbox_table');
});
}
function draw_templates_mbox_table() {
// just recalc width if instance already exists
@@ -1096,7 +1117,7 @@ jQuery(function($){
return;
}
$('#templates_mbox_table').DataTable({
var table = $('#templates_mbox_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1106,6 +1127,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-templates-mbox', '#templates_mbox_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/mailbox/template/all",
@@ -1304,6 +1328,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-templates-mbox', '#templates_mbox_table');
});
}
function draw_resource_table() {
// just recalc width if instance already exists
@@ -1312,7 +1340,7 @@ jQuery(function($){
return;
}
$('#resource_table').DataTable({
var table = $('#resource_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1321,6 +1349,9 @@ jQuery(function($){
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
initComplete: function(){
hideTableExpandCollapseBtn('#tab-resources', '#resource_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/resource/all",
@@ -1407,6 +1438,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-resources', '#resource_table');
});
}
function draw_bcc_table() {
$.get("/api/v1/get/bcc-destination-options", function(data){
@@ -1443,7 +1478,7 @@ jQuery(function($){
return;
}
$('#bcc_table').DataTable({
var table = $('#bcc_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1453,6 +1488,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#collapse-tab-bcc', '#bcc_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/bcc/all",
@@ -1537,6 +1575,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#collapse-tab-bcc', '#bcc_table');
});
}
function draw_recipient_map_table() {
// just recalc width if instance already exists
@@ -1545,7 +1587,7 @@ jQuery(function($){
return;
}
$('#recipient_map_table').DataTable({
var table = $('#recipient_map_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1555,6 +1597,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#collapse-tab-bcc-filters', '#recipient_map_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/recipient_map/all",
@@ -1626,6 +1671,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#collapse-tab-bcc-filters', '#recipient_map_table');
});
}
function draw_tls_policy_table() {
// just recalc width if instance already exists
@@ -1634,7 +1683,7 @@ jQuery(function($){
return;
}
$('#tls_policy_table').DataTable({
var table = $('#tls_policy_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1644,6 +1693,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-tls-policy', '#tls_policy_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/tls-policy-map/all",
@@ -1725,6 +1777,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-tls-policy', '#tls_policy_table');
});
}
function draw_alias_table() {
// just recalc width if instance already exists
@@ -1733,7 +1789,7 @@ jQuery(function($){
return;
}
$('#alias_table').DataTable({
var table = $('#alias_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1743,6 +1799,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-mbox-aliases', '#alias_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/alias/all",
@@ -1871,6 +1930,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-mbox-aliases', '#alias_table');
});
}
function draw_aliasdomain_table() {
// just recalc width if instance already exists
@@ -1879,7 +1942,7 @@ jQuery(function($){
return;
}
$('#aliasdomain_table').DataTable({
var table = $('#aliasdomain_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1888,6 +1951,9 @@ jQuery(function($){
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
initComplete: function(){
hideTableExpandCollapseBtn('#tab-domain-aliases', '#aliasdomain_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/alias-domain/all",
@@ -1958,6 +2024,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-domain-aliases', '#aliasdomain_table');
});
}
function draw_sync_job_table() {
// just recalc width if instance already exists
@@ -1966,7 +2036,7 @@ jQuery(function($){
return;
}
$('#sync_job_table').DataTable({
var table = $('#sync_job_table').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -1976,6 +2046,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-syncjobs', '#sync_job_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/syncjobs/all/no_log",
@@ -2103,6 +2176,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-syncjobs', '#sync_job_table');
});
}
function draw_filter_table() {
// just recalc width if instance already exists
@@ -2122,6 +2199,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order:[[2, 'desc']],
initComplete: function(){
hideTableExpandCollapseBtn('#tab-filters', '#filter_table');
},
ajax: {
type: "GET",
url: "/api/v1/get/filters/all",
@@ -2206,8 +2286,19 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#tab-filters', '#filter_table');
});
};
function hideTableExpandCollapseBtn(tab, table){
if ($(table).hasClass('collapsed'))
$(tab).find(".table_collapse_option").show();
else
$(tab).find(".table_collapse_option").hide();
}
// detect element visibility changes
function onVisible(element, callback) {
$(document).ready(function() {

View File

@@ -13,7 +13,7 @@ jQuery(function($){
$('#' + table_name).DataTable().ajax.reload();
});
function draw_quarantine_table() {
$('#quarantinetable').DataTable({
var table = $('#quarantinetable').DataTable({
responsive: true,
processing: true,
serverSide: false,
@@ -22,6 +22,9 @@ jQuery(function($){
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
initComplete: function(){
hideTableExpandCollapseBtn('#quarantinetable');
},
ajax: {
type: "GET",
url: "/api/v1/get/quarantine/all",
@@ -153,6 +156,10 @@ jQuery(function($){
},
]
});
table.on('responsive-resize', function (e, datatable, columns){
hideTableExpandCollapseBtn('#quarantinetable');
});
}
$('body').on('click', '.show_qid_info', function (e) {
@@ -268,4 +275,12 @@ jQuery(function($){
// Initial table drawings
draw_quarantine_table();
function hideTableExpandCollapseBtn(table){
if ($(table).hasClass('collapsed'))
$(".table_collapse_option").show();
else
$(".table_collapse_option").hide();
}
});