fixes
This commit is contained in:
parent
117ba360ac
commit
5ed91c05bf
@ -20,7 +20,7 @@ public function __construct(
|
||||
public string $type,
|
||||
public ?string $type_uuid = null,
|
||||
public ?Model $model = null,
|
||||
public string $status = ProcessStatus::HOLDING->value,
|
||||
public string $status = ProcessStatus::QUEUED->value,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
enum ProcessStatus: string
|
||||
{
|
||||
case HOLDING = 'holding';
|
||||
case QUEUED = 'queued';
|
||||
case IN_PROGRESS = 'in_progress';
|
||||
case FINISHED = 'finished';
|
||||
case ERROR = 'error';
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Enums\ProcessStatus;
|
||||
use Livewire\Component;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
@ -31,12 +32,24 @@ public function newMonitorActivity($activityId)
|
||||
public function polling()
|
||||
{
|
||||
$this->hydrateActivity();
|
||||
|
||||
if (data_get($this->activity, 'properties.exitCode') !== null) {
|
||||
$this->setStatus(ProcessStatus::IN_PROGRESS);
|
||||
$exit_code = data_get($this->activity, 'properties.exitCode');
|
||||
if ($exit_code !== null) {
|
||||
if ($exit_code === 0) {
|
||||
$this->setStatus(ProcessStatus::FINISHED);
|
||||
} else {
|
||||
$this->setStatus(ProcessStatus::ERROR);
|
||||
}
|
||||
$this->isPollingActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function setStatus($status)
|
||||
{
|
||||
$this->activity->properties = $this->activity->properties->merge([
|
||||
'status' => $status,
|
||||
]);
|
||||
$this->activity->save();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.activity-monitor');
|
||||
|
@ -26,7 +26,7 @@ public function mount()
|
||||
if (request()->query('server_id')) {
|
||||
$this->server_id = request()->query('server_id');
|
||||
} else {
|
||||
$this->server_id = Server::first()->id;
|
||||
$this->server_id = Server::validated()->first()->id;
|
||||
}
|
||||
$this->network = new Cuid2(7);
|
||||
$this->name = generateRandomName();
|
||||
|
@ -20,10 +20,11 @@ class Form extends Component
|
||||
'server.ip' => 'required',
|
||||
'server.user' => 'required',
|
||||
'server.port' => 'required',
|
||||
'server.settings.is_validated' => 'required'
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->server = Server::find($this->server_id);
|
||||
$this->server = Server::find($this->server_id)->load(['settings']);
|
||||
}
|
||||
public function installDocker()
|
||||
{
|
||||
@ -38,6 +39,11 @@ public function checkServer()
|
||||
if (!$this->uptime) {
|
||||
$this->uptime = 'Server not reachable.';
|
||||
throw new \Exception('Server not reachable.');
|
||||
} else {
|
||||
if (!$this->server->settings->is_validated) {
|
||||
$this->server->settings->is_validated = true;
|
||||
$this->server->settings->save();
|
||||
}
|
||||
}
|
||||
$this->dockerVersion = instantRemoteProcess(['docker version|head -2|grep -i version'], $this->server, false);
|
||||
if (!$this->dockerVersion) {
|
||||
|
@ -52,4 +52,9 @@ public function settings()
|
||||
{
|
||||
return $this->hasOne(ServerSetting::class);
|
||||
}
|
||||
|
||||
static public function validated()
|
||||
{
|
||||
return Server::where('team_id', session('currentTeam')->id)->whereRelation('settings', 'is_validated', true)->get();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public function up(): void
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->boolean('is_build_server')->default(false);
|
||||
$table->boolean('is_validated')->default(false);
|
||||
|
||||
$table->foreignId('server_id');
|
||||
$table->timestamps();
|
||||
|
@ -15,11 +15,12 @@ public function run(): void
|
||||
{
|
||||
$server_2 = Server::find(1)->load(['settings']);
|
||||
$server_2->settings->is_build_server = true;
|
||||
$server_2->settings->is_validated = true;
|
||||
$server_2->settings->save();
|
||||
|
||||
$server_3 = Server::find(2)->load(['settings']);
|
||||
$server_3->settings->is_build_server = true;
|
||||
$server_3->settings->is_build_server = false;
|
||||
$server_3->settings->is_validated = false;
|
||||
$server_3->settings->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
@props([
|
||||
'isWarning' => null,
|
||||
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600 w-28 h-6',
|
||||
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 w-28 h-6',
|
||||
'loadingClass' => 'text-black bg-green-500 w-28 h-6',
|
||||
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600 h-8',
|
||||
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-8',
|
||||
'loadingClass' => 'text-black bg-green-500 h-8',
|
||||
'confirm' => null,
|
||||
'confirmAction' => null,
|
||||
])
|
||||
|
@ -9,7 +9,7 @@
|
||||
])
|
||||
|
||||
<span @class([
|
||||
'flex justify-end' => $type === 'checkbox',
|
||||
'flex' => $type === 'checkbox',
|
||||
'flex flex-col' => $type !== 'checkbox',
|
||||
])>
|
||||
@if (!$noLabel)
|
||||
|
@ -1,7 +1,9 @@
|
||||
<div>
|
||||
@isset($this->activity)
|
||||
<span>Status: {{ $this->activity?->properties->get('status') }}</span>
|
||||
<pre class="flex flex-col-reverse w-full overflow-y-scroll"
|
||||
<pre class="flex flex-col-reverse w-full overflow-y-hidden"
|
||||
@if ($isPollingActive) wire:poll.750ms="polling" @endif>{{ \App\Actions\CoolifyTask\RunRemoteProcess::decodeOutput($this->activity) }}</pre>
|
||||
@else
|
||||
<span>Output will be here...</span>
|
||||
@endisset
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div>
|
||||
<x-inputs.button class="w-32 text-white bg-neutral-800 hover:bg-violet-600" wire:click='checkUpdate' type="submit">
|
||||
Check for updates</x-inputs.button>
|
||||
<x-inputs.button wire:click='checkUpdate' type="submit">
|
||||
Check Update</x-inputs.button>
|
||||
@if ($updateAvailable)
|
||||
Update available
|
||||
@endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div>
|
||||
<a @if ($status === 'in_progress' || $status === 'holding') wire:poll='polling' @endif href="{{ url()->current() }}/{{ $deployment_uuid }}">
|
||||
<a @if ($status === 'in_progress' || $status === 'queued') wire:poll='polling' @endif href="{{ url()->current() }}/{{ $deployment_uuid }}">
|
||||
{{ $created_at }}
|
||||
{{ $deployment_uuid }}</a>
|
||||
{{ $status }}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div>
|
||||
<form class="flex gap-2" wire:submit.prevent='runCommand'>
|
||||
<x-inputs.input autofocus id="command" label="Command" required />
|
||||
<form class="flex items-end justify-center gap-2" wire:submit.prevent='runCommand'>
|
||||
<x-inputs.input noDirty noLabel autofocus id="command" label="Command" required />
|
||||
<select wire:model.defer="server">
|
||||
@foreach ($servers as $server)
|
||||
<option value="{{ $server->uuid }}">{{ $server->name }}</option>
|
||||
@ -8,5 +8,7 @@
|
||||
</select>
|
||||
<x-inputs.button type="submit">Run</x-inputs.button>
|
||||
</form>
|
||||
<livewire:activity-monitor />
|
||||
<div class="container w-full pt-10 mx-auto">
|
||||
<livewire:activity-monitor />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -18,7 +18,7 @@
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex">
|
||||
<x-inputs.button type="submit">Submit</x-inputs.button>
|
||||
<x-inputs.button wire:click.prevent='checkServer'>Check Server</x-inputs.button>
|
||||
<x-inputs.button wire:click.prevent='installDocker'>Install Docker</x-inputs.button>
|
||||
@ -26,7 +26,9 @@
|
||||
Delete
|
||||
</x-inputs.button>
|
||||
</div>
|
||||
<x-inputs.input class="" disabled type="checkbox" id="server.settings.is_validated" label="Validated" />
|
||||
</form>
|
||||
|
||||
@isset($uptime)
|
||||
<p>Uptime: {{ $uptime }}</p>
|
||||
@endisset
|
||||
|
@ -93,7 +93,7 @@
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/destination/new', function () {
|
||||
$servers = Server::where('team_id', session('currentTeam')->id)->get();
|
||||
$servers = Server::validated();
|
||||
return view('destination.new', [
|
||||
"servers" => $servers,
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user