Skip to content

Livewire 3 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"illuminate/http": "^10.0",
"illuminate/routing": "^10.0",
"illuminate/support": "^10.0",
"livewire/livewire": "^2.11",
"livewire/livewire": "^3.0@beta",
"nesbot/carbon": "^2.67"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion dist/pulse.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/pulse.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/js/pulse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ window.LineChart = LineChart;
window.PieChart = PieChart;
window.Interpolation = Interpolation;

window.pulse = { initialDataLoaded: {}, charts: {} }
window.pulse = { charts: {} }
5 changes: 0 additions & 5 deletions resources/views/components/loading-indicator.blade.php

This file was deleted.

10 changes: 10 additions & 0 deletions resources/views/components/placeholder.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<x-pulse::card class="animate-pulse {{ $class ?? '' }}">
<x-slot:title>
<div class="rounded bg-gray-100 h-6 w-1/2"></div>
</x-slot:title>
<div class="space-y-4">
<div class="rounded bg-gray-100 h-4 w-1/3"></div>
<div class="rounded bg-gray-100 h-4 w-2/3"></div>
<div class="rounded bg-gray-100 h-4 w-3/5"></div>
</div>
</x-pulse::card>
4 changes: 0 additions & 4 deletions resources/views/components/pulse.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
{!! Laravel\Pulse\Facades\Pulse::css() !!}
</style>

<!-- Scripts -->
@livewireStyles
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
<script>
{!! Laravel\Pulse\Facades\Pulse::js() !!}
</script>
Expand Down Expand Up @@ -50,7 +47,6 @@
</main>
</div>

@livewireScripts
@stack('scripts')
</body>
</html>
24 changes: 12 additions & 12 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<x-pulse>
<livewire:servers />
<livewire:usage>
{{-- <livewire:usage type="dispatched_job_counts"> --}}
{{-- <livewire:usage type="slow_endpoint_counts"> --}}
{{-- <livewire:usage type="request_counts"> --}}
<livewire:exceptions />
<livewire:slow-routes />
<livewire:slow-queries />
<livewire:slow-jobs />
<livewire:slow-outgoing-requests />
<livewire:cache />
<livewire:queues />
<livewire:servers lazy />
<livewire:usage lazy />
{{-- <livewire:usage type="dispatched_job_counts" lazy /> --}}
{{-- <livewire:usage type="slow_endpoint_counts" lazy /> --}}
{{-- <livewire:usage type="request_counts" lazy /> --}}
<livewire:exceptions lazy />
<livewire:slow-routes lazy />
<livewire:slow-queries lazy />
<livewire:slow-jobs lazy />
<livewire:slow-outgoing-requests lazy />
<livewire:cache lazy />
<livewire:queues lazy />
</x-pulse>
136 changes: 62 additions & 74 deletions resources/views/livewire/cache.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,94 +12,82 @@
</x-slot:title>

<div class="max-h-56 h-full relative overflow-y-auto" wire:poll.5s>
<script>
window.pulse.initialDataLoaded[@js($this->id)] = @js($initialDataLoaded)
</script>
<div x-data="{
initialDataLoaded: window.pulse.initialDataLoaded[@js($this->id)],
loadingNewDataset: false,
init() {
Livewire.on('periodChanged', () => (this.loadingNewDataset = true))
Livewire.on('period-changed', () => (this.loadingNewDataset = true))

window.addEventListener('cache:dataLoaded', () => {
this.initialDataLoaded = true
this.loadingNewDataset = false
})

if (! this.initialDataLoaded) {
@this.loadData()
}
}
}">
<x-pulse::loading-indicator x-cloak x-show="! initialDataLoaded" />
<div x-cloak x-show="initialDataLoaded" :class="[loadingNewDataset ? 'opacity-25 animate-pulse' : '', 'space-y-6']">
@if ($initialDataLoaded)
<div class="grid grid-cols-3 text-center">
<div>
<span class="text-xl uppercase font-bold text-gray-700">
{{ number_format($allCacheInteractions->hits) }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
Hits
</span>
</div>
<div>
<span class="text-xl uppercase font-bold text-gray-700">
{{ number_format($allCacheInteractions->count - $allCacheInteractions->hits) }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
Misses
</span>
</div>
<div>
<span class="text-xl uppercase font-bold text-gray-700">
{{ $allCacheInteractions->count > 0 ? round(($allCacheInteractions->hits / $allCacheInteractions->count) * 100, 2).'%' : '-' }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
Hit Rate
</span>
</div>
<div :class="[loadingNewDataset ? 'opacity-25 animate-pulse' : '', 'space-y-6']">
<div class="grid grid-cols-3 text-center">
<div>
<span class="text-xl uppercase font-bold text-gray-700">
{{ number_format($allCacheInteractions->hits) }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
Hits
</span>
</div>
@if ($monitoredCacheInteractions === [])
<div class="flex flex-col items-center justify-center p-4 py-6">
<div class="bg-gray-50 rounded-full text-xs leading-none px-2 py-1 text-gray-500">
No keys configured to monitor
</div>
<div>
<span class="text-xl uppercase font-bold text-gray-700">
{{ number_format($allCacheInteractions->count - $allCacheInteractions->hits) }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
Misses
</span>
</div>
<div>
<span class="text-xl uppercase font-bold text-gray-700">
{{ $allCacheInteractions->count > 0 ? round(($allCacheInteractions->hits / $allCacheInteractions->count) * 100, 2).'%' : '-' }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
Hit Rate
</span>
</div>
</div>
@if ($monitoredCacheInteractions === [])
<div class="flex flex-col items-center justify-center p-4 py-6">
<div class="bg-gray-50 rounded-full text-xs leading-none px-2 py-1 text-gray-500">
No keys configured to monitor
</div>
</div>

<div class="flex h-32 items-center text-center text-"></div>
@else
<x-pulse::table>
<x-pulse::thead>
<div class="flex h-32 items-center text-center text-"></div>
@else
<x-pulse::table>
<x-pulse::thead>
<tr>
<x-pulse::th class="w-full text-left">Name</x-pulse::th>
<x-pulse::th class="text-right">Hits</x-pulse::th>
<x-pulse::th class="text-right">Misses</x-pulse::th>
<x-pulse::th class="text-right whitespace-nowrap">Hit Rate</x-pulse::th>
</tr>
</x-pulse::thead>
<tbody>
@foreach ($monitoredCacheInteractions as $interaction)
<tr>
<x-pulse::th class="w-full text-left">Name</x-pulse::th>
<x-pulse::th class="text-right">Hits</x-pulse::th>
<x-pulse::th class="text-right">Misses</x-pulse::th>
<x-pulse::th class="text-right whitespace-nowrap">Hit Rate</x-pulse::th>
<x-pulse::td>
<code class="block text-xs text-gray-900">
{{ $interaction->key }}
</code>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm">
<strong>{{ number_format($interaction->hits) }}</strong>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm whitespace-nowrap">
<strong>{{ number_format($interaction->count - $interaction->hits) }}</strong>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm whitespace-nowrap">
<strong>{{ $interaction->count > 0 ? round(($interaction->hits / $interaction->count) * 100, 2).'%' : '-' }}</strong>
</x-pulse::td>
</tr>
</x-pulse::thead>
<tbody>
@foreach ($monitoredCacheInteractions as $interaction)
<tr>
<x-pulse::td>
<code class="block text-xs text-gray-900">
{{ $interaction->key }}
</code>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm">
<strong>{{ number_format($interaction->hits) }}</strong>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm whitespace-nowrap">
<strong>{{ number_format($interaction->count - $interaction->hits) }}</strong>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm whitespace-nowrap">
<strong>{{ $interaction->count > 0 ? round(($interaction->hits / $interaction->count) * 100, 2).'%' : '-' }}</strong>
</x-pulse::td>
</tr>
@endforeach
</tbody>
</x-pulse::table>
@endif
@endforeach
</tbody>
</x-pulse::table>
@endif
</div>
</div>
Expand Down
22 changes: 6 additions & 16 deletions resources/views/livewire/exceptions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="text-sm text-gray-700">Sort by</div>
<select
wire:model="orderBy"
wire:change="$emit('exceptionChanged', $event.target.value)"
wire:change="$dispatch('exception-changed', { orderBy: $event.target.value })"
class="rounded-md border-gray-200 text-gray-700 py-1 text-sm"
>
<option value="count">count</option>
Expand All @@ -23,32 +23,22 @@ class="rounded-md border-gray-200 text-gray-700 py-1 text-sm"
</x-slot:title>

<div class="max-h-56 h-full relative overflow-y-auto" wire:poll.5s>
<script>
window.pulse.initialDataLoaded[@js($this->id)] = @js($initialDataLoaded)
</script>
<div x-data="{
initialDataLoaded: window.pulse.initialDataLoaded[@js($this->id)],
loadingNewDataset: false,
init() {
Livewire.on('periodChanged', () => (this.loadingNewDataset = true))
Livewire.on('exceptionChanged', () => (this.loadingNewDataset = true))
Livewire.on('period-changed', () => (this.loadingNewDataset = true))
Livewire.on('exception-changed', () => (this.loadingNewDataset = true))

window.addEventListener('exceptions:dataLoaded', () => {
this.initialDataLoaded = true
this.loadingNewDataset = false
})

if (! this.initialDataLoaded) {
@this.loadData()
}
}
}">
<x-pulse::loading-indicator x-cloak x-show="! initialDataLoaded" />
<div x-cloak x-show="initialDataLoaded">
<div>
<div :class="loadingNewDataset ? 'opacity-25 animate-pulse' : ''">
@if ($initialDataLoaded && count($exceptions) === 0)
@if (count($exceptions) === 0)
<x-pulse::no-results />
@elseif ($initialDataLoaded && count($exceptions) > 0)
@else
<x-pulse::table>
<x-pulse::thead>
<tr>
Expand Down
Loading