refactor: simplify power management UI by removing confirmation modal and updating button styles for improved user experience
This commit is contained in:
@@ -9,108 +9,17 @@
|
||||
</div>
|
||||
<span class="font-medium">{{ $status->name }}</span>
|
||||
</div>
|
||||
<div x-data="{ showPowerOffModal: false }" @click.stop>
|
||||
<button
|
||||
type="button"
|
||||
@click.stop="
|
||||
@if($status->status == 'running')
|
||||
showPowerOffModal = true
|
||||
@else
|
||||
$wire.do('start')
|
||||
@endif
|
||||
"
|
||||
class="relative size-12 rounded-full cursor-pointer transition-all duration-300 ease-in-out hover:scale-110 focus:outline-none focus:ring-2 focus:ring-offset-2
|
||||
@if($status->status == 'running')
|
||||
bg-success hover:bg-success/90 focus:ring-success animate-pulse
|
||||
@elseif($status->status == 'stopped')
|
||||
bg-red-500 hover:bg-red-600 focus:ring-red-500
|
||||
@else
|
||||
bg-warning hover:bg-warning/90 focus:ring-warning
|
||||
@endif"
|
||||
title="@if($status->status == 'running') Power Off @else Power On @endif"
|
||||
>
|
||||
<i class="absolute inset-0 flex items-center justify-center text-white text-xl transition-transform duration-300">
|
||||
<x-ri-shut-down-line class="size-6" />
|
||||
</i>
|
||||
</button>
|
||||
|
||||
{{-- Power Off Confirmation Modal --}}
|
||||
<div
|
||||
x-show="showPowerOffModal"
|
||||
x-cloak
|
||||
class="fixed inset-0 z-50 overflow-y-auto"
|
||||
aria-labelledby="modal-title"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
style="display: none;"
|
||||
>
|
||||
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
|
||||
{{-- Background overlay --}}
|
||||
<div
|
||||
x-show="showPowerOffModal"
|
||||
x-transition:enter="ease-out duration-300"
|
||||
x-transition:enter-start="opacity-0"
|
||||
x-transition:enter-end="opacity-100"
|
||||
x-transition:leave="ease-in duration-200"
|
||||
x-transition:leave-start="opacity-100"
|
||||
x-transition:leave-end="opacity-0"
|
||||
class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"
|
||||
@click="showPowerOffModal = false"
|
||||
aria-hidden="true"
|
||||
></div>
|
||||
|
||||
{{-- Center modal --}}
|
||||
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">​</span>
|
||||
|
||||
{{-- Modal panel --}}
|
||||
<div
|
||||
x-show="showPowerOffModal"
|
||||
x-transition:enter="ease-out duration-300"
|
||||
x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
|
||||
x-transition:leave="ease-in duration-200"
|
||||
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
|
||||
x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||
class="inline-block align-bottom bg-background-secondary rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full border border-neutral"
|
||||
>
|
||||
<div class="bg-background-secondary px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 dark:bg-red-900/20 sm:mx-0 sm:h-10 sm:w-10">
|
||||
<x-ri-alert-line class="h-6 w-6 text-red-600 dark:text-red-500" />
|
||||
</div>
|
||||
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
|
||||
<h3 class="text-lg leading-6 font-medium text-base" id="modal-title">
|
||||
Confirm Power Off
|
||||
</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-base/70">
|
||||
Are you sure you want to power off <strong>{{ $status->name }}</strong>? This will immediately shut down the server.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-background-secondary px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse gap-2">
|
||||
<button
|
||||
type="button"
|
||||
wire:click="do('stop')"
|
||||
@click="showPowerOffModal = false"
|
||||
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm"
|
||||
>
|
||||
Power Off
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="showPowerOffModal = false"
|
||||
class="mt-3 w-full inline-flex justify-center rounded-md border border-neutral shadow-sm px-4 py-2 bg-background text-base font-medium text-base hover:bg-background-secondary focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-secondary sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="size-3 rounded-full transition-all duration-300
|
||||
@if($status->status == 'running')
|
||||
bg-success animate-pulse
|
||||
@elseif($status->status == 'stopped')
|
||||
bg-red-500
|
||||
@else
|
||||
bg-warning
|
||||
@endif"
|
||||
title="@if($status->status == 'running') Running @elseif($status->status == 'stopped') Stopped @else {{ ucfirst($status->status) }} @endif"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row flex-wrap gap-4 mt-4">
|
||||
|
||||
Reference in New Issue
Block a user