From 4d168cb323f7cf60c0d235c560c5a39d84c3060d Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 16:26:27 +0200 Subject: [PATCH 01/10] First try --- app/Filament/Pages/Dashboard.php | 4 + app/Filament/Resources/ResultResource.php | 12 ++ .../RecentDownloadLatencyChartWidget.php | 103 ++++++++++++++++++ .../RecentUploadLatencyChartWidget.php | 103 ++++++++++++++++++ app/Models/Result.php | 68 +++++++++++- 5 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 app/Filament/Widgets/RecentDownloadLatencyChartWidget.php create mode 100644 app/Filament/Widgets/RecentUploadLatencyChartWidget.php diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index 5b5b43b66..8d3f02b89 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -8,6 +8,8 @@ use App\Filament\Widgets\RecentPingChartWidget; use App\Filament\Widgets\RecentUploadChartWidget; use App\Filament\Widgets\StatsOverviewWidget; +use App\Filament\Widgets\RecentUploadLatencyChartWidget; +use App\Filament\Widgets\RecentDownloadLatencyChartWidget; use App\Settings\GeneralSettings; use Filament\Actions\Action; use Filament\Actions\ActionGroup; @@ -67,6 +69,8 @@ protected function getHeaderWidgets(): array RecentUploadChartWidget::make(), RecentPingChartWidget::make(), RecentJitterChartWidget::make(), + RecentUploadLatencyChartWidget::make(), + RecentDownloadLatencyChartWidget::make(), ]; } } diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index 14101f699..8afd4c1fe 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -68,8 +68,20 @@ public static function form(Form $form): Form ->label('Ping (ms)'), Forms\Components\TextInput::make('data.download.latency.jitter') ->label('Download Jitter (ms)'), + Forms\Components\TextInput::make('data.download.latency.high') + ->label('Download Latency High'), + Forms\Components\TextInput::make('data.download.latency.low') + ->label('Download Latency low'), + Forms\Components\TextInput::make('data.download.latency.iqm') + ->label('Download Latency iqm'), Forms\Components\TextInput::make('data.upload.latency.jitter') ->label('Upload Jitter (ms)'), + Forms\Components\TextInput::make('data.upload.latency.high') + ->label('Upload Latency High'), + Forms\Components\TextInput::make('data.upload.latency.low') + ->label('Upload Latency low'), + Forms\Components\TextInput::make('data.upload.latency.iqm') + ->label('Upload Latency iqm'), Forms\Components\TextInput::make('data.ping.jitter') ->label('Ping Jitter (ms)'), Forms\Components\TextInput::make('data.packetLoss') diff --git a/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php new file mode 100644 index 000000000..9b8d33e78 --- /dev/null +++ b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php @@ -0,0 +1,103 @@ + 'Last 24h', + 'week' => 'Last week', + 'month' => 'Last month', + ]; + } + + protected function getData(): array + { + $settings = new GeneralSettings(); + + $results = Result::query() + ->select(['id', 'data', 'created_at']) + ->where('status', '=', ResultStatus::Completed) + ->when($this->filter == '24h', function ($query) { + $query->where('created_at', '>=', now()->subDay()); + }) + ->when($this->filter == 'week', function ($query) { + $query->where('created_at', '>=', now()->subWeek()); + }) + ->when($this->filter == 'month', function ($query) { + $query->where('created_at', '>=', now()->subMonth()); + }) + ->orderBy('created_at') + ->get(); + + return [ + 'datasets' => [ + [ + 'label' => 'Download Latency High (ms)', + 'data' => $results->map(fn ($item) => $item->download_latency_high ? number_format($item->download_latency_high, 2) : 0), + 'borderColor' => '#0ea5e9', + 'backgroundColor' => '#0ea5e9', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], + [ + 'label' => 'Download Latency Low (ms)', + 'data' => $results->map(fn ($item) => $item->download_latency_low ? number_format($item->download_latency_low, 2) : 0), + 'borderColor' => '#8b5cf6', + 'backgroundColor' => '#8b5cf6', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], + [ + 'label' => 'Download Latency iqm (ms)', + 'data' => $results->map(fn ($item) => $item->download_latency_iqm ? number_format($item->pdownload_latency_iqm, 2) : 0), + 'borderColor' => '#10b981', + 'backgroundColor' => '#10b981', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], + ], + 'labels' => $results->map(fn ($item) => $item->created_at->timezone(TimeZoneHelper::displayTimeZone($settings))->format('M d - G:i')), + ]; + } + + protected function getOptions(): array + { + return [ + 'scales' => [ + 'y' => [ + 'beginAtZero' => true, + ], + ], + ]; + } + + protected function getType(): string + { + return 'line'; + } +} diff --git a/app/Filament/Widgets/RecentUploadLatencyChartWidget.php b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php new file mode 100644 index 000000000..5e0e23e53 --- /dev/null +++ b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php @@ -0,0 +1,103 @@ + 'Last 24h', + 'week' => 'Last week', + 'month' => 'Last month', + ]; + } + + protected function getData(): array + { + $settings = new GeneralSettings(); + + $results = Result::query() + ->select(['id', 'data', 'created_at']) + ->where('status', '=', ResultStatus::Completed) + ->when($this->filter == '24h', function ($query) { + $query->where('created_at', '>=', now()->subDay()); + }) + ->when($this->filter == 'week', function ($query) { + $query->where('created_at', '>=', now()->subWeek()); + }) + ->when($this->filter == 'month', function ($query) { + $query->where('created_at', '>=', now()->subMonth()); + }) + ->orderBy('created_at') + ->get(); + + return [ + 'datasets' => [ + [ + 'label' => 'Upload Latency High (ms)', + 'data' => $results->map(fn ($item) => $item->upload_latency_high ? number_format($item->upload_latency_high, 2) : 0), + 'borderColor' => '#0ea5e9', + 'backgroundColor' => '#0ea5e9', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], + [ + 'label' => 'Upload Latency Low (ms)', + 'data' => $results->map(fn ($item) => $item->upload_latency_low ? number_format($item->upload_latency_low, 2) : 0), + 'borderColor' => '#8b5cf6', + 'backgroundColor' => '#8b5cf6', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], + [ + 'label' => 'Upload Latency iqm (ms)', + 'data' => $results->map(fn ($item) => $item->upload_latency_iqm ? number_format($item->upload_latency_iqm, 2) : 0), + 'borderColor' => '#10b981', + 'backgroundColor' => '#10b981', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], + ], + 'labels' => $results->map(fn ($item) => $item->created_at->timezone(TimeZoneHelper::displayTimeZone($settings))->format('M d - G:i')), + ]; + } + + protected function getOptions(): array + { + return [ + 'scales' => [ + 'y' => [ + 'beginAtZero' => true, + ], + ], + ]; + } + + protected function getType(): string + { + return 'line'; + } +} diff --git a/app/Models/Result.php b/app/Models/Result.php index 7a913a949..84c196187 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -101,6 +101,39 @@ protected function downloadJitter(): Attribute ); } + /** + * Get the result's download latency high in milliseconds. + */ + protected function downloadlatencyHigh(): Attribute + { + return Attribute::make( + get: fn () => Arr::get($this->data, 'download.latency.high'), + ); + } + + +/** + * Get the result's download latency low in milliseconds. + */ + protected function downloadlatencyLow(): Attribute + { + return Attribute::make( + get: fn () => Arr::get($this->data, 'download.latency.low'), + ); + } + + +/** + * Get the result's download latency iqm in milliseconds. + */ + protected function downloadlatencyiqm(): Attribute + { + return Attribute::make( + get: fn () => Arr::get($this->data, 'download.latency.iqm'), + ); + } + + /** * Get the result's download jitter in milliseconds. */ @@ -212,4 +245,37 @@ protected function uploadJitter(): Attribute get: fn () => Arr::get($this->data, 'upload.latency.jitter'), ); } -} + + + /** + * Get the result's upload latency high in milliseconds. + */ + protected function uploadlatencyHigh(): Attribute + { + return Attribute::make( + get: fn () => Arr::get($this->data, 'upload.latency.high'), + ); + } + + +/** + * Get the result's upload latency low in milliseconds. + */ + protected function uploadlatencyLow(): Attribute + { + return Attribute::make( + get: fn () => Arr::get($this->data, 'upload.latency.low'), + ); + } + + +/** + * Get the result's upload latency iqm in milliseconds. + */ + protected function uploadlatencyiqm(): Attribute + { + return Attribute::make( + get: fn () => Arr::get($this->data, 'upload.latency.iqm'), + ); + } +} \ No newline at end of file From bca325663e742f1fa3a878cc410c6e823c013e67 Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 16:48:51 +0200 Subject: [PATCH 02/10] Format fixing --- app/Filament/Widgets/RecentDownloadLatencyChartWidget.php | 8 ++++---- app/Filament/Widgets/RecentUploadLatencyChartWidget.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php index 9b8d33e78..5c2be5d49 100644 --- a/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php +++ b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php @@ -10,7 +10,7 @@ class RecentDownloadLatencyChartWidget extends ChartWidget { - protected static ?string $heading = 'Jitter'; + protected static ?string $heading = 'Download Latency'; protected int|string|array $columnSpan = 'full'; @@ -54,7 +54,7 @@ protected function getData(): array return [ 'datasets' => [ [ - 'label' => 'Download Latency High (ms)', + 'label' => 'High (ms)', 'data' => $results->map(fn ($item) => $item->download_latency_high ? number_format($item->download_latency_high, 2) : 0), 'borderColor' => '#0ea5e9', 'backgroundColor' => '#0ea5e9', @@ -63,7 +63,7 @@ protected function getData(): array 'tension' => 0.4, ], [ - 'label' => 'Download Latency Low (ms)', + 'label' => 'Low (ms)', 'data' => $results->map(fn ($item) => $item->download_latency_low ? number_format($item->download_latency_low, 2) : 0), 'borderColor' => '#8b5cf6', 'backgroundColor' => '#8b5cf6', @@ -72,7 +72,7 @@ protected function getData(): array 'tension' => 0.4, ], [ - 'label' => 'Download Latency iqm (ms)', + 'label' => 'iqm (ms)', 'data' => $results->map(fn ($item) => $item->download_latency_iqm ? number_format($item->pdownload_latency_iqm, 2) : 0), 'borderColor' => '#10b981', 'backgroundColor' => '#10b981', diff --git a/app/Filament/Widgets/RecentUploadLatencyChartWidget.php b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php index 5e0e23e53..6bf9522ea 100644 --- a/app/Filament/Widgets/RecentUploadLatencyChartWidget.php +++ b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php @@ -10,7 +10,7 @@ class RecentUploadLatencyChartWidget extends ChartWidget { - protected static ?string $heading = 'Jitter'; + protected static ?string $heading = 'Upload Latency'; protected int|string|array $columnSpan = 'full'; @@ -54,7 +54,7 @@ protected function getData(): array return [ 'datasets' => [ [ - 'label' => 'Upload Latency High (ms)', + 'label' => 'High (ms)', 'data' => $results->map(fn ($item) => $item->upload_latency_high ? number_format($item->upload_latency_high, 2) : 0), 'borderColor' => '#0ea5e9', 'backgroundColor' => '#0ea5e9', @@ -63,7 +63,7 @@ protected function getData(): array 'tension' => 0.4, ], [ - 'label' => 'Upload Latency Low (ms)', + 'label' => 'Low (ms)', 'data' => $results->map(fn ($item) => $item->upload_latency_low ? number_format($item->upload_latency_low, 2) : 0), 'borderColor' => '#8b5cf6', 'backgroundColor' => '#8b5cf6', @@ -72,7 +72,7 @@ protected function getData(): array 'tension' => 0.4, ], [ - 'label' => 'Upload Latency iqm (ms)', + 'label' => 'iqm (ms)', 'data' => $results->map(fn ($item) => $item->upload_latency_iqm ? number_format($item->upload_latency_iqm, 2) : 0), 'borderColor' => '#10b981', 'backgroundColor' => '#10b981', From 57833d49ece693695dfe8c92cdaa01331a463575 Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 16:58:30 +0200 Subject: [PATCH 03/10] Fix layout --- .../RecentDownloadLatencyChartWidget.php | 18 +++++++++--------- .../Widgets/RecentUploadLatencyChartWidget.php | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php index 5c2be5d49..40c6ee57b 100644 --- a/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php +++ b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php @@ -53,6 +53,15 @@ protected function getData(): array return [ 'datasets' => [ + [ + 'label' => 'Average (ms)', + 'data' => $results->map(fn ($item) => $item->download_latency_iqm ? number_format($item->pdownload_latency_iqm, 2) : 0), + 'borderColor' => '#10b981', + 'backgroundColor' => '#10b981', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], [ 'label' => 'High (ms)', 'data' => $results->map(fn ($item) => $item->download_latency_high ? number_format($item->download_latency_high, 2) : 0), @@ -71,15 +80,6 @@ protected function getData(): array 'cubicInterpolationMode' => 'monotone', 'tension' => 0.4, ], - [ - 'label' => 'iqm (ms)', - 'data' => $results->map(fn ($item) => $item->download_latency_iqm ? number_format($item->pdownload_latency_iqm, 2) : 0), - 'borderColor' => '#10b981', - 'backgroundColor' => '#10b981', - 'fill' => false, - 'cubicInterpolationMode' => 'monotone', - 'tension' => 0.4, - ], ], 'labels' => $results->map(fn ($item) => $item->created_at->timezone(TimeZoneHelper::displayTimeZone($settings))->format('M d - G:i')), ]; diff --git a/app/Filament/Widgets/RecentUploadLatencyChartWidget.php b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php index 6bf9522ea..6128e34ba 100644 --- a/app/Filament/Widgets/RecentUploadLatencyChartWidget.php +++ b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php @@ -53,6 +53,15 @@ protected function getData(): array return [ 'datasets' => [ + [ + 'label' => 'Average (ms)', + 'data' => $results->map(fn ($item) => $item->upload_latency_iqm ? number_format($item->upload_latency_iqm, 2) : 0), + 'borderColor' => '#10b981', + 'backgroundColor' => '#10b981', + 'fill' => false, + 'cubicInterpolationMode' => 'monotone', + 'tension' => 0.4, + ], [ 'label' => 'High (ms)', 'data' => $results->map(fn ($item) => $item->upload_latency_high ? number_format($item->upload_latency_high, 2) : 0), @@ -71,15 +80,6 @@ protected function getData(): array 'cubicInterpolationMode' => 'monotone', 'tension' => 0.4, ], - [ - 'label' => 'iqm (ms)', - 'data' => $results->map(fn ($item) => $item->upload_latency_iqm ? number_format($item->upload_latency_iqm, 2) : 0), - 'borderColor' => '#10b981', - 'backgroundColor' => '#10b981', - 'fill' => false, - 'cubicInterpolationMode' => 'monotone', - 'tension' => 0.4, - ], ], 'labels' => $results->map(fn ($item) => $item->created_at->timezone(TimeZoneHelper::displayTimeZone($settings))->format('M d - G:i')), ]; From cbc6371164325f42e12f16b60bdffd0878840141 Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 17:11:17 +0200 Subject: [PATCH 04/10] Add export and influxdb --- app/Filament/Exports/ResultExporter.php | 24 ++++++++++++++++++++++++ app/Models/Result.php | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/app/Filament/Exports/ResultExporter.php b/app/Filament/Exports/ResultExporter.php index 5acc680f5..9da6bc232 100644 --- a/app/Filament/Exports/ResultExporter.php +++ b/app/Filament/Exports/ResultExporter.php @@ -64,6 +64,30 @@ public static function getColumns(): array ->state(function (Result $record): ?string { return $record->ping_jitter; }), + ExportColumn::make('upload_latency_high') + ->state(function (Result $record): ?string { + return $record->pupload_latency_high; + }), + ExportColumn::make('upload_latency_low') + ->state(function (Result $record): ?string { + return $record->pupload_latency_low; + }), + ExportColumn::make('upload_latency_iqm') + ->state(function (Result $record): ?string { + return $record->pupload_latency_iqm; + }), + ExportColumn::make('download_latency_high') + ->state(function (Result $record): ?string { + return $record->pdownload_latency_high; + }), + ExportColumn::make('download_latency_low') + ->state(function (Result $record): ?string { + return $record->pdownload_latency_low; + }), + ExportColumn::make('download_latency_iqm') + ->state(function (Result $record): ?string { + return $record->pdownload_latency_iqm; + }), ExportColumn::make('comments') ->enabledByDefault(false), // ExportColumn::make('status'), // TODO: enable status when upgrading to PHP v8.3: https://php.watch/versions/8.3/dynamic-class-const-enum-member-syntax-support diff --git a/app/Models/Result.php b/app/Models/Result.php index 84c196187..a07b31419 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -60,6 +60,12 @@ public function formatForInfluxDB2() 'ping_jitter' => $this->ping_jitter, 'download_jitter' => $this->download_jitter, 'upload_jitter' => $this->upload_jitter, + 'download_latency_iqm' => $this->download_latency_iqm, + 'download_latency_low' => $this->download_latency_low, + 'download_latency_high' => $this->download_latency_high, + 'upload_latency_iqm' => $this->upload_latency_iqm, + 'upload_latency_low' => $this->upload_latency_low, + 'upload_latency_high' => $this->upload_latency_high, 'server_id' => $this?->server_id, 'server_host' => $this?->server_host, 'server_name' => $this?->server_name, From 478b0bc2779771c55eaa89404c92f3d570496d59 Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 17:16:39 +0200 Subject: [PATCH 05/10] Fix naming --- app/Filament/Exports/ResultExporter.php | 4 ++-- app/Models/Result.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Filament/Exports/ResultExporter.php b/app/Filament/Exports/ResultExporter.php index 9da6bc232..f42efbc8a 100644 --- a/app/Filament/Exports/ResultExporter.php +++ b/app/Filament/Exports/ResultExporter.php @@ -72,7 +72,7 @@ public static function getColumns(): array ->state(function (Result $record): ?string { return $record->pupload_latency_low; }), - ExportColumn::make('upload_latency_iqm') + ExportColumn::make('upload_latency_avg') ->state(function (Result $record): ?string { return $record->pupload_latency_iqm; }), @@ -84,7 +84,7 @@ public static function getColumns(): array ->state(function (Result $record): ?string { return $record->pdownload_latency_low; }), - ExportColumn::make('download_latency_iqm') + ExportColumn::make('download_latency_avg') ->state(function (Result $record): ?string { return $record->pdownload_latency_iqm; }), diff --git a/app/Models/Result.php b/app/Models/Result.php index a07b31419..3a6734a12 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -60,10 +60,10 @@ public function formatForInfluxDB2() 'ping_jitter' => $this->ping_jitter, 'download_jitter' => $this->download_jitter, 'upload_jitter' => $this->upload_jitter, - 'download_latency_iqm' => $this->download_latency_iqm, + 'download_latency_avg' => $this->download_latency_iqm, 'download_latency_low' => $this->download_latency_low, 'download_latency_high' => $this->download_latency_high, - 'upload_latency_iqm' => $this->upload_latency_iqm, + 'upload_latency_avg' => $this->upload_latency_iqm, 'upload_latency_low' => $this->upload_latency_low, 'upload_latency_high' => $this->upload_latency_high, 'server_id' => $this?->server_id, From 37954e25274726191f3000d505eda0afd96c21a3 Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 17:21:01 +0200 Subject: [PATCH 06/10] Fix typo in results --- app/Filament/Exports/ResultExporter.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Filament/Exports/ResultExporter.php b/app/Filament/Exports/ResultExporter.php index f42efbc8a..7fc33a367 100644 --- a/app/Filament/Exports/ResultExporter.php +++ b/app/Filament/Exports/ResultExporter.php @@ -66,27 +66,27 @@ public static function getColumns(): array }), ExportColumn::make('upload_latency_high') ->state(function (Result $record): ?string { - return $record->pupload_latency_high; + return $record->upload_latency_high; }), ExportColumn::make('upload_latency_low') ->state(function (Result $record): ?string { - return $record->pupload_latency_low; + return $record->upload_latency_low; }), ExportColumn::make('upload_latency_avg') ->state(function (Result $record): ?string { - return $record->pupload_latency_iqm; + return $record->upload_latency_iqm; }), ExportColumn::make('download_latency_high') ->state(function (Result $record): ?string { - return $record->pdownload_latency_high; + return $record->download_latency_high; }), ExportColumn::make('download_latency_low') ->state(function (Result $record): ?string { - return $record->pdownload_latency_low; + return $record->download_latency_low; }), ExportColumn::make('download_latency_avg') ->state(function (Result $record): ?string { - return $record->pdownload_latency_iqm; + return $record->download_latency_iqm; }), ExportColumn::make('comments') ->enabledByDefault(false), From 1db5a5d5f11b686ff86ba5fcd4866b5fc4cbecb3 Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 17:57:26 +0200 Subject: [PATCH 07/10] Try to add the results table --- app/Filament/Resources/ResultResource.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index 8afd4c1fe..9513910c9 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -175,6 +175,12 @@ public static function table(Table $table): Table ->sortable(query: function (Builder $query, string $direction): Builder { return $query->orderBy('data->ping->jitter', $direction); }), + Tables\Columns\TextColumn::make('download_latency_high') + ->toggleable() + ->toggledHiddenByDefault() + ->sortable(query: function (Builder $query, string $direction): Builder { + return $query->orderBy('data->download>latency>high', $direction); + }), Tables\Columns\TextColumn::make('packet_loss') ->toggleable() ->toggledHiddenByDefault(), From 579faea67e3ba5a511c413bf38f1c9609d592f0c Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 18:11:19 +0200 Subject: [PATCH 08/10] Add latency to the results table --- app/Filament/Resources/ResultResource.php | 38 ++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index 9513910c9..f159eeb3c 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -163,23 +163,53 @@ public static function table(Table $table): Table ->sortable(query: function (Builder $query, string $direction): Builder { return $query->orderBy('data->download->latency->jitter', $direction); }), + Tables\Columns\TextColumn::make('download_latency_high') + ->toggleable() + ->toggledHiddenByDefault() + ->sortable(query: function (Builder $query, string $direction): Builder { + return $query->orderBy('data->download>latency>high', $direction); + }), + Tables\Columns\TextColumn::make('download_latency_low') + ->toggleable() + ->toggledHiddenByDefault() + ->sortable(query: function (Builder $query, string $direction): Builder { + return $query->orderBy('data->download>latency>low', $direction); + }), + Tables\Columns\TextColumn::make('download_latency_avg') + ->toggleable() + ->toggledHiddenByDefault() + ->sortable(query: function (Builder $query, string $direction): Builder { + return $query->orderBy('data->download>latency>iqm', $direction); + }), Tables\Columns\TextColumn::make('upload_jitter') ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { return $query->orderBy('data->upload->latency->jitter', $direction); }), - Tables\Columns\TextColumn::make('ping_jitter') + Tables\Columns\TextColumn::make('upload_latency_high') ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->ping->jitter', $direction); + return $query->orderBy('data->upload>latency>high', $direction); }), - Tables\Columns\TextColumn::make('download_latency_high') + Tables\Columns\TextColumn::make('upload_latency_low') ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->download>latency>high', $direction); + return $query->orderBy('data->upload>latency>low', $direction); + }), + Tables\Columns\TextColumn::make('upload_latency_avg') + ->toggleable() + ->toggledHiddenByDefault() + ->sortable(query: function (Builder $query, string $direction): Builder { + return $query->orderBy('data->upload>latency>iqm', $direction); + }), + Tables\Columns\TextColumn::make('ping_jitter') + ->toggleable() + ->toggledHiddenByDefault() + ->sortable(query: function (Builder $query, string $direction): Builder { + return $query->orderBy('data->ping->jitter', $direction); }), Tables\Columns\TextColumn::make('packet_loss') ->toggleable() From f2a95e3084a93c87318452ac0c8c62ec73603f5d Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Thu, 4 Apr 2024 18:19:48 +0200 Subject: [PATCH 09/10] Fix avg latency colunm --- app/Filament/Resources/ResultResource.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index f159eeb3c..0507f8c70 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -167,19 +167,19 @@ public static function table(Table $table): Table ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->download>latency>high', $direction); + return $query->orderBy('data->download->latency->high', $direction); }), Tables\Columns\TextColumn::make('download_latency_low') ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->download>latency>low', $direction); + return $query->orderBy('data->download->latency->low', $direction); }), - Tables\Columns\TextColumn::make('download_latency_avg') + Tables\Columns\TextColumn::make('download_latency_iqm') ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->download>latency>iqm', $direction); + return $query->orderBy('data->download->latency->iqm', $direction); }), Tables\Columns\TextColumn::make('upload_jitter') ->toggleable() @@ -191,19 +191,19 @@ public static function table(Table $table): Table ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->upload>latency>high', $direction); + return $query->orderBy('data->upload->latency->high', $direction); }), Tables\Columns\TextColumn::make('upload_latency_low') ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->upload>latency>low', $direction); + return $query->orderBy('data->upload->latency->low', $direction); }), - Tables\Columns\TextColumn::make('upload_latency_avg') + Tables\Columns\TextColumn::make('upload_latency_iqm') ->toggleable() ->toggledHiddenByDefault() ->sortable(query: function (Builder $query, string $direction): Builder { - return $query->orderBy('data->upload>latency>iqm', $direction); + return $query->orderBy('data->upload->latency->iqm', $direction); }), Tables\Columns\TextColumn::make('ping_jitter') ->toggleable() From b6572cd749d8976774acce41197121d808b6f574 Mon Sep 17 00:00:00 2001 From: svenvg93 Date: Fri, 5 Apr 2024 15:05:24 +0200 Subject: [PATCH 10/10] Fix lint findings --- app/Filament/Pages/Dashboard.php | 4 ++-- app/Filament/Resources/ResultResource.php | 2 +- app/Models/Result.php | 20 +++++++------------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index 8d3f02b89..36f5def65 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -4,12 +4,12 @@ use App\Actions\Speedtests\RunOoklaSpeedtest; 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\StatsOverviewWidget; use App\Filament\Widgets\RecentUploadLatencyChartWidget; -use App\Filament\Widgets\RecentDownloadLatencyChartWidget; +use App\Filament\Widgets\StatsOverviewWidget; use App\Settings\GeneralSettings; use Filament\Actions\Action; use Filament\Actions\ActionGroup; diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index 0507f8c70..a80cd87b7 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -81,7 +81,7 @@ public static function form(Form $form): Form Forms\Components\TextInput::make('data.upload.latency.low') ->label('Upload Latency low'), Forms\Components\TextInput::make('data.upload.latency.iqm') - ->label('Upload Latency iqm'), + ->label('Upload Latency iqm'), Forms\Components\TextInput::make('data.ping.jitter') ->label('Ping Jitter (ms)'), Forms\Components\TextInput::make('data.packetLoss') diff --git a/app/Models/Result.php b/app/Models/Result.php index 3a6734a12..6dcfe12f4 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -107,7 +107,7 @@ protected function downloadJitter(): Attribute ); } - /** + /** * Get the result's download latency high in milliseconds. */ protected function downloadlatencyHigh(): Attribute @@ -117,8 +117,7 @@ protected function downloadlatencyHigh(): Attribute ); } - -/** + /** * Get the result's download latency low in milliseconds. */ protected function downloadlatencyLow(): Attribute @@ -128,8 +127,7 @@ protected function downloadlatencyLow(): Attribute ); } - -/** + /** * Get the result's download latency iqm in milliseconds. */ protected function downloadlatencyiqm(): Attribute @@ -139,7 +137,6 @@ protected function downloadlatencyiqm(): Attribute ); } - /** * Get the result's download jitter in milliseconds. */ @@ -252,8 +249,7 @@ protected function uploadJitter(): Attribute ); } - - /** + /** * Get the result's upload latency high in milliseconds. */ protected function uploadlatencyHigh(): Attribute @@ -263,8 +259,7 @@ protected function uploadlatencyHigh(): Attribute ); } - -/** + /** * Get the result's upload latency low in milliseconds. */ protected function uploadlatencyLow(): Attribute @@ -274,8 +269,7 @@ protected function uploadlatencyLow(): Attribute ); } - -/** + /** * Get the result's upload latency iqm in milliseconds. */ protected function uploadlatencyiqm(): Attribute @@ -284,4 +278,4 @@ protected function uploadlatencyiqm(): Attribute get: fn () => Arr::get($this->data, 'upload.latency.iqm'), ); } -} \ No newline at end of file +}