diff --git a/app/Livewire/Tags/Deployments.php b/app/Livewire/Tags/Deployments.php new file mode 100644 index 000000000..5c43edfb1 --- /dev/null +++ b/app/Livewire/Tags/Deployments.php @@ -0,0 +1,33 @@ +deployments_per_tag_per_server = ApplicationDeploymentQueue::whereIn("status", ["in_progress", "queued"])->whereIn('application_id', $this->resource_ids)->get([ + "id", + "application_id", + "application_name", + "deployment_url", + "pull_request_id", + "server_name", + "server_id", + "status" + ])->sortBy('id')->groupBy('server_name')->toArray(); + } catch (\Exception $e) { + return handleError($e, $this); + } + } +} diff --git a/app/Livewire/Tags/Index.php b/app/Livewire/Tags/Index.php index 75ed06f7b..d04bb53f9 100644 --- a/app/Livewire/Tags/Index.php +++ b/app/Livewire/Tags/Index.php @@ -20,32 +20,22 @@ class Index extends Component public $webhook = null; public $deployments_per_tag_per_server = []; - public function updatedTag() + public function tag_updated() { + if ($this->tag == "") { + return; + } $tag = $this->tags->where('name', $this->tag)->first(); + if (!$tag) { + $this->dispatch('error', "Tag ({$this->tag}) not found."); + $this->tag = ""; + return; + } $this->webhook = generatTagDeployWebhook($tag->name); $this->applications = $tag->applications()->get(); $this->services = $tag->services()->get(); - $this->get_deployments(); - } - public function get_deployments() - { - try { - $resource_ids = $this->applications->pluck('id'); - $this->deployments_per_tag_per_server = ApplicationDeploymentQueue::whereIn("status", ["in_progress", "queued"])->whereIn('application_id', $resource_ids)->get([ - "id", - "application_id", - "application_name", - "deployment_url", - "pull_request_id", - "server_name", - "server_id", - "status" - ])->sortBy('id')->groupBy('server_name')->toArray(); - } catch (\Exception $e) { - return handleError($e, $this); - } } + public function redeploy_all() { try { @@ -67,7 +57,7 @@ class Index extends Component { $this->tags = Tag::ownedByCurrentTeam()->get()->unique('name')->sortBy('name'); if ($this->tag) { - $this->updatedTag(); + $this->tag_updated(); } } public function render() diff --git a/app/View/Components/Forms/Datalist.php b/app/View/Components/Forms/Datalist.php new file mode 100644 index 000000000..d4ed44266 --- /dev/null +++ b/app/View/Components/Forms/Datalist.php @@ -0,0 +1,38 @@ +id)) $this->id = new Cuid2(7); + if (is_null($this->name)) $this->name = $this->id; + + $this->label = Str::title($this->label); + return view('components.forms.datalist'); + } +} diff --git a/resources/views/components/forms/datalist.blade.php b/resources/views/components/forms/datalist.blade.php new file mode 100644 index 000000000..c9710b728 --- /dev/null +++ b/resources/views/components/forms/datalist.blade.php @@ -0,0 +1,44 @@ +
+ + @error($id) + + @enderror + {{-- --}} +
diff --git a/resources/views/livewire/tags/deployments.blade.php b/resources/views/livewire/tags/deployments.blade.php new file mode 100644 index 000000000..4d8581f79 --- /dev/null +++ b/resources/views/livewire/tags/deployments.blade.php @@ -0,0 +1,28 @@ +
+ @forelse ($deployments_per_tag_per_server as $server_name => $deployments) +

{{ $server_name }}

+
+ @foreach ($deployments as $deployment) +
data_get($deployment, 'status') === 'queued', + 'border-yellow-500' => data_get($deployment, 'status') === 'in_progress', + ])> + +
+
+ {{ data_get($deployment, 'application_name') }} +
+
+ {{ str(data_get($deployment, 'status'))->headline() }} +
+
+
+
+
+ @endforeach +
+ @empty +
No deployments running.
+ @endforelse +
diff --git a/resources/views/livewire/tags/index.blade.php b/resources/views/livewire/tags/index.blade.php index 11442c1f2..1fd62cefe 100644 --- a/resources/views/livewire/tags/index.blade.php +++ b/resources/views/livewire/tags/index.blade.php @@ -6,12 +6,11 @@ @if ($tags->count() === 0)
No tags yet defined yet. Go to a resource and add a tag there.
@else - - + @foreach ($tags as $oneTag) @endforeach - + @if ($tag)
@@ -51,34 +50,7 @@ @endif
-
- @forelse ($deployments_per_tag_per_server as $server_name => $deployments) -

{{ $server_name }}

-
- @foreach ($deployments as $deployment) -
data_get($deployment, 'status') === 'queued', - 'border-yellow-500' => data_get($deployment, 'status') === 'in_progress', - ])> - -
-
- {{ data_get($deployment, 'application_name') }} -
-
- {{ str(data_get($deployment, 'status'))->headline() }} -
-
-
-
-
- @endforeach -
- @empty -
No deployments running.
- @endforelse -
+
@endif @endif