feat(navbar): add Traefik dashboard availability check and server IP handling; refactor dynamic configurations loading
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Livewire\Server;
|
||||
|
||||
use App\Actions\Proxy\CheckConfiguration;
|
||||
use App\Actions\Proxy\CheckProxy;
|
||||
use App\Actions\Proxy\StartProxy;
|
||||
use App\Actions\Proxy\StopProxy;
|
||||
@@ -17,6 +18,10 @@ class Navbar extends Component
|
||||
|
||||
public ?string $currentRoute = null;
|
||||
|
||||
public bool $traefikDashboardAvailable = false;
|
||||
|
||||
public ?string $serverIp = null;
|
||||
|
||||
public function getListeners()
|
||||
{
|
||||
$teamId = auth()->user()->currentTeam()->id;
|
||||
@@ -30,6 +35,21 @@ class Navbar extends Component
|
||||
{
|
||||
$this->server = $server;
|
||||
$this->currentRoute = request()->route()->getName();
|
||||
$this->serverIp = $this->server->id === 0 ? base_ip() : $this->server->ip;
|
||||
}
|
||||
|
||||
public function loadProxyConfiguration()
|
||||
{
|
||||
try {
|
||||
$proxy_settings = CheckConfiguration::run($this->server);
|
||||
if (str($proxy_settings)->contains('--api.dashboard=true') && str($proxy_settings)->contains('--api.insecure=true')) {
|
||||
$this->traefikDashboardAvailable = true;
|
||||
} else {
|
||||
$this->traefikDashboardAvailable = false;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function restart()
|
||||
|
@@ -107,11 +107,6 @@ class Proxy extends Component
|
||||
{
|
||||
try {
|
||||
$this->proxy_settings = CheckConfiguration::run($this->server);
|
||||
if (str($this->proxy_settings)->contains('--api.dashboard=true') && str($this->proxy_settings)->contains('--api.insecure=true')) {
|
||||
$this->dispatch('traefikDashboardAvailable', true);
|
||||
} else {
|
||||
$this->dispatch('traefikDashboardAvailable', false);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
@@ -28,6 +28,11 @@ class DynamicConfigurations extends Component
|
||||
'contents.*' => 'nullable|string',
|
||||
];
|
||||
|
||||
public function initLoadDynamicConfigurations()
|
||||
{
|
||||
$this->loadDynamicConfigurations();
|
||||
}
|
||||
|
||||
public function loadDynamicConfigurations()
|
||||
{
|
||||
$proxy_path = $this->server->proxyPath();
|
||||
@@ -43,6 +48,7 @@ class DynamicConfigurations extends Component
|
||||
}
|
||||
$this->contents = $contents;
|
||||
$this->dispatch('$refresh');
|
||||
$this->dispatch('success', 'Dynamic configurations loaded.');
|
||||
}
|
||||
|
||||
public function mount()
|
||||
|
Reference in New Issue
Block a user