From 7cb0c793b12fb5170c4c70bd19853d9ccd3a3d80 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Fri, 6 Oct 2023 17:14:21 +1000 Subject: [PATCH] Add loading state to queues card --- resources/views/livewire/queues.blade.php | 251 ++++++++++++---------- 1 file changed, 136 insertions(+), 115 deletions(-) diff --git a/resources/views/livewire/queues.blade.php b/resources/views/livewire/queues.blade.php index b8bf7b03f..fb05f9950 100644 --- a/resources/views/livewire/queues.blade.php +++ b/resources/views/livewire/queues.blade.php @@ -26,132 +26,153 @@ -
- @foreach ($queues as $queue => $readings) -
-

- {{ Str::after($queue, ':') }} - @if ($showConnection) - ({{ Str::before($queue, ':') }}) - @endif -

- @php $latest = $readings->last() @endphp - @php - $highest = $readings->map(fn ($reading) => max( - $reading->queued, - $reading->processed, - $reading->failed, - ))->max() - @endphp +
-
{{ number_format($highest) }}
+ Livewire.hook('commit', ({ component, succeed }) => { + if (component.name === $wire.__instance.name) { + succeed(() => this.loadingNewDataset = false) + } + }) + } + }" + class="min-h-full flex flex-col" + :class="loadingNewDataset ? 'opacity-25 animate-pulse' : ''" + > + @if (count($queues) === 0) + + @else +
+ @foreach ($queues as $queue => $readings) +
+

+ {{ Str::after($queue, ':') }} + @if ($showConnection) + ({{ Str::before($queue, ':') }}) + @endif +

+ @php $latest = $readings->last() @endphp + @php + $highest = $readings->map(fn ($reading) => max( + $reading->queued, + $reading->processed, + $reading->failed, + ))->max() + @endphp -
+
{{ number_format($highest) }}
+ +
- + chart.data.labels = queues['{{ $queue }}'].map(reading => reading.date) + chart.data.datasets[0].data = queues['{{ $queue }}'].map(reading => reading.queued) + chart.data.datasets[1].data = queues['{{ $queue }}'].map(reading => reading.processed) + chart.data.datasets[2].data = queues['{{ $queue }}'].map(reading => reading.failed) + chart.update() + }) + } + }" + > + +
+
-
+ @endforeach
- @endforeach + @endif