Refactor getLogs method and update view template

This commit is contained in:
Andras Bacsai 2024-02-27 09:08:15 +01:00
parent c71e1e107e
commit 5275ae8e9c
2 changed files with 9 additions and 5 deletions

View File

@ -71,10 +71,12 @@ public function instantSave()
}
public function getLogs($refresh = false)
{
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->resource?->getMorphClass() === 'App\Models\Application') {
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) {

View File

@ -2,7 +2,9 @@
<div x-init="$wire.getLogs" id="screen" x-data="{ fullscreen: false, alwaysScroll: false, intervalId: null }">
<div class="flex items-center gap-2">
<h3>{{ $container }}</h3>
<div>({{ $pull_request }})</div>
@if ($pull_request)
<div>({{ $pull_request }})</div>
@endif
@if ($streamLogs)
<span wire:poll.2000ms='getLogs(true)' class="loading loading-xs text-warning loading-spinner"></span>
@endif