merge graph timestamps into single array, use seconds

This commit is contained in:
Nick Krecklow
2020-05-11 04:12:46 -05:00
parent ef0c41ee1d
commit 84004f22be
9 changed files with 64 additions and 100 deletions

View File

@ -81,8 +81,6 @@ export class SocketManager {
break
case 'updateServers': {
let requestGraphRedraw = false
for (let serverId = 0; serverId < payload.updates.length; serverId++) {
// The backend may send "update" events prior to receiving all "add" events
// A server has only been added once it's ServerRegistration is defined
@ -92,28 +90,18 @@ export class SocketManager {
if (serverRegistration) {
serverRegistration.handlePing(serverUpdate, payload.timestamp)
serverRegistration.updateServerStatus(serverUpdate, this._app.publicConfig.minecraftVersions)
}
// Use update payloads to conditionally append data to graph
// Skip any incoming updates if the graph is disabled
if (serverUpdate.updateHistoryGraph && this._app.graphDisplayManager.isVisible) {
// Update may not be successful, safely append 0 points
const playerCount = serverUpdate.playerCount || 0
this._app.graphDisplayManager.addGraphPoint(serverRegistration.serverId, payload.timestamp, playerCount)
// Only redraw the graph if not mutating hidden data
if (serverRegistration.isVisible) {
requestGraphRedraw = true
}
}
}
// Run redraw tasks after handling bulk updates
if (requestGraphRedraw) {
this._app.graphDisplayManager.redraw()
// Bulk add playerCounts into graph during #updateHistoryGraph
if (payload.updateHistoryGraph) {
this._app.graphDisplayManager.addGraphPoint(payload.timestamp, Object.values(payload.updates).map(update => update.playerCount))
// Run redraw tasks after handling bulk updates
if (this._app.graphDisplayManager.isVisible) {
this._app.graphDisplayManager.redraw()
}
}
this._app.percentageBar.redraw()
@ -132,7 +120,7 @@ export class SocketManager {
// This is used for the manual graph load request behavior
this._app.graphDisplayManager.isVisible = true
this._app.graphDisplayManager.buildPlotInstance(payload.graphData)
this._app.graphDisplayManager.buildPlotInstance(payload.timestamps, payload.graphData)
// Build checkbox elements for graph controls
let lastRowCounter = 0