Skip to content

Commit

Permalink
Disconnect device after its moved product so it can go through the re…
Browse files Browse the repository at this point in the history
…connect process, display device.deployment_conflict when viewing device
  • Loading branch information
nshoes committed Dec 5, 2024
1 parent 775cc5f commit 995a8f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/nerves_hub/devices.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ defmodule NervesHub.Devices do
alias NervesHub.Products.Product
alias NervesHub.Repo
alias NervesHub.TaskSupervisor, as: Tasks
alias NervesHubWeb.Endpoint

@min_fwup_delta_updatable_version ">=1.10.0"

Expand Down Expand Up @@ -1086,7 +1087,7 @@ defmodule NervesHub.Devices do
|> Repo.transaction()
|> case do
{:ok, %{move: updated}} ->
_ = broadcast(updated, "moved")
_ = Endpoint.broadcast("device_socket:#{updated.id}", "disconnect", %{})
{:ok, updated}

err ->
Expand Down
14 changes: 0 additions & 14 deletions lib/nerves_hub_web/channels/device_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ defmodule NervesHubWeb.DeviceChannel do
subscribe("device:#{device.id}")
subscribe(deployment_channel)

if device_health_check_enabled?() do
send(self(), :health_check)
schedule_health_check()
end

send(self(), :device_registration)

socket =
Expand Down Expand Up @@ -480,14 +475,5 @@ defmodule NervesHubWeb.DeviceChannel do
socket
end

defp schedule_health_check() do
if device_health_check_enabled?() do
Process.send_after(self(), :health_check, device_health_check_interval())
:ok
else
:ok
end
end

defp is_safe_to_request_extensions?(version), do: Version.match?(version, ">= 2.2.0")
end
11 changes: 11 additions & 0 deletions lib/nerves_hub_web/live/devices/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
Device has disabled extensions: <%= Enum.join(@extension_overrides, ", ") %>
</div>

<%= if reason = @device.deployment_conflict do %>
<div class="display-box">
<div class="help-text mb-1 tooltip-label help-tooltip">
<span>Deployment Conflict Reason</span>
<span class="tooltip-info"></span>
<span class="tooltip-text">When a device connects and it's firmware and/or architecture don't match it's deployment, it's removed from the deployment and the conflict reason is set.</span>
</div>
<span><%= Phoenix.Naming.humanize(reason) %></span>
</div>
<% end %>

<div class="display-box">
<div class="help-text mb-1">Tags</div>
<p :if={is_nil(@device.tags)}>No Tags</p>
Expand Down

0 comments on commit 995a8f8

Please sign in to comment.