From b8b0d2243fcc1cab7f5407394fc90ffbcb8cac5d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 4 May 2023 10:00:08 +0200 Subject: [PATCH] command center --- app/Http/Livewire/RunCommand.php | 39 +++---------------- ...emo.blade.php => command-center.blade.php} | 0 .../views/components/inputs/input.blade.php | 37 +++++------------- resources/views/components/navbar.blade.php | 4 +- .../views/livewire/activity-monitor.blade.php | 1 - .../views/livewire/run-command.blade.php | 34 +++++----------- routes/web.php | 6 +-- 7 files changed, 30 insertions(+), 91 deletions(-) rename resources/views/{demo.blade.php => command-center.blade.php} (100%) diff --git a/app/Http/Livewire/RunCommand.php b/app/Http/Livewire/RunCommand.php index 41002ca17..c83a83084 100755 --- a/app/Http/Livewire/RunCommand.php +++ b/app/Http/Livewire/RunCommand.php @@ -8,51 +8,24 @@ class RunCommand extends Component { - public $activity; - - public $isKeepAliveOn = false; - - public $manualKeepAlive = false; - - public $command = 'ls'; - + public $command; public $server; - public $servers = []; protected $rules = [ 'server' => 'required', + 'command' => 'required', ]; public function mount() { - $this->servers = Server::all(); + $this->servers = Server::where('team_id', session('currentTeam')->id)->get(); $this->server = $this->servers[0]->uuid; } public function runCommand() { - $this->isKeepAliveOn = true; - $this->activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value); - } - - public function runSleepingBeauty() - { - $this->isKeepAliveOn = true; - $this->activity = remoteProcess(['x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done'], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value); - } - - public function runDummyProjectBuild() - { - $this->isKeepAliveOn = true; - $this->activity = remoteProcess([' cd projects/dummy-project', 'docker-compose build --no-cache'], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value); - } - - public function polling() - { - $this->activity?->refresh(); - - if (data_get($this->activity, 'properties.exitCode') !== null) { - $this->isKeepAliveOn = false; - } + $this->validate(); + $activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value); + $this->emit('newMonitorActivity', $activity->id); } } diff --git a/resources/views/demo.blade.php b/resources/views/command-center.blade.php similarity index 100% rename from resources/views/demo.blade.php rename to resources/views/command-center.blade.php diff --git a/resources/views/components/inputs/input.blade.php b/resources/views/components/inputs/input.blade.php index f899cb64e..a09af0496 100644 --- a/resources/views/components/inputs/input.blade.php +++ b/resources/views/components/inputs/input.blade.php @@ -1,32 +1,19 @@ @props([ 'id' => null, + 'type' => 'text', 'required' => false, 'readonly' => false, 'label' => null, - 'type' => 'text', - 'class' => '', 'instantSave' => false, 'disabled' => false, 'hidden' => false, ]) -@if ($type === 'checkbox') - - @error($id) - {{ $message }} - @enderror -@else + + $type === 'checkbox', + 'flex flex-col' => $type !== 'checkbox', +])> @if ($type === 'textarea') - + @else - + @endif @error($id)
{{ $message }}
@enderror -@endif +
diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 3d5ce67a1..7b6f91683 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -2,9 +2,7 @@
v{{ config('coolify.version') }}
@auth Home - @env('local') - Demo - @endenv + Command Center Profile @if (auth()->user()->isRoot()) Settings diff --git a/resources/views/livewire/activity-monitor.blade.php b/resources/views/livewire/activity-monitor.blade.php index 33a55da53..4f995e51f 100644 --- a/resources/views/livewire/activity-monitor.blade.php +++ b/resources/views/livewire/activity-monitor.blade.php @@ -1,6 +1,5 @@
@isset($this->activity) - Activity: {{ $this->activity?->id }} Status: {{ $this->activity?->properties->get('status') }}
{{ \App\Actions\CoolifyTask\RunRemoteProcess::decodeOutput($this->activity) }}
diff --git a/resources/views/livewire/run-command.blade.php b/resources/views/livewire/run-command.blade.php index 81473dd40..951fd5407 100755 --- a/resources/views/livewire/run-command.blade.php +++ b/resources/views/livewire/run-command.blade.php @@ -1,26 +1,12 @@
-
- - Run command - Run sleeping beauty - Build DummyProject -
- -
- - - @if ($isKeepAliveOn || $manualKeepAlive) - Polling... - @endif -
- @isset($activity?->id) -
{{ \App\Actions\CoolifyTask\RunRemoteProcess::decodeOutput($activity) }}
- @endisset +
+ + + Run + +
diff --git a/routes/web.php b/routes/web.php index ec3e7d7cd..e47acfaf1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -60,9 +60,9 @@ return view('update'); })->name('update'); - Route::get('/demo', function () { - return view('demo'); - })->name('demo'); + Route::get('/command-center', function () { + return view('command-center'); + })->name('command-center'); }); Route::middleware(['auth'])->group(function () {