Refactor livewire server show view to remove redundant code
This commit is contained in:
parent
b77ee11da5
commit
0a3b5cc4e3
2 changed files with 38 additions and 2745 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Livewire\Server;
|
namespace App\Livewire\Server;
|
||||||
|
|
||||||
|
use App\Actions\Server\StartSentinel;
|
||||||
|
use App\Actions\Server\StopSentinel;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Attributes\Rule;
|
use Livewire\Attributes\Rule;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
@ -177,6 +179,40 @@ public function checkLocalhostConnection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function restartSentinel()
|
||||||
|
{
|
||||||
|
$this->server->restartSentinel();
|
||||||
|
$this->dispatch('success', 'Sentinel restarted.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedIsSentinelDebugEnabled($value)
|
||||||
|
{
|
||||||
|
$this->server->settings->is_sentinel_debug_enabled = $value;
|
||||||
|
$this->server->settings->save();
|
||||||
|
$this->restartSentinel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedIsMetricsEnabled($value)
|
||||||
|
{
|
||||||
|
$this->server->settings->is_metrics_enabled = $value;
|
||||||
|
$this->server->settings->save();
|
||||||
|
$this->restartSentinel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedIsSentinelEnabled($value)
|
||||||
|
{
|
||||||
|
$this->server->settings->is_sentinel_enabled = $value;
|
||||||
|
if ($value === true) {
|
||||||
|
StartSentinel::run($this->server, true);
|
||||||
|
} else {
|
||||||
|
$this->server->settings->is_metrics_enabled = false;
|
||||||
|
$this->server->settings->is_sentinel_debug_enabled = false;
|
||||||
|
StopSentinel::dispatch($this->server);
|
||||||
|
}
|
||||||
|
$this->server->settings->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function regenerateSentinelToken()
|
public function regenerateSentinelToken()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
@ -196,7 +232,7 @@ public function submit()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->syncData(true);
|
$this->syncData(true);
|
||||||
$this->dispatch('success', 'Server updated');
|
$this->dispatch('success', 'Server updated.');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue