From eeee02875a7789d079f5727a21dc3cf045565c53 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Mon, 3 Mar 2025 18:14:19 +0100 Subject: [PATCH] WebUI: fix draw events for datatables sometimes the context menu was not working because the draw action was called too early Signed-off-by: Nicola Murino --- templates/webadmin/admins.html | 5 ++--- templates/webadmin/connections.html | 5 ++--- templates/webadmin/defender.html | 3 +-- templates/webadmin/eventactions.html | 5 ++--- templates/webadmin/eventrules.html | 5 ++--- templates/webadmin/events.html | 6 +++--- templates/webadmin/folders.html | 5 ++--- templates/webadmin/groups.html | 5 ++--- templates/webadmin/iplists.html | 3 +-- templates/webadmin/roles.html | 5 ++--- templates/webadmin/users.html | 5 ++--- templates/webclient/files.html | 3 +-- templates/webclient/shares.html | 3 +-- 13 files changed, 23 insertions(+), 35 deletions(-) diff --git a/templates/webadmin/admins.html b/templates/webadmin/admins.html index b9a9769d..13530133 100644 --- a/templates/webadmin/admins.html +++ b/templates/webadmin/admins.html @@ -432,12 +432,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webadmin/connections.html b/templates/webadmin/connections.html index 3f2ffa08..abd237a8 100644 --- a/templates/webadmin/connections.html +++ b/templates/webadmin/connections.html @@ -328,12 +328,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webadmin/defender.html b/templates/webadmin/defender.html index 85521f45..af28bd40 100644 --- a/templates/webadmin/defender.html +++ b/templates/webadmin/defender.html @@ -235,11 +235,10 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); + dt.on('draw.dt', drawAction); } function drawAction() { diff --git a/templates/webadmin/eventactions.html b/templates/webadmin/eventactions.html index 66908ebc..183619b5 100644 --- a/templates/webadmin/eventactions.html +++ b/templates/webadmin/eventactions.html @@ -274,12 +274,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webadmin/eventrules.html b/templates/webadmin/eventrules.html index 861638f1..6a357be7 100644 --- a/templates/webadmin/eventrules.html +++ b/templates/webadmin/eventrules.html @@ -332,12 +332,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webadmin/events.html b/templates/webadmin/events.html index a736dfc7..44d1cdb3 100644 --- a/templates/webadmin/events.html +++ b/templates/webadmin/events.html @@ -629,7 +629,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). }, }); - dt.on('draw', drawAction); + dt.on('draw.dt', drawAction); } function drawAction() { @@ -815,7 +815,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). }, }); - dt.on('draw', drawAction); + dt.on('draw.dt', drawAction); } function drawAction() { @@ -979,7 +979,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). }, }); - dt.on('draw', drawAction); + dt.on('draw.dt', drawAction); } function drawAction() { diff --git a/templates/webadmin/folders.html b/templates/webadmin/folders.html index b5ddc469..23899ada 100644 --- a/templates/webadmin/folders.html +++ b/templates/webadmin/folders.html @@ -350,12 +350,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webadmin/groups.html b/templates/webadmin/groups.html index e9eb1df9..90e19ed7 100644 --- a/templates/webadmin/groups.html +++ b/templates/webadmin/groups.html @@ -285,12 +285,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webadmin/iplists.html b/templates/webadmin/iplists.html index c7aa85e5..dd6b2927 100644 --- a/templates/webadmin/iplists.html +++ b/templates/webadmin/iplists.html @@ -387,11 +387,10 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); + dt.on('draw.dt', drawAction); } function drawAction() { diff --git a/templates/webadmin/roles.html b/templates/webadmin/roles.html index 290cc43e..2e825e68 100644 --- a/templates/webadmin/roles.html +++ b/templates/webadmin/roles.html @@ -286,12 +286,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webadmin/users.html b/templates/webadmin/users.html index 875a3137..63f3d885 100644 --- a/templates/webadmin/users.html +++ b/templates/webadmin/users.html @@ -619,12 +619,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); - dt.on('column-reorder', function(e, settings, details){ + dt.on('draw.dt', drawAction); + dt.on('columns-reordered', function(e, settings, details){ drawAction(); }); } diff --git a/templates/webclient/files.html b/templates/webclient/files.html index e280f5dd..66dc49af 100644 --- a/templates/webclient/files.html +++ b/templates/webclient/files.html @@ -840,11 +840,10 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#file_manager_list_container').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); + dt.on('draw.dt', drawAction); function drawAction() { //{{- if .CanAddFiles}} diff --git a/templates/webclient/shares.html b/templates/webclient/shares.html index 8733ebf4..7de12d32 100644 --- a/templates/webclient/shares.html +++ b/templates/webclient/shares.html @@ -414,11 +414,10 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). $('#card_content').removeClass("d-none"); let api = $.fn.dataTable.Api(settings); api.columns.adjust().draw("page"); - drawAction(); } }); - dt.on('draw', drawAction); + dt.on('draw.dt', drawAction); } function drawAction() {