Skip to content

Commit

Permalink
Change health section to not show boxes for non-reported default valu…
Browse files Browse the repository at this point in the history
…es (#1651)
  • Loading branch information
lawik authored Nov 20, 2024
1 parent c10783c commit c652716
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
12 changes: 1 addition & 11 deletions lib/nerves_hub_web/live/devices/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

<%= if (!Enum.any?(Map.values(@latest_metrics)) or !Enum.any?(Map.values(@latest_custom_metrics))) do %>
<div class="display-box">
No health information have been received for this device.
No health information has been received for this device.
</div>
<% end %>
<div>
Expand All @@ -127,23 +127,13 @@
<div class="help-text label">Memory used</div>
<%= round(@latest_metrics.used_mb) %>MB (<%= round(@latest_metrics.used_percent) %>%)
</div>
<% else %>
<div class="callout">
<div class="help-text label">Memory used</div>
Not reported
</div>
<% end %>

<%= if @latest_metrics.cpu_temp do %>
<div class={"callout #{Utils.cpu_temp_to_status(@latest_metrics.cpu_temp)}"}>
<div class="help-text label">CPU</div>
<%= round(@latest_metrics.cpu_temp) %>°
</div>
<% else %>
<div class="callout">
<div class="help-text label">CPU</div>
Not reported
</div>
<% end %>

<%= for {key, val} <- @latest_custom_metrics do %>
Expand Down
4 changes: 1 addition & 3 deletions test/nerves_hub_web/live/devices/show_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ defmodule NervesHubWeb.Live.Devices.ShowTest do
|> visit("/org/#{org.name}/#{product.name}/devices/#{device.identifier}")
|> assert_has("h1", text: device.identifier)
|> assert_has("div", text: "Health")
|> assert_has("div", text: "No health information have been received for this device.")
|> assert_has("div", text: "No health information has been received for this device.")
end

test "full set of information", %{
Expand Down Expand Up @@ -289,8 +289,6 @@ defmodule NervesHubWeb.Live.Devices.ShowTest do
|> assert_has("div", text: "0.0 | 0.0 | 0.0")
|> assert_has("div", text: "Memory used")
|> assert_has("div", text: "100MB (60%)")
|> assert_has("div", text: "CPU")
|> assert_has("div", text: "Not reported")
|> assert_has("span", text: "Last reported :")
|> assert_has("time", text: "ago")
end
Expand Down

0 comments on commit c652716

Please sign in to comment.