Skip to content

Commit 664a990

Browse files
committed
chore: Update listeners and proxy settings in server form and new server components
1 parent 16e472d commit 664a990

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

app/Livewire/Server/Form.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ class Form extends Component
2424

2525
public $timezones;
2626

27-
protected $listeners = ['serverInstalled', 'revalidate' => '$refresh'];
27+
protected $listeners = [
28+
'serverInstalled',
29+
'refreshServerShow' => 'serverInstalled',
30+
'revalidate' => '$refresh',
31+
];
2832

2933
protected $rules = [
3034
'server.name' => 'required',

app/Livewire/Server/New/ByIp.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace App\Livewire\Server\New;
44

5-
use App\Enums\ProxyStatus;
65
use App\Enums\ProxyTypes;
76
use App\Models\Server;
87
use App\Models\Team;
8+
use Illuminate\Support\Collection;
99
use Livewire\Component;
1010

1111
class ByIp extends Component
@@ -40,7 +40,7 @@ class ByIp extends Component
4040

4141
public bool $is_build_server = false;
4242

43-
public $swarm_managers = [];
43+
public Collection $swarm_managers;
4444

4545
protected $rules = [
4646
'name' => 'required|string',
@@ -102,11 +102,6 @@ public function submit()
102102
'port' => $this->port,
103103
'team_id' => currentTeam()->id,
104104
'private_key_id' => $this->private_key_id,
105-
'proxy' => [
106-
// set default proxy type to traefik v2
107-
'type' => ProxyTypes::TRAEFIK->value,
108-
'status' => ProxyStatus::EXITED->value,
109-
],
110105
];
111106
if ($this->is_swarm_worker) {
112107
$payload['swarm_cluster'] = $this->selected_swarm_cluster;
@@ -115,6 +110,9 @@ public function submit()
115110
data_forget($payload, 'proxy');
116111
}
117112
$server = Server::create($payload);
113+
$server->proxy->set('status', 'exited');
114+
$server->proxy->set('type', ProxyTypes::TRAEFIK->value);
115+
$server->save();
118116
if ($this->is_build_server) {
119117
$this->is_swarm_manager = false;
120118
$this->is_swarm_worker = false;

app/Livewire/Server/Show.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Show extends Component
1414

1515
public $parameters = [];
1616

17-
protected $listeners = ['refreshServerShow' => '$refresh'];
17+
protected $listeners = ['refreshServerShow'];
1818

1919
public function mount()
2020
{
@@ -29,6 +29,12 @@ public function mount()
2929
}
3030
}
3131

32+
public function refreshServerShow()
33+
{
34+
$this->server->refresh();
35+
$this->dispatch('$refresh');
36+
}
37+
3238
public function submit()
3339
{
3440
$this->dispatch('serverRefresh', false);

0 commit comments

Comments
 (0)