mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 15:34:44 +02:00
fix error on no node created
This commit is contained in:
parent
a9a39ae502
commit
4c09905503
@ -64,7 +64,7 @@ class ServerResource extends Resource
|
|||||||
Forms\Components\Select::make('node_id')
|
Forms\Components\Select::make('node_id')
|
||||||
->disabledOn('edit')
|
->disabledOn('edit')
|
||||||
->prefixIcon('tabler-server-2')
|
->prefixIcon('tabler-server-2')
|
||||||
->default(fn () => Node::query()->latest()->first()->id)
|
->default(fn () => Node::query()->latest()->first()?->id)
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->live()
|
->live()
|
||||||
->relationship('node', 'name')
|
->relationship('node', 'name')
|
||||||
@ -78,8 +78,9 @@ class ServerResource extends Resource
|
|||||||
->columnSpan(3)
|
->columnSpan(3)
|
||||||
->disabled(fn (Forms\Get $get) => $get('node_id') === null)
|
->disabled(fn (Forms\Get $get) => $get('node_id') === null)
|
||||||
->searchable(['ip', 'port', 'ip_alias'])
|
->searchable(['ip', 'port', 'ip_alias'])
|
||||||
->getOptionLabelFromRecordUsing(fn (Allocation $allocation) => "$allocation->ip:$allocation->port" .
|
->getOptionLabelFromRecordUsing(
|
||||||
($allocation->ip_alias ? " ($allocation->ip_alias)" : '')
|
fn (Allocation $allocation) => "$allocation->ip:$allocation->port" .
|
||||||
|
($allocation->ip_alias ? " ($allocation->ip_alias)" : '')
|
||||||
)
|
)
|
||||||
->placeholder(function (Forms\Get $get) {
|
->placeholder(function (Forms\Get $get) {
|
||||||
$node = Node::find($get('node_id'));
|
$node = Node::find($get('node_id'));
|
||||||
@ -308,8 +309,10 @@ class ServerResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
->live()
|
->live()
|
||||||
->rows(function ($state) {
|
->rows(function ($state) {
|
||||||
return str($state)->explode("\n")->reduce(fn (int $carry, $line) => $carry + floor(strlen($line) / 125),
|
return str($state)->explode("\n")->reduce(
|
||||||
0);
|
fn (int $carry, $line) => $carry + floor(strlen($line) / 125),
|
||||||
|
0
|
||||||
|
);
|
||||||
})
|
})
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
|
|
||||||
@ -331,7 +334,6 @@ class ServerResource extends Resource
|
|||||||
->default([])
|
->default([])
|
||||||
->hidden(fn ($state) => empty($state))
|
->hidden(fn ($state) => empty($state))
|
||||||
->afterStateUpdated(function () {
|
->afterStateUpdated(function () {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
->schema([
|
->schema([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user