Skip to content

Commit a47e322

Browse files
Release v1.12.0 (#2493)
Co-authored-by: Sven van Ginkel <[email protected]> Co-authored-by: Alex Justesen <[email protected]>
1 parent 9211aa4 commit a47e322

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1049
-230
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace App\Actions\Notifications;
4+
5+
use App\Notifications\Apprise\TestNotification;
6+
use Filament\Notifications\Notification;
7+
use Illuminate\Support\Facades\Notification as FacadesNotification;
8+
use Lorisleiva\Actions\Concerns\AsAction;
9+
10+
class SendAppriseTestNotification
11+
{
12+
use AsAction;
13+
14+
public function handle(array $channel_urls)
15+
{
16+
if (! count($channel_urls)) {
17+
Notification::make()
18+
->title('You need to add Apprise channel URLs!')
19+
->warning()
20+
->send();
21+
22+
return;
23+
}
24+
25+
foreach ($channel_urls as $row) {
26+
$channelUrl = $row['channel_url'] ?? null;
27+
if (! $channelUrl) {
28+
Notification::make()
29+
->title('Skipping missing channel URL!')
30+
->warning()
31+
->send();
32+
33+
continue;
34+
}
35+
36+
FacadesNotification::route('apprise_urls', $channelUrl)
37+
->notify(new TestNotification);
38+
}
39+
40+
Notification::make()
41+
->title('Test Apprise notification sent.')
42+
->success()
43+
->send();
44+
}
45+
}

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: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Filament\Pages\Settings;
44

5+
use App\Actions\Notifications\SendAppriseTestNotification;
56
use App\Actions\Notifications\SendDatabaseTestNotification;
67
use App\Actions\Notifications\SendDiscordTestNotification;
78
use App\Actions\Notifications\SendGotifyTestNotification;
@@ -12,6 +13,7 @@
1213
use App\Actions\Notifications\SendSlackTestNotification;
1314
use App\Actions\Notifications\SendTelegramTestNotification;
1415
use App\Actions\Notifications\SendWebhookTestNotification;
16+
use App\Rules\AppriseScheme;
1517
use App\Settings\NotificationSettings;
1618
use CodeWithDennis\SimpleAlert\Components\SimpleAlert;
1719
use Filament\Actions\Action;
@@ -33,7 +35,7 @@
3335

3436
class Notification extends SettingsPage
3537
{
36-
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-bell-alert';
38+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-bell-ringing';
3739

3840
protected static string|\UnitEnum|null $navigationGroup = 'Settings';
3941

@@ -199,6 +201,80 @@ public function form(Schema $schema): Schema
199201

200202
// ...
201203
]),
204+
Tab::make(__('settings/notifications.apprise'))
205+
->icon(Heroicon::CloudArrowUp)
206+
->schema([
207+
SimpleAlert::make('wehbook_info')
208+
->title(__('general.documentation'))
209+
->description(__('settings/notifications.apprise_hint_description'))
210+
->border()
211+
->info()
212+
->actions([
213+
Action::make('webhook_docs')
214+
->label(__('general.view_documentation'))
215+
->icon('heroicon-m-arrow-long-right')
216+
->color('info')
217+
->link()
218+
->url('https://docs.speedtest-tracker.dev/settings/notifications/apprise')
219+
->openUrlInNewTab(),
220+
])
221+
->columnSpanFull(),
222+
223+
Toggle::make('apprise_enabled')
224+
->label(__('settings/notifications.enable_apprise_notifications'))
225+
->reactive()
226+
->columnSpanFull(),
227+
Grid::make([
228+
'default' => 1,
229+
])
230+
->hidden(fn (Get $get) => $get('apprise_enabled') !== true)
231+
->schema([
232+
Fieldset::make(__('settings/notifications.apprise_server'))
233+
->schema([
234+
TextInput::make('apprise_server_url')
235+
->label(__('settings/notifications.apprise_server_url'))
236+
->placeholder('http://localhost:8000')
237+
->maxLength(2000)
238+
->required()
239+
->url()
240+
->columnSpanFull(),
241+
Checkbox::make('apprise_verify_ssl')
242+
->label(__('settings/notifications.apprise_verify_ssl'))
243+
->default(true)
244+
->columnSpanFull(),
245+
]),
246+
Fieldset::make(__('settings.triggers'))
247+
->schema([
248+
Checkbox::make('apprise_on_speedtest_run')
249+
->label(__('settings/notifications.notify_on_every_speedtest_run'))
250+
->columnSpanFull(),
251+
Checkbox::make('apprise_on_threshold_failure')
252+
->label(__('settings/notifications.notify_on_threshold_failures'))
253+
->columnSpanFull(),
254+
]),
255+
Repeater::make('apprise_channel_urls')
256+
->label(__('settings/notifications.apprise_channels'))
257+
->schema([
258+
TextInput::make('channel_url')
259+
->label(__('settings/notifications.apprise_channel_url'))
260+
->placeholder('discord://WebhookID/WebhookToken')
261+
->helperText(__('settings/notifications.apprise_channel_url_helper'))
262+
->maxLength(2000)
263+
->distinct()
264+
->required()
265+
->rule(new AppriseScheme),
266+
])
267+
->columnSpanFull(),
268+
Actions::make([
269+
Action::make('test apprise')
270+
->label(__('settings/notifications.test_apprise_channel'))
271+
->action(fn (Get $get) => SendAppriseTestNotification::run(
272+
channel_urls: $get('apprise_channel_urls'),
273+
))
274+
->hidden(fn (Get $get) => ! count($get('apprise_channel_urls'))),
275+
]),
276+
]),
277+
]),
202278
])
203279
->columnSpanFull(),
204280

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
}

0 commit comments

Comments
 (0)