Refactor variable and function names for consistency

This commit is contained in:
Andras Bacsai
2024-10-25 10:59:05 +02:00
parent cb9b485332
commit 35a1307e7b
6 changed files with 48 additions and 49 deletions

View File

@@ -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);
}

View File

@@ -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');
}
}

View File

@@ -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;