Merge branch 'main' of github.com:pelican-dev/panel
This commit is contained in:
commit
0b950832c2
@ -60,7 +60,7 @@ class MakeNodeCommand extends Command
|
||||
$data['upload_size'] = $this->option('uploadSize') ?? $this->ask('Enter the maximum filesize upload', '100');
|
||||
$data['daemon_listen'] = $this->option('daemonListeningPort') ?? $this->ask('Enter the daemon listening port', '8080');
|
||||
$data['daemon_sftp'] = $this->option('daemonSFTPPort') ?? $this->ask('Enter the daemon SFTP listening port', '2022');
|
||||
$data['daemon_base'] = $this->option('daemonBase') ?? $this->ask('Enter the base folder', '/var/lib/panel/volumes');
|
||||
$data['daemon_base'] = $this->option('daemonBase') ?? $this->ask('Enter the base folder', '/var/lib/pelican/volumes');
|
||||
|
||||
$node = $this->creationService->handle($data);
|
||||
$this->line('Successfully created a new node with the name ' . $data['name'] . ' and has an id of ' . $node->id . '.');
|
||||
|
@ -43,17 +43,17 @@ class NodeResource extends Resource
|
||||
->required()
|
||||
->integer()
|
||||
->default(100),
|
||||
Forms\Components\TextInput::make('daemonListen')
|
||||
Forms\Components\TextInput::make('daemon_listen')
|
||||
->required()
|
||||
->integer()
|
||||
->label('Daemon Port')
|
||||
->default(8080),
|
||||
Forms\Components\TextInput::make('daemonSFTP')
|
||||
Forms\Components\TextInput::make('daemon_sftp')
|
||||
->required()
|
||||
->integer()
|
||||
->label('Daemon SFTP Port')
|
||||
->default(2022),
|
||||
Forms\Components\TextInput::make('daemonBase')
|
||||
Forms\Components\TextInput::make('daemon_base')
|
||||
->required()
|
||||
->maxLength(191)
|
||||
->default('/home/daemon-files'),
|
||||
|
@ -113,7 +113,7 @@ class CreateNode extends CreateRecord
|
||||
'lg' => 1,
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('daemonListen')
|
||||
Forms\Components\TextInput::make('daemon_listen')
|
||||
->columnSpan([
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace App\Filament\Resources\NodeResource\Pages;
|
||||
|
||||
use App\Filament\Resources\NodeResource;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Node;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
|
||||
@ -91,6 +91,52 @@ class EditNode extends EditRecord
|
||||
'md' => 1,
|
||||
'lg' => 1,
|
||||
])
|
||||
->live()
|
||||
->afterStateUpdated(function ($state, Forms\Set $set) {
|
||||
$ports = collect();
|
||||
$update = false;
|
||||
foreach ($state as $portEntry) {
|
||||
if (!str_contains($portEntry, '-')) {
|
||||
if (is_numeric($portEntry)) {
|
||||
$ports->push((int) $portEntry);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not add non numerical ports
|
||||
$update = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$update = true;
|
||||
[$start, $end] = explode('-', $portEntry);
|
||||
if (!is_numeric($start) || !is_numeric($end)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$start = max((int) $start, 0);
|
||||
$end = min((int) $end, 2 ** 16 - 1);
|
||||
for ($i = $start; $i <= $end; $i++) {
|
||||
$ports->push($i);
|
||||
}
|
||||
}
|
||||
|
||||
$uniquePorts = $ports->unique()->values();
|
||||
if ($ports->count() > $uniquePorts->count()) {
|
||||
$update = true;
|
||||
$ports = $uniquePorts;
|
||||
}
|
||||
|
||||
$sortedPorts = $ports->sort()->values();
|
||||
if ($sortedPorts->all() !== $ports->all()) {
|
||||
$update = true;
|
||||
$ports = $sortedPorts;
|
||||
}
|
||||
if ($update) {
|
||||
$set('port', $ports->all());
|
||||
}
|
||||
})
|
||||
->placeholder('25565')
|
||||
->helperText('Individual ports or port ranges here separated by spaces')
|
||||
->splitKeys(['Tab', ' ']),
|
||||
@ -108,6 +154,15 @@ class EditNode extends EditRecord
|
||||
Forms\Components\Repeater::make('allocations')
|
||||
->orderColumn('server_id')
|
||||
->columnSpan(4)
|
||||
->collapsible()->collapsed()
|
||||
->itemLabel(function (array $state) {
|
||||
$host = $state['ip'] . ':' . $state['port'];
|
||||
if ($state['ip_alias']) {
|
||||
return $state['ip_alias'] ." ($host)";
|
||||
}
|
||||
|
||||
return $host;
|
||||
})
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 3,
|
||||
@ -133,7 +188,7 @@ class EditNode extends EditRecord
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 1,
|
||||
'lg' => 2,
|
||||
])
|
||||
->minValue(0)
|
||||
->maxValue(65535)
|
||||
@ -147,15 +202,21 @@ class EditNode extends EditRecord
|
||||
'lg' => 3,
|
||||
])
|
||||
->label('Alias'),
|
||||
Forms\Components\TextInput::make('server')
|
||||
Forms\Components\Select::make('server')
|
||||
->columnSpan([
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 2,
|
||||
'lg' => 3,
|
||||
'lg' => 2,
|
||||
])
|
||||
->formatStateUsing(fn (Allocation $allocation) => $allocation->server?->name)
|
||||
->activeUrl(true)
|
||||
->searchable()
|
||||
->preload()
|
||||
->relationship(
|
||||
'server',
|
||||
'name',
|
||||
fn (Builder $query, Forms\Get $get) => $query
|
||||
->where('node_id', $get('node_id')),
|
||||
)
|
||||
->placeholder('Not assigned'),
|
||||
]),
|
||||
]),
|
||||
|
Loading…
x
Reference in New Issue
Block a user