diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.php index 5e0745490..a3a63c154 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.php index 6f431b11e..db2170b5f 100644 --- a/app/Livewire/Project/Shared/GetLogs.php +++ b/app/Livewire/Project/Shared/GetLogs.php @@ -51,19 +51,26 @@ class GetLogs extends Component if ($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.php index a927ba9ef..f7c952b46 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.php index 1c9466575..1daade6af 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 + Logs {{ $application->status }} - Logs @endforeach @foreach ($databases as $database) @@ -90,9 +91,6 @@ @endif