Re-enable debugbar, add table to ServersContainer.tsx
This commit is contained in:
parent
ed73f6a020
commit
8f1a5bf0ab
15 changed files with 446 additions and 82 deletions
|
@ -67,6 +67,7 @@ abstract class ApplicationApiController extends Controller
|
|||
{
|
||||
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
|
||||
$transformer = Container::getInstance()->make($abstract);
|
||||
$transformer->setRootAdmin($this->request->user()->root_admin);
|
||||
$transformer->setKey($this->request->attributes->get('api_key'));
|
||||
|
||||
Assert::isInstanceOf($transformer, BaseTransformer::class);
|
||||
|
|
|
@ -22,6 +22,11 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
*/
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $rootAdmin;
|
||||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
|
@ -64,6 +69,30 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
* @param bool $rootAdmin
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRootAdmin(bool $rootAdmin)
|
||||
{
|
||||
$this->rootAdmin = $rootAdmin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isRootAdmin(): bool
|
||||
{
|
||||
return $this->rootAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the API key loaded onto the transformer has permission
|
||||
* to access a different resource. This is used when including other
|
||||
|
@ -75,6 +104,10 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
*/
|
||||
protected function authorize(string $resource): bool
|
||||
{
|
||||
if ($this->isRootAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return AdminAcl::check($this->getKey(), $resource, AdminAcl::READ);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,17 @@ class ServerTransformer extends BaseTransformer
|
|||
'identifier' => $model->uuidShort,
|
||||
'name' => $model->name,
|
||||
'description' => $model->description,
|
||||
'suspended' => (bool) $model->suspended,
|
||||
|
||||
'is_suspended' => $model->suspended,
|
||||
'is_installing' => $model->installed !== 1,
|
||||
'is_transferring' => ! is_null($model->transfer),
|
||||
|
||||
'user' => $model->owner_id,
|
||||
'node' => $model->node_id,
|
||||
'allocation' => $model->allocation_id,
|
||||
'nest' => $model->nest_id,
|
||||
'egg' => $model->egg_id,
|
||||
|
||||
'limits' => [
|
||||
'memory' => $model->memory,
|
||||
'swap' => $model->swap,
|
||||
|
@ -76,22 +86,20 @@ class ServerTransformer extends BaseTransformer
|
|||
'cpu' => $model->cpu,
|
||||
'threads' => $model->threads,
|
||||
],
|
||||
|
||||
'feature_limits' => [
|
||||
'databases' => $model->database_limit,
|
||||
'allocations' => $model->allocation_limit,
|
||||
'backups' => $model->backup_limit,
|
||||
],
|
||||
'user' => $model->owner_id,
|
||||
'node' => $model->node_id,
|
||||
'allocation' => $model->allocation_id,
|
||||
'nest' => $model->nest_id,
|
||||
'egg' => $model->egg_id,
|
||||
|
||||
'container' => [
|
||||
'startup_command' => $model->startup,
|
||||
'image' => $model->image,
|
||||
'installed' => (int) $model->installed === 1,
|
||||
'environment' => $this->environmentService->handle($model),
|
||||
],
|
||||
|
||||
$model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at),
|
||||
$model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at),
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue