feat: enhance drive reattachment UI by updating bus type labels and improving slot availability logic

This commit is contained in:
2025-12-05 04:36:30 -05:00
parent adc4632e24
commit 77ac1b1a4f

View File

@@ -802,61 +802,37 @@
@endif
<div>
<label class="block text-sm font-medium mb-2">Target Bus</label>
<label class="block text-sm font-medium mb-2">Target Bus Type</label>
<select wire:model="reattachTargetBus"
class="w-full px-4 py-2 text-sm rounded-lg border border-neutral bg-background focus:outline-none focus:ring-2 focus:ring-primary/50">
<option value="">Select bus type...</option>
<optgroup label="IDE (Max: 4)">
@for($i = 0; $i <= 3; $i++)
@php
$key = "ide{$i}";
$isUsed = isset($drives[$key]);
@endphp
<option value="{{ $key }}" @if($isUsed) disabled @endif>
ide{{ $i }} @if($isUsed) (In use) @endif
</option>
@endfor
</optgroup>
<optgroup label="SATA (Max: 6)">
@for($i = 0; $i <= 5; $i++)
@php
$key = "sata{$i}";
$isUsed = isset($drives[$key]);
@endphp
<option value="{{ $key }}" @if($isUsed) disabled @endif>
sata{{ $i }} @if($isUsed) (In use) @endif
</option>
@endfor
</optgroup>
<optgroup label="SCSI (Max: 31)">
@for($i = 0; $i <= 30; $i++)
@php
$key = "scsi{$i}";
$isUsed = isset($drives[$key]);
@endphp
<option value="{{ $key }}" @if($isUsed) disabled @endif>
scsi{{ $i }} @if($isUsed) (In use) @endif
</option>
@endfor
</optgroup>
<optgroup label="VirtIO (Max: 16)">
@for($i = 0; $i <= 15; $i++)
@php
$key = "virtio{$i}";
$isUsed = isset($drives[$key]);
@endphp
<option value="{{ $key }}" @if($isUsed) disabled @endif>
virtio{{ $i }} @if($isUsed) (In use) @endif
</option>
@endfor
</optgroup>
@php
// Calculate next available slot for each bus type
$busLimits = ['ide' => 4, 'sata' => 6, 'scsi' => 31, 'virtio' => 16];
$busLabels = ['ide' => 'IDE', 'sata' => 'SATA', 'scsi' => 'SCSI', 'virtio' => 'VirtIO'];
@endphp
@foreach($busLimits as $bus => $maxSlots)
@php
$nextSlot = null;
for ($i = 0; $i < $maxSlots; $i++) {
if (!isset($drives[$bus . $i])) {
$nextSlot = $i;
break;
}
}
$isFull = $nextSlot === null;
@endphp
<option value="{{ $bus }}" @if($isFull) disabled @endif>
{{ $busLabels[$bus] }} @if($isFull) (Full) @else (Next: {{ $bus }}{{ $nextSlot }}) @endif
</option>
@endforeach
</select>
</div>
<div class="flex items-start gap-2 p-3 rounded-lg bg-info/10 border border-info/30 text-info text-sm">
<x-ri-information-line class="size-4 flex-shrink-0 mt-0.5" />
<div>
<p>This will reattach the drive to the selected bus position.</p>
<p>The drive will be reattached to the lowest available slot on the selected bus.</p>
</div>
</div>