An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactor: service logs are now on one page
Andras Bacsai956416b52212
diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.phpindex 5e0745490a..a3a63c1548 100644--- a/app/Livewire/Project/Shared/ExecuteContainerCommand.php+++ b/app/Livewire/Project/Shared/ExecuteContainerCommand.php@@ -80,7 +80,7 @@ class ExecuteContainerCommand extends Component$this->resource = $resource;$this->server = $this->resource->destination->server;$this->container = $this->resource->uuid;- if (data_get($this,'resource.status') == 'running') {+ if (str(data_get($this,'resource.status'))->startsWith('running')) {$this->containers->push($this->container);}} else if (data_get($this->parameters, 'service_uuid')) {diff --git a/app/Livewire/Project/Shared/GetLogs.php b/app/Livewire/Project/Shared/GetLogs.phpindex 6f431b11ee..db2170b5f7 100644--- a/app/Livewire/Project/Shared/GetLogs.php+++ b/app/Livewire/Project/Shared/GetLogs.php@@ -51,19 +51,26 @@ class GetLogs extends Componentif ($this->resource->getMorphClass() === 'App\Models\Application') {$this->resource->settings->is_include_timestamps = $this->showTimeStamps;$this->resource->settings->save();- } else {- if ($this->servicesubtype) {- $this->servicesubtype->is_include_timestamps = $this->showTimeStamps;- $this->servicesubtype->save();+ }+ if ($this->resource->getMorphClass() === 'App\Models\Service') {+ $serviceName = str($this->container)->beforeLast('-')->value();+ $subType = $this->resource->applications()->where('name', $serviceName)->first();+ if ($subType) {+ $subType->is_include_timestamps = $this->showTimeStamps;+ $subType->save();} else {- $this->resource->is_include_timestamps = $this->showTimeStamps;- $this->resource->save();+ $subType = $this->resource->databases()->where('name', $serviceName)->first();+ if ($subType) {+ $subType->is_include_timestamps = $this->showTimeStamps;+ $subType->save();+ }}}}}public function getLogs($refresh = false){+ if (!$refresh && $this->resource->getMorphClass() === 'App\Models\Service') return;if ($this->container) {if ($this->showTimeStamps) {$sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}");diff --git a/app/Livewire/Project/Shared/Logs.php b/app/Livewire/Project/Shared/Logs.phpindex a927ba9efd..f7c952b466 100644--- a/app/Livewire/Project/Shared/Logs.php+++ b/app/Livewire/Project/Shared/Logs.php@@ -62,17 +62,24 @@ class Logs extends Component$this->status = $this->resource->status;$this->server = $this->resource->destination->server;$this->container = $this->resource->uuid;+ if (str(data_get($this,'resource.status'))->startsWith('running')) {+ $this->containers->push($this->container);+ }} else if (data_get($this->parameters, 'service_uuid')) {$this->type = 'service';$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();- $service_name = data_get($this->parameters, 'service_name');- $this->serviceSubType = $this->resource->applications()->where('name', $service_name)->first();- if (!$this->serviceSubType) {- $this->serviceSubType = $this->resource->databases()->where('name', $service_name)->first();- }- $this->status = $this->resource->status;+ $this->resource->applications()->get()->each(function ($application) {+ if (str(data_get($application, 'status'))->contains('running')) {+ $this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));+ }+ });+ $this->resource->databases()->get()->each(function ($database) {+ if (str(data_get($database, 'status'))->contains('running')) {+ $this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));+ }+ });+$this->server = $this->resource->server;- $this->container = data_get($this->parameters, 'service_name') . '-' . $this->resource->uuid;}}diff --git a/resources/views/livewire/project/service/index.blade.php b/resources/views/livewire/project/service/index.blade.phpindex 1c94665757..1daade6afc 100644--- a/resources/views/livewire/project/service/index.blade.php+++ b/resources/views/livewire/project/service/index.blade.php@@ -11,6 +11,10 @@@click.prevent="activeTab = 'execute-command';window.location.hash = 'execute-command'"href="#">Execute Command</a>+ <a :class="activeTab === 'logs' && 'text-white'"+ @click.prevent="activeTab = 'logs';+ window.location.hash = 'logs'"+ href="#">Logs</a><a :class="activeTab === 'storages' && 'text-white'"@click.prevent="activeTab = 'storages';window.location.hash = 'storages'"@@ -60,9 +64,6 @@@endif<div class="text-xs">{{ $application->status }}</div></a>- <a wire:navigate class="flex items-center gap-2 p-1 mx-4 font-bold rounded group-hover:text-white hover:no-underline"- href="{{ route('project.service.logs', [...$parameters, 'service_name' => $application->name]) }}"><span- class="hover:text-warning">Logs</span></a></div>@endforeach@foreach ($databases as $database)@@ -90,9 +91,6 @@@endif<div class="text-xs">{{ $database->status }}</div></a>- <a wire:navigate class="flex items-center gap-2 p-1 mx-4 font-bold rounded hover:no-underline group-hover:text-white"- href="{{ route('project.service.logs', [...$parameters, 'service_name' => $database->name]) }}"><span- class="hover:text-warning">Logs</span></a></div>@endforeach</div>@@ -114,8 +112,11 @@<div x-cloak x-show="activeTab === 'webhooks'"><livewire:project.shared.webhooks :resource="$service" /></div>+ <div x-cloak x-show="activeTab === 'logs'">+ <livewire:project.shared.logs :resource="$service" />+ </div><div x-cloak x-show="activeTab === 'execute-command'">- <livewire:project.shared.execute-container-command :resource="$service" />+ <livewire:project.shared.execute-container-command :resource="$service" /></div><div x-cloak x-show="activeTab === 'environment-variables'"><div x-cloak x-show="activeTab === 'environment-variables'">diff --git a/resources/views/livewire/project/service/show.blade.php b/resources/views/livewire/project/service/show.blade.phpindex e7feaae79c..8631aa20bc 100644--- a/resources/views/livewire/project/service/show.blade.php+++ b/resources/views/livewire/project/service/show.blade.php@@ -20,12 +20,6 @@<a :class="activeTab === 'backups' && 'text-white'"@click.prevent="activeTab = 'backups'; window.location.hash = 'backups'" href="#">Backups</a>@endif- @if (data_get($parameters, 'service_name'))- <a wire:navigate class="{{ request()->routeIs('project.service.logs') ? 'text-white' : '' }}"- href="{{ route('project.service.logs', $parameters) }}">- <button>Logs</button>- </a>- @endif</div><div class="w-full pl-8">@isset($serviceApplication)diff --git a/resources/views/livewire/project/shared/logs.blade.php b/resources/views/livewire/project/shared/logs.blade.phpindex 7495ef190c..3d011e1e89 100644--- a/resources/views/livewire/project/shared/logs.blade.php+++ b/resources/views/livewire/project/shared/logs.blade.php@@ -16,21 +16,25 @@<h1>Logs</h1><livewire:project.database.heading :database="$resource" /><div class="pt-4">- <livewire:project.shared.get-logs :resource="$resource" :server="$server" :container="$container" />+ @forelse ($containers as $container)+ @if ($loop->first)+ <h2 class="pb-4">Logs</h2>+ @endif+ <livewire:project.shared.get-logs :server="$server" :resource="$resource" :container="$container" />+ @empty+ <div>No containers are not running.</div>+ @endforelse</div>@elseif ($type === 'service')- <livewire:project.service.navbar :service="$resource" :parameters="$parameters" :query="$query" />- <div class="flex gap-4 pt-6">- <div>- <a wire:navigate class="{{ request()->routeIs('project.service.show') ? 'text-white' : '' }}"- href="{{ route('project.service.show', $parameters) }}">- <button><- Back</button>- </a>- </div>- <div class="flex-1 pl-8">- <livewire:project.shared.get-logs :server="$server" :resource="$resource" :servicesubtype="$serviceSubType"- :container="$container" />- </div>+ <div>+ @forelse ($containers as $container)+ @if ($loop->first)+ <h2 class="pb-4">Logs</h2>+ @endif+ <livewire:project.shared.get-logs :server="$server" :resource="$resource" :container="$container" />+ @empty+ <div>No containers are not running.</div>+ @endforelse</div>@endif</div>diff --git a/routes/web.php b/routes/web.phpindex dba77238d5..0b3aee8216 100644--- a/routes/web.php+++ b/routes/web.php@@ -136,7 +136,6 @@ Route::middleware(['auth', 'verified'])->group(function () {// ServicesRoute::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', ServiceIndex::class)->name('project.service.configuration');Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}', ServiceShow::class)->name('project.service.show');- Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}/logs', Logs::class)->name('project.service.logs');Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/command', ExecuteContainerCommand::class)->name('project.service.command');});