feat: initialize Dr-Panel project with patient file number support
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class ExpandableText extends Component
|
||||
{
|
||||
public string $html = '';
|
||||
public int $limit = 200;
|
||||
public bool $expanded = false;
|
||||
|
||||
public function toggle(): void
|
||||
{
|
||||
$this->expanded = ! $this->expanded;
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\View\View
|
||||
{
|
||||
return view('livewire.expandable-text');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Resources\PatientResource\Pages\EditPatient;
|
||||
use App\Models\Patient;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Schemas\Schema;
|
||||
use Livewire\Component;
|
||||
|
||||
class PatientMediaPlayer extends Component implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
public int $patientId;
|
||||
public string $field;
|
||||
public ?array $data = [];
|
||||
|
||||
public function mount(int $patientId, string $field): void
|
||||
{
|
||||
$this->patientId = $patientId;
|
||||
$this->field = $field;
|
||||
|
||||
$patient = Patient::find($patientId);
|
||||
|
||||
$this->form->fill([
|
||||
$field => EditPatient::normalizeFileList($patient?->{$field}),
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Schema $form): Schema
|
||||
{
|
||||
$component = match ($this->field) {
|
||||
'videos' => FileUpload::make('videos')
|
||||
->hiddenLabel()
|
||||
->multiple()
|
||||
->disk('public')
|
||||
->acceptedFileTypes([
|
||||
'video/mp4', 'video/quicktime', 'video/x-msvideo',
|
||||
'video/x-matroska', 'video/webm',
|
||||
'audio/mpeg', 'audio/mp3', 'audio/wav', 'audio/x-wav',
|
||||
'audio/ogg', 'audio/opus', 'audio/mp4', 'audio/x-m4a',
|
||||
'audio/aac', 'audio/x-aac', 'audio/flac', 'audio/x-flac',
|
||||
'audio/webm', 'audio/amr', 'audio/3gpp', 'audio/3gpp2',
|
||||
'audio/aiff', 'audio/x-aiff',
|
||||
])
|
||||
->maxSize(102400)
|
||||
->downloadable()
|
||||
->openable()
|
||||
->panelLayout('grid')
|
||||
->extraAttributes(['class' => 'fi-video-gallery', 'data-hide-dropzone' => 'true'])
|
||||
->disabled()
|
||||
->deletable(false)
|
||||
->fetchFileInformation(false),
|
||||
|
||||
'audio_files' => FileUpload::make('audio_files')
|
||||
->hiddenLabel()
|
||||
->multiple()
|
||||
->disk('public')
|
||||
->acceptedFileTypes([
|
||||
'audio/mpeg', 'audio/mp3', 'audio/wav', 'audio/x-wav',
|
||||
'audio/ogg', 'audio/opus', 'audio/mp4', 'audio/x-m4a',
|
||||
'audio/aac', 'audio/x-aac', 'audio/flac', 'audio/x-flac',
|
||||
'audio/webm', 'audio/amr', 'audio/3gpp', 'audio/3gpp2',
|
||||
'audio/aiff', 'audio/x-aiff',
|
||||
])
|
||||
->downloadable()
|
||||
->openable()
|
||||
->extraAttributes(['data-hide-dropzone' => 'true'])
|
||||
->disabled()
|
||||
->deletable(false)
|
||||
->fetchFileInformation(false),
|
||||
|
||||
default => throw new \InvalidArgumentException("Unknown field: {$this->field}"),
|
||||
};
|
||||
|
||||
return $form
|
||||
->schema([$component])
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\View\View
|
||||
{
|
||||
return view('livewire.patient-media-player');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Services\SyncService;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Component;
|
||||
|
||||
class SettingsDropdown extends Component
|
||||
{
|
||||
public bool $syncSuccess = false;
|
||||
public bool $syncFailed = false;
|
||||
public array $reportLines = [];
|
||||
|
||||
public bool $peerConnected = false;
|
||||
public ?string $peerPath = null;
|
||||
public bool $peerChecked = false;
|
||||
|
||||
public function checkPeerStatus(): void
|
||||
{
|
||||
$result = SyncService::fromConfig()->ping();
|
||||
|
||||
$this->peerConnected = $result['connected'];
|
||||
$this->peerPath = $result['path'];
|
||||
$this->peerChecked = true;
|
||||
}
|
||||
public function runSync(): void
|
||||
{
|
||||
$service = SyncService::fromConfig();
|
||||
|
||||
if (! $service->isConfigured()) {
|
||||
$this->syncFailed = true;
|
||||
$this->reportLines = [__('navigation.sync.error_not_configured')];
|
||||
$this->dispatch('sync-finished', success: false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $service->sync();
|
||||
|
||||
$this->reportLines = $result['report'] ?? [];
|
||||
|
||||
if ($result['success']) {
|
||||
$this->syncSuccess = true;
|
||||
$this->dispatch('sync-finished', success: true);
|
||||
} else {
|
||||
$this->syncFailed = true;
|
||||
$this->dispatch('sync-finished', success: false);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.settings-dropdown');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user