mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 20:24:44 +02:00
fix server startup and settings page
This commit is contained in:
parent
3afe18d7cf
commit
25dc471ef7
@ -8,6 +8,7 @@ use Filament\Forms\Concerns\InteractsWithForms;
|
|||||||
use Filament\Schemas\Components\Form;
|
use Filament\Schemas\Components\Form;
|
||||||
use Filament\Pages\Concerns\InteractsWithFormActions;
|
use Filament\Pages\Concerns\InteractsWithFormActions;
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Form $form
|
* @property Form $form
|
||||||
@ -28,11 +29,19 @@ abstract class ServerFormPage extends Page
|
|||||||
$this->fillForm();
|
$this->fillForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->statePath('data')
|
||||||
|
->model($this->getRecord());
|
||||||
|
}
|
||||||
|
|
||||||
protected function authorizeAccess(): void {}
|
protected function authorizeAccess(): void {}
|
||||||
|
|
||||||
protected function fillform(): void
|
protected function fillform(): void
|
||||||
{
|
{
|
||||||
$data = $this->getRecord()->attributesToArray();
|
$data = $this->getRecord()->attributesToArray();
|
||||||
|
|
||||||
$this->form->fill($data);
|
$this->form->fill($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ use App\Models\Server;
|
|||||||
use App\Services\Servers\ReinstallServerService;
|
use App\Services\Servers\ReinstallServerService;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Schemas\Components\Fieldset;
|
use Filament\Schemas\Components\Fieldset;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
@ -30,10 +29,7 @@ class Settings extends ServerFormPage
|
|||||||
*/
|
*/
|
||||||
public function form(Schema $schema): Schema
|
public function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
/** @var Server $server */
|
return parent::form($schema)
|
||||||
$server = Filament::getTenant();
|
|
||||||
|
|
||||||
return $schema
|
|
||||||
->columns([
|
->columns([
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
'sm' => 2,
|
'sm' => 2,
|
||||||
@ -42,6 +38,7 @@ class Settings extends ServerFormPage
|
|||||||
])
|
])
|
||||||
->components([
|
->components([
|
||||||
Section::make('Server Information')
|
Section::make('Server Information')
|
||||||
|
->columnSpanFull()
|
||||||
->columns([
|
->columns([
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
'sm' => 2,
|
'sm' => 2,
|
||||||
@ -55,7 +52,7 @@ class Settings extends ServerFormPage
|
|||||||
->schema([
|
->schema([
|
||||||
TextInput::make('name')
|
TextInput::make('name')
|
||||||
->label('Server Name')
|
->label('Server Name')
|
||||||
->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
|
->disabled(fn (Server $server) => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
|
||||||
->required()
|
->required()
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
@ -68,7 +65,7 @@ class Settings extends ServerFormPage
|
|||||||
Textarea::make('description')
|
Textarea::make('description')
|
||||||
->label('Server Description')
|
->label('Server Description')
|
||||||
->hidden(!config('panel.editable_server_descriptions'))
|
->hidden(!config('panel.editable_server_descriptions'))
|
||||||
->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
|
->disabled(fn (Server $server) => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
'sm' => 2,
|
'sm' => 2,
|
||||||
@ -147,6 +144,7 @@ class Settings extends ServerFormPage
|
|||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
Section::make('Node Information')
|
Section::make('Node Information')
|
||||||
|
->columnSpanFull()
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('node.name')
|
TextInput::make('node.name')
|
||||||
->label('Node Name')
|
->label('Node Name')
|
||||||
@ -154,7 +152,7 @@ class Settings extends ServerFormPage
|
|||||||
->disabled(),
|
->disabled(),
|
||||||
Fieldset::make('SFTP Information')
|
Fieldset::make('SFTP Information')
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->hidden(fn () => !auth()->user()->can(Permission::ACTION_FILE_SFTP, $server))
|
->hidden(fn (Server $server) => !auth()->user()->can(Permission::ACTION_FILE_SFTP, $server))
|
||||||
->label('SFTP Information')
|
->label('SFTP Information')
|
||||||
->columns([
|
->columns([
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
@ -197,12 +195,12 @@ class Settings extends ServerFormPage
|
|||||||
]),
|
]),
|
||||||
Section::make('Reinstall Server')
|
Section::make('Reinstall Server')
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->hidden(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server))
|
->hidden(fn (Server $server) => !auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server))
|
||||||
->collapsible()
|
->collapsible()
|
||||||
->footerActions([
|
->footerActions([
|
||||||
Action::make('reinstall')
|
Action::make('reinstall')
|
||||||
->color('danger')
|
->color('danger')
|
||||||
->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server))
|
->disabled(fn (Server $server) => !auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server))
|
||||||
->label('Reinstall')
|
->label('Reinstall')
|
||||||
->requiresConfirmation()
|
->requiresConfirmation()
|
||||||
->modalHeading('Are you sure you want to reinstall the server?')
|
->modalHeading('Are you sure you want to reinstall the server?')
|
||||||
|
@ -32,10 +32,7 @@ class Startup extends ServerFormPage
|
|||||||
*/
|
*/
|
||||||
public function form(Schema $schema): Schema
|
public function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
/** @var Server $server */
|
return parent::form($schema)
|
||||||
$server = Filament::getTenant();
|
|
||||||
|
|
||||||
return $schema
|
|
||||||
->columns([
|
->columns([
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
'sm' => 1,
|
'sm' => 1,
|
||||||
@ -71,7 +68,7 @@ class Startup extends ServerFormPage
|
|||||||
->label('Docker Image')
|
->label('Docker Image')
|
||||||
->live()
|
->live()
|
||||||
->visible(fn (Server $server) => in_array($server->image, $server->egg->docker_images))
|
->visible(fn (Server $server) => in_array($server->image, $server->egg->docker_images))
|
||||||
->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server))
|
->disabled(fn (Server $server) => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server))
|
||||||
->afterStateUpdated(function ($state, Server $server) {
|
->afterStateUpdated(function ($state, Server $server) {
|
||||||
$original = $server->image;
|
$original = $server->image;
|
||||||
$server->forceFill(['image' => $state])->saveOrFail();
|
$server->forceFill(['image' => $state])->saveOrFail();
|
||||||
@ -101,12 +98,13 @@ class Startup extends ServerFormPage
|
|||||||
'lg' => 2,
|
'lg' => 2,
|
||||||
]),
|
]),
|
||||||
Section::make('Server Variables')
|
Section::make('Server Variables')
|
||||||
|
->columnSpanFull()
|
||||||
->schema([
|
->schema([
|
||||||
Repeater::make('server_variables')
|
Repeater::make('server_variables')
|
||||||
->label('')
|
->label('')
|
||||||
->relationship('serverVariables', fn (Builder $query) => $query->where('egg_variables.user_viewable', true)->orderByPowerJoins('variable.sort'))
|
->relationship('serverVariables', fn (Builder $query) => $query->where('egg_variables.user_viewable', true)->orderByPowerJoins('variable.sort'))
|
||||||
->grid()
|
->grid()
|
||||||
->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
|
->disabled(fn (Server $server) => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
|
||||||
->reorderable(false)->addable(false)->deletable(false)
|
->reorderable(false)->addable(false)->deletable(false)
|
||||||
->schema(function () {
|
->schema(function () {
|
||||||
$text = TextInput::make('variable_value')
|
$text = TextInput::make('variable_value')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user