diff --git a/app/frontend/templates/panel/parts/details_stats.html b/app/frontend/templates/panel/parts/details_stats.html index ceea3319..38007544 100644 --- a/app/frontend/templates/panel/parts/details_stats.html +++ b/app/frontend/templates/panel/parts/details_stats.html @@ -5,39 +5,60 @@
{% if data['server_stats']['running'] %} - {{ translate('serverStats', 'serverStatus', data['lang']) }}: {{ translate('serverStats', 'online', data['lang']) }}
- {{ translate('serverStats', 'serverStarted', data['lang']) }}: {{ data['server_stats']['started'] }}
- {{ translate('serverStats', 'serverUptime', data['lang']) }}: {{ translate('serverStats', 'errorCalculatingUptime', data['lang']) }} + {{ translate('serverStats', 'serverStatus', data['lang']) }}: {{ translate('serverStats', 'online', data['lang']) }}
+ {{ translate('serverStats', 'serverStarted', data['lang']) }}: {{ + data['server_stats']['started'] }}
+ {{ translate('serverStats', 'serverUptime', data['lang']) }}: {{ + translate('serverStats', 'errorCalculatingUptime', data['lang']) }} {% elif data['server_stats']['crashed'] %} - {{ translate('serverStats', 'serverStatus', data['lang']) }}: {{ translate('dashboard', 'crashed', data['lang']) }}
- {{ translate('serverStats', 'serverStarted', data['lang']) }}: {{ translate('dashboard', 'crashed', data['lang']) }}
- {{ translate('serverStats', 'serverUptime', data['lang']) }}: {{ translate('dashboard', 'crashed', data['lang']) }} + {{ translate('serverStats', 'serverStatus', data['lang']) }}: + {{ translate('dashboard', 'crashed', data['lang']) + }}
+ {{ translate('serverStats', 'serverStarted', data['lang']) }}: {{ translate('dashboard', 'crashed', + data['lang']) }}
+ {{ translate('serverStats', 'serverUptime', data['lang']) }}: + {{ translate('dashboard', 'crashed', data['lang']) }} {% else %} - {{ translate('serverStats', 'serverStatus', data['lang']) }}: {{ translate('serverStats', 'offline', data['lang']) }}
- {{ translate('serverStats', 'serverStarted', data['lang']) }}: {{ translate('serverStats', 'offline', data['lang']) }}
- {{ translate('serverStats', 'serverUptime', data['lang']) }}: {{ translate('serverStats', 'offline', data['lang']) }} + {{ translate('serverStats', 'serverStatus', data['lang']) }}: {{ translate('serverStats', 'offline', data['lang']) }}
+ {{ translate('serverStats', 'serverStarted', data['lang']) }}: {{ translate('serverStats', 'offline', data['lang']) }}
+ {{ translate('serverStats', 'serverUptime', data['lang']) }}: {{ translate('serverStats', 'offline', data['lang']) }} {% end %}
- {{ translate('serverStats', 'serverTimeZone', data['lang']) }}: {{ data['serverTZ'] }} + {{ translate('serverStats', 'serverTimeZone', data['lang']) }}: {{ + data['serverTZ'] }}
- {{ translate('serverStats', 'cpuUsage', data['lang']) }}: {{ data['server_stats']['cpu'] }}%
- {{ translate('serverStats', 'memUsage', data['lang']) }}: {{ data['server_stats']['mem'] }}
+ {{ translate('serverStats', 'cpuUsage', data['lang']) }}: {{ + data['server_stats']['cpu'] }}%
+ {{ translate('serverStats', 'memUsage', data['lang']) }}: {{ + data['server_stats']['mem'] }}
{% if data['server_stats']['int_ping_results'] %} - {{ translate('serverStats', 'players', data['lang']) }}: {{ data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}
+ {{ translate('serverStats', 'players', data['lang']) }}: {{ + data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}
{% else %} - {{ translate('serverStats', 'players', data['lang']) }}: 0/0
+ {{ translate('serverStats', 'players', data['lang']) }}: 0/0
{% end %}
{% 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', 'version', data['lang']) }}: {{ + data['server_stats']['version'] }}
+ {{ 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', 'version', 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']}} @@ -64,6 +85,15 @@ seconds: duration._data.seconds } + if (Math.round(duration._data.days)) { + obj = { + days: Math.round(duration._data.days), + hours: Math.round(duration._data.hours -= duration._data.days * 24), + minutes: duration._data.minutes, + seconds: duration._data.seconds + } + } + output = Object.entries(obj) .map(([type, num]) => { // make them strings @@ -135,9 +165,9 @@ server_input_motd = document.getElementById('input_motd'); /* TODO Update each element */ - if (server.running){ - server_status.setAttribute("class", "text-success"); - server_status.innerHTML = `{{ translate('serverStats', 'online', data['lang']) }}`; + if (server.running) { + server_status.setAttribute("class", "text-success"); + server_status.innerHTML = `{{ translate('serverStats', 'online', data['lang']) }}`; startedUTC = server.started; startedUTC = moment.utc(startedUTC, 'YYYY-MM-DD HH:mm:ss'); @@ -156,9 +186,8 @@ uptimeLoop = setInterval(calculateUptime, 1000); } } - else - { - if (server.crashed){ + else { + if (server.crashed) { server_status.setAttribute("class", "text-danger"); server_status.innerHTML = ` {{ translate('dashboard', 'crashed', data['lang']) }}`; server_started.setAttribute("class", "text-danger"); @@ -167,37 +196,33 @@ uptimeLoop = null; server_uptime.setAttribute("class", "text-danger"); server_uptime.innerHTML = ` {{ translate('dashboard', 'crashed', data['lang']) }}`; - }else{ - server_status.setAttribute("class", "text-warning"); - server_status.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`; - server_started.setAttribute("class", "text-warning"); - server_started.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`; - clearInterval(uptimeLoop); - uptimeLoop = null; - server_uptime.setAttribute("class", "text-warning"); - server_uptime.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`; + } else { + server_status.setAttribute("class", "text-warning"); + server_status.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`; + server_started.setAttribute("class", "text-warning"); + server_started.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`; + clearInterval(uptimeLoop); + uptimeLoop = null; + server_uptime.setAttribute("class", "text-warning"); + server_uptime.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`; } } server_cpu.innerHTML = server.cpu + ` %`; server_mem.innerHTML = server.mem; - if (server.int_ping_results) - { + if (server.int_ping_results) { server_players.innerHTML = server.online + `/` + server.max; } - else - { + else { server_players.innerHTML = `0/0`; } - if (server.version) - { + if (server.version) { server_version.innerHTML = server.version; server_input_motd.innerHTML = server.desc; } - else - { + else { server_version.innerHTML = `{{ translate('serverStats', 'unableToConnect', data['lang']) }}`; server_input_motd.innerHTML = `{{ translate('serverStats', 'unableToConnect', data['lang']) }}`; } @@ -213,4 +238,4 @@ webSocket.on('update_server_details', update_server_details); //} }); - + \ No newline at end of file