2018-09-16 16:34:16 -04:00
|
|
|
|
function getPlayerHistoryChart(playerHistory, i, width, color, maxClients) {
|
2018-02-21 20:29:23 -05:00
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
// thanks to canvasjs :(
|
|
|
|
|
playerHistory.forEach(function (item, i) {
|
2021-08-29 14:10:10 -04:00
|
|
|
|
playerHistory[i].x = new Date(playerHistory[i].timeString);
|
|
|
|
|
playerHistory[i].y = playerHistory[i].clientCount;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return new CanvasJS.Chart(`server_history_${i}`, {
|
2018-04-05 00:38:45 -04:00
|
|
|
|
backgroundColor: '#191919',
|
2018-02-21 20:29:23 -05:00
|
|
|
|
height: 100,
|
|
|
|
|
width: width,
|
|
|
|
|
animationEnabled: true,
|
|
|
|
|
toolTip: {
|
|
|
|
|
contentFormatter: function (e) {
|
2018-04-02 23:11:19 -04:00
|
|
|
|
const date = moment.utc(e.entries[0].dataPoint.x);
|
2021-08-29 21:47:25 -04:00
|
|
|
|
return date.local().calendar() + " - " + e.entries[0].dataPoint.y + " players";
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
axisX: {
|
|
|
|
|
interval: 1,
|
|
|
|
|
gridThickness: 0,
|
|
|
|
|
lineThickness: 0,
|
|
|
|
|
tickThickness: 0,
|
|
|
|
|
margin: 0,
|
2018-03-27 00:54:20 -04:00
|
|
|
|
valueFormatString: " "
|
2018-02-21 20:29:23 -05:00
|
|
|
|
},
|
|
|
|
|
axisY: {
|
|
|
|
|
gridThickness: 0,
|
|
|
|
|
lineThickness: 0,
|
|
|
|
|
tickThickness: 0,
|
|
|
|
|
minimum: 0,
|
2018-09-16 16:34:16 -04:00
|
|
|
|
maximum: maxClients + 1,
|
2018-02-21 20:29:23 -05:00
|
|
|
|
margin: 0,
|
|
|
|
|
valueFormatString: " ",
|
2018-03-27 00:54:20 -04:00
|
|
|
|
labelMaxWidth: 0
|
2018-02-21 20:29:23 -05:00
|
|
|
|
},
|
|
|
|
|
legend: {
|
|
|
|
|
maxWidth: 0,
|
|
|
|
|
maxHeight: 0,
|
2018-03-27 00:54:20 -04:00
|
|
|
|
dockInsidePlotArea: true
|
2018-02-21 20:29:23 -05:00
|
|
|
|
},
|
|
|
|
|
data: [{
|
|
|
|
|
showInLegend: false,
|
|
|
|
|
type: "splineArea",
|
2018-04-05 00:38:45 -04:00
|
|
|
|
color: color,
|
2018-02-21 20:29:23 -05:00
|
|
|
|
markerSize: 0,
|
2018-03-27 00:54:20 -04:00
|
|
|
|
dataPoints: playerHistory
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}]
|
|
|
|
|
});
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
}
|
|
|
|
|
var charts = {};
|
|
|
|
|
|
|
|
|
|
$(window).resize(function () {
|
|
|
|
|
$('.server-history-row').each(function (index) {
|
|
|
|
|
let serverId = $(this).data('serverid');
|
|
|
|
|
charts[serverId].options.width = $('.server-header').first().width();
|
2018-03-27 00:54:20 -04:00
|
|
|
|
charts[serverId].render();
|
2018-02-21 20:29:23 -05:00
|
|
|
|
});
|
2018-03-27 00:54:20 -04:00
|
|
|
|
});
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
|
|
|
|
function refreshClientActivity() {
|
|
|
|
|
$('.server-history-row').each(function (index) {
|
|
|
|
|
let serverId = $(this).data("serverid");
|
|
|
|
|
|
2018-02-22 01:06:21 -05:00
|
|
|
|
$.get({
|
|
|
|
|
url: "/server/clientactivity/" + serverId,
|
|
|
|
|
cache: false
|
|
|
|
|
})
|
2018-02-21 20:29:23 -05:00
|
|
|
|
.done(function (response) {
|
2019-08-04 18:06:07 -04:00
|
|
|
|
const clientCount = $(response).find('a').length;
|
2018-03-27 20:27:01 -04:00
|
|
|
|
$('#server_header_' + serverId + ' .server-clientcount').text(clientCount);
|
2018-02-21 20:29:23 -05:00
|
|
|
|
$('#server_clientactivity_' + serverId).html(response);
|
|
|
|
|
})
|
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
2019-05-17 10:02:09 -04:00
|
|
|
|
$('#server_clientactivity_' + serverId).html('');
|
2018-02-21 20:29:23 -05:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 15:54:39 -04:00
|
|
|
|
$(document).ready(function () {
|
2019-04-08 13:29:48 -04:00
|
|
|
|
$('.server-join-button').click(function (e) {
|
|
|
|
|
$(this).children('.server-header-ip-address').show();
|
|
|
|
|
});
|
2019-08-10 18:35:34 -04:00
|
|
|
|
|
|
|
|
|
$('.server-history-row').each(function (index, element) {
|
2021-08-29 14:10:10 -04:00
|
|
|
|
let clientHistory = $(this).data('clienthistory-ex');
|
2019-08-10 18:35:34 -04:00
|
|
|
|
let serverId = $(this).data('serverid');
|
|
|
|
|
let maxClients = parseInt($('#server_header_' + serverId + ' .server-maxclients').text());
|
2019-08-18 12:20:19 -04:00
|
|
|
|
let primaryColor = $('title').css('background-color');
|
2019-08-10 18:35:34 -04:00
|
|
|
|
let color = $(this).data('online') === 'True' ? primaryColor : '#ff6060';
|
|
|
|
|
let width = $('.server-header').first().width();
|
|
|
|
|
let historyChart = getPlayerHistoryChart(clientHistory, serverId, width, color, maxClients);
|
|
|
|
|
historyChart.render();
|
|
|
|
|
charts[serverId] = historyChart;
|
|
|
|
|
});
|
2019-07-19 15:54:39 -04:00
|
|
|
|
});
|
2019-04-08 13:29:48 -04:00
|
|
|
|
|
2018-04-02 23:11:19 -04:00
|
|
|
|
setInterval(refreshClientActivity, 2000);
|