command center
This commit is contained in:
parent
135f9ab048
commit
b8b0d2243f
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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')
|
||||
<label for={{ $id }}>
|
||||
@if ($label)
|
||||
{{ $label }}
|
||||
@else
|
||||
{{ $id }}
|
||||
@endif
|
||||
@if ($required)
|
||||
*
|
||||
@endif
|
||||
<input type="checkbox" id={{ $id }}
|
||||
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $id }} @endif>
|
||||
</label>
|
||||
@error($id)
|
||||
<span class="text-red-500">{{ $message }}</span>
|
||||
@enderror
|
||||
@else
|
||||
|
||||
<span @class([
|
||||
'flex justify-end' => $type === 'checkbox',
|
||||
'flex flex-col' => $type !== 'checkbox',
|
||||
])>
|
||||
<label for={{ $id }}>
|
||||
@if ($label)
|
||||
{{ $label }}
|
||||
@ -38,17 +25,13 @@
|
||||
@endif
|
||||
</label>
|
||||
@if ($type === 'textarea')
|
||||
<textarea class={{ $class }} type={{ $type }} id={{ $id }}
|
||||
wire:model.defer={{ $id }} @if ($required) required @endif
|
||||
@if ($disabled) disabled @endif @if ($readonly) readOnly disabled @endif></textarea>
|
||||
<textarea {{ $attributes }} type={{ $type }} id={{ $id }} wire:model.defer={{ $id }}></textarea>
|
||||
@else
|
||||
<input class={{ $class }} type={{ $type }} id={{ $id }}
|
||||
wire:model.defer={{ $id }} @if ($required) required @endif
|
||||
@if ($disabled) disabled @endif
|
||||
@if ($readonly) readOnly disabled @endif />
|
||||
<input {{ $attributes }} type={{ $type }} id={{ $id }}
|
||||
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $id }} @endif />
|
||||
@endif
|
||||
|
||||
@error($id)
|
||||
<div class="text-red-500">{{ $message }}</div>
|
||||
@enderror
|
||||
@endif
|
||||
</span>
|
||||
|
@ -2,9 +2,7 @@
|
||||
<div>v{{ config('coolify.version') }}</div>
|
||||
@auth
|
||||
<a href="/">Home</a>
|
||||
@env('local')
|
||||
<a href="/demo">Demo</a>
|
||||
@endenv
|
||||
<a href="/command-center">Command Center</a>
|
||||
<a href="/profile">Profile</a>
|
||||
@if (auth()->user()->isRoot())
|
||||
<a href="/settings">Settings</a>
|
||||
|
@ -1,6 +1,5 @@
|
||||
<div>
|
||||
@isset($this->activity)
|
||||
<span>Activity: {{ $this->activity?->id }}</span>
|
||||
<span>Status: {{ $this->activity?->properties->get('status') }}</span>
|
||||
<pre class="flex flex-col-reverse w-full overflow-y-scroll"
|
||||
@if ($isPollingActive) wire:poll.750ms="polling" @endif>{{ \App\Actions\CoolifyTask\RunRemoteProcess::decodeOutput($this->activity) }}</pre>
|
||||
|
@ -1,26 +1,12 @@
|
||||
<div>
|
||||
<div>
|
||||
<label for="command">
|
||||
<input autofocus id="command" wire:model.defer="command" type="text" wire:keydown.enter="runCommand" />
|
||||
<select wire:model.defer="server">
|
||||
@foreach ($servers as $server)
|
||||
<option value="{{ $server->uuid }}">{{ $server->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
<x-inputs.button wire:click="runCommand">Run command</x-inputs.button>
|
||||
<x-inputs.button wire:click="runSleepingBeauty">Run sleeping beauty</x-inputs.button>
|
||||
<x-inputs.button wire:click="runDummyProjectBuild">Build DummyProject</x-inputs.button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input id="manualKeepAlive" name="manualKeepAlive" type="checkbox" wire:model="manualKeepAlive">
|
||||
<label for="manualKeepAlive">Real-time logs</label>
|
||||
@if ($isKeepAliveOn || $manualKeepAlive)
|
||||
Polling...
|
||||
@endif
|
||||
</div>
|
||||
@isset($activity?->id)
|
||||
<pre style="width: 100%;overflow-y: scroll;" @if ($isKeepAliveOn) wire:poll.750ms="polling" @endif>{{ \App\Actions\CoolifyTask\RunRemoteProcess::decodeOutput($activity) }}</pre>
|
||||
@endisset
|
||||
<form class="flex gap-2" wire:submit.prevent='runCommand'>
|
||||
<x-inputs.input autofocus id="command" label="Command" required />
|
||||
<select wire:model.defer="server">
|
||||
@foreach ($servers as $server)
|
||||
<option value="{{ $server->uuid }}">{{ $server->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<x-inputs.button type="submit">Run</x-inputs.button>
|
||||
</form>
|
||||
<livewire:activity-monitor />
|
||||
</div>
|
||||
|
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user