From 931664c0c0f85059cf5270eabe28faf2a1ca2c5a Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Fri, 12 May 2023 19:15:36 +0100 Subject: [PATCH] wip --- app/Actions/Proxy/InstallProxy.php | 10 ++-- app/Http/Livewire/Server/Proxy.php | 13 +++++ docker/dev-ssu/Dockerfile | 5 ++ .../livewire/server/_proxy/loading.blade.php | 12 +++++ .../livewire/server/_proxy/options.blade.php | 48 +++++++++++++++++++ .../livewire/server/_proxy/problems.blade.php | 5 ++ .../views/livewire/server/proxy.blade.php | 27 +++++++---- resources/views/server/show.blade.php | 1 - scripts/run | 3 ++ 9 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 resources/views/livewire/server/_proxy/loading.blade.php create mode 100644 resources/views/livewire/server/_proxy/options.blade.php create mode 100644 resources/views/livewire/server/_proxy/problems.blade.php diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.php index 84429c7cf..42864b415 100644 --- a/app/Actions/Proxy/InstallProxy.php +++ b/app/Actions/Proxy/InstallProxy.php @@ -3,12 +3,14 @@ namespace App\Actions\Proxy; use App\Enums\ActivityTypes; +use App\Enums\ProxyTypes; use App\Models\Server; +use Spatie\Activitylog\Models\Activity; use Symfony\Component\Yaml\Yaml; class InstallProxy { - public function __invoke(Server $server) + public function __invoke(Server $server): Activity { $docker_compose_yml_base64 = base64_encode( $this->getDockerComposeContents() @@ -30,6 +32,10 @@ class InstallProxy 'docker ps', ], $server, ActivityTypes::INLINE->value); + // Persist to Database + $server->extra_attributes->proxy = ProxyTypes::TRAEFIK_V2->value; + $server->save(); + return $activity; } @@ -47,8 +53,6 @@ class InstallProxy ? config('proxy.project_path_on_host') . '/_testing_hosts/host_2_proxy' : '.'; - ray($cwd); - return [ "version" => "3.7", "networks" => [ diff --git a/app/Http/Livewire/Server/Proxy.php b/app/Http/Livewire/Server/Proxy.php index bc4298287..a44bb9e6d 100644 --- a/app/Http/Livewire/Server/Proxy.php +++ b/app/Http/Livewire/Server/Proxy.php @@ -13,6 +13,11 @@ class Proxy extends Component protected string $selectedProxy = ''; + public $is_proxy_installed; + + public $is_check_proxy_complete = false; + public $is_proxy_settings_in_sync = false; + public function mount(Server $server) { $this->server = $server; @@ -25,6 +30,14 @@ class Proxy extends Component $this->emit('newMonitorActivity', $activity->id); } + public function checkProxySettingsInSync() + { + + + $this->is_check_proxy_complete = true; + $this->is_proxy_settings_in_sync = true; + } + public function render() { return view('livewire.server.proxy'); diff --git a/docker/dev-ssu/Dockerfile b/docker/dev-ssu/Dockerfile index c90e53d08..e8724828e 100644 --- a/docker/dev-ssu/Dockerfile +++ b/docker/dev-ssu/Dockerfile @@ -5,4 +5,9 @@ RUN apt-get -y autoremove \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* +RUN echo "alias ll='ls -al'" >> /etc/bash.bashrc +RUN echo "alias a='php artisan'" >> /etc/bash.bashrc +RUN echo "alias mfs='php artisan migrate:fresh --seed'" >> /etc/bash.bashrc +RUN echo "alias cda='composer dump-autoload'" >> /etc/bash.bashrc + # COPY --chmod=755 docker/dev-ssu/etc/s6-overlay/ /etc/s6-overlay/ diff --git a/resources/views/livewire/server/_proxy/loading.blade.php b/resources/views/livewire/server/_proxy/loading.blade.php new file mode 100644 index 000000000..cfab2d8db --- /dev/null +++ b/resources/views/livewire/server/_proxy/loading.blade.php @@ -0,0 +1,12 @@ +
+
+ Loading +
+
+ + + + +
+
diff --git a/resources/views/livewire/server/_proxy/options.blade.php b/resources/views/livewire/server/_proxy/options.blade.php new file mode 100644 index 000000000..e6610bc27 --- /dev/null +++ b/resources/views/livewire/server/_proxy/options.blade.php @@ -0,0 +1,48 @@ + +
+ +
+ +
+ +
+ +
+ Visit Dashboard +
+ +
+ +
+ +
+ +
+ diff --git a/resources/views/livewire/server/_proxy/problems.blade.php b/resources/views/livewire/server/_proxy/problems.blade.php new file mode 100644 index 000000000..541d15e6a --- /dev/null +++ b/resources/views/livewire/server/_proxy/problems.blade.php @@ -0,0 +1,5 @@ +
+
+ Problems! +
+
diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.php index 91832611c..6feb45043 100644 --- a/resources/views/livewire/server/proxy.blade.php +++ b/resources/views/livewire/server/proxy.blade.php @@ -2,20 +2,29 @@

Proxy

@if($this->server->extra_attributes->proxy) -
+
Proxy type: {{ $this->server->extra_attributes->proxy }}
-
Features in W11.
-
    -
  • Edit config file
  • -
  • Enable dashboard (blocking port by firewall)
  • -
  • Dashboard access - login/password
  • -
  • Setup host for Traefik Dashboard
  • -
  • Visit (nav to traefik dashboard)
  • -
+ +
+ + {{-- Proxy is being checked against DB information --}} + @if(! $this->is_check_proxy_complete) + @include('livewire.server._proxy.loading') + @endif + + @if($this->is_check_proxy_complete && (! $this->is_proxy_settings_in_sync) ) + @include('livewire.server._proxy.problems') + @endif + + @include('livewire.server._proxy.options') +
+
@else + {{-- There is no Proxy installed --}} + No proxy installed.