diff --git a/app/frontend/templates/panel/parts/details_stats.html b/app/frontend/templates/panel/parts/details_stats.html
index 46d79afa..4d44c117 100644
--- a/app/frontend/templates/panel/parts/details_stats.html
+++ b/app/frontend/templates/panel/parts/details_stats.html
@@ -7,7 +7,7 @@
{% if data['server_stats'][0]['running'] %}
Server Status: Online
Server Started: {{ data['server_stats'][0]['started'] }} (Server Time)
- Server Uptime: Not calculated yet
+ Server Uptime: Error Calculating
{% else %}
Server Status: Offline
Server Started: Offline
@@ -63,9 +63,8 @@
.map(([type, num]) => {
// make them strings
returnData = num + ' ' + type;
- console.log(returnData);
// remove the s in the end if the data is -1 or 1
- if (returnData == -1 || returnData == 1)
+ if (num == -1 || num == 1)
returnData = returnData.slice(0, -1)
return returnData;
})
@@ -83,20 +82,26 @@
console.log('calculateTime');
let uptime = document.querySelector('#uptime');
let started = document.querySelector('#started');
+ let startedUTC;
+ let startedLocal;
if (started != null) {
- let startedUTC = '{{ (datetime.datetime.strptime(data['server_stats'][0]['started'], '%Y-%m-%d %H:%M:%S') - datetime.timedelta(seconds=-time.timezone)).strftime('%Y-%m-%d %H:%M:%S') }}';
+ console.log('88', '{{ data['server_stats'][0]['started'] }}');
+ {% if data['server_stats'][0]['started'] != 'False' %}
+ startedUTC = '{{ (datetime.datetime.strptime(data['server_stats'][0]['started'], '%Y-%m-%d %H:%M:%S') - datetime.timedelta(seconds=-time.timezone)).strftime('%Y-%m-%d %H:%M:%S') }}';
+ {% end %}
console.log('utc', startedUTC);
startedUTC = moment.utc(startedUTC, 'YYYY-MM-DD HH:mm:ss');
let browserUTCOffset = moment().utcOffset(); // This is in minutes
- let startedLocal = startedUTC.utcOffset(browserUTCOffset);
- startedLocal = startedLocal.format('YYYY-MM-DD HH:mm:ss');
+ startedLocal = startedUTC.utcOffset(browserUTCOffset);
+ startedLocalFormatted = startedLocal.format('YYYY-MM-DD HH:mm:ss');
- console.log('local', startedLocal);
+ console.log('startedLocal', startedLocal);
+ console.log('startedLocalFormatted', startedLocalFormatted);
- started.textContent = startedLocal
+ started.textContent = startedLocalFormatted
}
let nowServerTime = '{{ data['time'] }}';
@@ -109,6 +114,17 @@
var diff = moment.duration(msdiff);
uptime.textContent = durationToHumanizedString(diff);
+
+ console.log('startedLocal', startedLocal)
+ if (startedLocal) {
+ var uptimeLoop = setInterval(() => {
+ var msdiff = moment()
+ .diff(startedLocal);
+ var diff = moment.duration(msdiff);
+
+ uptime.textContent = durationToHumanizedString(diff);
+ }, 1000)
+ }
}
});