mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
Added username/password fields
This commit is contained in:
@@ -37,16 +37,25 @@ class InfluxDB
|
||||
|
||||
$host = SettingsHelper::get('influx_db_host')->value;
|
||||
$port = SettingsHelper::get('influx_db_port')->value;
|
||||
$token = '';
|
||||
$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)
|
||||
new Version1(
|
||||
str_replace(['http://', 'https://'], '', $host),
|
||||
$port,
|
||||
$username,
|
||||
$password
|
||||
)
|
||||
)
|
||||
: new InfluxDBVersion2Wrapper(
|
||||
new Version2([])
|
||||
new Version2([
|
||||
'url' => $host . ':' . $port,
|
||||
'token' => '',
|
||||
])
|
||||
);
|
||||
|
||||
return (new self($wrapper))->setDatabase($database)
|
||||
|
||||
@@ -47,6 +47,22 @@ class AddInfluxDbSettings extends Migration
|
||||
]);
|
||||
}
|
||||
|
||||
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',
|
||||
@@ -68,6 +84,8 @@ class AddInfluxDbSettings extends Migration
|
||||
'influx_db_host',
|
||||
'influx_db_port',
|
||||
'influx_db_database',
|
||||
'influx_db_username',
|
||||
'influx_db_password',
|
||||
'influx_db_version',
|
||||
])->delete();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user