An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Refactor variable and function names for consistency
Andras Bacsai35a1307e7b1a
diff --git a/app/Livewire/Tags/Deployments.php b/app/Livewire/Tags/Deployments.phpindex 270aa176a1..e4afa5b606 100644--- a/app/Livewire/Tags/Deployments.php+++ b/app/Livewire/Tags/Deployments.php@@ -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);}diff --git a/app/Livewire/Tags/Index.php b/app/Livewire/Tags/Index.phpindex a01d00a70e..642b2bded8 100644--- a/app/Livewire/Tags/Index.php+++ b/app/Livewire/Tags/Index.php@@ -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 Componentpublic $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()+ {+ return view('livewire.tags.index');+ }++ public function mount()+ {+ $this->tags = Tag::ownedByCurrentTeam()->get()->unique('name')->sortBy('name');+ if ($this->tag) {+ $this->tagUpdated();+ }+ }++ public function updateDeployments($deployments){- $this->deployments_per_tag_per_server = $deployments;+ $this->deploymentsPerTagPerServer = $deployments;}- public function tag_updated()+ 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 Componentreturn 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');- }}diff --git a/app/Livewire/Tags/Show.php b/app/Livewire/Tags/Show.phpindex 668101edb6..0dffcce577 100644--- a/app/Livewire/Tags/Show.php+++ b/app/Livewire/Tags/Show.php@@ -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 Componentif (! $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;diff --git a/resources/views/livewire/tags/deployments.blade.php b/resources/views/livewire/tags/deployments.blade.phpindex 03da021f9a..8f23d994d4 100644--- a/resources/views/livewire/tags/deployments.blade.php+++ b/resources/views/livewire/tags/deployments.blade.php@@ -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)diff --git a/resources/views/livewire/tags/index.blade.php b/resources/views/livewire/tags/index.blade.phpindex 287e1da55a..3a98519a7e 100644--- a/resources/views/livewire/tags/index.blade.php+++ b/resources/views/livewire/tags/index.blade.php@@ -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@endifdiff --git a/resources/views/livewire/tags/show.blade.php b/resources/views/livewire/tags/show.blade.phpindex 869b56daeb..f135a8246a 100644--- a/resources/views/livewire/tags/show.blade.php+++ b/resources/views/livewire/tags/show.blade.php@@ -1,7 +1,4 @@<div>- <x-slot:title>- Tag | Coolify- </x-slot><div class="flex items-start gap-2"><div><h1>Tags</h1>