From 276b51f47731ad7b7c03155cf2a8478e22e8bc87 Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:51:04 +0200 Subject: [PATCH] Remove locationId in MakeNodeCommand (#405) * Concat + Default * Concat + Default + Enforce scheme * fix typo --------- Co-authored-by: Boy132 --- app/Console/Commands/Node/MakeNodeCommand.php | 16 ++++++++-------- .../Resources/NodeResource/Pages/CreateNode.php | 8 ++++---- .../Resources/NodeResource/Pages/EditNode.php | 8 ++++---- app/Models/Node.php | 2 +- lang/en/commands.php | 3 +-- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/Console/Commands/Node/MakeNodeCommand.php b/app/Console/Commands/Node/MakeNodeCommand.php index c57d4ee90..f78f73c25 100644 --- a/app/Console/Commands/Node/MakeNodeCommand.php +++ b/app/Console/Commands/Node/MakeNodeCommand.php @@ -57,19 +57,19 @@ class MakeNodeCommand extends Command $data['public'] = $this->option('public') ?? $this->confirm(__('commands.make_node.public'), true); $data['behind_proxy'] = $this->option('proxy') ?? $this->confirm(__('commands.make_node.behind_proxy')); $data['maintenance_mode'] = $this->option('maintenance') ?? $this->confirm(__('commands.make_node.maintenance_mode')); - $data['memory'] = $this->option('maxMemory') ?? $this->ask(__('commands.make_node.memory')); - $data['memory_overallocate'] = $this->option('overallocateMemory') ?? $this->ask(__('commands.make_node.memory_overallocate')); - $data['disk'] = $this->option('maxDisk') ?? $this->ask(__('commands.make_node.disk')); - $data['disk_overallocate'] = $this->option('overallocateDisk') ?? $this->ask(__('commands.make_node.disk_overallocate')); - $data['cpu'] = $this->option('maxCpu') ?? $this->ask(__('commands.make_node.cpu')); - $data['cpu_overallocate'] = $this->option('overallocateCpu') ?? $this->ask(__('commands.make_node.cpu_overallocate')); - $data['upload_size'] = $this->option('uploadSize') ?? $this->ask(__('commands.make_node.upload_size'), '100'); + $data['memory'] = $this->option('maxMemory') ?? $this->ask(__('commands.make_node.memory'), '0'); + $data['memory_overallocate'] = $this->option('overallocateMemory') ?? $this->ask(__('commands.make_node.memory_overallocate'), '-1'); + $data['disk'] = $this->option('maxDisk') ?? $this->ask(__('commands.make_node.disk'), '0'); + $data['disk_overallocate'] = $this->option('overallocateDisk') ?? $this->ask(__('commands.make_node.disk_overallocate'), '-1'); + $data['cpu'] = $this->option('maxCpu') ?? $this->ask(__('commands.make_node.cpu'), '0'); + $data['cpu_overallocate'] = $this->option('overallocateCpu') ?? $this->ask(__('commands.make_node.cpu_overallocate'), '-1'); + $data['upload_size'] = $this->option('uploadSize') ?? $this->ask(__('commands.make_node.upload_size'), '256'); $data['daemon_listen'] = $this->option('daemonListeningPort') ?? $this->ask(__('commands.make_node.daemonListen'), '8080'); $data['daemon_sftp'] = $this->option('daemonSFTPPort') ?? $this->ask(__('commands.make_node.daemonSFTP'), '2022'); $data['daemon_sftp_alias'] = $this->option('daemonSFTPAlias') ?? $this->ask(__('commands.make_node.daemonSFTPAlias'), ''); $data['daemon_base'] = $this->option('daemonBase') ?? $this->ask(__('commands.make_node.daemonBase'), '/var/lib/pelican/volumes'); $node = $this->creationService->handle($data); - $this->line(__('commands.make_node.succes1') . $data['name'] . __('commands.make_node.succes2') . $node->id . '.'); + $this->line(__('commands.make_node.success', ['name' => $data['name'], 'id' => $node->id])); } } diff --git a/app/Filament/Resources/NodeResource/Pages/CreateNode.php b/app/Filament/Resources/NodeResource/Pages/CreateNode.php index 7a7465726..34611416e 100644 --- a/app/Filament/Resources/NodeResource/Pages/CreateNode.php +++ b/app/Filament/Resources/NodeResource/Pages/CreateNode.php @@ -131,8 +131,8 @@ class CreateNode extends CreateRecord ]) ->label(trans('strings.port')) ->helperText('If you are running the daemon behind Cloudflare you should set the daemon port to 8443 to allow websocket proxying over SSL.') - ->minValue(0) - ->maxValue(65536) + ->minValue(1) + ->maxValue(65535) ->default(8080) ->required() ->integer(), @@ -242,8 +242,8 @@ class CreateNode extends CreateRecord Forms\Components\TextInput::make('daemon_sftp') ->columnSpan(1) ->label('SFTP Port') - ->minValue(0) - ->maxValue(65536) + ->minValue(1) + ->maxValue(65535) ->default(2022) ->required() ->integer(), diff --git a/app/Filament/Resources/NodeResource/Pages/EditNode.php b/app/Filament/Resources/NodeResource/Pages/EditNode.php index 4d2dae7a4..ccd2e97bb 100644 --- a/app/Filament/Resources/NodeResource/Pages/EditNode.php +++ b/app/Filament/Resources/NodeResource/Pages/EditNode.php @@ -132,8 +132,8 @@ class EditNode extends EditRecord ]) ->label(trans('strings.port')) ->helperText('If you are running the daemon behind Cloudflare you should set the daemon port to 8443 to allow websocket proxying over SSL.') - ->minValue(0) - ->maxValue(65536) + ->minValue(1) + ->maxValue(65535) ->default(8080) ->required() ->integer(), @@ -217,8 +217,8 @@ class EditNode extends EditRecord Forms\Components\TextInput::make('daemon_sftp') ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 1, 'lg' => 3]) ->label('SFTP Port') - ->minValue(0) - ->maxValue(65536) + ->minValue(1) + ->maxValue(65535) ->default(2022) ->required() ->integer(), diff --git a/app/Models/Node.php b/app/Models/Node.php index 4a44e6f57..473d3a4a2 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -83,7 +83,7 @@ class Node extends Model 'description' => 'string|nullable', 'public' => 'boolean', 'fqdn' => 'required|string', - 'scheme' => 'required', + 'scheme' => 'required|string|in:http,https', 'behind_proxy' => 'boolean', 'memory' => 'required|numeric|min:0', 'memory_overallocate' => 'required|numeric|min:-1', diff --git a/lang/en/commands.php b/lang/en/commands.php index ba0cc0723..a42ca228b 100644 --- a/lang/en/commands.php +++ b/lang/en/commands.php @@ -39,8 +39,7 @@ return [ 'daemonSFTP' => 'Enter the daemon SFTP listening port', 'daemonSFTPAlias' => 'Enter the daemon SFTP alias (can be empty)', 'daemonBase' => 'Enter the base folder', - 'succes1' => 'Successfully created a new node with the name: ', - 'succes2' => 'and has an id of: ', + 'success' => 'Successfully created a new node with the name :name and has an id of :id', ], 'node_config' => [ 'error_not_exist' => 'The selected node does not exist.',