Polished it up
This commit is contained in:
parent
93a7d11c28
commit
28a97fea54
3 changed files with 84 additions and 6 deletions
|
@ -12,13 +12,22 @@ use Pterodactyl\Models\Server;
|
|||
use Pterodactyl\Models\User;
|
||||
use JavaScript;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Pterodactyl\Services\DaemonKeys\DaemonKeyProviderService;
|
||||
|
||||
class StatisticsController extends Controller
|
||||
{
|
||||
|
||||
private $keyProviderService;
|
||||
|
||||
function __construct(DaemonKeyProviderService $keyProviderService)
|
||||
{
|
||||
$this->keyProviderService = $keyProviderService;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$servers = Server::all();
|
||||
$nodes = Node::all();
|
||||
$serversCount = count($servers);
|
||||
$nodesCount = Node::count();
|
||||
$usersCount = User::count();
|
||||
|
@ -29,17 +38,26 @@ class StatisticsController extends Controller
|
|||
$totalServerDisk = DB::table('servers')->sum('disk');
|
||||
$totalNodeDisk = DB::table('nodes')->sum('disk');
|
||||
$totalAllocations = Allocation::count();
|
||||
$totalUsersCount = User::count();
|
||||
$totalDBCount = Database::count();
|
||||
|
||||
$suspendedServersCount = Server::where('suspended', true)->count();
|
||||
|
||||
$tokens = [];
|
||||
foreach ($nodes as $node) {
|
||||
$tokens[$node->id] = $this->keyProviderService->handle($node->servers->get(0), $request->user());
|
||||
}
|
||||
|
||||
Javascript::put([
|
||||
'servers' => Server::all(),
|
||||
'servers' => $servers,
|
||||
'serverCount' => $serversCount,
|
||||
'suspendedServers' => $suspendedServersCount,
|
||||
'totalServerRam' => $totalServerRam,
|
||||
'totalNodeRam' => $totalNodeRam,
|
||||
'totalServerDisk' => $totalServerDisk,
|
||||
'totalNodeDisk' => $totalNodeDisk,
|
||||
'nodes' => $nodes,
|
||||
'tokens' => $tokens,
|
||||
]);
|
||||
|
||||
return view('admin.statistics', [
|
||||
|
@ -53,6 +71,8 @@ class StatisticsController extends Controller
|
|||
'totalNodeDisk' => $totalNodeDisk,
|
||||
'totalServerDisk' => $totalServerDisk,
|
||||
'totalAllocations' => $totalAllocations,
|
||||
'totalUsersCount' => $totalUsersCount,
|
||||
'totalDBCount' => $totalDBCount,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue