Refactor getLogs method and update get-logs.blade.php view

This commit is contained in:
Andras Bacsai
2024-02-27 09:05:28 +01:00
parent 8ab72c7e10
commit c71e1e107e
2 changed files with 14 additions and 10 deletions

View File

@@ -71,13 +71,13 @@ class GetLogs extends Component
}
public function getLogs($refresh = false)
{
if (!$refresh && $this->resource?->getMorphClass() === 'App\Models\Service') return;
if (str($this->container)->contains('-pr-')) {
$this->pull_request = "Pull Request: " . str($this->container)->afterLast('-pr-')->beforeLast('_')->value();
} else {
$this->pull_request = 'branch';
}
if (!$refresh && ($this->resource?->getMorphClass() === 'App\Models\Service' || str($this->container)->contains('-pr-'))) return;
if ($this->container) {
if (str($this->container)->contains('-pr-')) {
$this->pull_request = "Pull Request: " . str($this->container)->afterLast('-pr-')->beforeLast('_')->value();
} else {
$this->pull_request = 'branch';
}
if ($this->showTimeStamps) {
if ($this->server->isSwarm()) {
$sshCommand = generateSshCommand($this->server, "docker service logs -n {$this->numberOfLines} -t {$this->container}");