From 6b4273544418504d4a3e1285a4ea5e446e95dfa4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 13 Mar 2022 16:02:55 -0400 Subject: [PATCH] Add search to dashboard Fix MOTD formatting --- app/frontend/templates/panel/dashboard.html | 56 ++++++++++++++----- .../templates/panel/parts/details_stats.html | 4 +- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 40d0ce13..cb88644a 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -111,16 +111,16 @@ {% end %} {% if len(data['servers']) > 0 %} - +
- - - - - - - - + + + + + + + + @@ -228,7 +228,7 @@ data['lang']) }}
{% if server['stats']['desc'] != 'False' %} - {{ server['stats']['desc'] }}
+
{{ server['stats']['desc'] }}

{% end %} {% if server['stats']['version'] != 'False' %} @@ -438,7 +438,7 @@ var motd = ""; if (server.desc) { motd = `` + server.desc + ``; - server_infos = server_infos + motd + "
"; + server_infos = server_infos + '
' + motd + '
' + "
"; } /* Version */ @@ -464,7 +464,11 @@ } function update_servers_status(data) { + try{ update_one_server_status(data[0]); + }catch{ + + } display_motd(); } @@ -617,8 +621,13 @@ } } console.log(id_string) - sendOrder(id_string) + if($('#servers_table').find('input[type=search]').length == 0){ + sendOrder(id_string) + }else{ + console.log("Will not reorder when servers are filtered") + } } + function sendOrder(id_string) { var token = getCookie("_xsrf") $.ajax({ @@ -634,7 +643,28 @@ }, }); } - + $(document).ready(function () { + var servers_table = $('#servers_table').DataTable({ + "ordering": false, // false to disable sorting (or any other option) + "paging": false + }); + document.getElementById('first').setAttribute('draggable', false); + $('.dataTables_length').addClass('bs-select'); + }); + $('#servers_table').on('search.dt', function() { + let value = $('.dataTables_filter input').val() + if(value == ''){ + const table = document.querySelector("table"); + for (const row of table.rows) { + row.setAttribute('draggable', true) + } + }else{ + const table = document.querySelector("table"); + for (const row of table.rows) { + row.setAttribute('draggable', false) + } + } + } ); {% end %} diff --git a/app/frontend/templates/panel/parts/details_stats.html b/app/frontend/templates/panel/parts/details_stats.html index aa199340..ceea3319 100644 --- a/app/frontend/templates/panel/parts/details_stats.html +++ b/app/frontend/templates/panel/parts/details_stats.html @@ -34,10 +34,10 @@
{% if data['server_stats']['version'] != 'False' %} {{ translate('serverStats', 'version', data['lang']) }}: {{ data['server_stats']['version'] }}
- {{ translate('serverStats', 'description', data['lang']) }}: {{ data['server_stats']['desc'] }}
+ {{ translate('serverStats', 'description', data['lang']) }}: {{ data['server_stats']['desc'] }}
{% else %} {{ translate('serverStats', 'version', data['lang']) }}: {{ translate('serverStats', 'unableToConnect', data['lang']) }}
- {{ translate('serverStats', 'description', data['lang']) }}: {{ translate('serverStats', 'unableToConnect', data['lang']) }}
+ {{ translate('serverStats', 'description', data['lang']) }}: {{ translate('serverStats', 'unableToConnect', data['lang']) }}
{% end %} Server Type: {{data['server_stats']['server_type']}}
{{ translate('dashboard', 'server', data['lang']) }}{{ translate('dashboard', 'actions', data['lang']) }}{{ translate('dashboard', 'cpuUsage', data['lang']) }}{{ translate('dashboard', 'memUsage', data['lang']) }}{{ translate('dashboard', 'size', data['lang']) }}{{ translate('dashboard', 'players', data['lang']) }}{{ translate('dashboard', 'status', data['lang']) }}
{{ translate('dashboard', 'server', data['lang']) }}{{ translate('dashboard', 'actions', data['lang']) }}{{ translate('dashboard', 'cpuUsage', data['lang']) }}{{ translate('dashboard', 'memUsage', data['lang']) }}{{ translate('dashboard', 'size', data['lang']) }}{{ translate('dashboard', 'players', data['lang']) }}{{ translate('dashboard', 'status', data['lang']) }}