Skip to content
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

Cache servers data and show stats #23

Merged
merged 1 commit into from
Oct 6, 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 resources/views/livewire/servers.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class="overflow-x-auto pb-px default:col-span-full default:lg:col-span-{{ $cols
</div>
<div class="flex items-center pr-8 xl:pr-12 [&:nth-child(1n+15)]:border-t {{ count($servers) > 1 ? 'py-2' : '' }} {{ ! $server->recently_reported ? 'opacity-25 animate-pulse' : '' }}" :class="loadingNewDataset ? 'opacity-25 animate-pulse' : ''">
<x-pulse::icons.server class="w-6 h-6 mr-2 stroke-gray-500 dark:stroke-gray-400" />
<span class="text-base font-bold text-gray-600 dark:text-gray-300">{{ $server->name }}</span>
<span class="text-base font-bold text-gray-600 dark:text-gray-300" title="Time: {{ $time }}; Run at: {{ $runAt }};">{{ $server->name }}</span>
</div>
<div class="flex items-center [&:nth-child(1n+15)]:border-t {{ count($servers) > 1 ? 'py-2' : '' }} {{ ! $server->recently_reported ? 'opacity-25 animate-pulse' : '' }}" :class="loadingNewDataset ? 'opacity-25 animate-pulse' : ''">
<div class="text-xl font-bold text-gray-700 dark:text-gray-200 w-14 whitespace-nowrap tabular-nums">
Expand Down
7 changes: 5 additions & 2 deletions src/Livewire/Servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,30 @@
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Support\Facades\View;
use Laravel\Pulse\Livewire\Concerns\HasPeriod;
use Laravel\Pulse\Livewire\Concerns\RemembersQueries;
use Laravel\Pulse\Livewire\Concerns\ShouldNotReportUsage;
use Livewire\Attributes\Lazy;

#[Lazy]
class Servers extends Card
{
use HasPeriod, ShouldNotReportUsage;
use HasPeriod, RemembersQueries, ShouldNotReportUsage;

/**
* Render the component.
*/
public function render(callable $query): Renderable
{
$servers = $query($this->periodAsInterval());
[$servers, $time, $runAt] = $this->remember($query);

if (request()->hasHeader('X-Livewire')) {
$this->dispatch('chart-update', servers: $servers);
}

return View::make('pulse::livewire.servers', [
'servers' => $servers,
'time' => $time,
'runAt' => $runAt,
]);
}

Expand Down