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