Skip to content
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
45 changes: 45 additions & 0 deletions app/Actions/Notifications/SendAppriseTestNotification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Actions\Notifications;

use App\Notifications\Apprise\TestNotification;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Notification as FacadesNotification;
use Lorisleiva\Actions\Concerns\AsAction;

class SendAppriseTestNotification
{
use AsAction;

public function handle(array $channel_urls)
{
if (! count($channel_urls)) {
Notification::make()
->title('You need to add Apprise channel URLs!')
->warning()
->send();

return;
}

foreach ($channel_urls as $row) {
$channelUrl = $row['channel_url'] ?? null;
if (! $channelUrl) {
Notification::make()
->title('Skipping missing channel URL!')
->warning()
->send();

continue;
}

FacadesNotification::route('apprise_urls', $channelUrl)
->notify(new TestNotification);
}

Notification::make()
->title('Test Apprise notification sent.')
->success()
->send();
}
}
39 changes: 1 addition & 38 deletions app/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@

namespace App\Filament\Pages;

use App\Filament\Widgets\RecentDownloadChartWidget;
use App\Filament\Widgets\RecentDownloadLatencyChartWidget;
use App\Filament\Widgets\RecentJitterChartWidget;
use App\Filament\Widgets\RecentPingChartWidget;
use App\Filament\Widgets\RecentUploadChartWidget;
use App\Filament\Widgets\RecentUploadLatencyChartWidget;
use App\Filament\Widgets\StatsOverviewWidget;
use Carbon\Carbon;
use Cron\CronExpression;
use Filament\Pages\Dashboard as BasePage;

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

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

Expand All @@ -28,32 +19,4 @@ public static function getNavigationLabel(): string
{
return __('dashboard.title');
}

public function getSubheading(): ?string
{
$schedule = config('speedtest.schedule');

if (blank($schedule) || $schedule === false) {
return __('dashboard.no_speedtests_scheduled');
}

$cronExpression = new CronExpression($schedule);

$nextRunDate = Carbon::parse($cronExpression->getNextRunDate(timeZone: config('app.display_timezone')))->format(config('app.datetime_format'));

return __('dashboard.next_speedtest_at').': '.$nextRunDate;
}

protected function getHeaderWidgets(): array
{
return [
StatsOverviewWidget::make(),
RecentDownloadChartWidget::make(),
RecentUploadChartWidget::make(),
RecentPingChartWidget::make(),
RecentJitterChartWidget::make(),
RecentDownloadLatencyChartWidget::make(),
RecentUploadLatencyChartWidget::make(),
];
}
}
2 changes: 1 addition & 1 deletion app/Filament/Pages/Settings/DataIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

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

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

Expand Down
78 changes: 77 additions & 1 deletion app/Filament/Pages/Settings/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Filament\Pages\Settings;

use App\Actions\Notifications\SendAppriseTestNotification;
use App\Actions\Notifications\SendDatabaseTestNotification;
use App\Actions\Notifications\SendDiscordTestNotification;
use App\Actions\Notifications\SendGotifyTestNotification;
Expand All @@ -12,6 +13,7 @@
use App\Actions\Notifications\SendSlackTestNotification;
use App\Actions\Notifications\SendTelegramTestNotification;
use App\Actions\Notifications\SendWebhookTestNotification;
use App\Rules\AppriseScheme;
use App\Settings\NotificationSettings;
use CodeWithDennis\SimpleAlert\Components\SimpleAlert;
use Filament\Actions\Action;
Expand All @@ -33,7 +35,7 @@

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

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

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

// ...
]),
Tab::make(__('settings/notifications.apprise'))
->icon(Heroicon::CloudArrowUp)
->schema([
SimpleAlert::make('wehbook_info')
->title(__('general.documentation'))
->description(__('settings/notifications.apprise_hint_description'))
->border()
->info()
->actions([
Action::make('webhook_docs')
->label(__('general.view_documentation'))
->icon('heroicon-m-arrow-long-right')
->color('info')
->link()
->url('https://docs.speedtest-tracker.dev/settings/notifications/apprise')
->openUrlInNewTab(),
])
->columnSpanFull(),

Toggle::make('apprise_enabled')
->label(__('settings/notifications.enable_apprise_notifications'))
->reactive()
->columnSpanFull(),
Grid::make([
'default' => 1,
])
->hidden(fn (Get $get) => $get('apprise_enabled') !== true)
->schema([
Fieldset::make(__('settings/notifications.apprise_server'))
->schema([
TextInput::make('apprise_server_url')
->label(__('settings/notifications.apprise_server_url'))
->placeholder('http://localhost:8000')
->maxLength(2000)
->required()
->url()
->columnSpanFull(),
Checkbox::make('apprise_verify_ssl')
->label(__('settings/notifications.apprise_verify_ssl'))
->default(true)
->columnSpanFull(),
]),
Fieldset::make(__('settings.triggers'))
->schema([
Checkbox::make('apprise_on_speedtest_run')
->label(__('settings/notifications.notify_on_every_speedtest_run'))
->columnSpanFull(),
Checkbox::make('apprise_on_threshold_failure')
->label(__('settings/notifications.notify_on_threshold_failures'))
->columnSpanFull(),
]),
Repeater::make('apprise_channel_urls')
->label(__('settings/notifications.apprise_channels'))
->schema([
TextInput::make('channel_url')
->label(__('settings/notifications.apprise_channel_url'))
->placeholder('discord://WebhookID/WebhookToken')
->helperText(__('settings/notifications.apprise_channel_url_helper'))
->maxLength(2000)
->distinct()
->required()
->rule(new AppriseScheme),
])
->columnSpanFull(),
Actions::make([
Action::make('test apprise')
->label(__('settings/notifications.test_apprise_channel'))
->action(fn (Get $get) => SendAppriseTestNotification::run(
channel_urls: $get('apprise_channel_urls'),
))
->hidden(fn (Get $get) => ! count($get('apprise_channel_urls'))),
]),
]),
]),
])
->columnSpanFull(),

Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Pages/Settings/Thresholds.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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

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

Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/Results/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ResultResource extends Resource
{
protected static ?string $model = Result::class;

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

public static function getNavigationLabel(): string
{
Expand Down
4 changes: 1 addition & 3 deletions app/Filament/Resources/Users/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class UserResource extends Resource
{
protected static ?string $model = User::class;

protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-users';

protected static string|\UnitEnum|null $navigationGroup = 'Settings';
protected static string|\BackedEnum|null $navigationIcon = 'tabler-users';

protected static ?int $navigationSort = 4;

Expand Down
76 changes: 0 additions & 76 deletions app/Filament/Widgets/StatsOverviewWidget.php

This file was deleted.

12 changes: 1 addition & 11 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Http\Controllers;

use App\Enums\ResultStatus;
use App\Models\Result;
use Illuminate\Http\Request;

class HomeController extends Controller
Expand All @@ -13,14 +11,6 @@ class HomeController extends Controller
*/
public function __invoke(Request $request)
{
$latestResult = Result::query()
->select(['id', 'ping', 'download', 'upload', 'status', 'created_at'])
->where('status', '=', ResultStatus::Completed)
->latest()
->first();

return view('dashboard', [
'latestResult' => $latestResult,
]);
return view('dashboard');
}
}
Loading
Loading