Skip to content

Commit

Permalink
Cache servers data and show stats
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher committed Oct 6, 2023
1 parent 4b53151 commit 5d10a52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 5d10a52

Please sign in to comment.