mirror of
https://github.com/alexjustesen/speedtest-tracker.git
synced 2026-06-23 07:40:08 +00:00
Add default chart range (#2369)
Co-authored-by: Laurent P <1441170+vadius45@users.noreply.github.com> Co-authored-by: Laurent Parodi <laurent+git@parodi.swiss> Co-authored-by: Alex Justesen <1144087+alexjustesen@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Concerns;
|
||||
|
||||
trait HasChartFilters
|
||||
{
|
||||
protected function getFilters(): ?array
|
||||
{
|
||||
return [
|
||||
'24h' => 'Last 24 hours',
|
||||
'week' => 'Last 7 days',
|
||||
'month' => 'Last 30 days',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ResultStatus;
|
||||
use App\Filament\Widgets\Concerns\HasChartFilters;
|
||||
use App\Helpers\Average;
|
||||
use App\Helpers\Number;
|
||||
use App\Models\Result;
|
||||
@@ -10,6 +11,8 @@ use Filament\Widgets\ChartWidget;
|
||||
|
||||
class RecentDownloadChartWidget extends ChartWidget
|
||||
{
|
||||
use HasChartFilters;
|
||||
|
||||
protected static ?string $heading = 'Download (Mbps)';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
@@ -18,15 +21,11 @@ class RecentDownloadChartWidget extends ChartWidget
|
||||
|
||||
protected static ?string $pollingInterval = '60s';
|
||||
|
||||
public ?string $filter = '24h';
|
||||
public ?string $filter = null;
|
||||
|
||||
protected function getFilters(): ?array
|
||||
public function mount(): void
|
||||
{
|
||||
return [
|
||||
'24h' => 'Last 24h',
|
||||
'week' => 'Last week',
|
||||
'month' => 'Last month',
|
||||
];
|
||||
$this->filter = $this->filter ?? config('speedtest.default_chart_range', '24h');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ResultStatus;
|
||||
use App\Filament\Widgets\Concerns\HasChartFilters;
|
||||
use App\Models\Result;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class RecentDownloadLatencyChartWidget extends ChartWidget
|
||||
{
|
||||
use HasChartFilters;
|
||||
|
||||
protected static ?string $heading = 'Download Latency';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
@@ -16,15 +19,11 @@ class RecentDownloadLatencyChartWidget extends ChartWidget
|
||||
|
||||
protected static ?string $pollingInterval = '60s';
|
||||
|
||||
public ?string $filter = '24h';
|
||||
public ?string $filter = null;
|
||||
|
||||
protected function getFilters(): ?array
|
||||
public function mount(): void
|
||||
{
|
||||
return [
|
||||
'24h' => 'Last 24h',
|
||||
'week' => 'Last week',
|
||||
'month' => 'Last month',
|
||||
];
|
||||
$this->filter = $this->filter ?? config('speedtest.default_chart_range', '24h');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ResultStatus;
|
||||
use App\Filament\Widgets\Concerns\HasChartFilters;
|
||||
use App\Models\Result;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class RecentJitterChartWidget extends ChartWidget
|
||||
{
|
||||
use HasChartFilters;
|
||||
|
||||
protected static ?string $heading = 'Jitter';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
@@ -16,15 +19,11 @@ class RecentJitterChartWidget extends ChartWidget
|
||||
|
||||
protected static ?string $pollingInterval = '60s';
|
||||
|
||||
public ?string $filter = '24h';
|
||||
public ?string $filter = null;
|
||||
|
||||
protected function getFilters(): ?array
|
||||
public function mount(): void
|
||||
{
|
||||
return [
|
||||
'24h' => 'Last 24h',
|
||||
'week' => 'Last week',
|
||||
'month' => 'Last month',
|
||||
];
|
||||
$this->filter = $this->filter ?? config('speedtest.default_chart_range', '24h');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ResultStatus;
|
||||
use App\Filament\Widgets\Concerns\HasChartFilters;
|
||||
use App\Helpers\Average;
|
||||
use App\Models\Result;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class RecentPingChartWidget extends ChartWidget
|
||||
{
|
||||
use HasChartFilters;
|
||||
|
||||
protected static ?string $heading = 'Ping (ms)';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
@@ -17,15 +20,11 @@ class RecentPingChartWidget extends ChartWidget
|
||||
|
||||
protected static ?string $pollingInterval = '60s';
|
||||
|
||||
public ?string $filter = '24h';
|
||||
public ?string $filter = null;
|
||||
|
||||
protected function getFilters(): ?array
|
||||
public function mount(): void
|
||||
{
|
||||
return [
|
||||
'24h' => 'Last 24h',
|
||||
'week' => 'Last week',
|
||||
'month' => 'Last month',
|
||||
];
|
||||
$this->filter = $this->filter ?? config('speedtest.default_chart_range', '24h');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ResultStatus;
|
||||
use App\Filament\Widgets\Concerns\HasChartFilters;
|
||||
use App\Helpers\Average;
|
||||
use App\Helpers\Number;
|
||||
use App\Models\Result;
|
||||
@@ -10,6 +11,8 @@ use Filament\Widgets\ChartWidget;
|
||||
|
||||
class RecentUploadChartWidget extends ChartWidget
|
||||
{
|
||||
use HasChartFilters;
|
||||
|
||||
protected static ?string $heading = 'Upload (Mbps)';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
@@ -18,15 +21,11 @@ class RecentUploadChartWidget extends ChartWidget
|
||||
|
||||
protected static ?string $pollingInterval = '60s';
|
||||
|
||||
public ?string $filter = '24h';
|
||||
public ?string $filter = null;
|
||||
|
||||
protected function getFilters(): ?array
|
||||
public function mount(): void
|
||||
{
|
||||
return [
|
||||
'24h' => 'Last 24h',
|
||||
'week' => 'Last week',
|
||||
'month' => 'Last month',
|
||||
];
|
||||
$this->filter = $this->filter ?? config('speedtest.default_chart_range', '24h');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Enums\ResultStatus;
|
||||
use App\Filament\Widgets\Concerns\HasChartFilters;
|
||||
use App\Models\Result;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class RecentUploadLatencyChartWidget extends ChartWidget
|
||||
{
|
||||
use HasChartFilters;
|
||||
|
||||
protected static ?string $heading = 'Upload Latency';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
@@ -16,15 +19,11 @@ class RecentUploadLatencyChartWidget extends ChartWidget
|
||||
|
||||
protected static ?string $pollingInterval = '60s';
|
||||
|
||||
public ?string $filter = '24h';
|
||||
public ?string $filter = null;
|
||||
|
||||
protected function getFilters(): ?array
|
||||
public function mount(): void
|
||||
{
|
||||
return [
|
||||
'24h' => 'Last 24h',
|
||||
'week' => 'Last week',
|
||||
'month' => 'Last month',
|
||||
];
|
||||
$this->filter = $this->filter ?? config('speedtest.default_chart_range', '24h');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
|
||||
@@ -6,7 +6,6 @@ return [
|
||||
/**
|
||||
* General settings.
|
||||
*/
|
||||
|
||||
'build_date' => Carbon::parse('2025-10-24'),
|
||||
|
||||
'build_version' => 'v1.6.9',
|
||||
@@ -17,6 +16,7 @@ return [
|
||||
|
||||
'public_dashboard' => env('PUBLIC_DASHBOARD', false),
|
||||
|
||||
'default_chart_range' => env('DEFAULT_CHART_RANGE', '24h'),
|
||||
|
||||
/**
|
||||
* Speedtest settings.
|
||||
@@ -31,25 +31,21 @@ return [
|
||||
|
||||
'checkinternet_url' => env('SPEEDTEST_CHECKINTERNET_URL', 'https://icanhazip.com'),
|
||||
|
||||
|
||||
/**
|
||||
* IP filtering settings.
|
||||
*/
|
||||
|
||||
'allowed_ips' => env('ALLOWED_IPS'),
|
||||
|
||||
'skip_ips' => env('SPEEDTEST_SKIP_IPS', ''),
|
||||
|
||||
|
||||
/**
|
||||
* Threshold settings.
|
||||
*/
|
||||
'threshold_enabled' => env('THRESHOLD_ENABLED', false),
|
||||
|
||||
'threshold_enabled' => env('THRESHOLD_ENABLED', false),
|
||||
'threshold_download' => env('THRESHOLD_DOWNLOAD', 0),
|
||||
|
||||
'threshold_download' => env('THRESHOLD_DOWNLOAD', 0),
|
||||
'threshold_upload' => env('THRESHOLD_UPLOAD', 0),
|
||||
|
||||
'threshold_upload' => env('THRESHOLD_UPLOAD', 0),
|
||||
|
||||
'threshold_ping' => env('THRESHOLD_PING', 0) ,
|
||||
'threshold_ping' => env('THRESHOLD_PING', 0),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user