Skip to content

Commit e775e70

Browse files
authored
Merge branch 'alexjustesen:main' into feat/add-speedtest-button
2 parents 6abbfa2 + 8e869a0 commit e775e70

File tree

12 files changed

+102
-38
lines changed

12 files changed

+102
-38
lines changed

app/Filament/Resources/Results/Tables/ResultTable.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Enums\ResultStatus;
66
use App\Filament\Exports\ResultExporter;
7+
use App\Filament\Tables\Columns\ResultServerColumn;
78
use App\Helpers\Number;
89
use App\Models\Result;
910
use Filament\Actions\Action;
@@ -49,19 +50,9 @@ public static function table(Table $table): Table
4950
->label(__('results.service'))
5051
->toggleable(isToggledHiddenByDefault: true),
5152

52-
TextColumn::make('data.server.id')
53-
->label(__('results.server_id'))
54-
->toggleable(isToggledHiddenByDefault: false)
55-
->sortable(query: function (Builder $query, string $direction): Builder {
56-
return $query->orderBy('data->server->id', $direction);
57-
}),
58-
59-
TextColumn::make('data.server.name')
60-
->label(__('results.server_name'))
61-
->toggleable(isToggledHiddenByDefault: false)
62-
->sortable(query: function (Builder $query, string $direction): Builder {
63-
return $query->orderBy('data->server->name', $direction);
64-
}),
53+
ResultServerColumn::make('server')
54+
->label(__('general.server'))
55+
->toggleable(isToggledHiddenByDefault: false),
6556

6657
TextColumn::make('download')
6758
->label(__('results.download'))
@@ -131,7 +122,7 @@ public static function table(Table $table): Table
131122
->label(__('general.created_at'))
132123
->dateTime(config('app.datetime_format'))
133124
->timezone(config('app.display_timezone'))
134-
->toggleable(isToggledHiddenByDefault: true)
125+
->toggleable(isToggledHiddenByDefault: false)
135126
->sortable(),
136127
])
137128
->filters([
@@ -158,6 +149,7 @@ public static function table(Table $table): Table
158149
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
159150
);
160151
}),
152+
161153
SelectFilter::make('ip_address')
162154
->label(__('results.ip_address'))
163155
->multiple()
@@ -175,6 +167,7 @@ public static function table(Table $table): Table
175167
->toArray();
176168
})
177169
->attribute('data->interface->externalIp'),
170+
178171
SelectFilter::make('server_name')
179172
->label(__('results.server_name'))
180173
->multiple()
@@ -192,6 +185,25 @@ public static function table(Table $table): Table
192185
->toArray();
193186
})
194187
->attribute('data->server->name'),
188+
189+
SelectFilter::make('server_id')
190+
->label(__('results.server_id'))
191+
->multiple()
192+
->options(function (): array {
193+
return Result::query()
194+
->select('data->server->id AS data_server_id')
195+
->whereNotNull('data->server->id')
196+
->where('status', '=', ResultStatus::Completed)
197+
->distinct()
198+
->orderBy('data->server->id')
199+
->get()
200+
->mapWithKeys(function (Result $item, int $key) {
201+
return [$item['data_server_id'] => $item['data_server_id']];
202+
})
203+
->toArray();
204+
})
205+
->attribute('data->server->id'),
206+
195207
TernaryFilter::make('scheduled')
196208
->label(__('results.scheduled'))
197209
->nullable()
@@ -203,10 +215,12 @@ public static function table(Table $table): Table
203215
false: fn (Builder $query) => $query->where('scheduled', false),
204216
blank: fn (Builder $query) => $query,
205217
),
218+
206219
SelectFilter::make('status')
207220
->label(__('general.status'))
208221
->multiple()
209222
->options(ResultStatus::class),
223+
210224
TernaryFilter::make('healthy')
211225
->label(__('general.healthy'))
212226
->nullable()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Filament\Tables\Columns;
4+
5+
use Filament\Tables\Columns\Column;
6+
7+
class ResultServerColumn extends Column
8+
{
9+
protected string $view = 'filament.tables.columns.result-server-column';
10+
11+
protected ?string $serverName = null;
12+
13+
protected ?int $serverId = null;
14+
15+
public function getServerName(): ?string
16+
{
17+
$this->serverName = $this->record->server_name;
18+
19+
return $this->serverName;
20+
}
21+
22+
public function getServerId(): ?int
23+
{
24+
$this->serverId = $this->record->server_id;
25+
26+
return $this->serverId;
27+
}
28+
}

app/Listeners/ProcessCompletedSpeedtest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private function notifyAppriseChannels(Result $result): void
8888
}
8989

9090
Notification::route('apprise_urls', $channelUrl)
91-
->notify(new SpeedtestNotification($title, $body, 'info'));
91+
->notify(new SpeedtestNotification($title, $body, 'info', 'markdown'));
9292
}
9393
}
9494

app/Listeners/ProcessUnhealthySpeedtest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function notifyAppriseChannels(Result $result): void
110110
}
111111

112112
Notification::route('apprise_urls', $channelUrl)
113-
->notify(new SpeedtestNotification($title, $body, 'warning'));
113+
->notify(new SpeedtestNotification($title, $body, 'warning', 'markdown'));
114114
}
115115
}
116116

app/Notifications/Apprise/SpeedtestNotification.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function __construct(
1414
public string $title,
1515
public string $body,
1616
public string $type = 'info',
17+
public string $format = 'markdown',
1718
) {}
1819

1920
/**
@@ -35,6 +36,7 @@ public function toApprise(object $notifiable): AppriseMessage
3536
->urls($notifiable->routes['apprise_urls'])
3637
->title($this->title)
3738
->body($this->body)
38-
->type($this->type);
39+
->type($this->type)
40+
->format($this->format);
3941
}
4042
}

app/Notifications/Apprise/TestNotification.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ public function via(object $notifiable): array
2525
*/
2626
public function toApprise(object $notifiable): AppriseMessage
2727
{
28+
$body = '👋 This is a test notification from **'.config('app.name')."**.\n\n";
29+
$body .= "If you're seeing this, your Apprise notification channel is configured correctly!\n\n";
30+
2831
return AppriseMessage::create()
2932
->urls($notifiable->routes['apprise_urls'])
3033
->title('Test Notification')
31-
->body('👋 Testing the Apprise notification channel.')
32-
->type('info');
34+
->body($body)
35+
->type('info')
36+
->format('markdown');
3337
}
3438
}

config/speedtest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
/**
77
* General settings.
88
*/
9-
'build_date' => Carbon::parse('2025-12-06'),
9+
'build_date' => Carbon::parse('2025-12-08'),
1010

11-
'build_version' => 'v1.12.2',
11+
'build_version' => 'v1.12.3',
1212

1313
'content_width' => env('CONTENT_WIDTH', '7xl'),
1414

lang/en/general.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
'created_at' => 'Created at',
3838
'updated_at' => 'Updated at',
3939
'url' => 'URL',
40+
'server' => 'Server',
41+
'servers' => 'Servers',
4042
'stats' => 'Stats',
4143
'statistics' => 'Statistics',
4244

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
A new speedtest on {{ config('app.name') }} was completed using {{ $service }}.
1+
A new speedtest on **{{ config('app.name') }}** was completed using **{{ $service }}**.
22

3-
Server name: {{ $serverName }}
4-
Server ID: {{ $serverId }}
5-
ISP: {{ $isp }}
6-
Ping: {{ $ping }}
7-
Download: {{ $download }}
8-
Upload: {{ $upload }}
9-
Packet Loss: {{ $packetLoss }} %
10-
Ookla Speedtest: {{ $speedtest_url }}
11-
URL: {{ $url }}
3+
### Results
4+
- **Server:** {{ $serverName }} (ID: {{ $serverId }})
5+
- **ISP:** {{ $isp }}
6+
- **Ping:** {{ $ping }}
7+
- **Download:** {{ $download }}
8+
- **Upload:** {{ $upload }}
9+
- **Packet Loss:** {{ $packetLoss }}%
10+
11+
### Links
12+
- [View Ookla Results]({{ $speedtest_url }})
13+
- [View Dashboard]({{ $url }})
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
A new speedtest on **{{ config('app.name') }}** was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached.
2-
1+
A new speedtest on **{{ config('app.name') }}** was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached
2+
### Failed Metrics
33
@foreach ($metrics as $item)
4-
- **{{ $item['name'] }}** {{ $item['threshold'] }}: {{ $item['value'] }}
4+
- **{{ $item['name'] }}**
5+
- **Threshold:** {{ $item['threshold'] }} | **Actual:** {{ $item['value'] }}
56
@endforeach
6-
- **Ookla Speedtest:** {{ $speedtest_url }}
7-
- **URL:** {{ $url }}
7+
### Server Information
8+
- **Server:** {{ $serverName }} (ID: {{ $serverId }})
9+
- **ISP:** {{ $isp }}
10+
### Links
11+
- [View Ookla Results]({{ $speedtest_url }})
12+
- [View Dashboard]({{ $url }})

0 commit comments

Comments
 (0)