diff --git a/app/Http/Controllers/Admin/StatisticsController.php b/app/Http/Controllers/Admin/StatisticsController.php index a3777e4e7..aedca3d6b 100644 --- a/app/Http/Controllers/Admin/StatisticsController.php +++ b/app/Http/Controllers/Admin/StatisticsController.php @@ -3,6 +3,8 @@ namespace Pterodactyl\Http\Controllers\Admin; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; +use JavaScript; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Models\Allocation; use Pterodactyl\Models\Database; @@ -10,8 +12,6 @@ use Pterodactyl\Models\Egg; use Pterodactyl\Models\Node; use Pterodactyl\Models\Server; use Pterodactyl\Models\User; -use JavaScript; -use Illuminate\Support\Facades\DB; use Pterodactyl\Services\DaemonKeys\DaemonKeyProviderService; class StatisticsController extends Controller @@ -29,7 +29,7 @@ class StatisticsController extends Controller $servers = Server::all(); $nodes = Node::all(); $serversCount = count($servers); - $nodesCount = Node::count(); + $nodesCount = count($nodes); $usersCount = User::count(); $eggsCount = Egg::count(); $databasesCount = Database::count(); @@ -43,7 +43,11 @@ class StatisticsController extends Controller $tokens = []; foreach ($nodes as $node) { - $tokens[$node->id] = $this->keyProviderService->handle($node->servers->get(0), $request->user()); + $server = Server::where('node_id', $node->id)->first(); + if ($server == null) + continue; + + $tokens[$node->id] = $this->keyProviderService->handle($server, $request->user()); } Javascript::put([ diff --git a/public/themes/pterodactyl/js/admin/statistics.js b/public/themes/pterodactyl/js/admin/statistics.js index f2c1c13dd..12f4277bd 100644 --- a/public/themes/pterodactyl/js/admin/statistics.js +++ b/public/themes/pterodactyl/js/admin/statistics.js @@ -61,12 +61,10 @@ var servers = Pterodactyl.servers; var nodes = Pterodactyl.nodes; for (let i = 0; i < servers.length; i++) { - setTimeout(getStatus, 200 * i); + setTimeout(getStatus, 200 * i, servers[i]); } -var index = 0; -function getStatus() { - var server = servers[index]; +function getStatus(server) { var uuid = server.uuid; var node = getNodeByID(server.node_id); @@ -109,13 +107,12 @@ function getStatus() { statusChart.data.datasets[0].data[3]++; statusChart.update(); }); - - index++; } function getNodeByID(id) { for (var i = 0; i < nodes.length; i++) { - if (nodes[i].id === id) + if (nodes[i].id === id) { return nodes[i]; + } } } \ No newline at end of file