Skip to content

Commit

Permalink
Merge branch 'alexjustesen:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
garanda21 authored Jan 4, 2023
2 parents 59b75bb + cc750d6 commit 9025087
Show file tree
Hide file tree
Showing 11 changed files with 353 additions and 334 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/cd-docker-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ env:
jobs:
build_and_push_image:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
Expand Down Expand Up @@ -55,5 +52,5 @@ jobs:
context: .
push: true
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
tags: ajustesen/speedtest-tracker:latest
labels: ${{ steps.meta.outputs.labels }}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> **Warning**
> Wow what a couple of months it's been, thank you everyone for the support on my little side project. It's the holidays and I'm planning on taking a little time off from Dec. 23 - Jan 2nd so support will likely be slow or non-existent. I hope everyone has a happy holidays, see you all in 2023!
## Speedtest Tracker

Speedtest Tracker is a self-hosted internet performance tracking application that runs speedtest checks against Ookla's Speedtest service.
Expand Down
77 changes: 54 additions & 23 deletions _ide_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* A helper file for Laravel, to provide autocomplete information to your IDE
* Generated for Laravel 9.44.0.
* Generated for Laravel 9.46.0.
*
* This file should not be included in your code, only analyzed by your IDE!
*
Expand Down Expand Up @@ -2575,6 +2575,19 @@ public static function getClassComponentAliases()
{
/** @var \Illuminate\View\Compilers\BladeCompiler $instance */
return $instance->getClassComponentAliases();
}
/**
* Register a new anonymous component path.
*
* @param string $path
* @param string|null $prefix
* @return void
* @static
*/
public static function anonymousComponentPath($path, $prefix = null)
{
/** @var \Illuminate\View\Compilers\BladeCompiler $instance */
$instance->anonymousComponentPath($path, $prefix);
}
/**
* Register an anonymous component namespace.
Expand All @@ -2601,6 +2614,17 @@ public static function componentNamespace($namespace, $prefix)
{
/** @var \Illuminate\View\Compilers\BladeCompiler $instance */
$instance->componentNamespace($namespace, $prefix);
}
/**
* Get the registered anonymous component paths.
*
* @return array
* @static
*/
public static function getAnonymousComponentPaths()
{
/** @var \Illuminate\View\Compilers\BladeCompiler $instance */
return $instance->getAnonymousComponentPaths();
}
/**
* Get the registered anonymous component namespaces.
Expand Down Expand Up @@ -3559,6 +3583,7 @@ public static function recordPendingBatch($pendingBatch)
*
*
* @see \Illuminate\Cache\CacheManager
* @mixin \Illuminate\Cache\Repository
*/
class Cache {
/**
Expand Down Expand Up @@ -3671,7 +3696,7 @@ public static function extend($driver, $callback)
/**
* Determine if an item exists in the cache.
*
* @param string $key
* @param array|string $key
* @return bool
* @static
*/
Expand All @@ -3695,9 +3720,10 @@ public static function missing($key)
/**
* Retrieve an item from the cache by key.
*
* @template TCacheValue
* @param array|string $key
* @param mixed $default
* @return mixed
* @param \Illuminate\Cache\TCacheValue|\Illuminate\Cache\(\Closure(): TCacheValue) $default
* @return \Illuminate\Cache\(TCacheValue is null ? mixed : TCacheValue)
* @static
*/
public static function get($key, $default = null)
Expand Down Expand Up @@ -3739,9 +3765,10 @@ public static function getMultiple($keys, $default = null)
/**
* Retrieve an item from the cache and delete it.
*
* @param string $key
* @param mixed $default
* @return mixed
* @template TCacheValue
* @param array|string $key
* @param \Illuminate\Cache\TCacheValue|\Illuminate\Cache\(\Closure(): TCacheValue) $default
* @return \Illuminate\Cache\(TCacheValue is null ? mixed : TCacheValue)
* @static
*/
public static function pull($key, $default = null)
Expand Down Expand Up @@ -3870,10 +3897,11 @@ public static function forever($key, $value)
/**
* Get an item from the cache, or execute the given Closure and store the result.
*
* @template TCacheValue
* @param string $key
* @param \Closure|\DateTimeInterface|\DateInterval|int|null $ttl
* @param \Closure $callback
* @return mixed
* @param \Closure(): TCacheValue $callback
* @return \Illuminate\Cache\TCacheValue
* @static
*/
public static function remember($key, $ttl, $callback)
Expand All @@ -3884,9 +3912,10 @@ public static function remember($key, $ttl, $callback)
/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @template TCacheValue
* @param string $key
* @param \Closure $callback
* @return mixed
* @param \Closure(): TCacheValue $callback
* @return \Illuminate\Cache\TCacheValue
* @static
*/
public static function sear($key, $callback)
Expand All @@ -3897,9 +3926,10 @@ public static function sear($key, $callback)
/**
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @template TCacheValue
* @param string $key
* @param \Closure $callback
* @return mixed
* @param \Closure(): TCacheValue $callback
* @return \Illuminate\Cache\TCacheValue
* @static
*/
public static function rememberForever($key, $callback)
Expand Down Expand Up @@ -7610,18 +7640,18 @@ public static function forgetDrivers()
* @method static \Illuminate\Http\Client\PendingRequest withMiddleware(callable $middleware)
* @method static \Illuminate\Http\Client\PendingRequest beforeSending(callable $callback)
* @method static \Illuminate\Http\Client\PendingRequest throw(callable|null $callback = null)
* @method static \Illuminate\Http\Client\PendingRequest throwIf(callable|bool $condition)
* @method static \Illuminate\Http\Client\PendingRequest throwIf(callable|bool $condition, callable|null $throwCallback = null)
* @method static \Illuminate\Http\Client\PendingRequest throwUnless(bool $condition)
* @method static \Illuminate\Http\Client\PendingRequest dump()
* @method static \Illuminate\Http\Client\PendingRequest dd()
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface get(string $url, array|string|null $query = null)
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface head(string $url, array|string|null $query = null)
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface post(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface patch(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface put(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface delete(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response get(string $url, array|string|null $query = null)
* @method static \Illuminate\Http\Client\Response head(string $url, array|string|null $query = null)
* @method static \Illuminate\Http\Client\Response post(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response patch(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response put(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response delete(string $url, array $data = [])
* @method static array pool(callable $callback)
* @method static \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface send(string $method, string $url, array $options = [])
* @method static \Illuminate\Http\Client\Response send(string $method, string $url, array $options = [])
* @method static \GuzzleHttp\Client buildClient()
* @method static \GuzzleHttp\Client createClient(\GuzzleHttp\HandlerStack $handlerStack)
* @method static \GuzzleHttp\HandlerStack buildHandlerStack()
Expand Down Expand Up @@ -12863,6 +12893,7 @@ public static function flushMacros()
* @method static \Illuminate\Routing\RouteRegistrar whereAlpha(array|string $parameters)
* @method static \Illuminate\Routing\RouteRegistrar whereAlphaNumeric(array|string $parameters)
* @method static \Illuminate\Routing\RouteRegistrar whereNumber(array|string $parameters)
* @method static \Illuminate\Routing\RouteRegistrar whereUlid(array|string $parameters)
* @method static \Illuminate\Routing\RouteRegistrar whereUuid(array|string $parameters)
* @method static \Illuminate\Routing\RouteRegistrar whereIn(array|string $parameters, array $values)
* @method static \Illuminate\Routing\RouteRegistrar as(string $value)
Expand Down Expand Up @@ -17535,7 +17566,7 @@ public static function useStyleTagAttributes($attributes)
/**
* Use the given callback to resolve attributes for preload tags.
*
* @param \Illuminate\Foundation\(callable(string, string, ?array, ?array): array)|array $attributes
* @param \Illuminate\Foundation\(callable(string, string, ?array, ?array): array|false)|array|false $attributes
* @return \Illuminate\Foundation\Vite
* @static
*/
Expand Down Expand Up @@ -23015,7 +23046,7 @@ public static function orderByDesc($column)
/**
* Put the query's results in random order.
*
* @param string $seed
* @param string|int $seed
* @return \Illuminate\Database\Query\Builder
* @static
*/
Expand Down
2 changes: 2 additions & 0 deletions app/Filament/Pages/Settings/GeneralPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Filament\Pages\Settings;

use App\Rules\ValidCronExpression;
use App\Settings\GeneralSettings;
use Filament\Forms\Components\Card;
use Filament\Forms\Components\Grid;
Expand Down Expand Up @@ -64,6 +65,7 @@ protected function getFormSchema(): array
Section::make('Speedtest Settings')
->schema([
TextInput::make('speedtest_schedule')
->rules([new ValidCronExpression()])
->helperText('Leave empty to disable the schedule. You can also use the cron expression generator [HERE](https://crontab.cronhub.io/) to help you make schedules.')
->nullable()
->columnSpan(1),
Expand Down
5 changes: 3 additions & 2 deletions app/Filament/Pages/Settings/NotificationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ protected function getFormSchema(): array
->label('Recipients')
->schema([
TextInput::make('email_address')
->email(),
->email()
->required(),
])
->hidden(fn (Closure $get) => $get('mail_enabled') !== true)
->columnSpan(['md' => 2]),
Expand Down Expand Up @@ -191,7 +192,7 @@ public function sendTestMailNotification()
{
$notificationSettings = new (NotificationSettings::class);

if (count($notificationSettings->mail_recipients)) {
if (! empty($notificationSettings->mail_recipients)) {
foreach ($notificationSettings->mail_recipients as $recipient) {
Mail::to($recipient)
->send(new Test());
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Widgets/RecentSpeedChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function getData(): array
'datasets' => [
[
'label' => 'Download',
'data' => $results->map(fn ($item) => formatBits(formatBytesToBits($item->download), 2, false)),
'data' => $results->map(fn ($item) => roundBytesToMegabits($item->download)),
'borderColor' => '#0ea5e9',
'backgroundColor' => '#0ea5e9',
'fill' => false,
Expand All @@ -58,7 +58,7 @@ protected function getData(): array
],
[
'label' => 'Upload',
'data' => $results->map(fn ($item) => formatBits(formatBytesToBits($item->upload), 2, false)),
'data' => $results->map(fn ($item) => roundBytesToMegabits($item->upload)),
'borderColor' => '#8b5cf6',
'backgroundColor' => '#8b5cf6',
'fill' => false,
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/FilamentServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function boot()
return true;
});

FilamentVersions::addItem('Speedtest Tracker', 'v0.9.1');
FilamentVersions::addItem('Speedtest Tracker', 'v'.config('speedtest.build_version'));

Filament::serving(function () {
Filament::registerNavigationGroups([
Expand Down
26 changes: 26 additions & 0 deletions app/Rules/ValidCronExpression.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Rules;

use Cron\CronExpression;
use Illuminate\Contracts\Validation\InvokableRule;

class ValidCronExpression implements InvokableRule
{
/**
* Validates a string cron expression is correct
*
* @param string $attribute
* @param mixed $value
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
*/
public function __invoke($attribute, $value, $fail)
{
$is_valid = CronExpression::isValidExpression($value);

if (! $is_valid) {
$fail('Cron expression is not valid');
}
}
}
15 changes: 15 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ function formatBytestoBits(int $bytes)
}
}

if (! function_exists('roundBytesToMegabits')) {
function roundBytesToMegabits(int $bytes)
{
if ($bytes > 0) {
$bits = formatBytesToBits($bytes);
$megabit_exponent = 2;
$precision = 2;

return round($bits / pow(1000, $megabit_exponent), $precision);
}

return 0;
}
}

if (! function_exists('percentChange')) {
function percentChange(float $dividend, float $divisor, int $precision = 0): string
{
Expand Down
Loading

0 comments on commit 9025087

Please sign in to comment.