Skip to content

Commit 4667f96

Browse files
committed
feat: db proxy logs
1 parent 28c320a commit 4667f96

File tree

18 files changed

+183
-39
lines changed

18 files changed

+183
-39
lines changed

app/Livewire/Project/Database/Clickhouse/General.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandaloneClickhouse;
89
use Exception;
910
use Livewire\Component;
1011

1112
class General extends Component
1213
{
14+
public Server $server;
1315
public StandaloneClickhouse $database;
1416
public ?string $db_url = null;
1517
public ?string $db_url_public = null;
@@ -43,10 +45,11 @@ public function mount()
4345
if ($this->database->is_public) {
4446
$this->db_url_public = $this->database->get_db_url();
4547
}
48+
$this->server = data_get($this->database,'destination.server');
4649
}
4750
public function instantSaveAdvanced() {
4851
try {
49-
if (!$this->database->destination->server->isLogDrainEnabled()) {
52+
if (!$this->server->isLogDrainEnabled()) {
5053
$this->database->is_log_drain_enabled = false;
5154
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
5255
return;

app/Livewire/Project/Database/Dragonfly/General.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandaloneDragonfly;
89
use Exception;
910
use Livewire\Component;
@@ -12,6 +13,7 @@ class General extends Component
1213
{
1314
protected $listeners = ['refresh'];
1415

16+
public Server $server;
1517
public StandaloneDragonfly $database;
1618
public ?string $db_url = null;
1719
public ?string $db_url_public = null;
@@ -41,10 +43,11 @@ public function mount()
4143
if ($this->database->is_public) {
4244
$this->db_url_public = $this->database->get_db_url();
4345
}
46+
$this->server = data_get($this->database,'destination.server');
4447
}
4548
public function instantSaveAdvanced() {
4649
try {
47-
if (!$this->database->destination->server->isLogDrainEnabled()) {
50+
if (!$this->server->isLogDrainEnabled()) {
4851
$this->database->is_log_drain_enabled = false;
4952
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
5053
return;

app/Livewire/Project/Database/Keydb/General.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandaloneKeydb;
89
use Exception;
910
use Livewire\Component;
@@ -12,6 +13,7 @@ class General extends Component
1213
{
1314
protected $listeners = ['refresh'];
1415

16+
public Server $server;
1517
public StandaloneKeydb $database;
1618
public ?string $db_url = null;
1719
public ?string $db_url_public = null;
@@ -43,10 +45,12 @@ public function mount()
4345
if ($this->database->is_public) {
4446
$this->db_url_public = $this->database->get_db_url();
4547
}
48+
$this->server = data_get($this->database,'destination.server');
49+
4650
}
4751
public function instantSaveAdvanced() {
4852
try {
49-
if (!$this->database->destination->server->isLogDrainEnabled()) {
53+
if (!$this->server->isLogDrainEnabled()) {
5054
$this->database->is_log_drain_enabled = false;
5155
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
5256
return;

app/Livewire/Project/Database/Mariadb/General.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandaloneMariadb;
89
use Exception;
910
use Livewire\Component;
@@ -12,6 +13,7 @@ class General extends Component
1213
{
1314
protected $listeners = ['refresh'];
1415

16+
public Server $server;
1517
public StandaloneMariadb $database;
1618
public ?string $db_url = null;
1719
public ?string $db_url_public = null;
@@ -50,10 +52,12 @@ public function mount()
5052
if ($this->database->is_public) {
5153
$this->db_url_public = $this->database->get_db_url();
5254
}
55+
$this->server = data_get($this->database,'destination.server');
56+
5357
}
5458
public function instantSaveAdvanced() {
5559
try {
56-
if (!$this->database->destination->server->isLogDrainEnabled()) {
60+
if (!$this->server->isLogDrainEnabled()) {
5761
$this->database->is_log_drain_enabled = false;
5862
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
5963
return;

app/Livewire/Project/Database/Mongodb/General.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandaloneMongodb;
89
use Exception;
910
use Livewire\Component;
@@ -12,6 +13,7 @@ class General extends Component
1213
{
1314
protected $listeners = ['refresh'];
1415

16+
public Server $server;
1517
public StandaloneMongodb $database;
1618
public ?string $db_url = null;
1719
public ?string $db_url_public = null;
@@ -48,11 +50,13 @@ public function mount()
4850
if ($this->database->is_public) {
4951
$this->db_url_public = $this->database->get_db_url();
5052
}
53+
$this->server = data_get($this->database,'destination.server');
54+
5155
}
5256
public function instantSaveAdvanced()
5357
{
5458
try {
55-
if (!$this->database->destination->server->isLogDrainEnabled()) {
59+
if (!$this->server->isLogDrainEnabled()) {
5660
$this->database->is_log_drain_enabled = false;
5761
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
5862
return;

app/Livewire/Project/Database/Mysql/General.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandaloneMysql;
89
use Exception;
910
use Livewire\Component;
@@ -13,6 +14,7 @@ class General extends Component
1314
protected $listeners = ['refresh'];
1415

1516
public StandaloneMysql $database;
17+
public Server $server;
1618
public ?string $db_url = null;
1719
public ?string $db_url_public = null;
1820

@@ -50,11 +52,12 @@ public function mount()
5052
if ($this->database->is_public) {
5153
$this->db_url_public = $this->database->get_db_url();
5254
}
55+
$this->server = data_get($this->database,'destination.server');
5356
}
5457
public function instantSaveAdvanced()
5558
{
5659
try {
57-
if (!$this->database->destination->server->isLogDrainEnabled()) {
60+
if (!$this->server->isLogDrainEnabled()) {
5861
$this->database->is_log_drain_enabled = false;
5962
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
6063
return;

app/Livewire/Project/Database/Postgresql/General.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandalonePostgresql;
89
use Exception;
910
use Livewire\Component;
@@ -13,6 +14,7 @@
1314
class General extends Component
1415
{
1516
public StandalonePostgresql $database;
17+
public Server $server;
1618
public string $new_filename;
1719
public string $new_content;
1820
public ?string $db_url = null;
@@ -57,11 +59,12 @@ public function mount()
5759
if ($this->database->is_public) {
5860
$this->db_url_public = $this->database->get_db_url();
5961
}
62+
$this->server = data_get($this->database,'destination.server');
6063
}
6164
public function instantSaveAdvanced()
6265
{
6366
try {
64-
if (!$this->database->destination->server->isLogDrainEnabled()) {
67+
if (!$this->server->isLogDrainEnabled()) {
6568
$this->database->is_log_drain_enabled = false;
6669
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
6770
return;

app/Livewire/Project/Database/Redis/General.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Actions\Database\StartDatabaseProxy;
66
use App\Actions\Database\StopDatabaseProxy;
7+
use App\Models\Server;
78
use App\Models\StandaloneRedis;
89
use Exception;
910
use Livewire\Component;
@@ -12,6 +13,7 @@ class General extends Component
1213
{
1314
protected $listeners = ['refresh'];
1415

16+
public Server $server;
1517
public StandaloneRedis $database;
1618
public ?string $db_url = null;
1719
public ?string $db_url_public = null;
@@ -43,10 +45,12 @@ public function mount()
4345
if ($this->database->is_public) {
4446
$this->db_url_public = $this->database->get_db_url();
4547
}
48+
$this->server = data_get($this->database,'destination.server');
49+
4650
}
4751
public function instantSaveAdvanced() {
4852
try {
49-
if (!$this->database->destination->server->isLogDrainEnabled()) {
53+
if (!$this->server->isLogDrainEnabled()) {
5054
$this->database->is_log_drain_enabled = false;
5155
$this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.');
5256
return;

resources/views/livewire/project/database/clickhouse/general.blade.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
@if ($database->started_at)
1717
<div class="flex gap-2">
18-
<x-forms.input label="Initial Username" id="database.clickhouse_admin_user" placeholder="If empty: clickhouse"
19-
readonly helper="You can only change this in the database." />
18+
<x-forms.input label="Initial Username" id="database.clickhouse_admin_user"
19+
placeholder="If empty: clickhouse" readonly helper="You can only change this in the database." />
2020
<x-forms.input label="Initial Password" id="database.clickhouse_admin_password" type="password" required
2121
readonly helper="You can only change this in the database." />
2222
</div>
@@ -34,9 +34,6 @@
3434
<div class="flex items-end gap-2">
3535
<x-forms.input placeholder="3000:5432" id="database.ports_mappings" label="Ports Mappings"
3636
helper="A comma separated list of ports you would like to map to the host system.<br><span class='inline-block font-bold dark:text-warning'>Example</span>3000:5432,3002:5433" />
37-
<x-forms.input placeholder="5432" disabled="{{ $database->is_public }}" id="database.public_port"
38-
label="Public Port" />
39-
<x-forms.checkbox instantSave id="database.is_public" label="Make it publicly available" />
4037
</div>
4138
<x-forms.input label="Clickhouse URL (internal)"
4239
helper="If you change the user/password/port, this could be different. This is with the default values."
@@ -47,6 +44,23 @@
4744
type="password" readonly wire:model="db_url_public" />
4845
@endif
4946
</div>
47+
<div>
48+
<h3 class="py-2">Proxy</h3>
49+
<div class="flex items-end gap-2">
50+
<x-forms.input placeholder="5432" disabled="{{ data_get($database, 'is_public') }}"
51+
id="database.public_port" label="Public Port" />
52+
<x-slide-over fullScreen>
53+
<x-slot:title>Proxy Logs</x-slot:title>
54+
<x-slot:content>
55+
<livewire:project.shared.get-logs :server="$server" :resource="$database"
56+
container="{{ data_get($database, 'uuid') }}-proxy" lazy />
57+
</x-slot:content>
58+
<x-forms.button disabled="{{ !data_get($database, 'is_public') }}" @click="slideOverOpen=true"
59+
class="w-28">Proxy Logs</x-forms.button>
60+
</x-slide-over>
61+
<x-forms.checkbox instantSave id="database.is_public" label="Make it publicly available" />
62+
</div>
63+
</div>
5064
</form>
5165
<h3 class="pt-4">Advanced</h3>
5266
<div class="flex flex-col">

0 commit comments

Comments
 (0)