Disaster Recovery v3 + filament v4b8

This commit is contained in:
Charles 2025-06-23 08:54:51 -04:00
parent dfaf287088
commit ea19202609
197 changed files with 1020 additions and 697 deletions

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands\Environment;
use PDOException;
use App\Traits\EnvironmentWriterTrait;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
@ -105,7 +106,7 @@ class DatabaseSettingsCommand extends Command
]);
$this->database->connection('_panel_command_test')->getPdo();
} catch (\PDOException $exception) {
} catch (PDOException $exception) {
$this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
$this->output->error(trans('commands.database_settings.DB_error_2'));
@ -165,7 +166,7 @@ class DatabaseSettingsCommand extends Command
]);
$this->database->connection('_panel_command_test')->getPdo();
} catch (\PDOException $exception) {
} catch (PDOException $exception) {
$this->output->error(sprintf('Unable to connect to the MariaDB server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
$this->output->error(trans('commands.database_settings.DB_error_2'));

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands\Environment;
use App\Exceptions\PanelException;
use App\Traits\EnvironmentWriterTrait;
use Illuminate\Console\Command;
@ -28,7 +29,7 @@ class EmailSettingsCommand extends Command
/**
* Handle command execution.
*
* @throws \App\Exceptions\PanelException
* @throws PanelException
*/
public function handle(): void
{

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands\Maintenance;
use InvalidArgumentException;
use App\Models\Backup;
use Carbon\CarbonImmutable;
use Illuminate\Console\Command;
@ -16,7 +17,7 @@ class PruneOrphanedBackupsCommand extends Command
{
$since = $this->option('prune-age') ?? config('backups.prune_age', 360);
if (!$since || !is_digit($since)) {
throw new \InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
throw new InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
}
$query = Backup::query()

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands\Node;
use App\Exceptions\Model\DataValidationException;
use App\Models\Node;
use Illuminate\Console\Command;
@ -34,7 +35,7 @@ class MakeNodeCommand extends Command
/**
* Handle the command execution process.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function handle(): void
{

View File

@ -17,7 +17,7 @@ class NodeConfigurationCommand extends Command
{
$column = ctype_digit((string) $this->argument('node')) ? 'id' : 'uuid';
/** @var \App\Models\Node $node */
/** @var Node $node */
$node = Node::query()->where($column, $this->argument('node'))->firstOr(function () {
$this->error(trans('commands.node_config.error_not_exist'));

View File

@ -2,6 +2,9 @@
namespace App\Console\Commands;
use Closure;
use Exception;
use Illuminate\Foundation\Application;
use Illuminate\Console\Command;
use App\Console\Kernel;
use Symfony\Component\Process\Process;
@ -28,7 +31,7 @@ class UpgradeCommand extends Command
* This places the application in maintenance mode as well while the commands
* are being executed.
*
* @throws \Exception
* @throws Exception
*/
public function handle(): void
{
@ -129,9 +132,9 @@ class UpgradeCommand extends Command
});
});
/** @var \Illuminate\Foundation\Application $app */
/** @var Application $app */
$app = require __DIR__ . '/../../../bootstrap/app.php';
/** @var \App\Console\Kernel $kernel */
/** @var Kernel $kernel */
$kernel = $app->make(Kernel::class);
$kernel->bootstrap();
$this->setLaravel($app);
@ -174,7 +177,7 @@ class UpgradeCommand extends Command
$this->info(trans('commands.upgrade.success'));
}
protected function withProgress(ProgressBar $bar, \Closure $callback): void
protected function withProgress(ProgressBar $bar, Closure $callback): void
{
$bar->clear();
$callback();

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands\User;
use App\Exceptions\Model\DataValidationException;
use App\Models\User;
use Illuminate\Console\Command;
@ -14,7 +15,7 @@ class DisableTwoFactorCommand extends Command
/**
* Handle command execution process.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function handle(): void
{

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands\User;
use App\Exceptions\Model\DataValidationException;
use Exception;
use Illuminate\Console\Command;
use App\Services\Users\UserCreationService;
@ -25,7 +26,7 @@ class MakeUserCommand extends Command
* Handle command request to create a new user.
*
* @throws Exception
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function handle(): int
{

View File

@ -2,6 +2,7 @@
namespace App\Exceptions;
use Throwable;
use Exception;
use Filament\Notifications\Notification;
use Illuminate\Http\JsonResponse;
@ -28,7 +29,7 @@ class DisplayException extends PanelException implements HttpExceptionInterface
/**
* DisplayException constructor.
*/
public function __construct(string $message, ?\Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
public function __construct(string $message, ?Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
{
parent::__construct($message, $code, $previous);
}
@ -79,11 +80,11 @@ class DisplayException extends PanelException implements HttpExceptionInterface
* Log the exception to the logs using the defined error level only if the previous
* exception is set.
*
* @throws \Throwable
* @throws Throwable
*/
public function report(): void
{
if (!$this->getPrevious() instanceof \Exception || !Handler::isReportable($this->getPrevious())) {
if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) {
return;
}

View File

@ -2,6 +2,9 @@
namespace App\Exceptions;
use PDOException;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\JsonResponse;
@ -79,7 +82,7 @@ class Handler extends ExceptionHandler
$this->dontReport = [];
}
$this->reportable(function (\PDOException $ex) {
$this->reportable(function (PDOException $ex) {
$ex = $this->generateCleanedExceptionStack($ex);
});
@ -88,7 +91,7 @@ class Handler extends ExceptionHandler
});
}
private function generateCleanedExceptionStack(\Throwable $exception): string
private function generateCleanedExceptionStack(Throwable $exception): string
{
$cleanedStack = '';
foreach ($exception->getTrace() as $index => $item) {
@ -117,11 +120,11 @@ class Handler extends ExceptionHandler
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param Request $request
*
* @throws \Throwable
* @throws Throwable
*/
public function render($request, \Throwable $e): Response
public function render($request, Throwable $e): Response
{
$connections = $this->container->make(Connection::class);
@ -143,7 +146,7 @@ class Handler extends ExceptionHandler
* Transform a validation exception into a consistent format to be returned for
* calls to the API.
*
* @param \Illuminate\Http\Request $request
* @param Request $request
*/
public function invalidJson($request, ValidationException $exception): JsonResponse
{
@ -249,7 +252,7 @@ class Handler extends ExceptionHandler
/**
* Return an array of exceptions that should not be reported.
*/
public static function isReportable(\Exception $exception): bool
public static function isReportable(Exception $exception): bool
{
return (new self(Container::getInstance()))->shouldReport($exception);
}
@ -257,7 +260,7 @@ class Handler extends ExceptionHandler
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param Request $request
*/
protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse
{
@ -291,7 +294,7 @@ class Handler extends ExceptionHandler
*
* @return array<mixed>
*/
public static function toArray(\Throwable $e): array
public static function toArray(Throwable $e): array
{
return self::exceptionToArray($e);
}

View File

@ -2,6 +2,7 @@
namespace App\Exceptions\Http;
use Throwable;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
@ -10,7 +11,7 @@ class HttpForbiddenException extends HttpException
/**
* HttpForbiddenException constructor.
*/
public function __construct(?string $message = null, ?\Throwable $previous = null)
public function __construct(?string $message = null, ?Throwable $previous = null)
{
parent::__construct(Response::HTTP_FORBIDDEN, $message, $previous);
}

View File

@ -2,6 +2,7 @@
namespace App\Exceptions\Http\Server;
use Throwable;
use App\Enums\ServerState;
use App\Models\Server;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
@ -12,7 +13,7 @@ class ServerStateConflictException extends ConflictHttpException
* Exception thrown when the server is in an unsupported state for API access or
* certain operations within the codebase.
*/
public function __construct(Server $server, ?\Throwable $previous = null)
public function __construct(Server $server, ?Throwable $previous = null)
{
$message = 'This server is currently in an unsupported state, please try again later.';
if ($server->isSuspended()) {

View File

@ -2,6 +2,7 @@
namespace App\Exceptions\Http;
use Throwable;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
@ -11,7 +12,7 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept
/**
* TwoFactorAuthRequiredException constructor.
*/
public function __construct(?\Throwable $previous = null)
public function __construct(?Throwable $previous = null)
{
parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous);
}

View File

@ -2,13 +2,15 @@
namespace App\Exceptions;
use Exception;
use App\Exceptions\Solutions\ManifestDoesNotExistSolution;
use Spatie\Ignition\Contracts\Solution;
use Spatie\Ignition\Contracts\ProvidesSolution;
class ManifestDoesNotExistException extends \Exception implements ProvidesSolution
class ManifestDoesNotExistException extends Exception implements ProvidesSolution
{
public function getSolution(): Solution
{
return new Solutions\ManifestDoesNotExistSolution();
return new ManifestDoesNotExistSolution();
}
}

View File

@ -2,4 +2,6 @@
namespace App\Exceptions;
class PanelException extends \Exception {}
use Exception;
class PanelException extends Exception {}

View File

@ -2,6 +2,7 @@
namespace App\Exceptions\Service;
use Throwable;
use App\Exceptions\DisplayException;
class ServiceLimitExceededException extends DisplayException
@ -10,7 +11,7 @@ class ServiceLimitExceededException extends DisplayException
* Exception thrown when something goes over a defined limit, such as allocated
* ports, tasks, databases, etc.
*/
public function __construct(string $message, ?\Throwable $previous = null)
public function __construct(string $message, ?Throwable $previous = null)
{
parent::__construct($message, $previous, self::LEVEL_WARNING);
}

View File

@ -2,6 +2,7 @@
namespace App\Extensions\Backups;
use InvalidArgumentException;
use Closure;
use Aws\S3\S3Client;
use Illuminate\Support\Arr;
@ -64,7 +65,7 @@ class BackupManager
$config = $this->getConfig($name);
if (empty($config['adapter'])) {
throw new \InvalidArgumentException("Backup disk [$name] does not have a configured adapter.");
throw new InvalidArgumentException("Backup disk [$name] does not have a configured adapter.");
}
$adapter = $config['adapter'];
@ -82,7 +83,7 @@ class BackupManager
return $instance;
}
throw new \InvalidArgumentException("Adapter [$adapter] is not supported.");
throw new InvalidArgumentException("Adapter [$adapter] is not supported.");
}
/**

View File

@ -2,6 +2,7 @@
namespace App\Extensions\Captcha\Providers;
use Filament\Schemas\Components\Component;
use Filament\Forms\Components\TextInput;
use Illuminate\Foundation\Application;
use Illuminate\Support\Str;
@ -38,7 +39,7 @@ abstract class CaptchaProvider
abstract public function getId(): string;
abstract public function getComponent(): \Filament\Schemas\Components\Component;
abstract public function getComponent(): Component;
/**
* @return array<string, string|string[]|bool|null>
@ -54,7 +55,7 @@ abstract class CaptchaProvider
}
/**
* @return \Filament\Schemas\Components\Component[]
* @return Component[]
*/
public function getSettingsForm(): array
{

View File

@ -2,6 +2,7 @@
namespace App\Extensions\Captcha\Providers;
use Filament\Schemas\Components\Component;
use App\Filament\Components\Forms\Fields\TurnstileCaptcha;
use Exception;
use Filament\Infolists\Components\TextEntry;
@ -17,7 +18,7 @@ class TurnstileProvider extends CaptchaProvider
return 'turnstile';
}
public function getComponent(): \Filament\Schemas\Components\Component
public function getComponent(): Component
{
return TurnstileCaptcha::make('turnstile');
}
@ -33,7 +34,7 @@ class TurnstileProvider extends CaptchaProvider
}
/**
* @return \Filament\Schemas\Components\Component[]
* @return Component[]
*/
public function getSettingsForm(): array
{

View File

@ -41,7 +41,7 @@ class GSLToken extends FeatureProvider
}
/**
* @throws \Exception
* @throws Exception
*/
public function getAction(): Action
{
@ -59,7 +59,7 @@ class GSLToken extends FeatureProvider
->modalDescription('It seems like your Gameserver Login Token (GSL token) is invalid or has expired.')
->modalSubmitActionLabel('Update GSL Token')
->disabledSchema(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
->form([
->schema([
Placeholder::make('info')
->label(new HtmlString(Blade::render('You can either <x-filament::link href="https://steamcommunity.com/dev/managegameservers" target="_blank">generate a new one</x-filament::link> and enter it below or leave the field blank to remove it completely.'))),
TextInput::make('gsltoken')

View File

@ -6,7 +6,7 @@ use App\Models\ApiKey;
use Laravel\Sanctum\NewAccessToken as SanctumAccessToken;
/**
* @property \App\Models\ApiKey $accessToken
* @property ApiKey $accessToken
*/
class NewAccessToken extends SanctumAccessToken
{

View File

@ -2,6 +2,7 @@
namespace App\Extensions\Lcobucci\JWT\Encoding;
use DateTimeImmutable;
use Lcobucci\JWT\ClaimsFormatter;
use Lcobucci\JWT\Token\RegisteredClaims;
@ -20,7 +21,7 @@ final class TimestampDates implements ClaimsFormatter
continue;
}
assert($claims[$claim] instanceof \DateTimeImmutable);
assert($claims[$claim] instanceof DateTimeImmutable);
$claims[$claim] = $claims[$claim]->getTimestamp();
}

View File

@ -2,6 +2,7 @@
namespace App\Extensions\OAuth\Providers;
use Filament\Schemas\Components\Wizard\Step;
use Filament\Infolists\Components\TextEntry;
use Filament\Forms\Components\TextInput;
use Illuminate\Foundation\Application;
@ -30,7 +31,7 @@ final class DiscordProvider extends OAuthProvider
public function getSetupSteps(): array
{
return array_merge([
\Filament\Schemas\Components\Wizard\Step::make('Register new Discord OAuth App')
Step::make('Register new Discord OAuth App')
->schema([
TextEntry::make('INeedAName')
->hiddenLabel()

View File

@ -2,6 +2,7 @@
namespace App\Extensions\OAuth\Providers;
use Filament\Schemas\Components\Wizard\Step;
use Filament\Infolists\Components\TextEntry;
use Filament\Forms\Components\TextInput;
use Illuminate\Foundation\Application;
@ -24,7 +25,7 @@ final class GithubProvider extends OAuthProvider
public function getSetupSteps(): array
{
return array_merge([
\Filament\Schemas\Components\Wizard\Step::make('Register new Github OAuth App')
Step::make('Register new Github OAuth App')
->schema([
TextEntry::make('INeedAName2')
->hiddenLabel()
@ -39,7 +40,7 @@ final class GithubProvider extends OAuthProvider
->hiddenLabel()
->state(new HtmlString('<p>When you filled all fields click on <b>Register application</b>.</p>')),
]),
\Filament\Schemas\Components\Wizard\Step::make('Create Client Secret')
Step::make('Create Client Secret')
->schema([
TextEntry::make('INeedAName3')
->hiddenLabel()

View File

@ -2,6 +2,7 @@
namespace App\Extensions\OAuth\Providers;
use Filament\Schemas\Components\Wizard\Step;
use Filament\Infolists\Components\TextEntry;
use Filament\Forms\Components\TextInput;
use Illuminate\Foundation\Application;
@ -44,7 +45,7 @@ final class GitlabProvider extends OAuthProvider
public function getSetupSteps(): array
{
return array_merge([
\Filament\Schemas\Components\Wizard\Step::make('Register new Gitlab OAuth App')
Step::make('Register new Gitlab OAuth App')
->schema([
TextEntry::make('INeedAName')
->hiddenLabel()

View File

@ -2,6 +2,7 @@
namespace App\Extensions\OAuth\Providers;
use Filament\Schemas\Components\Wizard\Step;
use Filament\Infolists\Components\TextEntry;
use Filament\Forms\Components\TextInput;
use Illuminate\Foundation\Application;
@ -55,7 +56,7 @@ final class SteamProvider extends OAuthProvider
public function getSetupSteps(): array
{
return array_merge([
\Filament\Schemas\Components\Wizard\Step::make('Create API Key')
Step::make('Create API Key')
->schema([
TextEntry::make('INeedAName')
->hiddenLabel()

View File

@ -2,6 +2,8 @@
namespace App\Extensions\Spatie\Fractalistic;
use Spatie\Fractalistic\Exceptions\InvalidTransformation;
use Spatie\Fractalistic\Exceptions\NoTransformerSpecified;
use League\Fractal\Scope;
use League\Fractal\TransformerAbstract;
use Spatie\Fractal\Fractal as SpatieFractal;
@ -14,8 +16,8 @@ class Fractal extends SpatieFractal
/**
* Create fractal data.
*
* @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation
* @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified
* @throws InvalidTransformation
* @throws NoTransformerSpecified
*/
public function createData(): Scope
{

View File

@ -7,7 +7,7 @@ use Filament\Pages\Dashboard as BaseDashboard;
class Dashboard extends BaseDashboard
{
protected static string|\BackedEnum|null $navigationIcon = 'tabler-layout-dashboard';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-layout-dashboard';
private SoftwareVersionService $softwareVersionService;

View File

@ -13,7 +13,7 @@ use Spatie\Health\ResultStores\ResultStore;
class Health extends Page
{
protected static string|\BackedEnum|null $navigationIcon = 'tabler-heart';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-heart';
protected string $view = 'filament.pages.health';

View File

@ -54,7 +54,7 @@ class Settings extends Page implements HasSchemas
use EnvironmentWriterTrait;
use InteractsWithForms;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-settings';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-settings';
protected string $view = 'filament.pages.settings';

View File

@ -2,6 +2,9 @@
namespace App\Filament\Admin\Resources;
use Filament\Schemas\Schema;
use App\Filament\Admin\Resources\ApiKeyResource\Pages\ListApiKeys;
use App\Filament\Admin\Resources\ApiKeyResource\Pages\CreateApiKey;
use App\Filament\Admin\Resources\ApiKeyResource\Pages;
use App\Filament\Admin\Resources\UserResource\Pages\EditUser;
use App\Filament\Components\Tables\Columns\DateTimeColumn;
@ -33,7 +36,7 @@ class ApiKeyResource extends Resource
protected static ?string $model = ApiKey::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-key';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-key';
public static function getNavigationLabel(): string
{
@ -109,7 +112,7 @@ class ApiKeyResource extends Resource
/**
* @throws Exception
*/
public static function form(Form|\Filament\Schemas\Schema $form): \Filament\Schemas\Schema
public static function form(Form|Schema $form): Schema
{
return $form
->schema([
@ -163,8 +166,8 @@ class ApiKeyResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListApiKeys::route('/'),
'create' => Pages\CreateApiKey::route('/create'),
'index' => ListApiKeys::route('/'),
'create' => CreateApiKey::route('/create'),
];
}
}

View File

@ -2,6 +2,11 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\DatabaseHostResource\RelationManagers\DatabasesRelationManager;
use App\Filament\Admin\Resources\DatabaseHostResource\Pages\ListDatabaseHosts;
use App\Filament\Admin\Resources\DatabaseHostResource\Pages\CreateDatabaseHost;
use App\Filament\Admin\Resources\DatabaseHostResource\Pages\ViewDatabaseHost;
use App\Filament\Admin\Resources\DatabaseHostResource\Pages\EditDatabaseHost;
use App\Filament\Admin\Resources\DatabaseHostResource\Pages;
use App\Filament\Admin\Resources\DatabaseHostResource\RelationManagers;
use App\Models\DatabaseHost;
@ -34,7 +39,7 @@ class DatabaseHostResource extends Resource
protected static ?string $model = DatabaseHost::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-database';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-database';
protected static ?string $recordTitleAttribute = 'name';
@ -107,9 +112,9 @@ class DatabaseHostResource extends Resource
/**
* @throws Exception
*/
public static function form(Schema $form): Schema
public static function form(Schema $schema): Schema
{
return $form
return $schema
->components([
Section::make()
->columnSpanFull()
@ -173,7 +178,7 @@ class DatabaseHostResource extends Resource
public static function getDefaultRelations(): array
{
return [
RelationManagers\DatabasesRelationManager::class,
DatabasesRelationManager::class,
];
}
@ -181,10 +186,10 @@ class DatabaseHostResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListDatabaseHosts::route('/'),
'create' => Pages\CreateDatabaseHost::route('/create'),
'view' => Pages\ViewDatabaseHost::route('/{record}'),
'edit' => Pages\EditDatabaseHost::route('/{record}/edit'),
'index' => ListDatabaseHosts::route('/'),
'create' => CreateDatabaseHost::route('/create'),
'view' => ViewDatabaseHost::route('/{record}'),
'edit' => EditDatabaseHost::route('/{record}/edit'),
];
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Admin\Resources\DatabaseHostResource\RelationManagers;
use Filament\Schemas\Schema;
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
use App\Filament\Components\Tables\Columns\DateTimeColumn;
use App\Models\Database;
@ -15,7 +16,7 @@ class DatabasesRelationManager extends RelationManager
{
protected static string $relationship = 'databases';
public function form(Form|\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
public function form(Form|Schema $schema): Schema
{
return $schema
->schema([

View File

@ -2,6 +2,10 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\EggResource\RelationManagers\ServersRelationManager;
use App\Filament\Admin\Resources\EggResource\Pages\ListEggs;
use App\Filament\Admin\Resources\EggResource\Pages\CreateEgg;
use App\Filament\Admin\Resources\EggResource\Pages\EditEgg;
use App\Filament\Admin\Resources\EggResource\Pages;
use App\Filament\Admin\Resources\EggResource\RelationManagers;
use App\Models\Egg;
@ -18,7 +22,7 @@ class EggResource extends Resource
protected static ?string $model = Egg::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-eggs';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-eggs';
protected static ?string $recordTitleAttribute = 'name';
@ -56,7 +60,7 @@ class EggResource extends Resource
public static function getDefaultRelations(): array
{
return [
RelationManagers\ServersRelationManager::class,
ServersRelationManager::class,
];
}
@ -64,9 +68,9 @@ class EggResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListEggs::route('/'),
'create' => Pages\CreateEgg::route('/create'),
'edit' => Pages\EditEgg::route('/{record}/edit'),
'index' => ListEggs::route('/'),
'create' => CreateEgg::route('/create'),
'edit' => EditEgg::route('/{record}/edit'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Admin\Resources\EggResource\Pages;
use Exception;
use App\Filament\Admin\Resources\EggResource;
use App\Filament\Components\Forms\Fields\CopyFrom;
use App\Models\EggVariable;
@ -53,12 +54,12 @@ class CreateEgg extends CreateRecord
}
/**
* @throws \Exception
* @throws Exception
*/
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Tabs::make()->tabs([
Tab::make(trans('admin/egg.tabs.configuration'))
->columns(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 4])

View File

@ -2,6 +2,7 @@
namespace App\Filament\Admin\Resources\EggResource\Pages;
use Exception;
use App\Filament\Admin\Resources\EggResource;
use App\Filament\Components\Actions\ExportEggAction;
use App\Filament\Components\Actions\ImportEggAction;
@ -40,12 +41,12 @@ class EditEgg extends EditRecord
protected static string $resource = EggResource::class;
/**
* @throws \Exception
* @throws Exception
*/
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Tabs::make()->tabs([
Tab::make(trans('admin/egg.tabs.configuration'))
->columns(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 4])

View File

@ -2,6 +2,7 @@
namespace App\Filament\Admin\Resources\EggResource\Pages;
use Exception;
use App\Filament\Admin\Resources\EggResource;
use App\Filament\Components\Actions\ImportEggAction as ImportEggHeaderAction;
use App\Filament\Components\Tables\Actions\ExportEggAction;
@ -33,7 +34,7 @@ class ListEggs extends ListRecords
protected static string $resource = EggResource::class;
/**
* @throws \Exception
* @throws Exception
*/
public function table(Table $table): Table
{

View File

@ -2,6 +2,11 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\MountResource\Pages\ListMounts;
use App\Filament\Admin\Resources\MountResource\Pages\CreateMount;
use App\Filament\Admin\Resources\MountResource\Pages\ViewMount;
use App\Filament\Admin\Resources\MountResource\Pages\EditMount;
use Exception;
use App\Filament\Admin\Resources\MountResource\Pages;
use App\Models\Mount;
use App\Traits\Filament\CanCustomizePages;
@ -34,7 +39,7 @@ class MountResource extends Resource
protected static ?string $model = Mount::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-layers-linked';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-layers-linked';
protected static ?string $recordTitleAttribute = 'name';
@ -64,7 +69,7 @@ class MountResource extends Resource
}
/**
* @throws \Exception
* @throws Exception
*/
public static function defaultTable(Table $table): Table
{
@ -108,12 +113,12 @@ class MountResource extends Resource
}
/**
* @throws \Exception
* @throws Exception
*/
public static function form(Schema $form): Schema
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
Section::make()->schema([
TextInput::make('name')
->label(trans('admin/mount.name'))
@ -182,10 +187,10 @@ class MountResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListMounts::route('/'),
'create' => Pages\CreateMount::route('/create'),
'view' => Pages\ViewMount::route('/{record}'),
'edit' => Pages\EditMount::route('/{record}/edit'),
'index' => ListMounts::route('/'),
'create' => CreateMount::route('/create'),
'view' => ViewMount::route('/{record}'),
'edit' => EditMount::route('/{record}/edit'),
];
}

View File

@ -2,6 +2,11 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\NodeResource\RelationManagers\AllocationsRelationManager;
use App\Filament\Admin\Resources\NodeResource\RelationManagers\NodesRelationManager;
use App\Filament\Admin\Resources\NodeResource\Pages\ListNodes;
use App\Filament\Admin\Resources\NodeResource\Pages\CreateNode;
use App\Filament\Admin\Resources\NodeResource\Pages\EditNode;
use App\Filament\Admin\Resources\NodeResource\Pages;
use App\Filament\Admin\Resources\NodeResource\RelationManagers;
use App\Models\Node;
@ -19,7 +24,7 @@ class NodeResource extends Resource
protected static ?string $model = Node::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-server-2';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-server-2';
protected static ?string $recordTitleAttribute = 'name';
@ -52,8 +57,8 @@ class NodeResource extends Resource
public static function getDefaultRelations(): array
{
return [
RelationManagers\AllocationsRelationManager::class,
RelationManagers\NodesRelationManager::class,
AllocationsRelationManager::class,
NodesRelationManager::class,
];
}
@ -61,9 +66,9 @@ class NodeResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListNodes::route('/'),
'create' => Pages\CreateNode::route('/create'),
'edit' => Pages\EditNode::route('/{record}/edit'),
'index' => ListNodes::route('/'),
'create' => CreateNode::route('/create'),
'edit' => EditNode::route('/{record}/edit'),
];
}

View File

@ -37,7 +37,7 @@ class CreateNode extends CreateRecord
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Wizard::make([
Step::make('basic')
->label(trans('admin/node.tabs.basic_settings'))

View File

@ -2,6 +2,7 @@
namespace App\Filament\Admin\Resources\NodeResource\Pages;
use Throwable;
use App\Filament\Admin\Resources\NodeResource;
use App\Models\Node;
use App\Repositories\Daemon\DaemonConfigurationRepository;
@ -51,7 +52,7 @@ class EditNode extends EditRecord
}
/**
* @throws \Throwable
* @throws Throwable
*/
public function form(Schema $schema): Schema
{

View File

@ -27,7 +27,7 @@ class AllocationsRelationManager extends RelationManager
{
protected static string $relationship = 'allocations';
protected static string|\BackedEnum|null $icon = 'tabler-plug-connected';
protected static string | \BackedEnum | null $icon = 'tabler-plug-connected';
public function setTitle(): string
{

View File

@ -12,7 +12,7 @@ class NodesRelationManager extends RelationManager
{
protected static string $relationship = 'servers';
protected static string|\BackedEnum|null $icon = 'tabler-brand-docker';
protected static string | \BackedEnum | null $icon = 'tabler-brand-docker';
public function setTitle(): string
{

View File

@ -2,6 +2,11 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\RoleResource\Pages\ListRoles;
use App\Filament\Admin\Resources\RoleResource\Pages\CreateRole;
use App\Filament\Admin\Resources\RoleResource\Pages\ViewRole;
use App\Filament\Admin\Resources\RoleResource\Pages\EditRole;
use BackedEnum;
use App\Filament\Admin\Resources\RoleResource\Pages;
use App\Models\Role;
use Exception;
@ -39,7 +44,7 @@ class RoleResource extends Resource
protected static ?string $model = Role::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-users-group';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-users-group';
protected static ?string $recordTitleAttribute = 'name';
@ -159,7 +164,7 @@ class RoleResource extends Resource
}
/**
* @param string[]|int[]|Permission[]|\BackedEnum[] $options
* @param string[]|int[]|Permission[]|BackedEnum[] $options
*
* @throws Exception
*/
@ -222,10 +227,10 @@ class RoleResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListRoles::route('/'),
'create' => Pages\CreateRole::route('/create'),
'view' => Pages\ViewRole::route('/{record}'),
'edit' => Pages\EditRole::route('/{record}/edit'),
'index' => ListRoles::route('/'),
'create' => CreateRole::route('/create'),
'view' => ViewRole::route('/{record}'),
'edit' => EditRole::route('/{record}/edit'),
];
}
}

View File

@ -2,6 +2,11 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\ServerResource\RelationManagers\AllocationsRelationManager;
use App\Filament\Admin\Resources\ServerResource\Pages\ListServers;
use App\Filament\Admin\Resources\ServerResource\Pages\CreateServer;
use App\Filament\Admin\Resources\ServerResource\Pages\EditServer;
use Exception;
use App\Filament\Admin\Resources\ServerResource\Pages;
use App\Filament\Admin\Resources\ServerResource\RelationManagers;
use App\Models\Mount;
@ -22,7 +27,7 @@ class ServerResource extends Resource
protected static ?string $model = Server::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-brand-docker';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-brand-docker';
protected static ?string $recordTitleAttribute = 'name';
@ -52,7 +57,7 @@ class ServerResource extends Resource
}
/**
* @throws \Exception
* @throws Exception
*/
public static function getMountCheckboxList(Get $get): CheckboxList
{
@ -81,7 +86,7 @@ class ServerResource extends Resource
public static function getDefaultRelations(): array
{
return [
RelationManagers\AllocationsRelationManager::class,
AllocationsRelationManager::class,
];
}
@ -89,9 +94,9 @@ class ServerResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListServers::route('/'),
'create' => Pages\CreateServer::route('/create'),
'edit' => Pages\EditServer::route('/{record}/edit'),
'index' => ListServers::route('/'),
'create' => CreateServer::route('/create'),
'edit' => EditServer::route('/{record}/edit'),
];
}

View File

@ -70,7 +70,7 @@ class CreateServer extends CreateRecord
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Wizard::make([
Step::make('Information')
->label(trans('admin/server.tabs.information'))

View File

@ -163,7 +163,7 @@ class EditServer extends EditRecord
->modalSubmitAction(false)
->modalFooterActionsAlignment(Alignment::Right)
->modalCancelActionLabel(trans('filament::components/modal.actions.close.label'))
->form([
->schema([
MonacoEditor::make('logs')
->hiddenLabel()
->placeholderText(trans('admin/server.no_log'))

View File

@ -110,7 +110,7 @@ class ListServers extends ListRecords
protected function getDefaultHeaderActions(): array
{
return [
Actions\CreateAction::make()
CreateAction::make()
->hidden(fn () => Server::count() <= 0),
];
}

View File

@ -2,6 +2,11 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\UserResource\RelationManagers\ServersRelationManager;
use App\Filament\Admin\Resources\UserResource\Pages\ListUsers;
use App\Filament\Admin\Resources\UserResource\Pages\CreateUser;
use App\Filament\Admin\Resources\UserResource\Pages\ViewUser;
use App\Filament\Admin\Resources\UserResource\Pages\EditUser;
use App\Filament\Admin\Resources\UserResource\Pages;
use App\Filament\Admin\Resources\UserResource\RelationManagers;
use App\Models\Role;
@ -33,7 +38,7 @@ class UserResource extends Resource
protected static ?string $model = User::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-users';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-users';
protected static ?string $recordTitleAttribute = 'username';
@ -161,7 +166,7 @@ class UserResource extends Resource
public static function getDefaultRelations(): array
{
return [
RelationManagers\ServersRelationManager::class,
ServersRelationManager::class,
];
}
@ -169,10 +174,10 @@ class UserResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'view' => Pages\ViewUser::route('/{record}'),
'edit' => Pages\EditUser::route('/{record}/edit'),
'index' => ListUsers::route('/'),
'create' => CreateUser::route('/create'),
'view' => ViewUser::route('/{record}'),
'edit' => EditUser::route('/{record}/edit'),
];
}
}

View File

@ -2,6 +2,10 @@
namespace App\Filament\Admin\Resources;
use App\Filament\Admin\Resources\WebhookResource\Pages\ListWebhookConfigurations;
use App\Filament\Admin\Resources\WebhookResource\Pages\CreateWebhookConfiguration;
use App\Filament\Admin\Resources\WebhookResource\Pages\ViewWebhookConfiguration;
use App\Filament\Admin\Resources\WebhookResource\Pages\EditWebhookConfiguration;
use App\Filament\Admin\Resources\WebhookResource\Pages;
use App\Models\WebhookConfiguration;
use Filament\Actions\CreateAction;
@ -30,7 +34,7 @@ class WebhookResource extends Resource
protected static ?string $model = WebhookConfiguration::class;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-webhook';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-webhook';
protected static ?string $recordTitleAttribute = 'description';
@ -85,10 +89,10 @@ class WebhookResource extends Resource
]);
}
public static function form(Schema $form): Schema
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
TextInput::make('endpoint')
->label(trans('admin/webhook.endpoint'))
->activeUrl()
@ -112,10 +116,10 @@ class WebhookResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListWebhookConfigurations::route('/'),
'create' => Pages\CreateWebhookConfiguration::route('/create'),
'view' => Pages\ViewWebhookConfiguration::route('/{record}'),
'edit' => Pages\EditWebhookConfiguration::route('/{record}/edit'),
'index' => ListWebhookConfigurations::route('/'),
'create' => CreateWebhookConfiguration::route('/create'),
'view' => ViewWebhookConfiguration::route('/{record}'),
'edit' => EditWebhookConfiguration::route('/{record}/edit'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Admin\Widgets;
use Exception;
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Section;
@ -17,12 +18,12 @@ class CanaryWidget extends FormWidget
}
/**
* @throws \Exception
* @throws Exception
*/
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Section::make(trans('admin/dashboard.sections.intro-developers.heading'))
->icon('tabler-code')
->iconColor('primary')

View File

@ -18,7 +18,7 @@ class HelpWidget extends FormWidget
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Section::make(trans('admin/dashboard.sections.intro-help.heading'))
->icon('tabler-question-mark')
->iconColor('info')

View File

@ -2,6 +2,7 @@
namespace App\Filament\Admin\Widgets;
use Exception;
use App\Filament\Admin\Resources\NodeResource\Pages\CreateNode;
use App\Models\Node;
use Filament\Actions\Action;
@ -19,12 +20,12 @@ class NoNodesWidget extends FormWidget
}
/**
* @throws \Exception
* @throws Exception
*/
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Section::make(trans('admin/dashboard.sections.intro-first-node.heading'))
->icon('tabler-server-2')
->iconColor('primary')

View File

@ -18,7 +18,7 @@ class SupportWidget extends FormWidget
public function form(Schema $schema): Schema
{
return $schema
->schema([
->components([
Section::make(trans('admin/dashboard.sections.intro-support.heading'))
->icon('tabler-heart-filled')
->iconColor('danger')

View File

@ -28,7 +28,7 @@ class UpdateWidget extends FormWidget
$isLatest = $this->softwareVersionService->isLatestPanel();
return $schema
->schema([
->components([
$isLatest
? Section::make(trans('admin/dashboard.sections.intro-no-update.heading'))
->icon('tabler-checkbox')

View File

@ -2,6 +2,7 @@
namespace App\Filament\App\Resources;
use App\Filament\App\Resources\ServerResource\Pages\ListServers;
use App\Filament\App\Resources\ServerResource\Pages;
use App\Models\Server;
use Filament\Resources\Resource;
@ -22,7 +23,7 @@ class ServerResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListServers::route('/'),
'index' => ListServers::route('/'),
];
}
}

View File

@ -20,7 +20,7 @@ use Illuminate\Support\Number;
class Settings extends ServerFormPage
{
protected static string|\BackedEnum|null $navigationIcon = 'tabler-settings';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-settings';
protected static ?int $navigationSort = 10;

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Pages;
use Exception;
use App\Facades\Activity;
use App\Filament\Components\Forms\Actions\PreviewStartupAction;
use App\Models\Permission;
@ -23,12 +24,12 @@ use Illuminate\Support\Facades\Validator;
class Startup extends ServerFormPage
{
protected static string|\BackedEnum|null $navigationIcon = 'tabler-player-play';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-player-play';
protected static ?int $navigationSort = 9;
/**
* @throws \Exception
* @throws Exception
*/
public function form(Schema $schema): Schema
{
@ -175,7 +176,7 @@ class Startup extends ServerFormPage
return $containsRuleIn;
}
throw new \Exception('Component type not supported: ' . $component::class);
throw new Exception('Component type not supported: ' . $component::class);
}
/**
@ -235,7 +236,7 @@ class Startup extends ServerFormPage
->title('Updated: ' . $serverVariable->variable->name)
->body(fn () => $original . ' -> ' . $state)
->send();
} catch (\Exception $e) {
} catch (Exception $e) {
Notification::make()
->danger()
->title('Failed: ' . $serverVariable->variable->name)

View File

@ -2,6 +2,8 @@
namespace App\Filament\Server\Resources;
use App\Filament\Server\Resources\ActivityResource\Pages\ListActivities;
use Exception;
use App\Filament\Admin\Resources\UserResource\Pages\EditUser;
use App\Filament\Components\Tables\Columns\DateTimeColumn;
use App\Filament\Server\Resources\ActivityResource\Pages;
@ -44,12 +46,12 @@ class ActivityResource extends Resource
protected static ?int $navigationSort = 8;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-stack';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-stack';
protected static bool $isScopedToTenant = false;
/**
* @throws \Exception
* @throws Exception
*/
public static function defaultTable(Table $table): Table
{
@ -170,7 +172,7 @@ class ActivityResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListActivities::route('/'),
'index' => ListActivities::route('/'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Resources;
use App\Filament\Server\Resources\AllocationResource\Pages\ListAllocations;
use App\Facades\Activity;
use App\Filament\Server\Resources\AllocationResource\Pages;
use App\Models\Allocation;
@ -37,7 +38,7 @@ class AllocationResource extends Resource
protected static ?int $navigationSort = 7;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-network';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-network';
/**
* @throws Exception
@ -121,7 +122,7 @@ class AllocationResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListAllocations::route('/'),
'index' => ListAllocations::route('/'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Resources;
use App\Filament\Server\Resources\BackupResource\Pages\ListBackups;
use App\Enums\BackupStatus;
use App\Enums\ServerState;
use App\Facades\Activity;
@ -55,7 +56,7 @@ class BackupResource extends Resource
protected static ?int $navigationSort = 3;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-file-zip';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-file-zip';
protected static bool $canCreateAnother = false;
@ -137,7 +138,7 @@ class BackupResource extends Resource
->color('success')
->icon('tabler-folder-up')
->authorize(fn () => auth()->user()->can(Permission::ACTION_BACKUP_RESTORE, $server))
->form([
->schema([
TextEntry::make('INeedAName')
->hiddenLabel()
->helperText('Your server will be stopped. You will not be able to control the power state, access the file manager, or create additional backups until this process is completed.'),
@ -230,7 +231,7 @@ class BackupResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListBackups::route('/'),
'index' => ListBackups::route('/'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Resources;
use App\Filament\Server\Resources\DatabaseResource\Pages\ListDatabases;
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
use App\Filament\Components\Tables\Columns\DateTimeColumn;
use App\Filament\Server\Resources\DatabaseResource\Pages;
@ -40,7 +41,7 @@ class DatabaseResource extends Resource
protected static ?int $navigationSort = 6;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-database';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-database';
protected static function getBadgeCount(): int
{
@ -67,7 +68,7 @@ class DatabaseResource extends Resource
$server = Filament::getTenant();
return $schema
->schema([
->components([
TextInput::make('host')
->formatStateUsing(fn (Database $database) => $database->address()),
// TODO ->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
@ -151,7 +152,7 @@ class DatabaseResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListDatabases::route('/'),
'index' => ListDatabases::route('/'),
];
}
}

View File

@ -2,6 +2,10 @@
namespace App\Filament\Server\Resources;
use App\Filament\Server\Resources\FileResource\Pages\EditFiles;
use App\Filament\Server\Resources\FileResource\Pages\SearchFiles;
use App\Filament\Server\Resources\FileResource\Pages\DownloadFiles;
use App\Filament\Server\Resources\FileResource\Pages\ListFiles;
use App\Filament\Server\Resources\FileResource\Pages;
use App\Models\File;
use App\Models\Permission;
@ -23,7 +27,7 @@ class FileResource extends Resource
protected static ?int $navigationSort = 2;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-files';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-files';
protected static bool $isScopedToTenant = false;
@ -51,10 +55,10 @@ class FileResource extends Resource
public static function getDefaultPages(): array
{
return [
'edit' => Pages\EditFiles::route('/edit/{path}'),
'search' => Pages\SearchFiles::route('/search/{searchTerm}'), // TODO: find better way?
'download' => Pages\DownloadFiles::route('/download/{path}'),
'index' => Pages\ListFiles::route('/{path?}'),
'edit' => EditFiles::route('/edit/{path}'),
'search' => SearchFiles::route('/search/{searchTerm}'), // TODO: find better way?
'download' => DownloadFiles::route('/download/{path}'),
'index' => ListFiles::route('/{path?}'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Resources\FileResource\Pages;
use Throwable;
use App\Enums\EditorLanguages;
use App\Exceptions\Http\Server\FileSizeTooLargeException;
use App\Exceptions\Repository\FileNotEditableException;
@ -58,7 +59,7 @@ class EditFiles extends Page
public ?array $data = [];
/**
* @throws \Throwable
* @throws Throwable
*/
public function form(Schema $schema): Schema
{
@ -70,7 +71,7 @@ class EditFiles extends Page
->log();
return $schema
->schema([
->components([
Section::make('Editing: ' . $this->path)
->footerActions([
Action::make('save_and_close')

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Resources\FileResource\Pages;
use Exception;
use App\Facades\Activity;
use App\Filament\Server\Resources\FileResource;
use App\Models\File;
@ -70,7 +71,7 @@ class ListFiles extends ListRecords
}
/**
* @throws \Exception
* @throws Exception
*/
public function table(Table $table): Table
{
@ -405,7 +406,7 @@ class ListFiles extends ListRecords
}
/** @return array<HeaderAction|HeaderActionGroup>
* @throws \Exception
* @throws Exception
*/
protected function getDefaultHeaderActions(): array
{

View File

@ -2,6 +2,10 @@
namespace App\Filament\Server\Resources;
use App\Filament\Server\Resources\ScheduleResource\Pages\ListSchedules;
use App\Filament\Server\Resources\ScheduleResource\Pages\CreateSchedule;
use App\Filament\Server\Resources\ScheduleResource\Pages\ViewSchedule;
use App\Filament\Server\Resources\ScheduleResource\Pages\EditSchedule;
use App\Facades\Activity;
use App\Filament\Components\Tables\Columns\DateTimeColumn;
use App\Filament\Server\Resources\ScheduleResource\Pages;
@ -53,7 +57,7 @@ class ScheduleResource extends Resource
protected static ?int $navigationSort = 4;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-clock';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-clock';
public static function canViewAny(): bool
{
@ -85,7 +89,7 @@ class ScheduleResource extends Resource
'default' => 4,
'lg' => 5,
])
->schema([
->components([
TextInput::make('name')
->columnSpan([
'default' => 4,
@ -370,10 +374,10 @@ class ScheduleResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListSchedules::route('/'),
'create' => Pages\CreateSchedule::route('/create'),
'view' => Pages\ViewSchedule::route('/{record}'),
'edit' => Pages\EditSchedule::route('/{record}/edit'),
'index' => ListSchedules::route('/'),
'create' => CreateSchedule::route('/create'),
'view' => ViewSchedule::route('/{record}'),
'edit' => EditSchedule::route('/{record}/edit'),
];
}

View File

@ -2,6 +2,7 @@
namespace App\Filament\Server\Resources;
use App\Filament\Server\Resources\UserResource\Pages\ListUsers;
use App\Filament\Server\Resources\UserResource\Pages;
use App\Models\Permission;
use App\Models\Server;
@ -45,7 +46,7 @@ class UserResource extends Resource
protected static ?int $navigationSort = 5;
protected static string|\BackedEnum|null $navigationIcon = 'tabler-users';
protected static string | \BackedEnum | null $navigationIcon = 'tabler-users';
protected static ?string $tenantOwnershipRelationshipName = 'subServers';
@ -228,7 +229,7 @@ class UserResource extends Resource
public static function getDefaultPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'index' => ListUsers::route('/'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Helpers;
use Exception;
use Carbon\Carbon;
use Cron\CronExpression;
use Illuminate\Support\ViewErrorBag;
@ -23,7 +24,7 @@ class Utilities
$string = substr_replace($string, $character, random_int(0, $length - 1), 1);
}
} catch (\Exception $exception) {
} catch (Exception $exception) {
// Just log the error and hope for the best at this point.
logger()->error($exception);
}
@ -34,7 +35,7 @@ class Utilities
/**
* Converts schedule cron data into a carbon object.
*
* @throws \Exception
* @throws Exception
*/
public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek): Carbon
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Application\DatabaseHosts;
use Throwable;
use Exception;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use App\Models\DatabaseHost;
@ -66,7 +68,7 @@ class DatabaseHostController extends ApplicationApiController
* Store a new database host on the Panel and return an HTTP/201 response code with the
* new database host attached.
*
* @throws \Throwable
* @throws Throwable
*/
public function store(StoreDatabaseHostRequest $request): JsonResponse
{
@ -89,7 +91,7 @@ class DatabaseHostController extends ApplicationApiController
*
* @return array<mixed>
*
* @throws \Throwable
* @throws Throwable
*/
public function update(UpdateDatabaseHostRequest $request, DatabaseHost $databaseHost): array
{
@ -105,7 +107,7 @@ class DatabaseHostController extends ApplicationApiController
*
* Delete a database host from the Panel.
*
* @throws \Exception
* @throws Exception
*/
public function delete(DeleteDatabaseHostRequest $request, DatabaseHost $databaseHost): Response
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Application\Mounts;
use App\Exceptions\Model\DataValidationException;
use Throwable;
use Ramsey\Uuid\Uuid;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
@ -56,7 +58,7 @@ class MountController extends ApplicationApiController
* Create a new mount on the Panel. Returns the created mount and an HTTP/201
* status response on success.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function store(StoreMountRequest $request): JsonResponse
{
@ -83,7 +85,7 @@ class MountController extends ApplicationApiController
*
* @return array<array-key, mixed>
*
* @throws \Throwable
* @throws Throwable
*/
public function update(UpdateMountRequest $request, Mount $mount): array
{
@ -100,7 +102,7 @@ class MountController extends ApplicationApiController
* Deletes a given mount from the Panel as long as there are no servers
* currently attached to it.
*
* @throws \App\Exceptions\Service\HasActiveServersException
* @throws HasActiveServersException
*/
public function delete(DeleteMountRequest $request, Mount $mount): JsonResponse
{

View File

@ -2,6 +2,11 @@
namespace App\Http\Controllers\Api\Application\Nodes;
use App\Exceptions\DisplayException;
use App\Exceptions\Service\Allocation\CidrOutOfRangeException;
use App\Exceptions\Service\Allocation\InvalidPortMappingException;
use App\Exceptions\Service\Allocation\PortOutOfRangeException;
use App\Exceptions\Service\Allocation\TooManyPortsInRangeException;
use App\Models\Node;
use Illuminate\Http\JsonResponse;
use App\Models\Allocation;
@ -62,11 +67,11 @@ class AllocationController extends ApplicationApiController
*
* Store new allocations for a given node.
*
* @throws \App\Exceptions\DisplayException
* @throws \App\Exceptions\Service\Allocation\CidrOutOfRangeException
* @throws \App\Exceptions\Service\Allocation\InvalidPortMappingException
* @throws \App\Exceptions\Service\Allocation\PortOutOfRangeException
* @throws \App\Exceptions\Service\Allocation\TooManyPortsInRangeException
* @throws DisplayException
* @throws CidrOutOfRangeException
* @throws InvalidPortMappingException
* @throws PortOutOfRangeException
* @throws TooManyPortsInRangeException
*/
public function store(StoreAllocationRequest $request, Node $node): JsonResponse
{

View File

@ -2,6 +2,9 @@
namespace App\Http\Controllers\Api\Application\Nodes;
use App\Exceptions\Model\DataValidationException;
use Throwable;
use App\Exceptions\Service\HasActiveServersException;
use App\Models\Node;
use Illuminate\Http\JsonResponse;
use Spatie\QueryBuilder\QueryBuilder;
@ -69,7 +72,7 @@ class NodeController extends ApplicationApiController
* Create a new node on the Panel. Returns the created node and an HTTP/201
* status response on success.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function store(StoreNodeRequest $request): JsonResponse
{
@ -92,7 +95,7 @@ class NodeController extends ApplicationApiController
*
* @return array<mixed>
*
* @throws \Throwable
* @throws Throwable
*/
public function update(UpdateNodeRequest $request, Node $node): array
{
@ -117,7 +120,7 @@ class NodeController extends ApplicationApiController
* Deletes a given node from the Panel as long as there are no servers
* currently attached to it.
*
* @throws \App\Exceptions\Service\HasActiveServersException
* @throws HasActiveServersException
*/
public function delete(DeleteNodeRequest $request, Node $node): JsonResponse
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Application\Roles;
use Throwable;
use Exception;
use App\Exceptions\PanelException;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
@ -55,7 +57,7 @@ class RoleController extends ApplicationApiController
* Store a new role on the Panel and return an HTTP/201 response code with the
* new role attached.
*
* @throws \Throwable
* @throws Throwable
*/
public function store(StoreRoleRequest $request): JsonResponse
{
@ -78,7 +80,7 @@ class RoleController extends ApplicationApiController
*
* @return array<array-key, mixed>
*
* @throws \Throwable
* @throws Throwable
*/
public function update(UpdateRoleRequest $request, Role $role): array
{
@ -98,7 +100,7 @@ class RoleController extends ApplicationApiController
*
* Delete a role from the Panel.
*
* @throws \Exception
* @throws Exception
*/
public function delete(DeleteRoleRequest $request, Role $role): Response
{

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Application\Servers;
use Throwable;
use Illuminate\Http\Response;
use App\Models\Server;
use App\Models\Database;
@ -62,7 +63,7 @@ class DatabaseController extends ApplicationApiController
*
* Reset the password for a specific server database.
*
* @throws \Throwable
* @throws Throwable
*/
public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): JsonResponse
{
@ -76,7 +77,7 @@ class DatabaseController extends ApplicationApiController
*
* Create a new database on the Panel for a given server.
*
* @throws \Throwable
* @throws Throwable
*/
public function store(StoreServerDatabaseRequest $request, Server $server): JsonResponse
{

View File

@ -2,6 +2,11 @@
namespace App\Http\Controllers\Api\Application\Servers;
use Throwable;
use Illuminate\Validation\ValidationException;
use App\Exceptions\DisplayException;
use App\Exceptions\Model\DataValidationException;
use App\Exceptions\Service\Deployment\NoViableAllocationException;
use Illuminate\Http\Response;
use App\Models\Server;
use Illuminate\Http\JsonResponse;
@ -53,11 +58,11 @@ class ServerController extends ApplicationApiController
*
* Create a new server on the system.
*
* @throws \Throwable
* @throws \Illuminate\Validation\ValidationException
* @throws \App\Exceptions\DisplayException
* @throws \App\Exceptions\Model\DataValidationException
* @throws \App\Exceptions\Service\Deployment\NoViableAllocationException
* @throws Throwable
* @throws ValidationException
* @throws DisplayException
* @throws DataValidationException
* @throws NoViableAllocationException
*/
public function store(StoreServerRequest $request): JsonResponse
{
@ -87,7 +92,7 @@ class ServerController extends ApplicationApiController
*
* Deletes a server.
*
* @throws \App\Exceptions\DisplayException
* @throws DisplayException
*/
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Application\Servers;
use App\Exceptions\DisplayException;
use App\Exceptions\Model\DataValidationException;
use App\Models\Server;
use App\Services\Servers\BuildModificationService;
use App\Services\Servers\DetailsModificationService;
@ -31,8 +33,8 @@ class ServerDetailsController extends ApplicationApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\DisplayException
* @throws \App\Exceptions\Model\DataValidationException
* @throws DisplayException
* @throws DataValidationException
*/
public function details(UpdateServerDetailsRequest $request, Server $server): array
{
@ -56,8 +58,8 @@ class ServerDetailsController extends ApplicationApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\DisplayException
* @throws \App\Exceptions\Model\DataValidationException
* @throws DisplayException
* @throws DataValidationException
*/
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
{

View File

@ -2,6 +2,9 @@
namespace App\Http\Controllers\Api\Application\Servers;
use Throwable;
use App\Exceptions\DisplayException;
use App\Exceptions\Model\DataValidationException;
use App\Enums\SuspendAction;
use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Servers\ServerWriteRequest;
@ -35,7 +38,7 @@ class ServerManagementController extends ApplicationApiController
*
* Suspend a server on the Panel.
*
* @throws \Throwable
* @throws Throwable
*/
public function suspend(ServerWriteRequest $request, Server $server): Response
{
@ -49,7 +52,7 @@ class ServerManagementController extends ApplicationApiController
*
* Unsuspend a server on the Panel.
*
* @throws \Throwable
* @throws Throwable
*/
public function unsuspend(ServerWriteRequest $request, Server $server): Response
{
@ -63,8 +66,8 @@ class ServerManagementController extends ApplicationApiController
*
* Mark a server as needing to be reinstalled.
*
* @throws \App\Exceptions\DisplayException
* @throws \App\Exceptions\Model\DataValidationException
* @throws DisplayException
* @throws DataValidationException
*/
public function reinstall(ServerWriteRequest $request, Server $server): Response
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Application\Users;
use App\Exceptions\Model\DataValidationException;
use Exception;
use App\Models\User;
use Illuminate\Http\JsonResponse;
use Spatie\QueryBuilder\QueryBuilder;
@ -78,7 +80,7 @@ class UserController extends ApplicationApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function update(UpdateUserRequest $request, User $user): array
{
@ -143,8 +145,8 @@ class UserController extends ApplicationApiController
* Store a new user on the system. Returns the created user and an HTTP/201
* header on successful creation.
*
* @throws \Exception
* @throws \App\Exceptions\Model\DataValidationException
* @throws Exception
* @throws DataValidationException
*/
public function store(StoreUserRequest $request): JsonResponse
{

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Client;
use Throwable;
use Illuminate\Auth\SessionGuard;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@ -60,7 +61,7 @@ class AccountController extends ClientApiController
* Update the authenticated user's password. All existing sessions will be logged
* out immediately.
*
* @throws \Throwable
* @throws Throwable
*/
public function updatePassword(UpdatePasswordRequest $request): JsonResponse
{

View File

@ -33,7 +33,7 @@ class ApiKeyController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\DisplayException
* @throws DisplayException
*/
public function store(StoreApiKeyRequest $request): array
{
@ -64,7 +64,7 @@ class ApiKeyController extends ClientApiController
*/
public function delete(ClientApiRequest $request, string $identifier): JsonResponse
{
/** @var \App\Models\ApiKey $key */
/** @var ApiKey $key */
$key = $request->user()->apiKeys()
->where('key_type', ApiKey::TYPE_ACCOUNT)
->where('identifier', $identifier)

View File

@ -2,6 +2,9 @@
namespace App\Http\Controllers\Api\Client\Servers;
use Spatie\Fractalistic\Exceptions\InvalidTransformation;
use Spatie\Fractalistic\Exceptions\NoTransformerSpecified;
use Throwable;
use App\Enums\ServerState;
use Illuminate\Http\Request;
use App\Models\Backup;
@ -65,9 +68,9 @@ class BackupController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation
* @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified
* @throws \Throwable
* @throws InvalidTransformation
* @throws NoTransformerSpecified
* @throws Throwable
*/
public function store(StoreBackupRequest $request, Server $server): array
{
@ -101,8 +104,8 @@ class BackupController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \Throwable
* @throws \Illuminate\Auth\Access\AuthorizationException
* @throws Throwable
* @throws AuthorizationException
*/
public function toggleLock(Request $request, Server $server, Backup $backup): array
{
@ -128,7 +131,7 @@ class BackupController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \Illuminate\Auth\Access\AuthorizationException
* @throws AuthorizationException
*/
public function view(Request $request, Server $server, Backup $backup): array
{
@ -147,7 +150,7 @@ class BackupController extends ClientApiController
* Deletes a backup from the panel as well as the remote source where it is currently
* being stored.
*
* @throws \Throwable
* @throws Throwable
*/
public function delete(Request $request, Server $server, Backup $backup): JsonResponse
{
@ -172,8 +175,8 @@ class BackupController extends ClientApiController
* will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated
* which the user is redirected to.
*
* @throws \Throwable
* @throws \Illuminate\Auth\Access\AuthorizationException
* @throws Throwable
* @throws AuthorizationException
*/
public function download(Request $request, Server $server, Backup $backup): JsonResponse
{
@ -206,7 +209,7 @@ class BackupController extends ClientApiController
* files that currently exist on the server will be deleted before restoring.
* Otherwise, the archive will simply be unpacked over the existing files.
*
* @throws \Throwable
* @throws Throwable
*/
public function restore(RestoreBackupRequest $request, Server $server, Backup $backup): JsonResponse
{

View File

@ -2,6 +2,9 @@
namespace App\Http\Controllers\Api\Client\Servers;
use Throwable;
use App\Exceptions\Service\Database\TooManyDatabasesException;
use App\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException;
use Illuminate\Http\Response;
use App\Models\Server;
use App\Models\Database;
@ -52,9 +55,9 @@ class DatabaseController extends ClientApiController
*
* @return array<string, mixed>
*
* @throws \Throwable
* @throws \App\Exceptions\Service\Database\TooManyDatabasesException
* @throws \App\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException
* @throws Throwable
* @throws TooManyDatabasesException
* @throws DatabaseClientFeatureNotEnabledException
*/
public function store(StoreDatabaseRequest $request, Server $server): array
{
@ -79,7 +82,7 @@ class DatabaseController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \Throwable
* @throws Throwable
*/
public function rotatePassword(RotatePasswordRequest $request, Server $server, Database $database): array
{

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Client\Servers;
use Throwable;
use Carbon\CarbonImmutable;
use Illuminate\Http\Response;
use App\Models\Server;
@ -63,7 +64,7 @@ class FileController extends ClientApiController
*
* Return the contents of a specified file for the user.
*
* @throws \Throwable
* @throws Throwable
*/
public function contents(GetFileContentsRequest $request, Server $server): Response
{
@ -86,7 +87,7 @@ class FileController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \Throwable
* @throws Throwable
*/
public function download(GetFileContentsRequest $request, Server $server): array
{
@ -138,7 +139,7 @@ class FileController extends ClientApiController
*
* Creates a new folder on the server.
*
* @throws \Throwable
* @throws Throwable
*/
public function create(CreateFolderRequest $request, Server $server): JsonResponse
{
@ -159,7 +160,7 @@ class FileController extends ClientApiController
*
* Renames a file on the remote machine.
*
* @throws \Throwable
* @throws Throwable
*/
public function rename(RenameFileRequest $request, Server $server): JsonResponse
{
@ -291,7 +292,7 @@ class FileController extends ClientApiController
*
* Requests that a file be downloaded from a remote location by daemon.
*
* @throws \Throwable
* @throws Throwable
*/
public function pull(PullFileRequest $request, Server $server): JsonResponse
{

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Client\Servers;
use App\Exceptions\Model\DataValidationException;
use App\Models\Server;
use Illuminate\Http\JsonResponse;
use App\Facades\Activity;
@ -51,7 +52,7 @@ class NetworkAllocationController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function update(UpdateAllocationRequest $request, Server $server, Allocation $allocation): array
{
@ -78,7 +79,7 @@ class NetworkAllocationController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function setPrimary(SetPrimaryAllocationRequest $request, Server $server, Allocation $allocation): array
{
@ -102,7 +103,7 @@ class NetworkAllocationController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\DisplayException
* @throws DisplayException
*/
public function store(NewAllocationRequest $request, Server $server): array
{
@ -127,7 +128,7 @@ class NetworkAllocationController extends ClientApiController
*
* Delete an allocation from a server.
*
* @throws \App\Exceptions\DisplayException
* @throws DisplayException
*/
public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation): JsonResponse
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Client\Servers;
use App\Exceptions\Model\DataValidationException;
use Throwable;
use Carbon\Carbon;
use Exception;
use Illuminate\Http\Request;
@ -57,12 +59,12 @@ class ScheduleController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\DisplayException
* @throws \App\Exceptions\Model\DataValidationException
* @throws DisplayException
* @throws DataValidationException
*/
public function store(StoreScheduleRequest $request, Server $server): array
{
/** @var \App\Models\Schedule $model */
/** @var Schedule $model */
$model = Schedule::query()->create([
'server_id' => $server->id,
'name' => $request->input('name'),
@ -113,8 +115,8 @@ class ScheduleController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\DisplayException
* @throws \App\Exceptions\Model\DataValidationException
* @throws DisplayException
* @throws DataValidationException
*/
public function update(UpdateScheduleRequest $request, Server $server, Schedule $schedule): array
{
@ -156,7 +158,7 @@ class ScheduleController extends ClientApiController
* Executes a given schedule immediately rather than waiting on it's normally scheduled time
* to pass. This does not care about the schedule state.
*
* @throws \Throwable
* @throws Throwable
*/
public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse
{
@ -184,7 +186,7 @@ class ScheduleController extends ClientApiController
/**
* Get the next run timestamp based on the cron data provided.
*
* @throws \App\Exceptions\DisplayException
* @throws DisplayException
*/
protected function getNextRunAt(Request $request): Carbon
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Client\Servers;
use App\Exceptions\Model\DataValidationException;
use Exception;
use App\Models\Task;
use Illuminate\Http\Response;
use App\Models\Server;
@ -38,8 +40,8 @@ class ScheduleTaskController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws \App\Exceptions\Service\ServiceLimitExceededException
* @throws DataValidationException
* @throws ServiceLimitExceededException
*/
public function store(StoreTaskRequest $request, Server $server, Schedule $schedule): array
{
@ -52,10 +54,10 @@ class ScheduleTaskController extends ClientApiController
throw new HttpForbiddenException("A backup task cannot be created when the server's backup limit is set to 0.");
}
/** @var \App\Models\Task|null $lastTask */
/** @var Task|null $lastTask */
$lastTask = $schedule->tasks()->orderByDesc('sequence_id')->first();
/** @var \App\Models\Task $task */
/** @var Task $task */
$task = $this->connection->transaction(function () use ($request, $schedule, $lastTask) {
$sequenceId = ($lastTask->sequence_id ?? 0) + 1;
$requestSequenceId = $request->integer('sequence_id', $sequenceId);
@ -103,7 +105,7 @@ class ScheduleTaskController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function update(StoreTaskRequest $request, Server $server, Schedule $schedule, Task $task): array
{
@ -160,7 +162,7 @@ class ScheduleTaskController extends ClientApiController
* Delete a given task for a schedule. If there are subsequent tasks stored in the database
* for this schedule their sequence IDs are decremented properly.
*
* @throws \Exception
* @throws Exception
*/
public function delete(ClientApiRequest $request, Server $server, Schedule $schedule, Task $task): JsonResponse
{

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Client\Servers;
use Throwable;
use App\Facades\Activity;
use App\Http\Controllers\Api\Client\ClientApiController;
use App\Http\Requests\Api\Client\Servers\Settings\DescriptionServerRequest;
@ -75,7 +76,7 @@ class SettingsController extends ClientApiController
*
* Reinstalls the server on the daemon.
*
* @throws \Throwable
* @throws Throwable
*/
public function reinstall(ReinstallServerRequest $request, Server $server): JsonResponse
{
@ -91,7 +92,7 @@ class SettingsController extends ClientApiController
*
* Changes the Docker image in use by the server.
*
* @throws \Throwable
* @throws Throwable
*/
public function dockerImage(SetDockerImageRequest $request, Server $server): JsonResponse
{

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api\Client\Servers;
use Illuminate\Validation\ValidationException;
use App\Exceptions\Model\DataValidationException;
use App\Models\Server;
use App\Facades\Activity;
use App\Models\ServerVariable;
@ -55,8 +57,8 @@ class StartupController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \Illuminate\Validation\ValidationException
* @throws \App\Exceptions\Model\DataValidationException
* @throws ValidationException
* @throws DataValidationException
*/
public function update(UpdateStartupVariableRequest $request, Server $server): array
{

View File

@ -2,6 +2,11 @@
namespace App\Http\Controllers\Api\Client\Servers;
use App\Exceptions\Model\DataValidationException;
use App\Exceptions\Service\Subuser\ServerSubuserExistsException;
use App\Exceptions\Service\Subuser\UserIsServerOwnerException;
use Throwable;
use App\Models\Subuser;
use App\Models\User;
use App\Services\Subusers\SubuserDeletionService;
use App\Services\Subusers\SubuserUpdateService;
@ -70,10 +75,10 @@ class SubuserController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws \App\Exceptions\Service\Subuser\ServerSubuserExistsException
* @throws \App\Exceptions\Service\Subuser\UserIsServerOwnerException
* @throws \Throwable
* @throws DataValidationException
* @throws ServerSubuserExistsException
* @throws UserIsServerOwnerException
* @throws Throwable
*/
public function store(StoreSubuserRequest $request, Server $server): array
{
@ -100,11 +105,11 @@ class SubuserController extends ClientApiController
*
* @return array<array-key, mixed>
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function update(UpdateSubuserRequest $request, Server $server, User $user): array
{
/** @var \App\Models\Subuser $subuser */
/** @var Subuser $subuser */
$subuser = $request->attributes->get('subuser');
$this->updateService->handle($subuser, $server, $this->getDefaultPermissions($request));
@ -121,7 +126,7 @@ class SubuserController extends ClientApiController
*/
public function delete(DeleteSubuserRequest $request, Server $server, User $user): JsonResponse
{
/** @var \App\Models\Subuser $subuser */
/** @var Subuser $subuser */
$subuser = $request->attributes->get('subuser');
$this->deletionService->handle($subuser, $server);

View File

@ -2,6 +2,10 @@
namespace App\Http\Controllers\Api\Client;
use App\Exceptions\Model\DataValidationException;
use Throwable;
use Illuminate\Validation\ValidationException;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@ -32,7 +36,7 @@ class TwoFactorController extends ClientApiController
* it on their account. If two-factor is already enabled this endpoint
* will return a 400 error.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function index(Request $request): JsonResponse
{
@ -50,8 +54,8 @@ class TwoFactorController extends ClientApiController
*
* Updates a user's account to have two-factor enabled.
*
* @throws \Throwable
* @throws \Illuminate\Validation\ValidationException
* @throws Throwable
* @throws ValidationException
*/
public function store(Request $request): JsonResponse
{
@ -83,7 +87,7 @@ class TwoFactorController extends ClientApiController
* Disables two-factor authentication on an account if the password provided
* is valid.
*
* @throws \Throwable
* @throws Throwable
*/
public function delete(Request $request): JsonResponse
{
@ -91,7 +95,7 @@ class TwoFactorController extends ClientApiController
throw new BadRequestHttpException('The password provided was not valid.');
}
/** @var \App\Models\User $user */
/** @var User $user */
$user = $request->user();
$user->update([

View File

@ -2,6 +2,9 @@
namespace App\Http\Controllers\Api\Remote;
use DateTimeInterface;
use Exception;
use App\Models\Node;
use Carbon\Carbon;
use Illuminate\Support\Str;
use App\Models\User;
@ -14,7 +17,7 @@ class ActivityProcessingController extends Controller
{
public function __invoke(ActivityEventRequest $request): void
{
/** @var \App\Models\Node $node */
/** @var Node $node */
$node = $request->attributes->get('node');
$servers = $node->servers()->whereIn('uuid', $request->servers())->get()->keyBy('uuid');
@ -22,7 +25,7 @@ class ActivityProcessingController extends Controller
$logs = [];
foreach ($request->input('data') as $datum) {
/** @var \App\Models\Server|null $server */
/** @var Server|null $server */
$server = $servers->get($datum['server']);
if (is_null($server) || !Str::startsWith($datum['event'], 'server:')) {
continue;
@ -30,11 +33,11 @@ class ActivityProcessingController extends Controller
try {
$when = Carbon::createFromFormat(
\DateTimeInterface::RFC3339,
DateTimeInterface::RFC3339,
preg_replace('/(\.\d+)Z$/', 'Z', $datum['timestamp']),
'UTC'
);
} catch (\Exception $exception) {
} catch (Exception $exception) {
logger()->warning($exception, ['timestamp' => $datum['timestamp']]);
// If we cannot parse the value for some reason don't blow up this request, just go ahead

View File

@ -2,6 +2,11 @@
namespace App\Http\Controllers\Api\Remote\Backups;
use Exception;
use Throwable;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use App\Models\Node;
use App\Models\Server;
use Carbon\CarbonImmutable;
use Illuminate\Http\Request;
use App\Models\Backup;
@ -25,14 +30,14 @@ class BackupRemoteUploadController extends Controller
/**
* Returns the required presigned urls to upload a backup to S3 cloud storage.
*
* @throws \Exception
* @throws \Throwable
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
* @throws Exception
* @throws Throwable
* @throws ModelNotFoundException
*/
public function __invoke(Request $request, string $backup): JsonResponse
{
// Get the node associated with the request.
/** @var \App\Models\Node $node */
/** @var Node $node */
$node = $request->attributes->get('node');
// Get the size query parameter.
@ -41,14 +46,14 @@ class BackupRemoteUploadController extends Controller
throw new BadRequestHttpException('A non-empty "size" query parameter must be provided.');
}
/** @var \App\Models\Backup $model */
/** @var Backup $model */
$model = Backup::query()
->where('uuid', $backup)
->firstOrFail();
// Check that the backup is "owned" by the node making the request. This avoids other nodes
// from messing with backups that they don't own.
/** @var \App\Models\Server $server */
/** @var Server $server */
$server = $model->server;
if ($server->node_id !== $node->id) {
throw new HttpForbiddenException('You do not have permission to access that backup.');

View File

@ -2,6 +2,10 @@
namespace App\Http\Controllers\Api\Remote\Backups;
use Throwable;
use App\Models\Node;
use App\Models\Server;
use Exception;
use Carbon\CarbonImmutable;
use Illuminate\Http\Request;
use App\Models\Backup;
@ -25,22 +29,22 @@ class BackupStatusController extends Controller
/**
* Handles updating the state of a backup.
*
* @throws \Throwable
* @throws Throwable
*/
public function index(ReportBackupCompleteRequest $request, string $backup): JsonResponse
{
// Get the node associated with the request.
/** @var \App\Models\Node $node */
/** @var Node $node */
$node = $request->attributes->get('node');
/** @var \App\Models\Backup $model */
/** @var Backup $model */
$model = Backup::query()
->where('uuid', $backup)
->firstOrFail();
// Check that the backup is "owned" by the node making the request. This avoids other nodes
// from messing with backups that they don't own.
/** @var \App\Models\Server $server */
/** @var Server $server */
$server = $model->server;
if ($server->node_id !== $node->id) {
throw new HttpForbiddenException('You do not have permission to access that backup.');
@ -86,11 +90,11 @@ class BackupStatusController extends Controller
* The only thing the successful field does is update the entry value for the audit logs
* table tracking for this restoration.
*
* @throws \Throwable
* @throws Throwable
*/
public function restore(Request $request, string $backup): JsonResponse
{
/** @var \App\Models\Backup $model */
/** @var Backup $model */
$model = Backup::query()->where('uuid', $backup)->firstOrFail();
$model->server->update(['status' => null]);
@ -108,8 +112,8 @@ class BackupStatusController extends Controller
*
* @param ?array<array{int, etag: string, part_number: string}> $parts
*
* @throws \Exception
* @throws \App\Exceptions\DisplayException
* @throws Exception
* @throws DisplayException
*/
protected function completeMultipartUpload(Backup $backup, S3Filesystem $adapter, bool $successful, ?array $parts): void
{

View File

@ -2,6 +2,9 @@
namespace App\Http\Controllers\Api\Remote\Servers;
use App\Models\Node;
use Throwable;
use App\Models\ActivityLog;
use App\Enums\ServerState;
use App\Models\Backup;
use Illuminate\Http\Request;
@ -42,7 +45,7 @@ class ServerDetailsController extends Controller
*/
public function list(Request $request): ServerConfigurationCollection
{
/** @var \App\Models\Node $node */
/** @var Node $node */
$node = $request->attributes->get('node');
// Avoid run-away N+1 SQL queries by preloading the relationships that are used
@ -62,7 +65,7 @@ class ServerDetailsController extends Controller
* do not get incorrectly stuck in installing/restoring from backup states since
* a daemon reboot would completely stop those processes.
*
* @throws \Throwable
* @throws Throwable
*/
public function resetState(Request $request): JsonResponse
{
@ -85,9 +88,9 @@ class ServerDetailsController extends Controller
->get();
$this->connection->transaction(function () use ($node, $servers) {
/** @var \App\Models\Server $server */
/** @var Server $server */
foreach ($servers as $server) {
/** @var \App\Models\ActivityLog|null $activity */
/** @var ActivityLog|null $activity */
$activity = $server->activity->first();
if (!$activity) {
continue;

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Remote\Servers;
use App\Exceptions\Model\DataValidationException;
use App\Enums\ServerState;
use Illuminate\Http\Response;
use App\Models\Server;
@ -29,7 +30,7 @@ class ServerInstallController extends Controller
/**
* Updates the installation state of a server.
*
* @throws \App\Exceptions\Model\DataValidationException
* @throws DataValidationException
*/
public function store(InstallationDataRequest $request, Server $server): JsonResponse
{

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Remote\Servers;
use Throwable;
use App\Models\Server;
use App\Repositories\Daemon\DaemonServerRepository;
use Illuminate\Http\Response;
@ -26,7 +27,7 @@ class ServerTransferController extends Controller
/**
* The daemon notifies us about a transfer failure.
*
* @throws \Throwable
* @throws Throwable
*/
public function failure(Server $server): JsonResponse
{
@ -41,7 +42,7 @@ class ServerTransferController extends Controller
/**
* The daemon notifies us about a transfer success.
*
* @throws \Throwable
* @throws Throwable
*/
public function success(Server $server): JsonResponse
{
@ -50,7 +51,7 @@ class ServerTransferController extends Controller
throw new ConflictHttpException('Server is not being transferred.');
}
/** @var \App\Models\Server $server */
/** @var Server $server */
$server = $this->connection->transaction(function () use ($server, $transfer) {
$allocations = array_merge([$transfer->old_allocation], $transfer->old_additional_allocations);
@ -86,7 +87,7 @@ class ServerTransferController extends Controller
* Release all the reserved allocations for this transfer and mark it as failed in
* the database.
*
* @throws \Throwable
* @throws Throwable
*/
protected function processFailedTransfer(ServerTransfer $transfer): JsonResponse
{

View File

@ -2,6 +2,7 @@
namespace App\Http\Middleware\Activity;
use Closure;
use App\Facades\LogTarget;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
@ -12,7 +13,7 @@ class AccountSubject
* Sets the actor and default subject for all requests passing through this
* middleware to be the currently logged in user.
*/
public function handle(Request $request, \Closure $next): Response
public function handle(Request $request, Closure $next): Response
{
LogTarget::setActor($request->user());
LogTarget::setSubject($request->user());

View File

@ -2,6 +2,7 @@
namespace App\Http\Middleware\Activity;
use Closure;
use App\Models\Server;
use App\Facades\LogTarget;
use Illuminate\Http\Request;
@ -17,7 +18,7 @@ class ServerSubject
* If no server is found this is a no-op as the activity log service can always
* set the user based on the authmanager response.
*/
public function handle(Request $request, \Closure $next): Response
public function handle(Request $request, Closure $next): Response
{
$server = $request->route()->parameter('server');

View File

@ -2,6 +2,7 @@
namespace App\Http\Middleware\Activity;
use Closure;
use Illuminate\Http\Request;
use App\Models\ApiKey;
use App\Facades\LogTarget;
@ -14,7 +15,7 @@ class TrackAPIKey
* request singleton so that all tracked activity log events are properly associated
* with the given API key.
*/
public function handle(Request $request, \Closure $next): mixed
public function handle(Request $request, Closure $next): mixed
{
if ($request->user()) {
$token = $request->user()->currentAccessToken();

View File

@ -2,6 +2,8 @@
namespace App\Http\Middleware\Api\Application;
use Closure;
use App\Models\User;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@ -11,9 +13,9 @@ class AuthenticateApplicationUser
* Authenticate that the currently authenticated user is an administrator
* and should be allowed to proceed through the application API.
*/
public function handle(Request $request, \Closure $next): mixed
public function handle(Request $request, Closure $next): mixed
{
/** @var \App\Models\User|null $user */
/** @var User|null $user */
$user = $request->user();
if (!$user || !$user->isRootAdmin()) {
throw new AccessDeniedHttpException('This account does not have permission to access the API.');

Some files were not shown because too many files have changed in this diff Show More