mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 09:00:27 +00:00
Update DockerContainerResource.php
This commit is contained in:
parent
5ae6773758
commit
e48682965c
1 changed files with 54 additions and 6 deletions
|
@ -10,12 +10,14 @@ use Filament\Tables\Table;
|
|||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Modules\Docker\App\Models\DockerContainer;
|
||||
use Modules\Docker\App\Models\DockerTemplate;
|
||||
use Modules\Docker\DockerApi;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\CreateDockerContainer;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\EditDockerContainer;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\ListDockerContainers;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\ViewDockerContainer;
|
||||
use Modules\Docker\Filament\Clusters\DockerCluster;
|
||||
use Riodwanto\FilamentAceEditor\AceEditor;
|
||||
|
||||
|
||||
class DockerContainerResource extends Resource
|
||||
|
@ -75,12 +77,58 @@ class DockerContainerResource extends Resource
|
|||
$defaultPort = 83;
|
||||
}
|
||||
|
||||
$dockerTemplateContent = '';
|
||||
$dockerTemplateId = request()->get('docker_template_id', null);
|
||||
$findDockerTemplate = DockerTemplate::find($dockerTemplateId);
|
||||
if ($findDockerTemplate) {
|
||||
$dockerTemplateContent = $findDockerTemplate->docker_compose;
|
||||
}
|
||||
$buildType = request()->get('build_type', null);
|
||||
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->default($dockerFullImageName)
|
||||
->label('Container Name')->columnSpanFull(),
|
||||
|
||||
Forms\Components\Select::make('build_type')
|
||||
->label('Build container from')
|
||||
->live()
|
||||
->default($buildType)
|
||||
->options(['template'=>'Docker Template', 'image'=>'Docker Image'])
|
||||
->columnSpanFull(),
|
||||
|
||||
Forms\Components\Select::make('docker_template_id')
|
||||
->label('Template')
|
||||
->default($dockerTemplateId)
|
||||
->hidden(function (Forms\Get $get) {
|
||||
return $get('build_type') != 'template';
|
||||
})
|
||||
->live()
|
||||
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, ?string $old, ?string $state) {
|
||||
return redirect('/admin/docker/containers/create?build_type=template&docker_template_id=' . $state);
|
||||
})
|
||||
->options(DockerTemplate::all()->pluck('name', 'id'))
|
||||
->columnSpanFull(),
|
||||
|
||||
Forms\Components\Select::make('image')
|
||||
->label('Image')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
return $get('build_type') != 'image';
|
||||
})
|
||||
->options([$dockerImage=>$dockerFullImageName])
|
||||
->default($dockerImage)->columnSpanFull(),
|
||||
|
||||
AceEditor::make('docker_compose')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
return $get('build_type') != 'template';
|
||||
})
|
||||
->mode('yml')
|
||||
->theme('github')
|
||||
->default($dockerTemplateContent)
|
||||
->columnSpanFull()
|
||||
->darkTheme('dracula'),
|
||||
|
||||
Forms\Components\TextInput::make('memory_limit')
|
||||
->label('Memory Limit (MB)')
|
||||
->default(512)
|
||||
|
@ -106,18 +154,18 @@ class DockerContainerResource extends Resource
|
|||
->default($defaultExternalPort)
|
||||
->columnSpan(1),
|
||||
|
||||
|
||||
Forms\Components\Select::make('image')
|
||||
->label('Image')
|
||||
->options([$dockerImage=>$dockerFullImageName])
|
||||
->default($dockerImage)->columnSpanFull(),
|
||||
|
||||
Forms\Components\KeyValue::make('volume_mapping')
|
||||
->label('Volume Mapping')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
return $get('build_type') != 'image';
|
||||
})
|
||||
->columnSpanFull(),
|
||||
|
||||
Forms\Components\KeyValue::make('environment_variables')
|
||||
->label('Environment Variables')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
return $get('build_type') != 'image';
|
||||
})
|
||||
->default($environmentVariables)
|
||||
->columnSpanFull(),
|
||||
|
||||
|
|
Loading…
Reference in a new issue