Add back navigation links to edit pages
Added back navigation links at the top of all edit/new pages to improve UX and make it easier to navigate back to previous pages. Changes: - Added back link to equipment edit/new pages - Edit: goes back to equipment detail page - New: goes back to equipment list - Added back link to site edit/new pages - Edit: goes back to site detail page - New: goes back to sites list - Links styled with arrow icon and subtle hover effect - Added error handling to Counter64 decoder with try/rescue The back links appear above the page header and provide clear navigation context for users.
This commit is contained in:
parent
d209b3295a
commit
40a329ea78
3 changed files with 57 additions and 20 deletions
|
|
@ -246,29 +246,38 @@ defmodule Towerops.Snmp.PollerWorker do
|
|||
|
||||
defp decode_snmp_value(value) when is_binary(value) do
|
||||
# Try to decode based on byte size
|
||||
case byte_size(value) do
|
||||
8 ->
|
||||
# Standard Counter64 (8 bytes, big-endian unsigned integer)
|
||||
<<counter::unsigned-big-integer-size(64)>> = value
|
||||
counter
|
||||
try do
|
||||
case byte_size(value) do
|
||||
8 ->
|
||||
# Standard Counter64 (8 bytes, big-endian unsigned integer)
|
||||
<<counter::unsigned-big-integer-size(64)>> = value
|
||||
counter
|
||||
|
||||
16 ->
|
||||
# Some SNMP implementations return 16-byte values
|
||||
# Try reading last 8 bytes as Counter64
|
||||
<<_prefix::binary-size(8), counter::unsigned-big-integer-size(64)>> = value
|
||||
counter
|
||||
16 ->
|
||||
# Some SNMP implementations return 16-byte values
|
||||
# Try reading last 8 bytes as Counter64
|
||||
<<_prefix::binary-size(8), counter::unsigned-big-integer-size(64)>> = value
|
||||
counter
|
||||
|
||||
size when size > 8 ->
|
||||
# Large binary, try reading last 8 bytes
|
||||
offset = size - 8
|
||||
<<_prefix::binary-size(offset), counter::unsigned-big-integer-size(64)>> = value
|
||||
Logger.debug("Decoded #{size}-byte SNMP value as Counter64 from last 8 bytes: #{counter}")
|
||||
counter
|
||||
size when size > 8 ->
|
||||
# Large binary, try reading last 8 bytes
|
||||
offset = size - 8
|
||||
<<_prefix::binary-size(offset), counter::unsigned-big-integer-size(64)>> = value
|
||||
Logger.debug("Decoded #{size}-byte SNMP value as Counter64 from last 8 bytes: #{counter}")
|
||||
counter
|
||||
|
||||
_ ->
|
||||
# Unknown binary format or too small
|
||||
Logger.warning(
|
||||
"Unknown SNMP binary value format, size: #{byte_size(value)}, bytes: #{inspect(value)}"
|
||||
_ ->
|
||||
# Unknown binary format or too small
|
||||
Logger.warning(
|
||||
"Unknown SNMP binary value format, size: #{byte_size(value)}, bytes: #{inspect(value)}"
|
||||
)
|
||||
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
error ->
|
||||
Logger.error(
|
||||
"Failed to decode SNMP binary value (size: #{byte_size(value)}): #{inspect(error)}, bytes: #{inspect(value)}"
|
||||
)
|
||||
|
||||
nil
|
||||
|
|
|
|||
|
|
@ -1,4 +1,18 @@
|
|||
<Layouts.authenticated flash={@flash} current_organization={@organization}>
|
||||
<div class="mb-4">
|
||||
<.link
|
||||
navigate={
|
||||
if @live_action == :edit,
|
||||
do: ~p"/orgs/#{@organization.slug}/equipment/#{@equipment.id}",
|
||||
else: ~p"/orgs/#{@organization.slug}/equipment"
|
||||
}
|
||||
class="inline-flex items-center gap-1 text-sm text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100"
|
||||
>
|
||||
<.icon name="hero-arrow-left" class="h-4 w-4" />
|
||||
{if @live_action == :edit, do: "Back to Equipment", else: "Back to Equipment List"}
|
||||
</.link>
|
||||
</div>
|
||||
|
||||
<.header>
|
||||
{@page_title}
|
||||
<:subtitle>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,18 @@
|
|||
<Layouts.authenticated flash={@flash} current_organization={@organization}>
|
||||
<div class="mb-4">
|
||||
<.link
|
||||
navigate={
|
||||
if @live_action == :edit,
|
||||
do: ~p"/orgs/#{@organization.slug}/sites/#{@site.id}",
|
||||
else: ~p"/orgs/#{@organization.slug}/sites"
|
||||
}
|
||||
class="inline-flex items-center gap-1 text-sm text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100"
|
||||
>
|
||||
<.icon name="hero-arrow-left" class="h-4 w-4" />
|
||||
{if @live_action == :edit, do: "Back to Site", else: "Back to Sites"}
|
||||
</.link>
|
||||
</div>
|
||||
|
||||
<.header>
|
||||
{@page_title}
|
||||
<:subtitle>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue