mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
Merge pull request #563 from henrywhitaker3/alpha
Add InfluxDB integration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Speedtest Tracker
|
||||
|
||||
[](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits)  [](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE)
|
||||
[](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits)  [](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE)
|
||||
|
||||
This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses the [Ookla's speedtest cli](https://www.speedtest.net/apps/cli) package to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results.
|
||||
|
||||
@@ -18,6 +18,7 @@ Disclaimer: You will need to accept Ookla's EULA and privacy agreements in order
|
||||
- Slack/Discord/Telegram notifications
|
||||
- [healthchecks.io](https://healthchecks.io) integration
|
||||
- Organizr integration
|
||||
- InfluxDB integration (currently v1 only, v2 is a WIP)
|
||||
|
||||
## Installation & Setup
|
||||
|
||||
@@ -84,6 +85,8 @@ Container images are configured using parameters passed at runtime (such as thos
|
||||
| `-e PUID` | Optional. Supply a local user ID for volume permissions |
|
||||
| `-e PGID` | Optional. Supply a local group ID for volume permissions |
|
||||
| `-e AUTH` | Optional. Set to 'true' to enable authentication for the app |
|
||||
| `-e INFLUXDB_RETENTION`| Optional. Sets the InfluxDB retention period, defaults to `30d` |
|
||||
| `-e INFLUXDB_HOST_TAG | Optional. Sets the InfluxDB host tag value, defaults to `speedtest` |
|
||||
|
||||
### Authentication
|
||||
|
||||
@@ -101,3 +104,7 @@ After enabling, you should change the password through the web UI.
|
||||
### Manual Install
|
||||
|
||||
For manual installations, please follow the instructions [here](https://github.com/henrywhitaker3/Speedtest-Tracker/wiki/Manual-Installation).
|
||||
|
||||
### Kubernetes
|
||||
|
||||
There is a 3rd party helm chart available [here](https://github.com/sOblivionsCall/charts).
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Actions;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use DB;
|
||||
use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Auth\LoginSession;
|
||||
use App\Models\Auth\LoginSession;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
10
app/Exceptions/InfluxDBConnectionErrorException.php
Normal file
10
app/Exceptions/InfluxDBConnectionErrorException.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InfluxDBConnectionErrorException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Exceptions/InfluxDBNotEnabledException.php
Normal file
10
app/Exceptions/InfluxDBNotEnabledException.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InfluxDBNotEnabledException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Cache;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Auth\EmailVerification;
|
||||
use App\User;
|
||||
use App\Models\Auth\EmailVerification;
|
||||
use App\Models\User;
|
||||
|
||||
class EmailVerificationHelper {
|
||||
public static function checkVerificationAttempt($userID, $token)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Events\TestNotificationEvent;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Speedtest;
|
||||
use App\Interfaces\SpeedtestProvider;
|
||||
use App\Models\Speedtest;
|
||||
use App\Utils\OoklaTester;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
@@ -25,7 +26,7 @@ class SpeedtestHelper
|
||||
*/
|
||||
public static function runSpeedtest()
|
||||
{
|
||||
$tester = new OoklaTester();
|
||||
$tester = app()->make(SpeedtestProvider::class);
|
||||
return $tester->run();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Auth\EmailVerification;
|
||||
use App\Auth\LoginSession as AuthLoginSession;
|
||||
use App\Models\Auth\EmailVerification;
|
||||
use App\Models\Auth\LoginSession as AuthLoginSession;
|
||||
use App\Helpers\EmailVerificationHelper;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\LoginSession;
|
||||
use App\Rules\CurrentPasswordMatches;
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use DateTime;
|
||||
use Hash;
|
||||
use Illuminate\Support\Facades\Request as RequestFacade;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Rules\Cron;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
@@ -9,7 +9,7 @@ use App\Actions\QueueSpeedtest;
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Jobs\SpeedtestJob;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Auth\LoginSession;
|
||||
use App\Models\Auth\LoginSession;
|
||||
use Closure;
|
||||
use Exception;
|
||||
|
||||
|
||||
13
app/Interfaces/InfluxDBWrapperInterface.php
Normal file
13
app/Interfaces/InfluxDBWrapperInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
|
||||
use App\Models\Speedtest;
|
||||
|
||||
interface InfluxDBWrapperInterface
|
||||
{
|
||||
public function testConnection(): bool;
|
||||
public function doesDatabaseExist(string $database): bool;
|
||||
public function createDatabase(string $database): bool;
|
||||
public function store(Speedtest $speedtest): bool;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Interfaces;
|
||||
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
|
||||
interface SpeedtestProvider
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Auth;
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Auth;
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Casts\CommaSeparatedArrayCast;
|
||||
use App\Helpers\SettingsHelper;
|
||||
45
app/Models/Speedtest.php
Normal file
45
app/Models/Speedtest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Speedtest extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'ping',
|
||||
'download',
|
||||
'upload',
|
||||
'created_at',
|
||||
'server_id',
|
||||
'server_name',
|
||||
'server_host',
|
||||
'url',
|
||||
'scheduled',
|
||||
'failed',
|
||||
];
|
||||
|
||||
protected $table = 'speedtests';
|
||||
|
||||
public function formatForInfluxDB()
|
||||
{
|
||||
return [
|
||||
'id' => (int) $this->id,
|
||||
'download' => (float) $this->download,
|
||||
'upload' => (float) $this->upload,
|
||||
'ping' => (float) $this->ping,
|
||||
'server_id' => (int) $this->server_id,
|
||||
'server_host' => $this->server_host,
|
||||
'server_name' => $this->server_name,
|
||||
'scheduled' => (bool) $this->scheduled,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
30
app/Observers/SpeedtestObserver.php
Normal file
30
app/Observers/SpeedtestObserver.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Exceptions\InfluxDBNotEnabledException;
|
||||
use App\Models\Speedtest;
|
||||
use App\Utils\InfluxDB\InfluxDB;
|
||||
use Exception;
|
||||
use Log;
|
||||
|
||||
class SpeedtestObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Speedtest "created" event.
|
||||
*
|
||||
* @param \App\Speedtest $speedtest
|
||||
* @return void
|
||||
*/
|
||||
public function created(Speedtest $speedtest)
|
||||
{
|
||||
try {
|
||||
InfluxDB::connect()
|
||||
->store($speedtest);
|
||||
} catch (InfluxDBNotEnabledException $e) {
|
||||
// /
|
||||
} catch (Exception $e) {
|
||||
Log::error($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ use App\Listeners\SpeedtestCompleteListener;
|
||||
use App\Listeners\SpeedtestFailedListener;
|
||||
use App\Listeners\SpeedtestOverviewListener;
|
||||
use App\Listeners\TestNotificationListener;
|
||||
use App\Observers\SpeedtestObserver;
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
@@ -49,6 +51,6 @@ class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
Speedtest::observe(SpeedtestObserver::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Speedtest extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'ping',
|
||||
'download',
|
||||
'upload',
|
||||
'created_at',
|
||||
'server_id',
|
||||
'server_name',
|
||||
'server_host',
|
||||
'url',
|
||||
'scheduled',
|
||||
'failed',
|
||||
];
|
||||
|
||||
protected $table = 'speedtests';
|
||||
}
|
||||
113
app/Utils/InfluxDB/InfluxDB.php
Normal file
113
app/Utils/InfluxDB/InfluxDB.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils\InfluxDB;
|
||||
|
||||
use App\Exceptions\InfluxDBConnectionErrorException;
|
||||
use App\Exceptions\InfluxDBNotEnabledException;
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Models\Speedtest;
|
||||
use InfluxDB\Client as Version1;
|
||||
use InfluxDB2\Client as Version2;
|
||||
use App\Interfaces\InfluxDBWrapperInterface as Client;
|
||||
|
||||
class InfluxDB
|
||||
{
|
||||
private Client $client;
|
||||
|
||||
private string $database;
|
||||
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to influx db
|
||||
*
|
||||
* @param string $host
|
||||
* @param integer $port
|
||||
* @param string $database
|
||||
* @return InfluxDB
|
||||
*/
|
||||
public static function connect()
|
||||
{
|
||||
if (!(bool) SettingsHelper::get('influx_db_enabled')->value) {
|
||||
throw new InfluxDBNotEnabledException();
|
||||
}
|
||||
|
||||
$host = SettingsHelper::get('influx_db_host')->value;
|
||||
$port = SettingsHelper::get('influx_db_port')->value;
|
||||
$username = SettingsHelper::get('influx_db_username')->value;
|
||||
$password = SettingsHelper::get('influx_db_password')->value;
|
||||
$database = SettingsHelper::get('influx_db_database')->value;
|
||||
$version = (int) SettingsHelper::get('influx_db_version')->value;
|
||||
|
||||
$wrapper = $version === 1
|
||||
? new InfluxDBVersion1Wrapper(
|
||||
new Version1(
|
||||
str_replace(['http://', 'https://'], '', $host),
|
||||
$port,
|
||||
$username,
|
||||
$password
|
||||
)
|
||||
)
|
||||
: new InfluxDBVersion2Wrapper(
|
||||
new Version2([
|
||||
'url' => $host . ':' . $port,
|
||||
'token' => '',
|
||||
])
|
||||
);
|
||||
|
||||
return (new self($wrapper))->setDatabase($database)
|
||||
->testConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the database field
|
||||
*
|
||||
* @param string $database
|
||||
* @return InfluxDB
|
||||
*/
|
||||
public function setDatabase(string $database): InfluxDB
|
||||
{
|
||||
$this->database = $database;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the connection
|
||||
*
|
||||
* @throws InfluxDBConnectionErrorException
|
||||
* @return InfluxDB
|
||||
*/
|
||||
public function testConnection(): InfluxDB
|
||||
{
|
||||
if (!$this->client->testConnection()) {
|
||||
throw new InfluxDBConnectionErrorException();
|
||||
}
|
||||
|
||||
if (!$this->doesDatabaseExist()) {
|
||||
$this->createDatabase();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function doesDatabaseExist(): bool
|
||||
{
|
||||
return $this->client->doesDatabaseExist($this->database);
|
||||
}
|
||||
|
||||
public function createDatabase(): bool
|
||||
{
|
||||
return $this->client->createDatabase($this->database);
|
||||
}
|
||||
|
||||
public function store(Speedtest $speedtest): InfluxDB
|
||||
{
|
||||
$this->client->store($speedtest);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
74
app/Utils/InfluxDB/InfluxDBVersion1Wrapper.php
Normal file
74
app/Utils/InfluxDB/InfluxDBVersion1Wrapper.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils\InfluxDB;
|
||||
|
||||
use App\Interfaces\InfluxDBWrapperInterface;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
use InfluxDB\Client;
|
||||
use InfluxDB\Database;
|
||||
use InfluxDB\Database\RetentionPolicy;
|
||||
use InfluxDB\Point;
|
||||
use Log;
|
||||
|
||||
class InfluxDBVersion1Wrapper implements InfluxDBWrapperInterface
|
||||
{
|
||||
private Client $client;
|
||||
private Database $database;
|
||||
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function testConnection(): bool
|
||||
{
|
||||
try {
|
||||
$this->client->listDatabases();
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Log::error($e);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function doesDatabaseExist(string $database): bool
|
||||
{
|
||||
$this->database = $this->client->selectDB($database);
|
||||
|
||||
return (bool) $this->database->exists();
|
||||
}
|
||||
|
||||
public function createDatabase(string $database): bool
|
||||
{
|
||||
try {
|
||||
$this->database->create(
|
||||
new RetentionPolicy(
|
||||
'speedtest_retention_policy',
|
||||
config('services.influxdb.retention'),
|
||||
1,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Log::error($e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function store(Speedtest $speedtest): bool
|
||||
{
|
||||
return $this->database->writePoints([
|
||||
new Point(
|
||||
'speedtest',
|
||||
null,
|
||||
['host' => config('services.influxdb.host')],
|
||||
$speedtest->formatForInfluxDB(),
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
37
app/Utils/InfluxDB/InfluxDBVersion2Wrapper.php
Normal file
37
app/Utils/InfluxDB/InfluxDBVersion2Wrapper.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils\InfluxDB;
|
||||
|
||||
use App\Interfaces\InfluxDBWrapperInterface;
|
||||
use App\Models\Speedtest;
|
||||
use InfluxDB2\Client;
|
||||
|
||||
class InfluxDBVersion2Wrapper implements InfluxDBWrapperInterface
|
||||
{
|
||||
private Client $client;
|
||||
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function testConnection(): bool
|
||||
{
|
||||
return $this->client->health()->getStatus() !== 'pass';
|
||||
}
|
||||
|
||||
public function doesDatabaseExist(string $database): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createDatabase(string $database): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function store(Speedtest $speedtest): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use App\Exceptions\SpeedtestFailureException;
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Interfaces\SpeedtestProvider;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Cache;
|
||||
use Exception;
|
||||
use JsonException;
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"1.12.0": [
|
||||
{
|
||||
"description": "Added InfluxDB intergation.",
|
||||
"link": ""
|
||||
}
|
||||
],
|
||||
"1.11.1": [
|
||||
{
|
||||
"description": "Add option to show/hide columns in the all tests table.",
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"henrywhitaker3/healthchecks-io": "^1.0",
|
||||
"henrywhitaker3/laravel-actions": "^1.0",
|
||||
"influxdata/influxdb-client-php": "^1.12",
|
||||
"influxdb/influxdb-php": "^1.15",
|
||||
"laravel-notification-channels/telegram": "^0.5.0",
|
||||
"laravel/framework": "^8.0",
|
||||
"laravel/slack-notification-channel": "^2.0",
|
||||
@@ -45,12 +47,10 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
},
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
]
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
|
||||
114
composer.lock
generated
114
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "2c905613bf401a9978baa23d1a80b710",
|
||||
"content-hash": "46d75195c9e28db55cd2b086a6846e13",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm89/stack-cors",
|
||||
@@ -1309,6 +1309,118 @@
|
||||
},
|
||||
"time": "2021-02-06T09:50:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdata/influxdb-client-php",
|
||||
"version": "1.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/influxdata/influxdb-client-php.git",
|
||||
"reference": "e04f802a4d9c52b5b497077673269e8463fdb6ea"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/influxdata/influxdb-client-php/zipball/e04f802a4d9c52b5b497077673269e8463fdb6ea",
|
||||
"reference": "e04f802a4d9c52b5b497077673269e8463fdb6ea",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"guzzlehttp/guzzle": "^6.2|^7.0.1",
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.4|^9.1",
|
||||
"squizlabs/php_codesniffer": "~2.6"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"InfluxDB2\\": "src/InfluxDB2"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "InfluxDB (v2+) Client Library for PHP",
|
||||
"homepage": "https://www.github.com/influxdata/influxdb-client-php",
|
||||
"keywords": [
|
||||
"influxdb"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/influxdata/influxdb-client-php/issues",
|
||||
"source": "https://github.com/influxdata/influxdb-client-php/tree/1.12.0"
|
||||
},
|
||||
"time": "2021-04-01T06:28:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdb/influxdb-php",
|
||||
"version": "1.15.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/influxdata/influxdb-php.git",
|
||||
"reference": "d6e59f4f04ab9107574fda69c2cbe36671253d03"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/influxdata/influxdb-php/zipball/d6e59f4f04ab9107574fda69c2cbe36671253d03",
|
||||
"reference": "d6e59f4f04ab9107574fda69c2cbe36671253d03",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^6.0|^7.0",
|
||||
"php": "^5.5 || ^7.0 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dms/phpunit-arraysubset-asserts": "^0.2.1",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "Curl extension, needed for Curl driver",
|
||||
"stefanotorresi/influxdb-php-async": "An asyncronous client for InfluxDB, implemented via ReactPHP."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"InfluxDB\\": "src/InfluxDB"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Stephen Hoogendijk",
|
||||
"email": "stephen@tca0.nl"
|
||||
},
|
||||
{
|
||||
"name": "Daniel Martinez",
|
||||
"email": "danimartcas@hotmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Gianluca Arbezzano",
|
||||
"email": "gianarb92@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "InfluxDB client library for PHP",
|
||||
"keywords": [
|
||||
"client",
|
||||
"influxdata",
|
||||
"influxdb",
|
||||
"influxdb class",
|
||||
"influxdb client",
|
||||
"influxdb library",
|
||||
"time series"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/influxdata/influxdb-php/issues",
|
||||
"source": "https://github.com/influxdata/influxdb-php/tree/1.15.2"
|
||||
},
|
||||
"time": "2020-12-26T17:45:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel-notification-channels/telegram",
|
||||
"version": "0.5.1",
|
||||
|
||||
@@ -34,4 +34,9 @@ return [
|
||||
'token' => env('TELEGRAM_BOT_TOKEN', 'YOUR BOT TOKEN HERE')
|
||||
],
|
||||
|
||||
'influxdb' => [
|
||||
'retention' => env('INFLUXDB_RETENTION', '30d'),
|
||||
'host' => env('INFLUXDB_HOST_TAG', 'speedtest'),
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -7,7 +7,7 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'version' => '1.11.1',
|
||||
'version' => '1.12.0',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
32
database/factories/SpeedtestFactory.php
Normal file
32
database/factories/SpeedtestFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SpeedtestFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Speedtest::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'download' => rand(15, 900),
|
||||
'upload' => rand(15, 900),
|
||||
'ping' => rand(1, 25),
|
||||
'scheduled' => (bool) rand(0, 1),
|
||||
'failed' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddInfluxDbSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!SettingsHelper::get('influx_db_enabled')) {
|
||||
Setting::create([
|
||||
'name' => 'influx_db_enabled',
|
||||
'value' => false,
|
||||
'description' => 'Enable the InfluxDB integration for speedtests.'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!SettingsHelper::get('influx_db_host')) {
|
||||
Setting::create([
|
||||
'name' => 'influx_db_host',
|
||||
'value' => '',
|
||||
'description' => 'InfluxDB hostname, include the protocol (http:// or https://).'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!SettingsHelper::get('influx_db_port')) {
|
||||
Setting::create([
|
||||
'name' => 'influx_db_port',
|
||||
'value' => '',
|
||||
'description' => 'InfluxDB port'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!SettingsHelper::get('influx_db_database')) {
|
||||
Setting::create([
|
||||
'name' => 'influx_db_database',
|
||||
'value' => '',
|
||||
'description' => 'InfluxDB database'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!SettingsHelper::get('influx_db_username')) {
|
||||
Setting::create([
|
||||
'name' => 'influx_db_username',
|
||||
'value' => '',
|
||||
'description' => 'InfluxDB username'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!SettingsHelper::get('influx_db_password')) {
|
||||
Setting::create([
|
||||
'name' => 'influx_db_password',
|
||||
'value' => '',
|
||||
'description' => 'InfluxDB password'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!SettingsHelper::get('influx_db_version')) {
|
||||
Setting::create([
|
||||
'name' => 'influx_db_version',
|
||||
'value' => 1,
|
||||
'description' => 'InfluxDB version'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Setting::whereIn('name', [
|
||||
'influx_db_enabled',
|
||||
'influx_db_host',
|
||||
'influx_db_port',
|
||||
'influx_db_database',
|
||||
'influx_db_username',
|
||||
'influx_db_password',
|
||||
'influx_db_version',
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Database\Seeders\SpeedtestSeeder;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
@@ -11,6 +14,6 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call(UserSeeder::class);
|
||||
$this->call(SpeedtestSeeder::class);
|
||||
}
|
||||
}
|
||||
21
database/seeders/SpeedtestSeeder.php
Normal file
21
database/seeders/SpeedtestSeeder.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SpeedtestSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Speedtest::factory()
|
||||
->count(250)
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
170
public/js/app.js
vendored
170
public/js/app.js
vendored
@@ -146695,7 +146695,7 @@ var TableRow = /*#__PURE__*/function (_Component) {
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "delete", function (id) {
|
||||
var url = 'api/speedtest/delete/' + id;
|
||||
var url = 'api/speedtest/delete/' + id + '?token=' + window.token;
|
||||
axios__WEBPACK_IMPORTED_MODULE_3___default.a["delete"](url).then(function (resp) {
|
||||
console.log(resp);
|
||||
react_toastify__WEBPACK_IMPORTED_MODULE_4__["toast"].success('Speedtest deleted');
|
||||
@@ -148414,6 +148414,27 @@ var SettingsIndex = /*#__PURE__*/function (_Component) {
|
||||
inline: true,
|
||||
earlyReturn: true,
|
||||
classes: 'mr-2'
|
||||
}],
|
||||
influxdb: [{
|
||||
obj: data.influx_db_enabled,
|
||||
type: 'checkbox'
|
||||
}, {
|
||||
obj: data.influx_db_host,
|
||||
type: 'text'
|
||||
}, {
|
||||
obj: data.influx_db_port,
|
||||
type: 'number'
|
||||
}, {
|
||||
obj: data.influx_db_database,
|
||||
type: 'text'
|
||||
}, {
|
||||
obj: data.influx_db_username,
|
||||
type: 'text',
|
||||
autoComplete: false
|
||||
}, {
|
||||
obj: data.influx_db_password,
|
||||
type: 'password',
|
||||
autoComplete: false
|
||||
}]
|
||||
};
|
||||
});
|
||||
@@ -148552,6 +148573,10 @@ var SettingsInput = /*#__PURE__*/function (_Component) {
|
||||
input = _this.generateTextInput(disabled);
|
||||
}
|
||||
|
||||
if (_this.state.type === 'password') {
|
||||
input = _this.generatePasswordInput(disabled);
|
||||
}
|
||||
|
||||
if (_this.state.type === 'btn-get') {
|
||||
input = _this.generateButtonGetInput();
|
||||
}
|
||||
@@ -148593,7 +148618,8 @@ var SettingsInput = /*#__PURE__*/function (_Component) {
|
||||
url: _this.props.url,
|
||||
inline: _this.props.inline ? 'd-inline-block' : 'd-block',
|
||||
btnType: _this.props.btnType,
|
||||
earlyReturn: _this.props.earlyReturn ? true : false
|
||||
earlyReturn: _this.props.earlyReturn ? true : false,
|
||||
autoComplete: String(_this.props.autoComplete ? true : "off")
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
@@ -148621,7 +148647,8 @@ var SettingsInput = /*#__PURE__*/function (_Component) {
|
||||
disabled: disabled,
|
||||
min: this.state.min,
|
||||
max: this.state.max,
|
||||
onInput: this.handleInput
|
||||
onInput: this.handleInput,
|
||||
autoComplete: this.state.autoComplete
|
||||
});
|
||||
}
|
||||
}, {
|
||||
@@ -148662,7 +148689,20 @@ var SettingsInput = /*#__PURE__*/function (_Component) {
|
||||
type: this.state.type,
|
||||
defaultValue: this.state.value,
|
||||
disabled: disabled,
|
||||
onInput: this.handleInput
|
||||
onInput: this.handleInput,
|
||||
autoComplete: this.state.autoComplete
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "generatePasswordInput",
|
||||
value: function generatePasswordInput(disabled) {
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_1__["Form"].Control, {
|
||||
name: this.state.name,
|
||||
type: this.state.type,
|
||||
defaultValue: this.state.value,
|
||||
disabled: disabled,
|
||||
onInput: this.handleInput,
|
||||
autoComplete: this.state.autoComplete
|
||||
});
|
||||
}
|
||||
}, {
|
||||
@@ -148723,6 +148763,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _tabs_NotificationsSettings__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./tabs/NotificationsSettings */ "./resources/js/components/Settings/tabs/NotificationsSettings.js");
|
||||
/* harmony import */ var _Authentication_Authentication__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Authentication/Authentication */ "./resources/js/components/Authentication/Authentication.js");
|
||||
/* harmony import */ var _tabs_TableSettings__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tabs/TableSettings */ "./resources/js/components/Settings/tabs/TableSettings.js");
|
||||
/* harmony import */ var _tabs_InfluxDBSettings__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tabs/InfluxDBSettings */ "./resources/js/components/Settings/tabs/InfluxDBSettings.js");
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
@@ -148762,6 +148803,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
|
||||
|
||||
|
||||
|
||||
var SettingsTabs = /*#__PURE__*/function (_Component) {
|
||||
_inherits(SettingsTabs, _Component);
|
||||
|
||||
@@ -148775,7 +148817,7 @@ var SettingsTabs = /*#__PURE__*/function (_Component) {
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "generateTabs", function () {
|
||||
var tabs = ['General', 'Graphs', 'Tables', 'Notifications', 'healthchecks.io', 'Reset', 'Backup/Restore'];
|
||||
var tabs = ['General', 'Graphs', 'Tables', 'Notifications', 'healthchecks.io', 'InfluxDB', 'Reset', 'Backup/Restore'];
|
||||
|
||||
if (window.config.auth) {
|
||||
tabs.push('Authentication');
|
||||
@@ -148838,7 +148880,7 @@ var SettingsTabs = /*#__PURE__*/function (_Component) {
|
||||
description: setting.obj.description,
|
||||
handler: handler,
|
||||
label: setting.obj.name
|
||||
}, _defineProperty(_React$createElement, "description", setting.obj.description), _defineProperty(_React$createElement, "options", setting.type == 'select' ? setting.options : []), _defineProperty(_React$createElement, "hideDescription", setting.hideDescription ? setting.hideDescription : false), _defineProperty(_React$createElement, "min", setting.min ? setting.min : false), _defineProperty(_React$createElement, "max", setting.max ? setting.max : false), _defineProperty(_React$createElement, "btnType", setting.btnType), _defineProperty(_React$createElement, "inline", setting.inline), _defineProperty(_React$createElement, "url", setting.url), _defineProperty(_React$createElement, "earlyReturn", setting.earlyReturn ? true : false), _defineProperty(_React$createElement, "classes", setting.classes ? setting.classes : ''), _React$createElement));
|
||||
}, _defineProperty(_React$createElement, "description", setting.obj.description), _defineProperty(_React$createElement, "options", setting.type == 'select' ? setting.options : []), _defineProperty(_React$createElement, "hideDescription", setting.hideDescription ? setting.hideDescription : false), _defineProperty(_React$createElement, "min", setting.min ? setting.min : false), _defineProperty(_React$createElement, "max", setting.max ? setting.max : false), _defineProperty(_React$createElement, "btnType", setting.btnType), _defineProperty(_React$createElement, "inline", setting.inline), _defineProperty(_React$createElement, "url", setting.url), _defineProperty(_React$createElement, "earlyReturn", setting.earlyReturn ? true : false), _defineProperty(_React$createElement, "classes", setting.classes ? setting.classes : ''), _defineProperty(_React$createElement, "autoComplete", setting.autoComplete ? true : false), _React$createElement));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -148881,6 +148923,13 @@ var SettingsTabs = /*#__PURE__*/function (_Component) {
|
||||
save: _this.save
|
||||
});
|
||||
|
||||
case 'InfluxDB':
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(_tabs_InfluxDBSettings__WEBPACK_IMPORTED_MODULE_14__["default"], {
|
||||
data: data.influxdb,
|
||||
generateInputs: _this.generateInputs,
|
||||
save: _this.save
|
||||
});
|
||||
|
||||
case 'Reset':
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(_tabs_ResetSettings__WEBPACK_IMPORTED_MODULE_6__["default"], {
|
||||
data: data.healthchecks,
|
||||
@@ -149356,6 +149405,115 @@ if (document.getElementById('HealthchecksSettings')) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./resources/js/components/Settings/tabs/InfluxDBSettings.js":
|
||||
/*!*******************************************************************!*\
|
||||
!*** ./resources/js/components/Settings/tabs/InfluxDBSettings.js ***!
|
||||
\*******************************************************************/
|
||||
/*! exports provided: default */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return InfluxDBSettings; });
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js");
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
|
||||
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var react_bootstrap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-bootstrap */ "./node_modules/react-bootstrap/esm/index.js");
|
||||
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
|
||||
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_3__);
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var InfluxDBSettings = /*#__PURE__*/function (_Component) {
|
||||
_inherits(InfluxDBSettings, _Component);
|
||||
|
||||
var _super = _createSuper(InfluxDBSettings);
|
||||
|
||||
function InfluxDBSettings(props) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, InfluxDBSettings);
|
||||
|
||||
_this = _super.call(this, props);
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "inputHandler", function (name, val) {
|
||||
var settings = _this.state.data;
|
||||
var i = 0;
|
||||
settings.forEach(function (ele) {
|
||||
if (ele.obj.name == name) {
|
||||
ele.obj.value = val;
|
||||
}
|
||||
|
||||
settings[i] = ele;
|
||||
i++;
|
||||
});
|
||||
|
||||
_this.setState({
|
||||
data: settings
|
||||
});
|
||||
});
|
||||
|
||||
_this.state = {
|
||||
data: _this.props.data
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(InfluxDBSettings, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var settings = this.props.generateInputs(this.state.data, this.inputHandler);
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_bootstrap__WEBPACK_IMPORTED_MODULE_2__["Tab"].Content, null, settings, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
|
||||
className: "mt-3"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("button", {
|
||||
className: "btn btn-primary",
|
||||
onClick: function onClick() {
|
||||
_this2.props.save(_this2.state.data, 'healthchecks.io');
|
||||
}
|
||||
}, "Save")));
|
||||
}
|
||||
}]);
|
||||
|
||||
return InfluxDBSettings;
|
||||
}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]);
|
||||
|
||||
|
||||
|
||||
if (document.getElementById('InfluxDBSettings')) {
|
||||
react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(InfluxDBSettings, null), document.getElementById('InfluxDBSettings'));
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./resources/js/components/Settings/tabs/NotificationsSettings.js":
|
||||
/*!************************************************************************!*\
|
||||
!*** ./resources/js/components/Settings/tabs/NotificationsSettings.js ***!
|
||||
|
||||
@@ -259,7 +259,35 @@ export default class SettingsIndex extends Component {
|
||||
classes: 'mr-2'
|
||||
},
|
||||
|
||||
]
|
||||
],
|
||||
influxdb: [
|
||||
{
|
||||
obj: data.influx_db_enabled,
|
||||
type: 'checkbox'
|
||||
},
|
||||
{
|
||||
obj: data.influx_db_host,
|
||||
type: 'text'
|
||||
},
|
||||
{
|
||||
obj: data.influx_db_port,
|
||||
type: 'number'
|
||||
},
|
||||
{
|
||||
obj: data.influx_db_database,
|
||||
type: 'text'
|
||||
},
|
||||
{
|
||||
obj: data.influx_db_username,
|
||||
type: 'text',
|
||||
autoComplete: false,
|
||||
},
|
||||
{
|
||||
obj: data.influx_db_password,
|
||||
type: 'password',
|
||||
autoComplete: false,
|
||||
}
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ export default class SettingsInput extends Component {
|
||||
inline: this.props.inline ? 'd-inline-block' : 'd-block',
|
||||
btnType: this.props.btnType,
|
||||
earlyReturn: this.props.earlyReturn ? true : false,
|
||||
autoComplete: String(this.props.autoComplete ? true : Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 7)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +73,8 @@ export default class SettingsInput extends Component {
|
||||
disabled={disabled}
|
||||
min={this.state.min}
|
||||
max={this.state.max}
|
||||
onInput={this.handleInput} />
|
||||
onInput={this.handleInput}
|
||||
autoComplete={this.state.autoComplete} />
|
||||
}
|
||||
|
||||
generateSelectInput(disabled) {
|
||||
@@ -109,7 +111,18 @@ export default class SettingsInput extends Component {
|
||||
type={this.state.type}
|
||||
defaultValue={this.state.value}
|
||||
disabled={disabled}
|
||||
onInput={this.handleInput} />
|
||||
onInput={this.handleInput}
|
||||
autoComplete={this.state.autoComplete} />
|
||||
}
|
||||
|
||||
generatePasswordInput(disabled) {
|
||||
return <Form.Control
|
||||
name={this.state.name}
|
||||
type={this.state.type}
|
||||
defaultValue={this.state.value}
|
||||
disabled={disabled}
|
||||
onInput={this.handleInput}
|
||||
autoComplete={this.state.autoComplete} />
|
||||
}
|
||||
|
||||
generateButtonGetInput() {
|
||||
@@ -146,6 +159,10 @@ export default class SettingsInput extends Component {
|
||||
input = this.generateTextInput(disabled);
|
||||
}
|
||||
|
||||
if(this.state.type === 'password') {
|
||||
input = this.generatePasswordInput(disabled);
|
||||
}
|
||||
|
||||
if(this.state.type === 'btn-get') {
|
||||
input = this.generateButtonGetInput();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import HealthchecksSettings from './tabs/HealthchecksSettings';
|
||||
import NotificationsSettings from './tabs/NotificationsSettings';
|
||||
import Authentication from '../Authentication/Authentication';
|
||||
import TableSettings from './tabs/TableSettings';
|
||||
import InfluxDBSettings from './tabs/InfluxDBSettings';
|
||||
|
||||
export default class SettingsTabs extends Component {
|
||||
constructor(props) {
|
||||
@@ -30,6 +31,7 @@ export default class SettingsTabs extends Component {
|
||||
'Tables',
|
||||
'Notifications',
|
||||
'healthchecks.io',
|
||||
'InfluxDB',
|
||||
'Reset',
|
||||
'Backup/Restore',
|
||||
];
|
||||
@@ -105,6 +107,7 @@ export default class SettingsTabs extends Component {
|
||||
url={setting.url}
|
||||
earlyReturn={setting.earlyReturn ? true : false}
|
||||
classes={setting.classes ? setting.classes : ''}
|
||||
autoComplete={setting.autoComplete ? true : false}
|
||||
/>
|
||||
})
|
||||
}
|
||||
@@ -138,6 +141,11 @@ export default class SettingsTabs extends Component {
|
||||
data={data.healthchecks}
|
||||
generateInputs={this.generateInputs}
|
||||
save={this.save} />
|
||||
case 'InfluxDB':
|
||||
return <InfluxDBSettings
|
||||
data={data.influxdb}
|
||||
generateInputs={this.generateInputs}
|
||||
save={this.save} />
|
||||
case 'Reset':
|
||||
return <ResetSettings
|
||||
data={data.healthchecks}
|
||||
|
||||
50
resources/js/components/Settings/tabs/InfluxDBSettings.js
vendored
Normal file
50
resources/js/components/Settings/tabs/InfluxDBSettings.js
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import React, { Component } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Modal, Button, Tab } from 'react-bootstrap';
|
||||
import Axios from 'axios';
|
||||
|
||||
export default class InfluxDBSettings extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
data: this.props.data,
|
||||
}
|
||||
}
|
||||
|
||||
inputHandler = (name, val) => {
|
||||
var settings = this.state.data;
|
||||
var i = 0;
|
||||
settings.forEach(ele => {
|
||||
if(ele.obj.name == name) {
|
||||
ele.obj.value = val;
|
||||
}
|
||||
settings[i] = ele;
|
||||
i++;
|
||||
});
|
||||
this.setState({
|
||||
data: settings
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
var settings = this.props.generateInputs(this.state.data, this.inputHandler);
|
||||
|
||||
return (
|
||||
<Tab.Content>
|
||||
<form onSubmit={(e) => { e.preventDefault() }} autoComplete="off">
|
||||
<input type="text" autoComplete="username" style={{ display: 'none' }} />
|
||||
<input type="password" name="password" autoComplete="passoword" style={{ display: 'none' }} />
|
||||
{settings}
|
||||
</form>
|
||||
<div className="mt-3">
|
||||
<button className="btn btn-primary" onClick={() => { this.props.save(this.state.data, 'healthchecks.io') }}>Save</button>
|
||||
</div>
|
||||
</Tab.Content>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById('InfluxDBSettings')) {
|
||||
ReactDOM.render(<InfluxDBSettings />, document.getElementById('InfluxDBSettings'));
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use App\Http\Controllers\HomepageDataController;
|
||||
use App\Http\Controllers\SettingsController;
|
||||
use App\Http\Controllers\SpeedtestController;
|
||||
use App\Http\Controllers\UpdateController;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Faker\Factory;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
|
||||
@@ -3,14 +3,28 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Interfaces\SpeedtestProvider;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\Mocks\OoklaTesterMocker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SpeedtestTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->app->singleton(
|
||||
SpeedtestProvider::class,
|
||||
function () {
|
||||
return new OoklaTesterMocker();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a speedtest
|
||||
*
|
||||
|
||||
26
tests/Feature/Utils/InfluxDB/InfluxDBWrapperWrapperTest.php
Normal file
26
tests/Feature/Utils/InfluxDB/InfluxDBWrapperWrapperTest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Utils\InfluxDB;
|
||||
|
||||
use App\Exceptions\InfluxDBNotEnabledException;
|
||||
use App\Utils\InfluxDB\InfluxDB;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InfluxDBWrapperWrapperTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Test it throws the right exception.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_it_throws_excetpion_when_it_is_disabled()
|
||||
{
|
||||
$this->expectException(InfluxDBNotEnabledException::class);
|
||||
|
||||
InfluxDB::connect();
|
||||
}
|
||||
}
|
||||
59
tests/Mocks/OoklaTesterMocker.php
Normal file
59
tests/Mocks/OoklaTesterMocker.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Mocks;
|
||||
|
||||
use App\Exceptions\SpeedtestFailureException;
|
||||
use App\Interfaces\SpeedtestProvider;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
|
||||
class OoklaTesterMocker implements SpeedtestProvider
|
||||
{
|
||||
private bool $passes;
|
||||
|
||||
public function __construct(bool $passes = true)
|
||||
{
|
||||
$this->passes = $passes;
|
||||
}
|
||||
|
||||
public function run($output = null): Speedtest
|
||||
{
|
||||
$output = $output ?? $this->output();
|
||||
|
||||
try {
|
||||
$output = json_decode($output, true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (Exception $e) {
|
||||
throw new SpeedtestFailureException();
|
||||
}
|
||||
|
||||
return $this->passes
|
||||
? Speedtest::factory()->create()
|
||||
: Speedtest::factory()->create([
|
||||
'download' => 0,
|
||||
'upload' => 0,
|
||||
'ping' => 0,
|
||||
'failed' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function output()
|
||||
{
|
||||
return !$this->passes
|
||||
? null
|
||||
: json_encode([
|
||||
'type' => 'result',
|
||||
'download' => ['bandwidth' => '50'],
|
||||
'upload' => ['bandwidth' => '50'],
|
||||
'ping' => ['latency' => '50'],
|
||||
'server' => [
|
||||
'id' => '1',
|
||||
'name' => 'PHPUnit',
|
||||
'host' => 'phpunit',
|
||||
'port' => '443',
|
||||
],
|
||||
'result' => [
|
||||
'url' => 'some-url',
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Tests\Unit\Controllers\SpeedtestController;
|
||||
|
||||
use App\Http\Controllers\SpeedtestController;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Tests\Unit\Controllers\SpeedtestController;
|
||||
|
||||
use App\Http\Controllers\SpeedtestController;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use DB;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Helpers\SpeedtestHelper;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use InvalidArgumentException;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Tests\Unit\Helpers\SpeedtestHelper;
|
||||
|
||||
use App\Utils\OoklaTester;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Tests\Mocks\OoklaTesterMocker;
|
||||
|
||||
class CheckOutputTest extends TestCase
|
||||
{
|
||||
@@ -12,6 +13,7 @@ class CheckOutputTest extends TestCase
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->speedtestProvider = new OoklaTester();
|
||||
$this->mocker = new OoklaTesterMocker();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Tests\Unit\Helpers\SpeedtestHelper;
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Helpers\SpeedtestHelper;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Exceptions\SpeedtestFailureException;
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Utils\OoklaTester;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\Mocks\OoklaTesterMocker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SpeedtestTest extends TestCase
|
||||
@@ -22,17 +23,7 @@ class SpeedtestTest extends TestCase
|
||||
|
||||
$this->speedtestProvider = new OoklaTester();
|
||||
|
||||
$this->output = $this->speedtestProvider->output();
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic unit test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testOutputFunction()
|
||||
{
|
||||
$this->assertJson($this->output);
|
||||
$this->output = (new OoklaTesterMocker())->output();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestCompleteListener;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Listeners\SpeedtestCompleteListener;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use stdClass;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestCompleteListener;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Listeners\SpeedtestCompleteListener;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use stdClass;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestFailedListener;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Listeners\SpeedtestFailedListener;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use stdClass;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestFailedListener;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Listeners\SpeedtestFailedListener;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use stdClass;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestOverviewListener;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Listeners\SpeedtestOverviewListener;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use stdClass;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestOverviewListener;
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Listeners\SpeedtestOverviewListener;
|
||||
use App\Speedtest;
|
||||
use App\Models\Speedtest;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use stdClass;
|
||||
|
||||
Reference in New Issue
Block a user