Private
Public Access
1
0

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 @endif
<div> <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" <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"> 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> <option value="">Select bus type...</option>
<optgroup label="IDE (Max: 4)"> @php
@for($i = 0; $i <= 3; $i++) // Calculate next available slot for each bus type
@php $busLimits = ['ide' => 4, 'sata' => 6, 'scsi' => 31, 'virtio' => 16];
$key = "ide{$i}"; $busLabels = ['ide' => 'IDE', 'sata' => 'SATA', 'scsi' => 'SCSI', 'virtio' => 'VirtIO'];
$isUsed = isset($drives[$key]); @endphp
@endphp @foreach($busLimits as $bus => $maxSlots)
<option value="{{ $key }}" @if($isUsed) disabled @endif> @php
ide{{ $i }} @if($isUsed) (In use) @endif $nextSlot = null;
</option> for ($i = 0; $i < $maxSlots; $i++) {
@endfor if (!isset($drives[$bus . $i])) {
</optgroup> $nextSlot = $i;
<optgroup label="SATA (Max: 6)"> break;
@for($i = 0; $i <= 5; $i++) }
@php }
$key = "sata{$i}"; $isFull = $nextSlot === null;
$isUsed = isset($drives[$key]); @endphp
@endphp <option value="{{ $bus }}" @if($isFull) disabled @endif>
<option value="{{ $key }}" @if($isUsed) disabled @endif> {{ $busLabels[$bus] }} @if($isFull) (Full) @else (Next: {{ $bus }}{{ $nextSlot }}) @endif
sata{{ $i }} @if($isUsed) (In use) @endif </option>
</option> @endforeach
@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>
</select> </select>
</div> </div>
<div class="flex items-start gap-2 p-3 rounded-lg bg-info/10 border border-info/30 text-info text-sm"> <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" /> <x-ri-information-line class="size-4 flex-shrink-0 mt-0.5" />
<div> <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>
</div> </div>