From 7a28b892f3bd353604e05875553436b75aa25b72 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Thu, 30 Jan 2025 00:28:48 +0600 Subject: [PATCH] wip --- .../Resources/DicomServerResource.php | 36 +++++++++++++------ app/Models/Department.php | 3 +- app/Models/DicomServer.php | 4 +-- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/Filament/Resources/DicomServerResource.php b/app/Filament/Resources/DicomServerResource.php index ade0914..246b721 100644 --- a/app/Filament/Resources/DicomServerResource.php +++ b/app/Filament/Resources/DicomServerResource.php @@ -3,12 +3,14 @@ namespace App\Filament\Resources; use App\Filament\Resources\DicomServerResource\Pages; +use App\Models\Department; use App\Models\DicomServer; use App\Services\GeoLocation; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Filament\Forms\Form; +use Filament\Forms\Get; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Columns\IconColumn; @@ -30,6 +32,7 @@ public static function form(Form $form): Form ->required(), TextInput::make('server_name') ->required() + ->unique(ignoreRecord: true) ->maxLength(255), Select::make('geo_code') ->required() @@ -48,12 +51,11 @@ public static function form(Form $form): Form ->required() ->maxLength(255), TextInput::make('ae_title') - ->maxLength(255), + ->maxLength(24), TextInput::make('username') - ->maxLength(255), + ->maxLength(40), TextInput::make('password') - ->password() - ->maxLength(255), + ->maxLength(40), TextInput::make('wado_path') ->maxLength(255), TextInput::make('stone_viewer_path') @@ -62,10 +64,21 @@ public static function form(Form $form): Form ->maxLength(255), TextInput::make('meddream_viewer_path') ->maxLength(255), - TextInput::make('organization_id') - ->numeric(), - TextInput::make('department_id') - ->numeric(), + Select::make('organization_id') + ->label('Organization') + ->live() + ->relationship('organization', 'name'), + Select::make('department_id') + ->label('Department') + ->options(function (Get $get) { + $organization_id = $get('organization_id'); + $result = []; + if ($organization_id != null) { + $result = Department::active()->organization($organization_id)->pluck('name', 'id')->toArray(); + } + + return $result; + }), ]); } @@ -88,12 +101,13 @@ public static function table(Table $table): Table ->label('WADO'), TextColumn::make('dicom_port') ->label('DICOM'), - TextColumn::make('rest_api_endpoint') - ->label('REST') - ->searchable(), TextColumn::make('ae_title') ->label('AET') ->searchable(), + TextColumn::make('rest_api_endpoint') + ->label('REST') + ->url(fn (DicomServer $srv) => $srv->rest_api_endpoint, shouldOpenInNewTab: true) + ->searchable(), TextColumn::make('created_at') ->dateTime() ->sortable() diff --git a/app/Models/Department.php b/app/Models/Department.php index d2e047c..58d7d78 100644 --- a/app/Models/Department.php +++ b/app/Models/Department.php @@ -4,9 +4,8 @@ use App\Models\Traits\Active; use App\Models\Traits\HasOrganization; -use Illuminate\Database\Eloquent\Model; -class Department extends Model +class Department extends BaseModel { use Active; use HasOrganization; diff --git a/app/Models/DicomServer.php b/app/Models/DicomServer.php index 1e0e792..2c9a3d1 100644 --- a/app/Models/DicomServer.php +++ b/app/Models/DicomServer.php @@ -10,12 +10,12 @@ class DicomServer extends BaseModel { use Active; - public function institute(): BelongsTo + public function organization(): BelongsTo { return $this->belongsTo(Organization::class); } - public function facility(): BelongsTo + public function department(): BelongsTo { return $this->belongsTo(Department::class); }