Added a try catch to the loading to inform user

This commit is contained in:
Rsl1122 2019-08-26 11:46:11 +03:00
parent f2b6040469
commit 1bc8fbed42
4 changed files with 556 additions and 524 deletions

View File

@ -815,162 +815,170 @@
<script src="js/network-values.js"></script> <script src="js/network-values.js"></script>
<script> <script>
setLoadingText('Calculating values..'); try {
jsonRequest("../v1/network/overview", loadNetworkOverviewValues); setLoadingText('Calculating values..');
jsonRequest("../v1/network/servers", loadServerBoxes); jsonRequest("../v1/network/overview", loadNetworkOverviewValues);
jsonRequest("../v1/network/sessionsOverview", loadSessionValues); jsonRequest("../v1/network/servers", loadServerBoxes);
jsonRequest("../v1/network/playerbaseOverview", loadPlayerbaseOverviewValues); jsonRequest("../v1/network/sessionsOverview", loadSessionValues);
jsonRequest("../v1/sessions", loadSessionAccordion); jsonRequest("../v1/network/playerbaseOverview", loadPlayerbaseOverviewValues);
setLoadingText('Rendering graphs..'); jsonRequest("../v1/sessions", loadSessionAccordion);
setLoadingText('Rendering graphs..');
var v = { var v = {
colors: { colors: {
playersOnline: '${playersGraphColor}', playersOnline: '${playersGraphColor}',
newPlayers: '#8BC34A', newPlayers: '#8BC34A',
geolocationsLow: '${worldMapColLow}', geolocationsLow: '${worldMapColLow}',
geolocationsHigh: '${worldMapColHigh}', geolocationsHigh: '${worldMapColHigh}',
maxPing: '${maxPingColor}', maxPing: '${maxPingColor}',
minPing: '${minPingColor}', minPing: '${minPingColor}',
avgPing: '${avgPingColor}' avgPing: '${avgPingColor}'
}
};
// HighCharts Series
var s = {
name: {
playersOnline: 'Players Online',
uniquePlayers: 'Unique Players',
newPlayers: 'New Players',
maxPing: 'Worst Ping',
minPing: 'Best Ping',
avgPing: 'Average Ping'
},
tooltip: {
twoDecimals: {
valueDecimals: 2
},
zeroDecimals: {
valueDecimals: 0
} }
}, };
type: {
areaSpline: 'areaspline',
spline: 'spline'
}
};
jsonRequest("../v1/graph?type=playersOnline&server=${serverUUID}", function (data, error) { // HighCharts Series
if (data) { var s = {
var series = { name: {
playersOnline: { playersOnline: 'Players Online',
name: s.name.playersOnline, type: s.type.areaSpline, tooltip: s.tooltip.zeroDecimals, uniquePlayers: 'Unique Players',
data: data.playersOnline, color: v.colors.playersOnline, yAxis: 0 newPlayers: 'New Players',
maxPing: 'Worst Ping',
minPing: 'Best Ping',
avgPing: 'Average Ping'
},
tooltip: {
twoDecimals: {
valueDecimals: 2
},
zeroDecimals: {
valueDecimals: 0
} }
}; },
playersChart('playersOnlineChart', series.playersOnline, 2); type: {
} else if (error) { areaSpline: 'areaspline',
$('#playersOnlineChart').text("Failed to load graph data: " + error); spline: 'spline'
}
};
jsonRequest("../v1/graph?type=playersOnline&server=${serverUUID}", function (data, error) {
if (data) {
var series = {
playersOnline: {
name: s.name.playersOnline, type: s.type.areaSpline, tooltip: s.tooltip.zeroDecimals,
data: data.playersOnline, color: v.colors.playersOnline, yAxis: 0
}
};
playersChart('playersOnlineChart', series.playersOnline, 2);
} else if (error) {
$('#playersOnlineChart').text("Failed to load graph data: " + error);
}
});
jsonRequest("../v1/graph?type=uniqueAndNew", function (data, error) {
if (data) {
var uniquePlayers = {
name: s.name.uniquePlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.uniquePlayers, color: v.colors.playersOnline
};
var newPlayers = {
name: s.name.newPlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.newPlayers, color: v.colors.newPlayers
};
lineChart('uniqueChart', [uniquePlayers, newPlayers]);
} else if (error) {
$('#uniqueChart').text("Failed to load graph data: " + error)
}
});
jsonRequest("../v1/graph?type=serverPie", function (json, error) {
if (data) {
serverPieSeries = {
name: 'Server Playtime',
colorByPoint: true,
colors: json.server_pie_colors,
data: json.server_pie_series_30d
};
serverPie('serverPie', serverPieSeries);
} else if (error) {
$('#serverPie').text("Failed to load graph data: " + error)
}
});
jsonRequest("../v1/graph?type=activity", function (json, error) {
if (json) {
activityPie('activityPie', {
name: 'Players', colorByPoint: true, data: json.activity_pie_series
});
stackChart('activityStackGraph', json.activity_labels, json.activity_series, 'Players');
} else if (error) {
$('#activityPie').text("Failed to load graph data: " + error);
$('#activityStackGraph').text("Failed to load graph data: " + error);
}
});
jsonRequest("../v1/graph?type=geolocation", function (json, error) {
if (json) {
var geolocationSeries = {
name: 'Players',
type: 'map',
mapData: Highcharts.maps['custom/world'],
data: json.geolocation_series,
joinBy: ['iso-a3', 'code']
};
var geolocationBarSeries = {
color: '#4CAF50',
name: 'Players',
data: json.geolocation_bar_series.map(function (bar) {
return bar.value
})
};
var geolocationBarCategories = json.geolocation_bar_series.map(function (bar) {
return bar.label
});
worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, geolocationSeries);
horizontalBarChart('countryBarChart', geolocationBarCategories, [geolocationBarSeries], 'Players');
} else if (error) {
$('#worldMap').text("Failed to load graph data: " + error);
$('#countryBarChart').text("Failed to load graph data: " + error);
}
});
setLoadingText('Sorting out plugin tables..');
jsonRequest("../v1/network/pingTable", loadPingTable);
$('.server-name').text('${networkDisplayName}');
$('.player-plugin-table').DataTable({
responsive: true
});
setLoadingText('Almost done..');
var navButtons = document.getElementsByClassName("nav-button");
var tabs = document.getElementsByClassName("tab");
var slideIndex = window.sessionStorage.getItem("network_slide_index");
if (slideIndex === null) {
slideIndex = 0;
} }
}); var x = document.getElementById("content");
x.style.transform = "translate3d(0px,0px,0)";
jsonRequest("../v1/graph?type=uniqueAndNew", function (data, error) { x.style.width = "" + navButtons.length * 100 + "%";
if (data) { for (var i = 0; i < navButtons.length; i++) {
var uniquePlayers = { navButtons[i].onclick = openFunc(i);
name: s.name.uniquePlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals, tabs[i].style.width = "" + 100 / navButtons.length + "%";
data: data.uniquePlayers, color: v.colors.playersOnline
};
var newPlayers = {
name: s.name.newPlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.newPlayers, color: v.colors.newPlayers
};
lineChart('uniqueChart', [uniquePlayers, newPlayers]);
} else if (error) {
$('#uniqueChart').text("Failed to load graph data: " + error)
} }
}); x.style.opacity = "1";
openFunc(slideIndex)();
jsonRequest("../v1/graph?type=serverPie", function (json, error) { setLoadingText('Done.');
if (data) { setTimeout(function () {
serverPieSeries = { $('.page-loader').fadeOut();
name: 'Server Playtime', }, 50);
colorByPoint: true, } catch (loadingError) {
colors: json.server_pie_colors, setLoadingText("Error occurred, see Developer Console (Ctrl+Shift+I) - Please report this: " + loadingError);
data: json.server_pie_series_30d setTimeout(function () {
}; $('.page-loader').fadeOut();
serverPie('serverPie', serverPieSeries); }, 10000);
} else if (error) { throw loadingError;
$('#serverPie').text("Failed to load graph data: " + error)
}
});
jsonRequest("../v1/graph?type=activity", function (json, error) {
if (json) {
activityPie('activityPie', {
name: 'Players', colorByPoint: true, data: json.activity_pie_series
});
stackChart('activityStackGraph', json.activity_labels, json.activity_series, 'Players');
} else if (error) {
$('#activityPie').text("Failed to load graph data: " + error);
$('#activityStackGraph').text("Failed to load graph data: " + error);
}
});
jsonRequest("../v1/graph?type=geolocation", function (json, error) {
if (json) {
var geolocationSeries = {
name: 'Players',
type: 'map',
mapData: Highcharts.maps['custom/world'],
data: json.geolocation_series,
joinBy: ['iso-a3', 'code']
};
var geolocationBarSeries = {
color: '#4CAF50',
name: 'Players',
data: json.geolocation_bar_series.map(function (bar) {
return bar.value
})
};
var geolocationBarCategories = json.geolocation_bar_series.map(function (bar) {
return bar.label
});
worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, geolocationSeries);
horizontalBarChart('countryBarChart', geolocationBarCategories, [geolocationBarSeries], 'Players');
} else if (error) {
$('#worldMap').text("Failed to load graph data: " + error);
$('#countryBarChart').text("Failed to load graph data: " + error);
}
});
setLoadingText('Sorting out plugin tables..');
jsonRequest("../v1/network/pingTable", loadPingTable);
$('.server-name').text('${networkDisplayName}');
$('.player-plugin-table').DataTable({
responsive: true
});
setLoadingText('Almost done..');
var navButtons = document.getElementsByClassName("nav-button");
var tabs = document.getElementsByClassName("tab");
var slideIndex = window.sessionStorage.getItem("network_slide_index");
if (slideIndex === null) {
slideIndex = 0;
} }
var x = document.getElementById("content");
x.style.transform = "translate3d(0px,0px,0)";
x.style.width = "" + navButtons.length * 100 + "%";
for (var i = 0; i < navButtons.length; i++) {
navButtons[i].onclick = openFunc(i);
tabs[i].style.width = "" + 100 / navButtons.length + "%";
}
x.style.opacity = "1";
openFunc(slideIndex)();
setLoadingText('Done.');
setTimeout(function () {
$('.page-loader').fadeOut();
}, 50);
function openFunc(i) { function openFunc(i) {
return function () { return function () {

View File

@ -737,67 +737,75 @@
<script src="js/player-values.js"></script> <script src="js/player-values.js"></script>
<script> <script>
setLoadingText('Loading player values..'); try {
jsonRequest("../v1/player?player=${playerName}", function (json, error) { setLoadingText('Loading player values..');
loadPlayerOverviewValues(json, error); jsonRequest("../v1/player?player=${playerName}", function (json, error) {
loadSessionAccordion(json, error); loadPlayerOverviewValues(json, error);
loadServerAccordion(json, error); loadSessionAccordion(json, error);
loadPlayerKills(json, error); loadServerAccordion(json, error);
loadPlayerDeaths(json, error); loadPlayerKills(json, error);
loadPvPPvEValues(json, error); loadPlayerDeaths(json, error);
if (json) { loadPvPPvEValues(json, error);
var series = { if (json) {
worldPie: { var series = {
name: 'World Playtime', worldPie: {
colorByPoint: true, name: 'World Playtime',
data: json.world_pie_series colorByPoint: true,
}, data: json.world_pie_series
worldPieGMs: json.gm_series, },
punchCard: { worldPieGMs: json.gm_series,
name: 'Relative Activity', punchCard: {
color: '#222', name: 'Relative Activity',
data: json.punchcard_series color: '#222',
}, data: json.punchcard_series
serverPie: { },
name: 'Server Playtime', serverPie: {
colorByPoint: true, name: 'Server Playtime',
colors: json.server_pie_colors, colorByPoint: true,
data: json.server_pie_series colors: json.server_pie_colors,
} data: json.server_pie_series
}; }
punchCard("punchCard", series.punchCard); };
worldPie("worldPie", series.worldPie, series.worldPieGMs); punchCard("punchCard", series.punchCard);
serverPie('serverPie', series.serverPie); worldPie("worldPie", series.worldPie, series.worldPieGMs);
sessionCalendar("#sessionCalendar", json.calendar_series, json.first_day); serverPie('serverPie', series.serverPie);
} else if (error) { sessionCalendar("#sessionCalendar", json.calendar_series, json.first_day);
$('#punchCard').text("Failed to load graph data: " + error); } else if (error) {
$('#worldPie').text("Failed to load graph data: " + error); $('#punchCard').text("Failed to load graph data: " + error);
$('#serverPie').text("Failed to load graph data: " + error); $('#worldPie').text("Failed to load graph data: " + error);
$('#sessionCalendar').text("Failed to load calendar data: " + error) $('#serverPie').text("Failed to load graph data: " + error);
$('#sessionCalendar').text("Failed to load calendar data: " + error)
}
});
setLoadingText('Rendering graphs..');
setLoadingText('Sorting players table..');
setLoadingText('Almost done..');
var navButtons = document.getElementsByClassName("nav-button");
var tabs = document.getElementsByClassName("tab");
var slideIndex = window.sessionStorage.getItem("player_slide_index");
if (slideIndex === null) {
slideIndex = 0;
} }
}); var x = document.getElementById("content");
setLoadingText('Rendering graphs..'); x.style.transform = "translate3d(0px,0px,0)";
setLoadingText('Sorting players table..'); x.style.width = "" + navButtons.length * 100 + "%";
setLoadingText('Almost done..'); for (var i = 0; i < navButtons.length; i++) {
var navButtons = document.getElementsByClassName("nav-button"); navButtons[i].onclick = openFunc(i);
var tabs = document.getElementsByClassName("tab"); tabs[i].style.width = "" + 100 / navButtons.length + "%";
var slideIndex = window.sessionStorage.getItem("player_slide_index"); }
if (slideIndex === null) { x.style.opacity = "1";
slideIndex = 0; openFunc(slideIndex)();
setLoadingText('Done.');
setTimeout(function () {
$('.page-loader').fadeOut();
}, 50);
} catch (loadingError) {
setLoadingText("Error occurred, see Developer Console (Ctrl+Shift+I) - Please report this: " + loadingError);
setTimeout(function () {
$('.page-loader').fadeOut();
}, 10000);
throw loadingError;
} }
var x = document.getElementById("content");
x.style.transform = "translate3d(0px,0px,0)";
x.style.width = "" + navButtons.length * 100 + "%";
for (var i = 0; i < navButtons.length; i++) {
navButtons[i].onclick = openFunc(i);
tabs[i].style.width = "" + 100 / navButtons.length + "%";
}
x.style.opacity = "1";
openFunc(slideIndex)();
setLoadingText('Done.');
setTimeout(function () {
$('.page-loader').fadeOut();
}, 50);
function openFunc(i) { function openFunc(i) {
return function () { return function () {

View File

@ -271,21 +271,29 @@
<script src="js/color-selector.js"></script> <script src="js/color-selector.js"></script>
<script> <script>
jsonRequest("../v1/players", function (playersTableJson, error) { try {
if (playersTableJson) { jsonRequest("../v1/players", function (playersTableJson, error) {
$('.player-table').DataTable({ if (playersTableJson) {
responsive: true, $('.player-table').DataTable({
columns: playersTableJson.columns, responsive: true,
data: playersTableJson.data, columns: playersTableJson.columns,
order: [[5, "desc"]] data: playersTableJson.data,
}) order: [[5, "desc"]]
} else if (error) { })
$('.player-table').DataTable({ } else if (error) {
columns: [{title: "Error"}], $('.player-table').DataTable({
data: [["Failed to load Players table data: " + error]] columns: [{title: "Error"}],
}) data: [["Failed to load Players table data: " + error]]
} })
}); }
});
} catch (loadingError) {
window.alert("Error occurred, see Developer Console (Ctrl+Shift+I) - Please report this: " + loadingError);
setTimeout(function () {
$('.page-loader').fadeOut();
}, 10000);
throw loadingError;
}
</script> </script>
</body> </body>

View File

@ -1290,323 +1290,331 @@
<script src="js/server-values.js"></script> <script src="js/server-values.js"></script>
<script> <script>
var x = document.getElementById("content"); try {
var x = document.getElementById("content");
setLoadingText('Calculating values..'); setLoadingText('Calculating values..');
jsonRequest("../v1/serverOverview?server=${serverName}", loadServerOverviewValues); jsonRequest("../v1/serverOverview?server=${serverName}", loadServerOverviewValues);
jsonRequest("../v1/onlineOverview?server=${serverName}", loadOnlineActivityOverviewValues); jsonRequest("../v1/onlineOverview?server=${serverName}", loadOnlineActivityOverviewValues);
jsonRequest("../v1/sessionsOverview?server=${serverName}", loadSessionValues); jsonRequest("../v1/sessionsOverview?server=${serverName}", loadSessionValues);
jsonRequest("../v1/playerVersus?server=${serverName}", loadPvPPvEValues); jsonRequest("../v1/playerVersus?server=${serverName}", loadPvPPvEValues);
jsonRequest("../v1/playerbaseOverview?server=${serverName}", loadPlayerbaseOverviewValues); jsonRequest("../v1/playerbaseOverview?server=${serverName}", loadPlayerbaseOverviewValues);
jsonRequest("../v1/performanceOverview?server=${serverName}", loadPerformanceValues); jsonRequest("../v1/performanceOverview?server=${serverName}", loadPerformanceValues);
setLoadingText('Rendering graphs..'); setLoadingText('Rendering graphs..');
// TODO remove // TODO remove
var v = { var v = {
colors: { colors: {
playersOnline: '${playersGraphColor}', playersOnline: '${playersGraphColor}',
newPlayers: '#8BC34A', newPlayers: '#8BC34A',
tpsLow: '${tpsLowColor}', tpsLow: '${tpsLowColor}',
tpsMed: '${tpsMediumColor}', tpsMed: '${tpsMediumColor}',
tpsHigh: '${tpsHighColor}', tpsHigh: '${tpsHighColor}',
cpu: '#e0d264', cpu: '#e0d264',
ram: '#7dcc24', ram: '#7dcc24',
entities: '#ac69ef', entities: '#ac69ef',
chunks: '#b58310', chunks: '#b58310',
geolocationsLow: '${worldMapColLow}', geolocationsLow: '${worldMapColLow}',
geolocationsHigh: '${worldMapColHigh}', geolocationsHigh: '${worldMapColHigh}',
punchCard: '#222', punchCard: '#222',
maxPing: '${maxPingColor}', maxPing: '${maxPingColor}',
minPing: '${minPingColor}', minPing: '${minPingColor}',
avgPing: '${avgPingColor}' avgPing: '${avgPingColor}'
},
values: {
tpsMed: ${tpsMedium},
tpsHigh: ${tpsHigh},
diskMed: ${diskMedium},
diskHigh: ${diskHigh},
firstDay: ${firstDay},
timezoneOffset: ${timeZone}
}
};
Highcharts.setOptions({lang: {noData: "No Data to Display"}, time: {timezoneOffset: v.timezoneOffset * 60}});
// HighCharts Series
var s = {
name: {
playersOnline: 'Players Online',
uniquePlayers: 'Unique Players',
newPlayers: 'New Players',
tps: 'TPS',
cpu: 'CPU Usage (%)',
ram: 'RAM Usage (Mb)',
entities: 'Loaded Entities',
chunks: 'Loaded Chunks',
maxPing: 'Worst Ping',
minPing: 'Best Ping',
avgPing: 'Average Ping',
disk: 'Free Disk Space (Mb)'
},
tooltip: {
twoDecimals: {
valueDecimals: 2
}, },
zeroDecimals: { values: {
valueDecimals: 0 tpsMed: ${tpsMedium},
tpsHigh: ${tpsHigh},
diskMed: ${diskMedium},
diskHigh: ${diskHigh},
firstDay: ${firstDay},
timezoneOffset: ${timeZone}
} }
}, };
type: {
areaSpline: 'areaspline',
spline: 'spline'
},
zones: {
tps: [{
value: v.values.tpsMed,
color: v.colors.tpsLow
}, {
value: v.values.tpsHigh,
color: v.colors.tpsMed
}, {
value: 30,
color: v.colors.tpsHigh
}],
disk: [{
value: v.values.diskMed,
color: v.colors.tpsLow
}, {
value: v.values.diskHigh,
color: v.colors.tpsMed
}, {
value: Number.MAX_VALUE,
color: v.colors.tpsHigh
}]
}
};
jsonRequest("../v1/graph?type=performance&server=${serverName}", function (data, error) { Highcharts.setOptions({lang: {noData: "No Data to Display"}, time: {timezoneOffset: v.timezoneOffset * 60}});
if (data) {
var series = { // HighCharts Series
playersOnline: { var s = {
name: s.name.playersOnline, type: s.type.areaSpline, tooltip: s.tooltip.zeroDecimals, name: {
data: data.playersOnline, color: v.colors.playersOnline, yAxis: 0 playersOnline: 'Players Online',
uniquePlayers: 'Unique Players',
newPlayers: 'New Players',
tps: 'TPS',
cpu: 'CPU Usage (%)',
ram: 'RAM Usage (Mb)',
entities: 'Loaded Entities',
chunks: 'Loaded Chunks',
maxPing: 'Worst Ping',
minPing: 'Best Ping',
avgPing: 'Average Ping',
disk: 'Free Disk Space (Mb)'
},
tooltip: {
twoDecimals: {
valueDecimals: 2
}, },
tps: { zeroDecimals: {
name: s.name.tps, type: s.type.spline, color: v.colors.tpsHigh, valueDecimals: 0
zones: s.zones.tps, tooltip: s.tooltip.twoDecimals, data: data.tps,
yAxis: 1
},
cpu: {
name: s.name.cpu, type: s.type.spline, tooltip: s.tooltip.twoDecimals,
data: data.cpu, color: v.colors.cpu, yAxis: 2
},
cpu_alt: {
name: s.name.cpu, type: s.type.spline, tooltip: s.tooltip.twoDecimals,
data: data.cpu, color: v.colors.cpu, yAxis: 1
},
ram: {
name: s.name.ram, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.ram, color: v.colors.ram, yAxis: 3
},
ram_alt: {
name: s.name.ram, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.ram, color: v.colors.ram, yAxis: 2
},
entities: {
name: s.name.entities, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.entities, color: v.colors.entities, yAxis: 4
},
entities_alt: {
name: s.name.entities, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.entities, color: v.colors.entities, yAxis: 1
},
chunks: {
name: s.name.chunks, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.chunks, color: v.colors.chunks, yAxis: 5
},
chunks_alt: {
name: s.name.chunks, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.chunks, color: v.colors.chunks, yAxis: 2
},
disk: {
name: s.name.disk, type: s.type.spline, color: v.colors.tpsHigh,
zones: s.zones.disk, tooltip: s.tooltip.zeroDecimals, data: data.disk
} }
}; },
playersChart('playersOnlineChart', series.playersOnline, 2); type: {
performanceChart('performanceGraph', series.playersOnline, series.tps, series.cpu, series.ram, series.entities, series.chunks); areaSpline: 'areaspline',
tpsChart('tpsGraph', series.tps, series.playersOnline); spline: 'spline'
resourceChart('resourceGraph', series.cpu_alt, series.ram_alt, series.playersOnline); },
worldChart('worldGraph', series.entities_alt, series.chunks_alt, series.playersOnline); zones: {
diskChart('diskGraph', [series.disk]); tps: [{
} else if (error) { value: v.values.tpsMed,
$('#playersOnlineChart').text("Failed to load graph data: " + error); color: v.colors.tpsLow
$('#performanceGraph').text("Failed to load graph data: " + error); }, {
$('#tpsGraph').text("Failed to load graph data: " + error); value: v.values.tpsHigh,
$('#resourceGraph').text("Failed to load graph data: " + error); color: v.colors.tpsMed
$('#worldGraph').text("Failed to load graph data: " + error); }, {
$('#diskGraph').text("Failed to load graph data: " + error); value: 30,
} color: v.colors.tpsHigh
}); }],
disk: [{
value: v.values.diskMed,
color: v.colors.tpsLow
}, {
value: v.values.diskHigh,
color: v.colors.tpsMed
}, {
value: Number.MAX_VALUE,
color: v.colors.tpsHigh
}]
}
};
jsonRequest("../v1/graph?type=aggregatedPing&server=${serverName}", function (json, error) { jsonRequest("../v1/graph?type=performance&server=${serverName}", function (data, error) {
if (json) { if (data) {
var series = { var series = {
avgPing: { playersOnline: {
name: s.name.avgPing, name: s.name.playersOnline, type: s.type.areaSpline, tooltip: s.tooltip.zeroDecimals,
type: s.type.spline, data: data.playersOnline, color: v.colors.playersOnline, yAxis: 0
tooltip: s.tooltip.twoDecimals, },
data: json.avg_ping_series, tps: {
color: v.colors.avgPing name: s.name.tps, type: s.type.spline, color: v.colors.tpsHigh,
}, zones: s.zones.tps, tooltip: s.tooltip.twoDecimals, data: data.tps,
maxPing: { yAxis: 1
name: s.name.maxPing, },
type: s.type.spline, cpu: {
tooltip: s.tooltip.zeroDecimals, name: s.name.cpu, type: s.type.spline, tooltip: s.tooltip.twoDecimals,
data: json.max_ping_series, data: data.cpu, color: v.colors.cpu, yAxis: 2
color: v.colors.maxPing },
}, cpu_alt: {
minPing: { name: s.name.cpu, type: s.type.spline, tooltip: s.tooltip.twoDecimals,
name: s.name.minPing, data: data.cpu, color: v.colors.cpu, yAxis: 1
type: s.type.spline, },
tooltip: s.tooltip.zeroDecimals, ram: {
data: json.min_ping_series, name: s.name.ram, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
color: v.colors.minPing data: data.ram, color: v.colors.ram, yAxis: 3
} },
}; ram_alt: {
lineChart('pingGraph', [series.avgPing, series.maxPing, series.minPing]); name: s.name.ram, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
} else if (error) { data: data.ram, color: v.colors.ram, yAxis: 2
$('#pingGraph').text("Failed to load graph data: " + error); },
} entities: {
}); name: s.name.entities, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.entities, color: v.colors.entities, yAxis: 4
},
entities_alt: {
name: s.name.entities, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.entities, color: v.colors.entities, yAxis: 1
},
chunks: {
name: s.name.chunks, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.chunks, color: v.colors.chunks, yAxis: 5
},
chunks_alt: {
name: s.name.chunks, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.chunks, color: v.colors.chunks, yAxis: 2
},
disk: {
name: s.name.disk, type: s.type.spline, color: v.colors.tpsHigh,
zones: s.zones.disk, tooltip: s.tooltip.zeroDecimals, data: data.disk
}
};
playersChart('playersOnlineChart', series.playersOnline, 2);
performanceChart('performanceGraph', series.playersOnline, series.tps, series.cpu, series.ram, series.entities, series.chunks);
tpsChart('tpsGraph', series.tps, series.playersOnline);
resourceChart('resourceGraph', series.cpu_alt, series.ram_alt, series.playersOnline);
worldChart('worldGraph', series.entities_alt, series.chunks_alt, series.playersOnline);
diskChart('diskGraph', [series.disk]);
} else if (error) {
$('#playersOnlineChart').text("Failed to load graph data: " + error);
$('#performanceGraph').text("Failed to load graph data: " + error);
$('#tpsGraph').text("Failed to load graph data: " + error);
$('#resourceGraph').text("Failed to load graph data: " + error);
$('#worldGraph').text("Failed to load graph data: " + error);
$('#diskGraph').text("Failed to load graph data: " + error);
}
});
jsonRequest("../v1/graph?type=worldPie&server=${serverName}", function (json, error) { jsonRequest("../v1/graph?type=aggregatedPing&server=${serverName}", function (json, error) {
if (json) { if (json) {
var worldSeries = {name: 'World Playtime', colorByPoint: true, data: json.world_series}; var series = {
var gmSeries = json.gm_series; avgPing: {
worldPie("worldPie", worldSeries, gmSeries); name: s.name.avgPing,
} else if (error) { type: s.type.spline,
$('#worldPie').text("Failed to load graph data: " + error) tooltip: s.tooltip.twoDecimals,
} data: json.avg_ping_series,
}); color: v.colors.avgPing
},
maxPing: {
name: s.name.maxPing,
type: s.type.spline,
tooltip: s.tooltip.zeroDecimals,
data: json.max_ping_series,
color: v.colors.maxPing
},
minPing: {
name: s.name.minPing,
type: s.type.spline,
tooltip: s.tooltip.zeroDecimals,
data: json.min_ping_series,
color: v.colors.minPing
}
};
lineChart('pingGraph', [series.avgPing, series.maxPing, series.minPing]);
} else if (error) {
$('#pingGraph').text("Failed to load graph data: " + error);
}
});
jsonRequest("../v1/graph?type=activity&server=${serverName}", function (json, error) { jsonRequest("../v1/graph?type=worldPie&server=${serverName}", function (json, error) {
if (json) { if (json) {
activityPie('activityPie', { var worldSeries = {name: 'World Playtime', colorByPoint: true, data: json.world_series};
name: 'Players', colorByPoint: true, data: json.activity_pie_series var gmSeries = json.gm_series;
}); worldPie("worldPie", worldSeries, gmSeries);
stackChart('activityStackGraph', json.activity_labels, json.activity_series, 'Players'); } else if (error) {
} else if (error) { $('#worldPie').text("Failed to load graph data: " + error)
$('#activityPie').text("Failed to load graph data: " + error); }
$('#activityStackGraph').text("Failed to load graph data: " + error); });
}
});
jsonRequest("../v1/graph?type=geolocation&server=${serverName}", function (json, error) { jsonRequest("../v1/graph?type=activity&server=${serverName}", function (json, error) {
if (json) { if (json) {
var geolocationSeries = { activityPie('activityPie', {
name: 'Players', name: 'Players', colorByPoint: true, data: json.activity_pie_series
type: 'map', });
mapData: Highcharts.maps['custom/world'], stackChart('activityStackGraph', json.activity_labels, json.activity_series, 'Players');
data: json.geolocation_series, } else if (error) {
joinBy: ['iso-a3', 'code'] $('#activityPie').text("Failed to load graph data: " + error);
}; $('#activityStackGraph').text("Failed to load graph data: " + error);
var geolocationBarSeries = { }
color: '#4CAF50', });
name: 'Players',
data: json.geolocation_bar_series.map(function (bar) { jsonRequest("../v1/graph?type=geolocation&server=${serverName}", function (json, error) {
return bar.value if (json) {
var geolocationSeries = {
name: 'Players',
type: 'map',
mapData: Highcharts.maps['custom/world'],
data: json.geolocation_series,
joinBy: ['iso-a3', 'code']
};
var geolocationBarSeries = {
color: '#4CAF50',
name: 'Players',
data: json.geolocation_bar_series.map(function (bar) {
return bar.value
})
};
var geolocationBarCategories = json.geolocation_bar_series.map(function (bar) {
return bar.label
});
worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, geolocationSeries);
horizontalBarChart('countryBarChart', geolocationBarCategories, [geolocationBarSeries], 'Players');
} else if (error) {
$('#worldMap').text("Failed to load graph data: " + error);
$('#countryBarChart').text("Failed to load graph data: " + error);
}
});
jsonRequest("../v1/graph?type=uniqueAndNew&server=${serverName}", function (data, error) {
if (data) {
var uniquePlayers = {
name: s.name.uniquePlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.uniquePlayers, color: v.colors.playersOnline
};
var newPlayers = {
name: s.name.newPlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.newPlayers, color: v.colors.newPlayers
};
lineChart('uniqueChart', [uniquePlayers, newPlayers]);
} else if (error) {
$('#uniqueChart').text("Failed to load graph data: " + error)
}
});
jsonRequest("../v1/graph?type=serverCalendar&server=${serverName}", function (json, error) {
if (json) {
var clicked = false;
$('#online-calendar-tab').click(function () {
if (!clicked) {
onlineActivityCalendar('#calendar', json.data, json.firstDay);
clicked = true;
}
});
$('#calendar').text('');
} else if (error) {
$('#calendar').text("Failed to load calendar data: " + error)
}
});
jsonRequest("../v1/graph?type=punchCard&server=${serverName}", function (json, error) {
if (json) {
var punchCardSeries = {
name: 'Relative Join Activity',
color: v.colors.punchCard,
data: json.punchCard
};
punchCard('punchCard', punchCardSeries);
} else if (error) {
$('#punchCard').text("Failed to load graph data: " + error)
}
});
setLoadingText('Sorting players table..');
jsonRequest("../v1/players?server=${serverName}", function (playersTableJson, error) {
if (playersTableJson) {
$('.player-table').DataTable({
responsive: true,
columns: playersTableJson.columns,
data: playersTableJson.data,
order: [[5, "desc"]]
}) })
}; } else if (error) {
var geolocationBarCategories = json.geolocation_bar_series.map(function (bar) { $('.player-table').DataTable({
return bar.label columns: [{title: "Error"}],
}); data: [["Failed to load Players table data: " + error]]
worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, geolocationSeries); })
horizontalBarChart('countryBarChart', geolocationBarCategories, [geolocationBarSeries], 'Players'); }
} else if (error) { });
$('#worldMap').text("Failed to load graph data: " + error); jsonRequest("../v1/kills?server=${serverName}", loadPlayerKills);
$('#countryBarChart').text("Failed to load graph data: " + error); jsonRequest("../v1/pingTable?server=${serverName}", loadPingTable);
}
});
jsonRequest("../v1/graph?type=uniqueAndNew&server=${serverName}", function (data, error) { $('.server-name').text('${serverName}');
if (data) { $('.player-plugin-table').DataTable({
var uniquePlayers = { responsive: true
name: s.name.uniquePlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals, });
data: data.uniquePlayers, color: v.colors.playersOnline
};
var newPlayers = {
name: s.name.newPlayers, type: s.type.spline, tooltip: s.tooltip.zeroDecimals,
data: data.newPlayers, color: v.colors.newPlayers
};
lineChart('uniqueChart', [uniquePlayers, newPlayers]);
} else if (error) {
$('#uniqueChart').text("Failed to load graph data: " + error)
}
});
jsonRequest("../v1/graph?type=serverCalendar&server=${serverName}", function (json, error) { setLoadingText('Almost done..');
if (json) { openPageFunc();
var clicked = false;
$('#online-calendar-tab').click(function () {
if (!clicked) {
onlineActivityCalendar('#calendar', json.data, json.firstDay);
clicked = true;
}
});
$('#calendar').text('');
} else if (error) {
$('#calendar').text("Failed to load calendar data: " + error)
}
});
jsonRequest("../v1/graph?type=punchCard&server=${serverName}", function (json, error) { jsonRequest("../v1/sessions?server=${serverName}", loadSessionAccordion);
if (json) {
var punchCardSeries = {
name: 'Relative Join Activity',
color: v.colors.punchCard,
data: json.punchCard
};
punchCard('punchCard', punchCardSeries);
} else if (error) {
$('#punchCard').text("Failed to load graph data: " + error)
}
});
setLoadingText('Sorting players table..'); setLoadingText('Done.');
setTimeout(function () {
jsonRequest("../v1/players?server=${serverName}", function (playersTableJson, error) { $('.page-loader').fadeOut();
if (playersTableJson) { }, 50);
$('.player-table').DataTable({ } catch (loadingError) {
responsive: true, setLoadingText("Error occurred, see Developer Console (Ctrl+Shift+I) - Please report this: " + loadingError);
columns: playersTableJson.columns, setTimeout(function () {
data: playersTableJson.data, $('.page-loader').fadeOut();
order: [[5, "desc"]] }, 10000);
}) throw loadingError;
} else if (error) { }
$('.player-table').DataTable({
columns: [{title: "Error"}],
data: [["Failed to load Players table data: " + error]]
})
}
});
jsonRequest("../v1/kills?server=${serverName}", loadPlayerKills);
jsonRequest("../v1/pingTable?server=${serverName}", loadPingTable);
$('.server-name').text('${serverName}');
$('.player-plugin-table').DataTable({
responsive: true
});
setLoadingText('Almost done..');
openPageFunc();
jsonRequest("../v1/sessions?server=${serverName}", loadSessionAccordion);
setLoadingText('Done.');
setTimeout(function () {
$('.page-loader').fadeOut();
}, 50);
function openPageFunc() { function openPageFunc() {
var navButtons = document.getElementsByClassName("nav-button"); var navButtons = document.getElementsByClassName("nav-button");