fix crash when clicking site compound nodes on network map
Site compound nodes have IDs like "site_<uuid>" which can't be cast to binary_id in Ecto queries. Add guard clause to get_node_detail/2 and skip node_clicked events for site nodes in Cytoscape hook.
This commit is contained in:
parent
80304329bd
commit
793c38e784
3 changed files with 12 additions and 1 deletions
|
|
@ -867,11 +867,14 @@ const NetworkMap = {
|
|||
wheelSensitivity: 1
|
||||
})
|
||||
|
||||
// Add click handler for nodes
|
||||
// Add click handler for nodes (skip site compound nodes)
|
||||
this.cy.on('tap', 'node', (evt: any) => {
|
||||
const node = evt.target
|
||||
const nodeData = node.data()
|
||||
|
||||
// Don't open detail panel for site group nodes
|
||||
if (nodeData.type === 'site') return
|
||||
|
||||
// Push event to LiveView to open detail panel
|
||||
this.pushEvent("node_clicked", {
|
||||
node_id: nodeData.id,
|
||||
|
|
|
|||
|
|
@ -530,6 +530,8 @@ defmodule Towerops.Topology do
|
|||
end
|
||||
end
|
||||
|
||||
def get_node_detail("site_" <> _rest, _organization_id), do: nil
|
||||
|
||||
def get_node_detail(device_id, organization_id) do
|
||||
device =
|
||||
Repo.one(
|
||||
|
|
|
|||
|
|
@ -1362,6 +1362,12 @@ defmodule Towerops.TopologyTest do
|
|||
result = Topology.get_node_detail(Ecto.UUID.generate(), org.id)
|
||||
assert result == nil
|
||||
end
|
||||
|
||||
test "returns nil for site compound node IDs",
|
||||
%{organization: org, site: site} do
|
||||
result = Topology.get_node_detail("site_#{site.id}", org.id)
|
||||
assert result == nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "list_connected_devices/1" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue