mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 21:36:52 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			92 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Filament\Resources\NodeResource\Pages;
 | |
| 
 | |
| use App\Filament\Resources\NodeResource;
 | |
| use App\Filament\Resources\NodeResource\Widgets\NodeMemoryChart;
 | |
| use App\Filament\Resources\NodeResource\Widgets\NodeStorageChart;
 | |
| use App\Models\Node;
 | |
| use Filament\Actions;
 | |
| use Filament\Forms;
 | |
| use Filament\Forms\Components\Tabs;
 | |
| use Filament\Resources\Pages\EditRecord;
 | |
| use Illuminate\Support\HtmlString;
 | |
| use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
 | |
| 
 | |
| class EditNode extends EditRecord
 | |
| {
 | |
|     protected static string $resource = NodeResource::class;
 | |
| 
 | |
|     public function form(Forms\Form $form): Forms\Form
 | |
|     {
 | |
|         return $form->schema([
 | |
|             Tabs::make('Tabs')
 | |
|                 ->columns([
 | |
|                     'default' => 2,
 | |
|                     'sm' => 3,
 | |
|                     'md' => 3,
 | |
|                     'lg' => 4,
 | |
|                 ])
 | |
|                 ->persistTabInQueryString()
 | |
|                 ->columnSpanFull()
 | |
|                 ->tabs([
 | |
|                     Tabs\Tab::make('Basic Settings')
 | |
|                         ->icon('tabler-server')
 | |
|                         ->schema((new CreateNode())->form($form)->getComponents()),
 | |
|                     //                    Tabs\Tab::make('Advanced Settings')
 | |
|                     //                        ->icon('tabler-server-cog')
 | |
|                     //                        ->schema([
 | |
|                     //                            Forms\Components\Placeholder::make('Coming soon!'),
 | |
|                     //                        ]),
 | |
|                     Tabs\Tab::make('Configuration')
 | |
|                         ->icon('tabler-code')
 | |
|                         ->schema([
 | |
|                             Forms\Components\Placeholder::make('instructions')
 | |
|                                 ->columnSpanFull()
 | |
|                                 ->content(new HtmlString('
 | |
|                                   Save this file to your <span title="usually /etc/pelican/">daemon\'s root directory</span>, named <code>config.yml</code>
 | |
|                             ')),
 | |
|                             Forms\Components\Textarea::make('config')
 | |
|                                 ->label('/etc/pelican/config.yml')
 | |
|                                 ->disabled()
 | |
|                                 ->rows(19)
 | |
|                                 ->hintAction(CopyAction::make())
 | |
|                                 ->columnSpanFull(),
 | |
|                         ]),
 | |
|                 ]),
 | |
|         ]);
 | |
|     }
 | |
| 
 | |
|     protected function mutateFormDataBeforeFill(array $data): array
 | |
|     {
 | |
|         $node = Node::findOrFail($data['id']);
 | |
| 
 | |
|         $data['config'] = $node->getYamlConfiguration();
 | |
| 
 | |
|         return $data;
 | |
|     }
 | |
| 
 | |
|     protected function getSteps(): array
 | |
|     {
 | |
|         return [
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     protected function getHeaderActions(): array
 | |
|     {
 | |
|         return [
 | |
|             Actions\DeleteAction::make()
 | |
|                 ->disabled(fn (Node $node) => $node->servers()->count() > 0)
 | |
|                 ->label(fn (Node $node) => $node->servers()->count() > 0 ? 'Node Has Servers' : 'Delete'),
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     protected function getFooterWidgets(): array
 | |
|     {
 | |
|         return [
 | |
|             NodeStorageChart::class,
 | |
|             NodeMemoryChart::class,
 | |
|         ];
 | |
|     }
 | |
| }
 | 
