mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00
Interpret Server
StartupCommand
variables (#1009)
* Use `StartupCommandService` * Simplify variable name * Add `PreviewStartupAction`
This commit is contained in:
parent
09abec6ee6
commit
c1704eef3b
@ -7,6 +7,7 @@ use App\Enums\ServerState;
|
|||||||
use App\Enums\SuspendAction;
|
use App\Enums\SuspendAction;
|
||||||
use App\Filament\Admin\Resources\ServerResource;
|
use App\Filament\Admin\Resources\ServerResource;
|
||||||
use App\Filament\Admin\Resources\ServerResource\RelationManagers\AllocationsRelationManager;
|
use App\Filament\Admin\Resources\ServerResource\RelationManagers\AllocationsRelationManager;
|
||||||
|
use App\Filament\Components\Forms\Actions\PreviewStartupAction;
|
||||||
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
|
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
|
||||||
use App\Filament\Server\Pages\Console;
|
use App\Filament\Server\Pages\Console;
|
||||||
use App\Models\Database;
|
use App\Models\Database;
|
||||||
@ -549,12 +550,14 @@ class EditServer extends EditRecord
|
|||||||
true => 'tabler-code-off',
|
true => 'tabler-code-off',
|
||||||
])
|
])
|
||||||
->required(),
|
->required(),
|
||||||
|
Hidden::make('previewing')
|
||||||
|
->default(false),
|
||||||
Textarea::make('startup')
|
Textarea::make('startup')
|
||||||
->label(trans('admin/server.startup_cmd'))
|
->label(trans('admin/server.startup_cmd'))
|
||||||
->required()
|
->required()
|
||||||
->columnSpan(6)
|
->columnSpan(6)
|
||||||
->autosize(),
|
->autosize()
|
||||||
|
->hintAction(PreviewStartupAction::make('preview')),
|
||||||
|
|
||||||
Textarea::make('defaultStartup')
|
Textarea::make('defaultStartup')
|
||||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Components\Forms\Actions;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use App\Services\Servers\StartupCommandService;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
|
use Filament\Forms\Get;
|
||||||
|
use Filament\Forms\Set;
|
||||||
|
|
||||||
|
class PreviewStartupAction extends Action
|
||||||
|
{
|
||||||
|
public static function getDefaultName(): ?string
|
||||||
|
{
|
||||||
|
return 'preview';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->action(function (Get $get, Set $set, Server $server) {
|
||||||
|
$active = $get('previewing');
|
||||||
|
$set('previewing', !$active);
|
||||||
|
$set('startup', $active ? $server->startup : fn (Server $server, StartupCommandService $service) => $service->handle($server));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -3,12 +3,14 @@
|
|||||||
namespace App\Filament\Server\Pages;
|
namespace App\Filament\Server\Pages;
|
||||||
|
|
||||||
use App\Facades\Activity;
|
use App\Facades\Activity;
|
||||||
|
use App\Filament\Components\Forms\Actions\PreviewStartupAction;
|
||||||
use App\Models\Permission;
|
use App\Models\Permission;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\ServerVariable;
|
use App\Models\ServerVariable;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms\Components\Component;
|
use Filament\Forms\Components\Component;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
@ -37,6 +39,8 @@ class Startup extends ServerFormPage
|
|||||||
'lg' => 6,
|
'lg' => 6,
|
||||||
])
|
])
|
||||||
->schema([
|
->schema([
|
||||||
|
Hidden::make('previewing')
|
||||||
|
->default(false),
|
||||||
Textarea::make('startup')
|
Textarea::make('startup')
|
||||||
->label('Startup Command')
|
->label('Startup Command')
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
@ -46,6 +50,7 @@ class Startup extends ServerFormPage
|
|||||||
'lg' => 4,
|
'lg' => 4,
|
||||||
])
|
])
|
||||||
->autosize()
|
->autosize()
|
||||||
|
->hintAction(PreviewStartupAction::make('preview'))
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
TextInput::make('custom_image')
|
TextInput::make('custom_image')
|
||||||
->label('Docker Image')
|
->label('Docker Image')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user