mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-31 06:04:46 +02:00
cleanup server boilerplate
This commit is contained in:
parent
e2399eb4e2
commit
5c8097d9b7
@ -7,7 +7,6 @@ use App\Models\Allocation;
|
|||||||
use App\Models\Egg;
|
use App\Models\Egg;
|
||||||
use App\Models\Node;
|
use App\Models\Node;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Repositories\Daemon\DaemonServerRepository;
|
|
||||||
use App\Services\Allocations\AssignmentService;
|
use App\Services\Allocations\AssignmentService;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
@ -154,12 +153,12 @@ class ServerResource extends Resource
|
|||||||
->label('Additional Allocations')
|
->label('Additional Allocations')
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->disabled(fn (Forms\Get $get) => $get('allocation_id') === null)
|
->disabled(fn (Forms\Get $get) => $get('allocation_id') === null)
|
||||||
->hintActions([Forms\Components\Actions\Action::make('asdf')->action(function (Forms\Components\Repeater $component) {
|
// ->hintActions([Forms\Components\Actions\Action::make('asdf')->action(function (Forms\Components\Repeater $component) {
|
||||||
$state = $component->getState();
|
// $state = $component->getState();
|
||||||
dd($state);
|
// dd($state);
|
||||||
})])
|
// })])
|
||||||
// ->addable() TODO disable when all allocations are taken
|
// ->addable() TODO disable when all allocations are taken
|
||||||
// ->addable() TODO disable until first additional allocation is selected
|
// ->addable() TODO disable until first additional allocation is selected
|
||||||
->simple(
|
->simple(
|
||||||
Forms\Components\Select::make('extra_allocations')
|
Forms\Components\Select::make('extra_allocations')
|
||||||
->live()
|
->live()
|
||||||
@ -180,7 +179,9 @@ class ServerResource extends Resource
|
|||||||
'ip',
|
'ip',
|
||||||
fn (Builder $query, Forms\Get $get, Forms\Components\Select $component, $state) => $query
|
fn (Builder $query, Forms\Get $get, Forms\Components\Select $component, $state) => $query
|
||||||
->where('node_id', $get('../../node_id'))
|
->where('node_id', $get('../../node_id'))
|
||||||
->whereNotIn('id', collect(($repeater = $component->getParentRepeater())->getState())
|
->whereNotIn(
|
||||||
|
'id',
|
||||||
|
collect(($repeater = $component->getParentRepeater())->getState())
|
||||||
->pluck(
|
->pluck(
|
||||||
(string) str($component->getStatePath())
|
(string) str($component->getStatePath())
|
||||||
->after("{$repeater->getStatePath()}.")
|
->after("{$repeater->getStatePath()}.")
|
||||||
@ -445,66 +446,6 @@ class ServerResource extends Resource
|
|||||||
])
|
])
|
||||||
->required(),
|
->required(),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\Textarea::make('startup')
|
|
||||||
->hintIcon('tabler-code')
|
|
||||||
->label('Startup Command')
|
|
||||||
->required()
|
|
||||||
->live()
|
|
||||||
->rows(function ($state) {
|
|
||||||
return str($state)->explode("\n")->reduce(
|
|
||||||
fn (int $carry, $line) => $carry + floor(strlen($line) / 125),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
})
|
|
||||||
->columnSpanFull(),
|
|
||||||
|
|
||||||
Forms\Components\Hidden::make('environment')
|
|
||||||
->default([])
|
|
||||||
->columnSpanFull(),
|
|
||||||
|
|
||||||
Forms\Components\Section::make('Egg Variables')
|
|
||||||
->icon('tabler-eggs')
|
|
||||||
->iconColor('primary')
|
|
||||||
->collapsible()
|
|
||||||
->collapsed()
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Placeholder::make('Select an egg first to show its variables!')
|
|
||||||
->hidden(fn (Forms\Get $get) => !empty($get('server_variables'))),
|
|
||||||
|
|
||||||
Forms\Components\Repeater::make('server_variables')
|
|
||||||
->relationship('serverVariables')
|
|
||||||
->grid(2)
|
|
||||||
->reorderable(false)
|
|
||||||
->addable(false)
|
|
||||||
->deletable(false)
|
|
||||||
->default([])
|
|
||||||
->hidden(fn ($state) => empty($state))
|
|
||||||
->schema([
|
|
||||||
Forms\Components\TextInput::make('variable_value')
|
|
||||||
->rules([
|
|
||||||
fn (Forms\Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
|
|
||||||
$validator = Validator::make(['validatorkey' => $value], [
|
|
||||||
'validatorkey' => $get('rules'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
|
||||||
$message = str($validator->errors()->first())->replace('validatorkey', $get('name'));
|
|
||||||
|
|
||||||
$fail($message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
])
|
|
||||||
->label(fn (Forms\Get $get) => $get('name'))
|
|
||||||
->hint(fn (Forms\Get $get) => $get('rules'))
|
|
||||||
->prefix(fn (Forms\Get $get) => '{{' . $get('env_variable') . '}}')
|
|
||||||
->helperText(fn (Forms\Get $get) => empty($get('description')) ? '—' : $get('description'))
|
|
||||||
->maxLength(191),
|
|
||||||
|
|
||||||
Forms\Components\Hidden::make('variable_id')->default(0),
|
|
||||||
])
|
|
||||||
->columnSpanFull(),
|
|
||||||
]),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user