Skip to content

Commit

Permalink
Merge pull request #479 from andreapollastri/4.x
Browse files Browse the repository at this point in the history
Stats Fix
  • Loading branch information
andreapollastri authored Mar 17, 2024
2 parents 320f6ff + 92b4130 commit f4dd2f3
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions app/Filament/Widgets/StatsOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,28 @@

class StatsOverview extends BaseWidget
{
protected static ?string $pollingInterval = '60s';
protected static ?string $pollingInterval = '45s';

protected function getStats(): array
{
$ip = config('panel.serverIp');
$name = config('panel.serverName');
$sites = Site::count();
$stats = StatModel::latest()->first();
$chart = StatModel::limit(120)
->orderBy('created_at', 'desc')
->get();
$chart = StatModel::limit(120)->orderBy('created_at', 'desc')->get();

return [
Stat::make('IP', $ip)
Stat::make('IP', config('panel.serverIp'))
->description('Server IP')
->descriptionIcon('heroicon-m-globe-alt'),
Stat::make('Name', $name)
Stat::make('Name', config('panel.serverName'))
->description('Server name')
->descriptionIcon('heroicon-m-rocket-launch'),
Stat::make('Sites', $sites)
Stat::make('Sites', Site::count())
->description('Hosted sites')
->descriptionIcon('heroicon-m-computer-desktop'),
Stat::make('CPU', (isset($stats->cpu)) ? $stats->cpu : '0'.'%')
Stat::make('CPU', (isset($stats->cpu)) ? $stats->cpu.'%' : '0'.'%')
->description('CPU usage')
->descriptionIcon('heroicon-m-cpu-chip')
->chart($chart->pluck('cpu')->reverse()->toArray()),
Stat::make('RAM', (isset($stats->ram)) ? $stats->ram : '0'.'%')
Stat::make('RAM', (isset($stats->ram)) ? $stats->ram.'%' : '0'.'%')
->description('RAM usage')
->descriptionIcon('heroicon-m-rectangle-stack')
->chart($chart->pluck('ram')->reverse()->toArray()),
Expand Down

0 comments on commit f4dd2f3

Please sign in to comment.