2020-09-04 02:49:20 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-12 grid-margin">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-body pt-3 pb-3">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-3 mr-2">
|
2021-03-22 04:02:18 +00:00
|
|
|
{% if data['server_stats']['running'] %}
|
2021-09-29 02:25:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span class="text-success">{{ translate('serverStats', 'online', data['lang']) }}</span><br />
|
|
|
|
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started">{{ data['server_stats']['started'] }} ({{ translate('serverStats', 'serverTime', data['lang']) }})</span><br />
|
|
|
|
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime">{{ translate('serverStats', 'errorCalculatingUptime', data['lang']) }}</span>
|
2020-09-04 02:49:20 +00:00
|
|
|
{% else %}
|
2021-09-29 02:25:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
|
|
|
|
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
|
|
|
|
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span>
|
2020-09-04 02:49:20 +00:00
|
|
|
{% end %}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-sm-3 mr-2">
|
2021-09-29 02:25:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'cpuUsage', data['lang']) }}:</b> {{ data['server_stats']['cpu'] }}% <br />
|
|
|
|
<b>{{ translate('serverStats', 'memUsage', data['lang']) }}:</b> {{ data['server_stats']['mem'] }} <br />
|
2021-03-22 04:02:18 +00:00
|
|
|
{% if data['server_stats']['int_ping_results'] %}
|
2021-09-29 02:25:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> {{ data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}<br />
|
2020-09-04 02:49:20 +00:00
|
|
|
{% else %}
|
2021-09-29 02:25:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> 0/0<br />
|
2020-09-04 02:49:20 +00:00
|
|
|
{% end %}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-sm-3 mr-2">
|
2021-03-22 04:02:18 +00:00
|
|
|
{% if data['server_stats']['version'] != 'False' %}
|
2021-09-29 02:25:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> {{ data['server_stats']['version'] }} <br />
|
2021-11-19 22:01:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span id="input_motd" class="input_motd">{{ data['server_stats']['desc'] }}</span> <br />
|
2020-09-04 02:49:20 +00:00
|
|
|
{% else %}
|
2021-09-29 02:25:47 +00:00
|
|
|
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> {{ translate('serverStats', 'unableToConnect', data['lang']) }} <br />
|
|
|
|
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> {{ translate('serverStats', 'unableToConnect', data['lang']) }} <br />
|
2020-09-04 02:49:20 +00:00
|
|
|
{% end %}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-12-14 15:59:59 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="/static/assets/vendors/moment/moment.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
|
|
2021-11-19 22:01:47 +00:00
|
|
|
<script src="/static/assets/js/motd.js"></script>
|
2020-12-14 15:59:59 +00:00
|
|
|
<script>
|
|
|
|
|
2020-12-14 21:52:46 +00:00
|
|
|
function durationToHumanizedString (duration) {
|
|
|
|
duration._data.months += duration._data.years * 12;
|
|
|
|
// 30.45833333333 = average month length, calculate with (31+28.5+31+30+31+30+31+31+30+31+30+31) / 12
|
|
|
|
duration._data.days += duration._data.months * 30.45833333333;
|
|
|
|
duration._data.hours += duration._data.days * 24;
|
|
|
|
|
|
|
|
let obj = {
|
|
|
|
hours: Math.round(duration._data.hours),
|
|
|
|
minutes: duration._data.minutes,
|
|
|
|
seconds: duration._data.seconds
|
|
|
|
}
|
|
|
|
|
|
|
|
output = Object.entries(obj)
|
|
|
|
.map(([type, num]) => {
|
|
|
|
// make them strings
|
|
|
|
returnData = num + ' ' + type;
|
|
|
|
// remove the s in the end if the data is -1 or 1
|
2020-12-31 17:41:02 +00:00
|
|
|
if (num == -1 || num == 1)
|
2020-12-14 21:52:46 +00:00
|
|
|
returnData = returnData.slice(0, -1)
|
|
|
|
return returnData;
|
|
|
|
})
|
2020-12-14 15:59:59 +00:00
|
|
|
.map((v, i, a) => // example input: [1,2,3], output: "1, 2 and 3"
|
|
|
|
v + (i !== a.length - 1
|
|
|
|
? i !== a.length - 2
|
|
|
|
? ', '
|
|
|
|
: ' and '
|
|
|
|
: '')).join('');
|
2020-12-14 21:52:46 +00:00
|
|
|
return output;
|
|
|
|
}
|
2020-12-14 15:59:59 +00:00
|
|
|
|
2020-12-15 23:17:41 +00:00
|
|
|
document.body.onload = (() => {
|
2020-12-14 15:59:59 +00:00
|
|
|
|
2020-12-14 21:52:46 +00:00
|
|
|
console.log('calculateTime');
|
|
|
|
let uptime = document.querySelector('#uptime');
|
|
|
|
let started = document.querySelector('#started');
|
2020-12-31 17:41:02 +00:00
|
|
|
let startedUTC;
|
|
|
|
let startedLocal;
|
2020-12-14 21:52:46 +00:00
|
|
|
|
2020-12-15 23:17:41 +00:00
|
|
|
if (started != null) {
|
2021-04-17 21:20:23 +00:00
|
|
|
startedUTC = '{{ data['server_stats']['started'] }}';
|
|
|
|
console.log('started utc:', startedUTC);
|
2020-12-15 23:17:41 +00:00
|
|
|
startedUTC = moment.utc(startedUTC, 'YYYY-MM-DD HH:mm:ss');
|
|
|
|
|
|
|
|
let browserUTCOffset = moment().utcOffset(); // This is in minutes
|
|
|
|
|
2020-12-31 17:41:02 +00:00
|
|
|
startedLocal = startedUTC.utcOffset(browserUTCOffset);
|
|
|
|
startedLocalFormatted = startedLocal.format('YYYY-MM-DD HH:mm:ss');
|
2020-12-15 23:17:41 +00:00
|
|
|
|
2021-04-17 21:20:23 +00:00
|
|
|
console.log('started local time:', startedLocalFormatted);
|
2020-12-15 23:17:41 +00:00
|
|
|
|
2020-12-31 17:41:02 +00:00
|
|
|
started.textContent = startedLocalFormatted
|
2020-12-15 23:17:41 +00:00
|
|
|
}
|
|
|
|
|
2021-04-17 21:20:23 +00:00
|
|
|
var calculateUptime = () => {
|
|
|
|
var msdiff = moment()
|
|
|
|
.diff(startedLocal);
|
2020-12-14 21:52:46 +00:00
|
|
|
var diff = moment.duration(msdiff);
|
|
|
|
|
|
|
|
uptime.textContent = durationToHumanizedString(diff);
|
2021-04-17 21:20:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (uptime != null && started != null) {
|
2020-12-31 17:41:02 +00:00
|
|
|
|
|
|
|
console.log('startedLocal', startedLocal)
|
|
|
|
if (startedLocal) {
|
2021-04-17 21:20:23 +00:00
|
|
|
calculateUptime()
|
|
|
|
var uptimeLoop = setInterval(calculateUptime, 1000)
|
2020-12-31 17:41:02 +00:00
|
|
|
}
|
2020-12-14 21:52:46 +00:00
|
|
|
}
|
|
|
|
|
2021-11-19 22:01:47 +00:00
|
|
|
initParser('input_motd', 'input_motd');
|
|
|
|
|
2020-12-14 21:52:46 +00:00
|
|
|
});
|
2020-12-14 15:59:59 +00:00
|
|
|
</script>
|