use computed property

This commit is contained in:
mahansky
2024-09-04 03:39:50 +02:00
parent 63a07e7649
commit b0039885eb
2 changed files with 8 additions and 13 deletions

View File

@@ -13,8 +13,6 @@ class Show extends Component
public ApplicationDeploymentQueue $application_deployment_queue;
public Collection $logLines;
public string $deployment_uuid;
public $isKeepAliveOn = true;
@@ -56,13 +54,11 @@ class Show extends Component
$this->application = $application;
$this->application_deployment_queue = $application_deployment_queue;
$this->deployment_uuid = $deploymentUuid;
$this->buildLogLines();
}
public function refreshQueue()
{
$this->application_deployment_queue->refresh();
$this->buildLogLines();
}
public function polling()
@@ -72,17 +68,11 @@ class Show extends Component
if (data_get($this->application_deployment_queue, 'status') == 'finished' || data_get($this->application_deployment_queue, 'status') == 'failed') {
$this->isKeepAliveOn = false;
}
$this->buildLogLines();
}
public function render()
public function getLogLinesProperty()
{
return view('livewire.project.application.deployment.show');
}
private function buildLogLines()
{
$this->logLines = decode_remote_command_output($this->application_deployment_queue)->map(function ($logLine) {
return decode_remote_command_output($this->application_deployment_queue)->map(function ($logLine) {
$logLine['line'] = e($logLine['line']);
$logLine['line'] = preg_replace(
'/(https?:\/\/[^\s]+)/',
@@ -93,4 +83,9 @@ class Show extends Component
return $logLine;
});
}
public function render()
{
return view('livewire.project.application.deployment.show');
}
}

View File

@@ -93,7 +93,7 @@
</div>
<div id="logs" class="flex flex-col font-mono">
@forelse ($logLines as $line)
@forelse ($this->logLines as $line)
<div
@class([
'mt-2' => $line['command'] ?? false,