Added the server as argument, and improved the bug fix
This commit is contained in:
parent
06a67bb4bb
commit
095d85bb60
2 changed files with 12 additions and 11 deletions
|
@ -3,6 +3,8 @@
|
||||||
namespace Pterodactyl\Http\Controllers\Admin;
|
namespace Pterodactyl\Http\Controllers\Admin;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use JavaScript;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Models\Allocation;
|
use Pterodactyl\Models\Allocation;
|
||||||
use Pterodactyl\Models\Database;
|
use Pterodactyl\Models\Database;
|
||||||
|
@ -10,8 +12,6 @@ use Pterodactyl\Models\Egg;
|
||||||
use Pterodactyl\Models\Node;
|
use Pterodactyl\Models\Node;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use JavaScript;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Pterodactyl\Services\DaemonKeys\DaemonKeyProviderService;
|
use Pterodactyl\Services\DaemonKeys\DaemonKeyProviderService;
|
||||||
|
|
||||||
class StatisticsController extends Controller
|
class StatisticsController extends Controller
|
||||||
|
@ -29,7 +29,7 @@ class StatisticsController extends Controller
|
||||||
$servers = Server::all();
|
$servers = Server::all();
|
||||||
$nodes = Node::all();
|
$nodes = Node::all();
|
||||||
$serversCount = count($servers);
|
$serversCount = count($servers);
|
||||||
$nodesCount = Node::count();
|
$nodesCount = count($nodes);
|
||||||
$usersCount = User::count();
|
$usersCount = User::count();
|
||||||
$eggsCount = Egg::count();
|
$eggsCount = Egg::count();
|
||||||
$databasesCount = Database::count();
|
$databasesCount = Database::count();
|
||||||
|
@ -43,7 +43,11 @@ class StatisticsController extends Controller
|
||||||
|
|
||||||
$tokens = [];
|
$tokens = [];
|
||||||
foreach ($nodes as $node) {
|
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([
|
Javascript::put([
|
||||||
|
|
|
@ -61,12 +61,10 @@ var servers = Pterodactyl.servers;
|
||||||
var nodes = Pterodactyl.nodes;
|
var nodes = Pterodactyl.nodes;
|
||||||
|
|
||||||
for (let i = 0; i < servers.length; i++) {
|
for (let i = 0; i < servers.length; i++) {
|
||||||
setTimeout(getStatus, 200 * i);
|
setTimeout(getStatus, 200 * i, servers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = 0;
|
function getStatus(server) {
|
||||||
function getStatus() {
|
|
||||||
var server = servers[index];
|
|
||||||
var uuid = server.uuid;
|
var uuid = server.uuid;
|
||||||
var node = getNodeByID(server.node_id);
|
var node = getNodeByID(server.node_id);
|
||||||
|
|
||||||
|
@ -109,13 +107,12 @@ function getStatus() {
|
||||||
statusChart.data.datasets[0].data[3]++;
|
statusChart.data.datasets[0].data[3]++;
|
||||||
statusChart.update();
|
statusChart.update();
|
||||||
});
|
});
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNodeByID(id) {
|
function getNodeByID(id) {
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
if (nodes[i].id === id)
|
if (nodes[i].id === id) {
|
||||||
return nodes[i];
|
return nodes[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue