Skip to content

Commit 22f65c3

Browse files
authored
Improvements to the 'updating' header on the deployments summary tab (#1868)
All devices up to date: <img width="1512" alt="Screenshot 2025-02-03 at 5 59 49 PM" src="https://github.com/user-attachments/assets/796ed39c-afb4-428b-ac6f-702a46e423ca" /> Updating: <img width="1512" alt="Screenshot 2025-02-03 at 6 00 52 PM" src="https://github.com/user-attachments/assets/4f065886-56a7-4cb7-a28e-11bf9b078137" />
1 parent f89e100 commit 22f65c3

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

lib/nerves_hub/devices.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,14 @@ defmodule NervesHub.Devices do
901901
|> Repo.aggregate(:count)
902902
end
903903

904+
@spec updating_count(Deployment.t()) :: term() | nil
905+
def updating_count(%Deployment{id: id}) do
906+
InflightUpdate
907+
|> where([ifu], ifu.deployment_id == ^id)
908+
|> Repo.aggregate(:count)
909+
end
910+
911+
@spec waiting_for_update_count(Deployment.t()) :: term() | nil
904912
def waiting_for_update_count(%Deployment{} = deployment) do
905913
Device
906914
|> where([d], d.deployment_id == ^deployment.id)

lib/nerves_hub_web/components/deployment_page/summary.ex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defmodule NervesHubWeb.Components.DeploymentPage.Summary do
1212
|> assign(:inflight_updates, inflight_updates)
1313
|> assign(:up_to_date_count, Devices.up_to_date_count(deployment))
1414
|> assign(:waiting_for_update_count, Devices.waiting_for_update_count(deployment))
15+
|> assign(:updating_count, Devices.updating_count(deployment))
1516
|> ok()
1617
end
1718

@@ -24,18 +25,19 @@ defmodule NervesHubWeb.Components.DeploymentPage.Summary do
2425
def render(assigns) do
2526
~H"""
2627
<div class="h-full flex flex-col items-start gap-4 p-6">
27-
<div :if={@waiting_for_update_count == 0} class="w-full flex p-4 items-center justify-center rounded border border-zinc-700 bg-zinc-900">
28-
<div class="text-neutral-50 font-medium leading-6">All devices are up to date!</div>
28+
<div :if={@waiting_for_update_count == 0} class="w-full p-4 items-center justify-center rounded border border-zinc-700 bg-zinc-900">
29+
<div class="flex text-xl text-neutral-50 font-medium leading-6 h-10 justify-center items-center">All devices are up to date!</div>
2930
</div>
3031
31-
<div :if={@waiting_for_update_count > 0} class="w-full box-content flex items-center justify-center rounded border border-zinc-700 bg-zinc-900">
32+
<div :if={@waiting_for_update_count > 0} class="w-full h-24 box-content flex items-center justify-center rounded border border-zinc-700 bg-zinc-900">
3233
<div class="relative sticky top-0 w-full items-center justify-center rounded overflow-visible z-20">
3334
<div class="z-40 absolute -top-px border-t rounded-tl border-success-500" role="progressbar" style={"width: #{deployment_percentage(@up_to_date_count, @deployment)}%"}>
3435
<div class="animate-pulse bg-progress-glow w-full h-16" />
3536
</div>
3637
37-
<div class="flex items-center justify-center my-1 py-2 px-2 bg-base-900/20 text-sm font-medium">
38-
{deployment_percentage(@up_to_date_count, @deployment)}% of devices updated - {@waiting_for_update_count} device(s) waiting to be updated
38+
<div class="flex flex-col gap-1 items-center justify-center my-1 py-2 px-2 bg-base-900/20 text-sm font-medium">
39+
<div class="text-base">{deployment_percentage(@up_to_date_count, @deployment)}% of devices updated</div>
40+
<div>{@updating_count} device(s) updating - {@waiting_for_update_count} device(s) waiting</div>
3941
</div>
4042
</div>
4143
</div>

lib/nerves_hub_web/live/deployments/show-new.html.heex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
inflight_updates={@inflight_updates}
9797
up_to_date_count={@up_to_date_count}
9898
waiting_for_update_count={@waiting_for_update_count}
99+
updating_count={@updating_count}
99100
product={@product}
100101
org={@org}
101102
org_user={@org_user}

lib/nerves_hub_web/live/deployments/show.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ defmodule NervesHubWeb.Live.Deployments.Show do
3737

3838
inflight_updates = Devices.inflight_updates_for(deployment)
3939
current_device_count = Deployments.get_device_count(deployment)
40+
updating_count = Devices.updating_count(deployment)
4041

4142
socket
4243
|> page_title("Deployment - #{deployment.name} - #{product.name}")
@@ -45,6 +46,7 @@ defmodule NervesHubWeb.Live.Deployments.Show do
4546
|> assign(:deployment, deployment)
4647
|> assign(:up_to_date_count, Devices.up_to_date_count(deployment))
4748
|> assign(:waiting_for_update_count, Devices.waiting_for_update_count(deployment))
49+
|> assign(:updating_count, updating_count)
4850
|> assign(:audit_logs, logs)
4951
|> assign(:audit_pager, audit_pager)
5052
|> assign(:inflight_updates, inflight_updates)
@@ -118,6 +120,7 @@ defmodule NervesHubWeb.Live.Deployments.Show do
118120
|> assign(:inflight_updates, inflight_updates)
119121
|> assign(:up_to_date_count, Devices.up_to_date_count(deployment))
120122
|> assign(:waiting_for_update_count, Devices.waiting_for_update_count(deployment))
123+
|> assign(:updating_count, Devices.updating_count(deployment))
121124
|> noreply()
122125
end
123126

0 commit comments

Comments
 (0)