From 3e01e483fb9da1c9352ecd14a44aa61401b94246 Mon Sep 17 00:00:00 2001 From: notCharles Date: Thu, 18 Apr 2024 17:13:17 -0400 Subject: [PATCH 1/6] Allow variables to be sorted todo: save order in db in a new column 'sort' --- .gitignore | 4 ++++ app/Filament/Resources/EggResource.php | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 2c9fda4ca6..64fd8ad3a1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ resources/lang/locales.js /public/hot result docker-compose.yaml + +public/css/filament-monaco-editor/ + +public/js/filament-monaco-editor/ diff --git a/app/Filament/Resources/EggResource.php b/app/Filament/Resources/EggResource.php index 019acd0351..f8f192d02c 100644 --- a/app/Filament/Resources/EggResource.php +++ b/app/Filament/Resources/EggResource.php @@ -37,12 +37,13 @@ public static function form(Form $form): Form ->helperText('This is the globally unique identifier for this Egg which the Daemon uses as an identifier.'), Forms\Components\TextInput::make('author')->required()->maxLength(191)->disabled() ->helperText('The author of this version of the Egg. Uploading a new Egg configuration from a different author will change this.'), + Forms\Components\Textarea::make('startup')->rows(3)->columnSpanFull() + ->helperText('The default startup command that should be used for new servers using this Egg.'), + Forms\Components\TagsInput::make('file_denylist')->placeholder('denied-file.txt'), Forms\Components\Toggle::make('force_outgoing_ip')->required() ->helperText("Forces all outgoing network traffic to have its Source IP NATed to the IP of the server's primary allocation IP. Required for certain games to work properly when the Node has multiple public IP addresses. Enabling this option will disable internal networking for any servers using this egg, causing them to be unable to internally access other servers on the same node."), - Forms\Components\Textarea::make('startup')->rows(5) - ->helperText('The default startup command that should be used for new servers using this Egg.'), Forms\Components\KeyValue::make('docker_images') ->columnSpanFull() ->addActionLabel('Add Image') @@ -51,6 +52,7 @@ public static function form(Form $form): Form ->helperText('The docker images available to servers using this egg.'), ]), + Forms\Components\Tabs\Tab::make('Process Management') ->columns(2) ->schema([ @@ -79,21 +81,23 @@ public static function form(Form $form): Form ]), Forms\Components\Tabs\Tab::make('Variables') ->columnSpanFull() - // ->columns(2) + ->columns(2) ->schema([ Forms\Components\Repeater::make('Blah') - ->grid(3) + ->grid() ->relationship('variables') ->name('name') - ->columns(1) - ->columnSpan(1) + ->columns(2) + ->reorderable()->reorderableWithDragAndDrop() + ->collapsible()->collapsed() + ->columnSpan(2) ->itemLabel(fn (array $state) => $state['name']) ->schema([ Forms\Components\TextInput::make('name')->live()->maxLength(191)->columnSpanFull(), Forms\Components\Textarea::make('description')->columnSpanFull(), - Forms\Components\TextInput::make('env_variable')->maxLength(191), + Forms\Components\TextInput::make('env_variable')->maxLength(191)->required()->hint(fn ($state) => "{{{$state}}}"), Forms\Components\TextInput::make('default_value')->maxLength(191), - Forms\Components\Textarea::make('rules')->rows(3)->columnSpanFull()->required(), + Forms\Components\TextInput::make('rules')->columnSpanFull()->required(), ]), ]), Forms\Components\Tabs\Tab::make('Install Script') @@ -124,7 +128,6 @@ public static function form(Form $form): Form ])->columnSpanFull()->persistTabInQueryString(), // Forms\Components\TagsInput::make('features'), - // Forms\Components\TagsInput::make('file_denylist')->placeholder('new-file.txt'), // Forms\Components\TextInput::make('update_url'), // Forms\Components\Toggle::make('script_is_privileged')->required(), ]); From 22c03c8075c9cf4fe1ca02e0afd678a161ea25e5 Mon Sep 17 00:00:00 2001 From: notCharles Date: Sat, 20 Apr 2024 17:57:14 -0400 Subject: [PATCH 2/6] add sort column --- .../2024_04_20_214441_add_egg_var_sort.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 database/migrations/2024_04_20_214441_add_egg_var_sort.php diff --git a/database/migrations/2024_04_20_214441_add_egg_var_sort.php b/database/migrations/2024_04_20_214441_add_egg_var_sort.php new file mode 100644 index 0000000000..f1a4346cd4 --- /dev/null +++ b/database/migrations/2024_04_20_214441_add_egg_var_sort.php @@ -0,0 +1,28 @@ +unsignedTinyInteger('sort')->nullable()->after('egg_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('egg_variables', function (Blueprint $table) { + $table->dropColumn('sort'); + }); + } +}; From 53ad87a3494579ec45d1921e244fa7709580a8c2 Mon Sep 17 00:00:00 2001 From: notCharles Date: Sun, 21 Apr 2024 13:30:55 -0400 Subject: [PATCH 3/6] update egg configuration tab --- app/Filament/Resources/EggResource.php | 57 +++++++++++++++++--------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/app/Filament/Resources/EggResource.php b/app/Filament/Resources/EggResource.php index 15a5962c64..dd3d62b3e6 100644 --- a/app/Filament/Resources/EggResource.php +++ b/app/Filament/Resources/EggResource.php @@ -27,23 +27,49 @@ public static function form(Form $form): Form ->schema([ Forms\Components\Tabs::make()->tabs([ Forms\Components\Tabs\Tab::make('Configuration') - ->columns(2) + ->columns(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 4]) ->schema([ - Forms\Components\TextInput::make('name')->required()->maxLength(191) + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(191) + ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]) ->helperText('A simple, human-readable name to use as an identifier for this Egg.'), - Forms\Components\Textarea::make('description')->rows(5) + Forms\Components\TextInput::make('uuid') + ->disabled() + ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]) + ->helperText('This is the globally unique identifier for this Egg which Wings uses as an identifier.'), + Forms\Components\Textarea::make('description') + ->rows(3) + ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]) ->helperText('A description of this Egg that will be displayed throughout the Panel as needed.'), - Forms\Components\TextInput::make('uuid')->disabled() - ->helperText('This is the globally unique identifier for this Egg which the Daemon uses as an identifier.'), - Forms\Components\TextInput::make('author')->required()->maxLength(191)->disabled() + Forms\Components\TextInput::make('author') + ->required() + ->maxLength(191) + ->disabled() + ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]) ->helperText('The author of this version of the Egg. Uploading a new Egg configuration from a different author will change this.'), - Forms\Components\Textarea::make('startup')->rows(3)->columnSpanFull() + Forms\Components\Textarea::make('startup') + ->rows(2) + ->columnSpanFull() ->helperText('The default startup command that should be used for new servers using this Egg.'), - Forms\Components\TagsInput::make('file_denylist')->placeholder('denied-file.txt'), - Forms\Components\Toggle::make('force_outgoing_ip')->required() + Forms\Components\TagsInput::make('file_denylist') + ->placeholder('denied-file.txt') + ->helperText('A list of files that the end user is not allowed to edit.') + ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]), + Forms\Components\TagsInput::make('features') + ->placeholder('Add Feature') + ->helperText('') + ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]), + Forms\Components\Toggle::make('force_outgoing_ip') ->helperText("Forces all outgoing network traffic to have its Source IP NATed to the IP of the server's primary allocation IP. Required for certain games to work properly when the Node has multiple public IP addresses. Enabling this option will disable internal networking for any servers using this egg, causing them to be unable to internally access other servers on the same node."), + Forms\Components\Toggle::make('script_is_privileged') + ->helperText('The docker images available to servers using this egg.'), + Forms\Components\TextInput::make('update_url') + ->disabled() + ->helperText('Not implemented.') + ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]), Forms\Components\KeyValue::make('docker_images') ->columnSpanFull() ->addActionLabel('Add Image') @@ -52,29 +78,24 @@ public static function form(Form $form): Form ->helperText('The docker images available to servers using this egg.'), ]), - Forms\Components\Tabs\Tab::make('Process Management') - ->columns(2) + ->columns() ->schema([ Forms\Components\Select::make('config_from') ->label('Copy Settings From') ->placeholder('None') ->relationship('configFrom', 'name', ignoreRecord: true) ->helperText('If you would like to default to settings from another Egg select it from the menu above.'), - Forms\Components\TextInput::make('config_stop') ->maxLength(191) ->label('Stop Command') ->helperText('The command that should be sent to server processes to stop them gracefully. If you need to send a SIGINT you should enter ^C here.'), - Forms\Components\Textarea::make('config_startup')->rows(10)->json() ->label('Start Configuration') ->helperText('List of values the daemon should be looking for when booting a server to determine completion.'), - Forms\Components\Textarea::make('config_files')->rows(10)->json() ->label('Configuration Files') ->helperText('This should be a JSON representation of configuration files to modify and what parts should be changed.'), - Forms\Components\Textarea::make('config_logs')->rows(10)->json() ->label('Log Configuration') ->helperText('This should be a JSON representation of where log files are stored, and whether or not the daemon should be creating custom logs.'), @@ -96,7 +117,7 @@ public static function form(Form $form): Form Forms\Components\TextInput::make('name')->live()->maxLength(191)->columnSpanFull(), Forms\Components\Textarea::make('description')->columnSpanFull(), Forms\Components\TextInput::make('env_variable')->maxLength(191)->required()->hint(fn ($state) => "{{{$state}}}"), - Forms\Components\TextInput::make('default_value')->maxLength(191), + Forms\Components\TextInput::make('default_value')->maxLength(191)->required(), Forms\Components\TextInput::make('rules')->columnSpanFull()->required(), ]), ]), @@ -126,10 +147,6 @@ public static function form(Form $form): Form ]), ])->columnSpanFull()->persistTabInQueryString(), - - // Forms\Components\TagsInput::make('features'), - // Forms\Components\TextInput::make('update_url'), - // Forms\Components\Toggle::make('script_is_privileged')->required(), ]); } From a9a18464ddf07806c1e29dea319f72c05294b5e9 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 21 Apr 2024 21:06:21 -0400 Subject: [PATCH 4/6] Wip --- app/Filament/Resources/EggResource.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/EggResource.php b/app/Filament/Resources/EggResource.php index dd3d62b3e6..3bb4cf5c08 100644 --- a/app/Filament/Resources/EggResource.php +++ b/app/Filament/Resources/EggResource.php @@ -109,8 +109,10 @@ public static function form(Form $form): Form ->relationship('variables') ->name('name') ->columns(2) - ->reorderable()->reorderableWithDragAndDrop() - ->collapsible()->collapsed() + ->reorderable() + // ->reorderableWithDragAndDrop() + ->collapsible() + ->collapsed() ->columnSpan(2) ->itemLabel(fn (array $state) => $state['name']) ->schema([ From 1a884c0cdf5c9b0d5ceed67a51f458e56310405d Mon Sep 17 00:00:00 2001 From: notCharles Date: Sun, 21 Apr 2024 21:11:18 -0400 Subject: [PATCH 5/6] Save sort order --- app/Filament/Resources/EggResource.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Filament/Resources/EggResource.php b/app/Filament/Resources/EggResource.php index 2fc7af6c6c..0472c9791e 100644 --- a/app/Filament/Resources/EggResource.php +++ b/app/Filament/Resources/EggResource.php @@ -51,6 +51,7 @@ public static function form(Form $form): Form Forms\Components\Textarea::make('startup') ->rows(2) ->columnSpanFull() + ->required() ->helperText('The default startup command that should be used for new servers using this Egg.'), Forms\Components\TagsInput::make('file_denylist') ->placeholder('denied-file.txt') @@ -72,6 +73,7 @@ public static function form(Form $form): Form ->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]), Forms\Components\KeyValue::make('docker_images') ->columnSpanFull() + ->required() ->addActionLabel('Add Image') ->keyLabel('Name') ->valueLabel('Image URI') @@ -105,18 +107,14 @@ public static function form(Form $form): Form ->columns(2) ->schema([ Forms\Components\Repeater::make('variables') -<<<<<<< HEAD ->grid() -======= - ->grid(3) ->>>>>>> 0f360fcdd1fa5ab9d0ae87afeeb30061a5b6b4c9 ->relationship('variables') ->name('name') ->columns(2) ->reorderable() - // ->reorderableWithDragAndDrop() ->collapsible() ->collapsed() + ->orderColumn() ->columnSpan(2) ->itemLabel(fn (array $state) => $state['name']) ->mutateRelationshipDataBeforeCreateUsing(function (array $data): array { From c31eafaf4fee5767b7a91042699e132cee303095 Mon Sep 17 00:00:00 2001 From: notCharles Date: Sun, 21 Apr 2024 21:16:05 -0400 Subject: [PATCH 6/6] Pint --- app/Filament/Resources/EggResource.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Filament/Resources/EggResource.php b/app/Filament/Resources/EggResource.php index 0472c9791e..efeb9714a0 100644 --- a/app/Filament/Resources/EggResource.php +++ b/app/Filament/Resources/EggResource.php @@ -137,8 +137,7 @@ public static function form(Form $form): Form ->debounce(750) ->maxLength(191) ->columnSpanFull() - ->afterStateUpdated(fn (Forms\Set $set, $state) => - $set('env_variable', str($state)->trim()->snake()->upper()->toString()) + ->afterStateUpdated(fn (Forms\Set $set, $state) => $set('env_variable', str($state)->trim()->snake()->upper()->toString()) ) ->required(), Forms\Components\Textarea::make('description')->columnSpanFull(),