Refactor variable and function names for consistency
This commit is contained in:
@@ -7,19 +7,19 @@ use Livewire\Component;
|
||||
|
||||
class Deployments extends Component
|
||||
{
|
||||
public $deployments_per_tag_per_server = [];
|
||||
public $deploymentsPerTagPerServer = [];
|
||||
|
||||
public $resource_ids = [];
|
||||
public $resourceIds = [];
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.tags.deployments');
|
||||
}
|
||||
|
||||
public function get_deployments()
|
||||
public function getDeployments()
|
||||
{
|
||||
try {
|
||||
$this->deployments_per_tag_per_server = ApplicationDeploymentQueue::whereIn('status', ['in_progress', 'queued'])->whereIn('application_id', $this->resource_ids)->get([
|
||||
$this->deploymentsPerTagPerServer = ApplicationDeploymentQueue::whereIn('status', ['in_progress', 'queued'])->whereIn('application_id', $this->resourceIds)->get([
|
||||
'id',
|
||||
'application_id',
|
||||
'application_name',
|
||||
@@ -29,7 +29,7 @@ class Deployments extends Component
|
||||
'server_id',
|
||||
'status',
|
||||
])->sortBy('id')->groupBy('server_name')->toArray();
|
||||
$this->dispatch('deployments', $this->deployments_per_tag_per_server);
|
||||
$this->dispatch('deployments', $this->deploymentsPerTagPerServer);
|
||||
} catch (\Exception $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ namespace App\Livewire\Tags;
|
||||
use App\Http\Controllers\Api\DeployController;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Title('Tags | Coolify')]
|
||||
class Index extends Component
|
||||
{
|
||||
#[Url()]
|
||||
@@ -21,33 +23,47 @@ class Index extends Component
|
||||
|
||||
public $webhook = null;
|
||||
|
||||
public $deployments_per_tag_per_server = [];
|
||||
public $deploymentsPerTagPerServer = [];
|
||||
|
||||
protected $listeners = ['deployments' => 'update_deployments'];
|
||||
protected $listeners = ['deployments' => 'updateDeployments'];
|
||||
|
||||
public function update_deployments($deployments)
|
||||
public function render()
|
||||
{
|
||||
$this->deployments_per_tag_per_server = $deployments;
|
||||
return view('livewire.tags.index');
|
||||
}
|
||||
|
||||
public function tag_updated()
|
||||
public function mount()
|
||||
{
|
||||
$this->tags = Tag::ownedByCurrentTeam()->get()->unique('name')->sortBy('name');
|
||||
if ($this->tag) {
|
||||
$this->tagUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
public function updateDeployments($deployments)
|
||||
{
|
||||
$this->deploymentsPerTagPerServer = $deployments;
|
||||
}
|
||||
|
||||
public function tagUpdated()
|
||||
{
|
||||
if ($this->tag == '') {
|
||||
return;
|
||||
}
|
||||
$tag = $this->tags->where('name', $this->tag)->first();
|
||||
$sanitizedTag = htmlspecialchars($this->tag, ENT_QUOTES, 'UTF-8');
|
||||
$tag = $this->tags->where('name', $sanitizedTag)->first();
|
||||
if (! $tag) {
|
||||
$this->dispatch('error', "Tag ({$this->tag}) not found.");
|
||||
$this->dispatch('error', 'Tag ('.e($sanitizedTag).') not found.');
|
||||
$this->tag = '';
|
||||
|
||||
return;
|
||||
}
|
||||
$this->webhook = generatTagDeployWebhook($tag->name);
|
||||
$this->webhook = generateTagDeployWebhook($tag->name);
|
||||
$this->applications = $tag->applications()->get();
|
||||
$this->services = $tag->services()->get();
|
||||
}
|
||||
|
||||
public function redeploy_all()
|
||||
public function redeployAll()
|
||||
{
|
||||
try {
|
||||
$this->applications->each(function ($resource) {
|
||||
@@ -63,17 +79,4 @@ class Index extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->tags = Tag::ownedByCurrentTeam()->get()->unique('name')->sortBy('name');
|
||||
if ($this->tag) {
|
||||
$this->tag_updated();
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.tags.index');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace App\Livewire\Tags;
|
||||
use App\Http\Controllers\Api\DeployController;
|
||||
use App\Models\ApplicationDeploymentQueue;
|
||||
use App\Models\Tag;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Title('Tags | Coolify')]
|
||||
class Show extends Component
|
||||
{
|
||||
public $tags;
|
||||
@@ -28,7 +30,7 @@ class Show extends Component
|
||||
if (! $tag) {
|
||||
return redirect()->route('tags.index');
|
||||
}
|
||||
$this->webhook = generatTagDeployWebhook($tag->name);
|
||||
$this->webhook = generateTagDeployWebhook($tag->name);
|
||||
$this->applications = $tag->applications()->get();
|
||||
$this->services = $tag->services()->get();
|
||||
$this->tag = $tag;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div wire:poll.2000ms="get_deployments" wire:init='get_deployments'>
|
||||
@forelse ($deployments_per_tag_per_server as $server_name => $deployments)
|
||||
<div wire:poll.2000ms="getDeployments" wire:init='getDeployments'>
|
||||
@forelse ($deploymentsPerTagPerServer as $server_name => $deployments)
|
||||
<h4 class="py-4">{{ $server_name }}</h4>
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
@foreach ($deployments as $deployment)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
<div>
|
||||
<x-slot:title>
|
||||
Tags | Coolify
|
||||
</x-slot>
|
||||
<h1>Tags</h1>
|
||||
<div class="flex flex-col pb-6 ">
|
||||
<div class="flex flex-col pb-6">
|
||||
<div class="subtitle">Tags help you to perform actions on multiple resources.</div>
|
||||
<div class="">
|
||||
@if ($tags->count() === 0)
|
||||
<div>No tags yet defined yet. Go to a resource and add a tag there.</div>
|
||||
@else
|
||||
<x-forms.datalist wire:model="tag" onUpdate='tag_updated'>
|
||||
<x-forms.datalist wire:model="tag" onUpdate='tagUpdated'>
|
||||
@foreach ($tags as $oneTag)
|
||||
<option value="{{ $oneTag->name }}">{{ $oneTag->name }}</option>
|
||||
@endforeach
|
||||
@@ -21,7 +18,7 @@
|
||||
<x-forms.input readonly label="Deploy Webhook URL" id="webhook" />
|
||||
</div>
|
||||
<x-modal-confirmation title="Redeploy all resources with this tag?" isHighlighted
|
||||
buttonTitle="Redeploy All" submitAction="redeploy_all" :actions="[
|
||||
buttonTitle="Redeploy All" submitAction="redeployAll" :actions="[
|
||||
'All resources with this tag will be redeployed.',
|
||||
'During redeploy resources will be temporarily unavailable.',
|
||||
]"
|
||||
@@ -31,34 +28,34 @@
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-2 pt-4 lg:grid-cols-2 xl:grid-cols-3">
|
||||
@foreach ($applications as $application)
|
||||
<div class="box group">
|
||||
<a href="{{ $application->link() }}" class="flex flex-col ">
|
||||
<a href="{{ $application->link() }}"class="box group">
|
||||
<div class="flex flex-col">
|
||||
<div class="box-title">{{ $application->name }}</div>
|
||||
<div class="box-description">
|
||||
{{ $application->project()->name }}/{{ $application->environment->name }}
|
||||
</div>
|
||||
<div class="box-description">{{ $application->description }}</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
@foreach ($services as $service)
|
||||
<div class="box group">
|
||||
<a href="{{ $service->link() }}" class="flex flex-col ">
|
||||
<a href="{{ $service->link() }}" class="box group">
|
||||
<div class="flex flex-col ">
|
||||
<div class="box-title">{{ $service->name }}</div>
|
||||
<div class="box-description">
|
||||
{{ $service->project()->name }}/{{ $service->environment->name }}</div>
|
||||
<div class="box-description">{{ $service->description }}</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<h3 class="py-4">Deployments</h3>
|
||||
@if (count($deployments_per_tag_per_server) > 0)
|
||||
@if (count($deploymentsPerTagPerServer) > 0)
|
||||
<x-loading />
|
||||
@endif
|
||||
</div>
|
||||
<livewire:tags.deployments :deployments_per_tag_per_server="$deployments_per_tag_per_server" :resource_ids="$applications->pluck('id')" />
|
||||
<livewire:tags.deployments :deploymentsPerTagPerServer="$deploymentsPerTagPerServer" :resourceIds="$applications->pluck('id')" />
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<div>
|
||||
<x-slot:title>
|
||||
Tag | Coolify
|
||||
</x-slot>
|
||||
<div class="flex items-start gap-2">
|
||||
<div>
|
||||
<h1>Tags</h1>
|
||||
|
||||
Reference in New Issue
Block a user