Skip to content

Commit 08f8fa7

Browse files
authored
Remove admin panel charts (#2476)
Co-authored-by: Alex Justesen <[email protected]>
1 parent 17bdf73 commit 08f8fa7

26 files changed

+451
-198
lines changed

app/Filament/Pages/Dashboard.php

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@
22

33
namespace App\Filament\Pages;
44

5-
use App\Filament\Widgets\RecentDownloadChartWidget;
6-
use App\Filament\Widgets\RecentDownloadLatencyChartWidget;
7-
use App\Filament\Widgets\RecentJitterChartWidget;
8-
use App\Filament\Widgets\RecentPingChartWidget;
9-
use App\Filament\Widgets\RecentUploadChartWidget;
10-
use App\Filament\Widgets\RecentUploadLatencyChartWidget;
11-
use App\Filament\Widgets\StatsOverviewWidget;
12-
use Carbon\Carbon;
13-
use Cron\CronExpression;
145
use Filament\Pages\Dashboard as BasePage;
156

167
class Dashboard extends BasePage
178
{
18-
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-chart-bar';
9+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-layout-dashboard';
1910

2011
protected string $view = 'filament.pages.dashboard';
2112

@@ -28,32 +19,4 @@ public static function getNavigationLabel(): string
2819
{
2920
return __('dashboard.title');
3021
}
31-
32-
public function getSubheading(): ?string
33-
{
34-
$schedule = config('speedtest.schedule');
35-
36-
if (blank($schedule) || $schedule === false) {
37-
return __('dashboard.no_speedtests_scheduled');
38-
}
39-
40-
$cronExpression = new CronExpression($schedule);
41-
42-
$nextRunDate = Carbon::parse($cronExpression->getNextRunDate(timeZone: config('app.display_timezone')))->format(config('app.datetime_format'));
43-
44-
return __('dashboard.next_speedtest_at').': '.$nextRunDate;
45-
}
46-
47-
protected function getHeaderWidgets(): array
48-
{
49-
return [
50-
StatsOverviewWidget::make(),
51-
RecentDownloadChartWidget::make(),
52-
RecentUploadChartWidget::make(),
53-
RecentPingChartWidget::make(),
54-
RecentJitterChartWidget::make(),
55-
RecentDownloadLatencyChartWidget::make(),
56-
RecentUploadLatencyChartWidget::make(),
57-
];
58-
}
5922
}

app/Filament/Pages/Settings/DataIntegration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
class DataIntegration extends SettingsPage
2525
{
26-
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-circle-stack';
26+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-database';
2727

2828
protected static string|\UnitEnum|null $navigationGroup = 'Settings';
2929

app/Filament/Pages/Settings/Notification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
class Notification extends SettingsPage
3737
{
38-
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-bell-alert';
38+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-bell-ringing';
3939

4040
protected static string|\UnitEnum|null $navigationGroup = 'Settings';
4141

app/Filament/Pages/Settings/Thresholds.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class Thresholds extends SettingsPage
1717
{
18-
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-exclamation-triangle';
18+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-alert-triangle';
1919

2020
protected static string|\UnitEnum|null $navigationGroup = 'Settings';
2121

app/Filament/Resources/Results/ResultResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ResultResource extends Resource
1414
{
1515
protected static ?string $model = Result::class;
1616

17-
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-table-cells';
17+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-table';
1818

1919
public static function getNavigationLabel(): string
2020
{

app/Filament/Resources/Users/UserResource.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ class UserResource extends Resource
1414
{
1515
protected static ?string $model = User::class;
1616

17-
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-users';
18-
19-
protected static string|\UnitEnum|null $navigationGroup = 'Settings';
17+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-users';
2018

2119
protected static ?int $navigationSort = 4;
2220

app/Filament/Widgets/StatsOverviewWidget.php

Lines changed: 0 additions & 76 deletions
This file was deleted.

app/Http/Controllers/HomeController.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace App\Http\Controllers;
44

5-
use App\Enums\ResultStatus;
6-
use App\Models\Result;
75
use Illuminate\Http\Request;
86

97
class HomeController extends Controller
@@ -13,14 +11,6 @@ class HomeController extends Controller
1311
*/
1412
public function __invoke(Request $request)
1513
{
16-
$latestResult = Result::query()
17-
->select(['id', 'ping', 'download', 'upload', 'status', 'created_at'])
18-
->where('status', '=', ResultStatus::Completed)
19-
->latest()
20-
->first();
21-
22-
return view('dashboard', [
23-
'latestResult' => $latestResult,
24-
]);
14+
return view('dashboard');
2515
}
2616
}

app/Livewire/LatestResultStats.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Livewire;
4+
5+
use App\Enums\ResultStatus;
6+
use App\Models\Result;
7+
use Livewire\Attributes\Computed;
8+
use Livewire\Component;
9+
10+
class LatestResultStats extends Component
11+
{
12+
#[Computed]
13+
public function latestResult(): ?Result
14+
{
15+
return Result::where('status', ResultStatus::Completed)
16+
->latest()
17+
->first();
18+
}
19+
20+
public function render()
21+
{
22+
return view('livewire.latest-result-stats');
23+
}
24+
}

app/Livewire/PlatformStats.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace App\Livewire;
4+
5+
use App\Enums\ResultStatus;
6+
use App\Models\Result;
7+
use Carbon\Carbon;
8+
use Cron\CronExpression;
9+
use Illuminate\Support\Number;
10+
use Livewire\Attributes\Computed;
11+
use Livewire\Component;
12+
13+
class PlatformStats extends Component
14+
{
15+
#[Computed]
16+
public function nextSpeedtest(): ?Carbon
17+
{
18+
if ($schedule = config('speedtest.schedule')) {
19+
$cronExpression = new CronExpression($schedule);
20+
21+
return Carbon::parse(time: $cronExpression->getNextRunDate(timeZone: config('app.display_timezone')));
22+
}
23+
24+
return null;
25+
}
26+
27+
#[Computed]
28+
public function platformStats(): array
29+
{
30+
$totalResults = Result::count();
31+
$completedResults = Result::where('status', ResultStatus::Completed)->count();
32+
$failedResults = Result::where('status', ResultStatus::Failed)->count();
33+
34+
return [
35+
'total' => Number::format($totalResults),
36+
'completed' => Number::format($completedResults),
37+
'failed' => Number::format($failedResults),
38+
];
39+
}
40+
41+
public function render()
42+
{
43+
return view('livewire.platform-stats');
44+
}
45+
}

0 commit comments

Comments
 (0)