2019-11-24 23:08:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Admin\Nodes;
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
use Illuminate\View\View;
|
2019-11-24 23:08:54 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Pterodactyl\Models\Node;
|
|
|
|
use Illuminate\Support\Collection;
|
2020-09-13 19:47:05 +00:00
|
|
|
use Pterodactyl\Models\Allocation;
|
2019-11-24 23:08:54 +00:00
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Illuminate\Contracts\View\Factory as ViewFactory;
|
2019-11-24 23:08:54 +00:00
|
|
|
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
|
|
|
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
|
|
|
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
|
|
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
|
|
|
use Pterodactyl\Repositories\Eloquent\LocationRepository;
|
|
|
|
use Pterodactyl\Repositories\Eloquent\AllocationRepository;
|
|
|
|
|
|
|
|
class NodeViewController extends Controller
|
|
|
|
{
|
|
|
|
use JavascriptInjection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NodeViewController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct(
|
2022-10-14 16:59:20 +00:00
|
|
|
private AllocationRepository $allocationRepository,
|
|
|
|
private LocationRepository $locationRepository,
|
|
|
|
private NodeRepository $repository,
|
|
|
|
private ServerRepository $serverRepository,
|
|
|
|
private SoftwareVersionService $versionService,
|
|
|
|
private ViewFactory $view
|
2019-11-24 23:08:54 +00:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns index view for a specific node on the system.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function index(Request $request, Node $node): View
|
2019-11-24 23:08:54 +00:00
|
|
|
{
|
|
|
|
$node = $this->repository->loadLocationAndServerCount($node);
|
|
|
|
|
|
|
|
return $this->view->make('admin.nodes.view.index', [
|
|
|
|
'node' => $node,
|
|
|
|
'stats' => $this->repository->getUsageStats($node),
|
|
|
|
'version' => $this->versionService,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the settings page for a specific node.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function settings(Request $request, Node $node): View
|
2019-11-24 23:08:54 +00:00
|
|
|
{
|
|
|
|
return $this->view->make('admin.nodes.view.settings', [
|
|
|
|
'node' => $node,
|
|
|
|
'locations' => $this->locationRepository->all(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the node configuration page for a specific node.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function configuration(Request $request, Node $node): View
|
2019-11-24 23:08:54 +00:00
|
|
|
{
|
|
|
|
return $this->view->make('admin.nodes.view.configuration', compact('node'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the node allocation management page.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function allocations(Request $request, Node $node): View
|
2019-11-24 23:08:54 +00:00
|
|
|
{
|
|
|
|
$node = $this->repository->loadNodeAllocations($node);
|
|
|
|
|
|
|
|
$this->plainInject(['node' => Collection::wrap($node)->only(['id'])]);
|
|
|
|
|
|
|
|
return $this->view->make('admin.nodes.view.allocation', [
|
|
|
|
'node' => $node,
|
2020-09-13 19:47:05 +00:00
|
|
|
'allocations' => Allocation::query()->where('node_id', $node->id)
|
|
|
|
->groupBy('ip')
|
|
|
|
->orderByRaw('INET_ATON(ip) ASC')
|
|
|
|
->get(['ip']),
|
2019-11-24 23:08:54 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a listing of servers that exist for this specific node.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function servers(Request $request, Node $node): View
|
2019-11-24 23:08:54 +00:00
|
|
|
{
|
|
|
|
$this->plainInject([
|
2020-04-10 22:15:38 +00:00
|
|
|
'node' => Collection::wrap($node->makeVisible(['daemon_token_id', 'daemon_token']))
|
|
|
|
->only(['scheme', 'fqdn', 'daemonListen', 'daemon_token_id', 'daemon_token']),
|
2019-11-24 23:08:54 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
return $this->view->make('admin.nodes.view.servers', [
|
|
|
|
'node' => $node,
|
|
|
|
'servers' => $this->serverRepository->loadAllServersForNode($node->id, 25),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|