Merge feature/activity-monitor: list display fixes
This commit is contained in:
commit
d046596766
2 changed files with 39 additions and 28 deletions
|
|
@ -283,13 +283,19 @@ function cmd::list::_collect_all_rows() {
|
||||||
local status="${state%%|*}"
|
local status="${state%%|*}"
|
||||||
|
|
||||||
# Resolve last seen
|
# Resolve last seen
|
||||||
local last_seen="—"
|
local last_seen="-"
|
||||||
if [[ "$is_blocked" == "true" && -n "$last_ts" && "$last_ts" != "0" ]]; then
|
if [[ "$is_blocked" == "true" && -n "$last_ts" && "$last_ts" != "0" ]]; then
|
||||||
local attempt_ts
|
local attempt_ts
|
||||||
attempt_ts=$(json::iso_to_ts "$last_ts")
|
attempt_ts=$(json::iso_to_ts "$last_ts")
|
||||||
last_seen=$(fmt::datetime_short "$attempt_ts")
|
last_seen="$(fmt::datetime_short "$attempt_ts") (dropped)"
|
||||||
elif [[ -n "$handshake_ts" && "$handshake_ts" != "0" ]]; then
|
elif [[ -n "$handshake_ts" && "$handshake_ts" != "0" ]]; then
|
||||||
last_seen=$(fmt::datetime_short "$handshake_ts")
|
local ts_display
|
||||||
|
ts_display=$(fmt::datetime_short "$handshake_ts")
|
||||||
|
if [[ "$status" == "online" ]]; then
|
||||||
|
last_seen="${ts_display} (handshake)"
|
||||||
|
else
|
||||||
|
last_seen="$ts_display"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "%s|%s|%s|%s|%s|%s|%s|%s|%s\n" \
|
printf "%s|%s|%s|%s|%s|%s|%s|%s|%s\n" \
|
||||||
|
|
@ -413,7 +419,11 @@ function cmd::list::_render_detailed() {
|
||||||
while IFS='|' read -r name ip type rule group status last_seen is_blocked is_restricted; do
|
while IFS='|' read -r name ip type rule group status last_seen is_blocked is_restricted; do
|
||||||
[[ -z "$name" ]] && continue
|
[[ -z "$name" ]] && continue
|
||||||
local subnet
|
local subnet
|
||||||
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null) || subnet="-"
|
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null)
|
||||||
|
if [[ -z "$subnet" ]]; then
|
||||||
|
local peer_type="${p_types[$name]:-}"
|
||||||
|
[[ -n "$peer_type" ]] && subnet="$peer_type"
|
||||||
|
fi
|
||||||
[[ -z "$subnet" ]] && subnet="-"
|
[[ -z "$subnet" ]] && subnet="-"
|
||||||
ui::peer::list_row_detailed \
|
ui::peer::list_row_detailed \
|
||||||
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
|
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
|
||||||
|
|
@ -431,8 +441,12 @@ function cmd::list::_render_detailed() {
|
||||||
while IFS='|' read -r name ip type rule group status last_seen is_blocked is_restricted; do
|
while IFS='|' read -r name ip type rule group status last_seen is_blocked is_restricted; do
|
||||||
[[ -z "$name" ]] && continue
|
[[ -z "$name" ]] && continue
|
||||||
local subnet
|
local subnet
|
||||||
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null) || subnet="—"
|
subnet=$(peers::get_meta "$name" "subnet" 2>/dev/null)
|
||||||
[[ -z "$subnet" ]] && subnet="—"
|
if [[ -z "$subnet" ]]; then
|
||||||
|
local peer_type="${p_types[$name]:-}"
|
||||||
|
[[ -n "$peer_type" ]] && subnet="$peer_type"
|
||||||
|
fi
|
||||||
|
[[ -z "$subnet" ]] && subnet="-"
|
||||||
ui::peer::list_row_detailed \
|
ui::peer::list_row_detailed \
|
||||||
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
|
"$w_name" "$w_ip" "$w_type" "$w_rule" "$w_group" "$w_subnet" \
|
||||||
"$name" "$ip" "$type" "$rule" "$group" "$subnet" \
|
"$name" "$ip" "$type" "$rule" "$group" "$subnet" \
|
||||||
|
|
|
||||||
|
|
@ -29,21 +29,18 @@ function ui::peer::list_row_compact() {
|
||||||
status_color="\033[1;32m"
|
status_color="\033[1;32m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local ls_color="\033[0;37m"
|
# Last seen mirrors status color
|
||||||
[[ "$status" == "online" ]] && ls_color="\033[1;32m"
|
local ls_color="$status_color"
|
||||||
|
|
||||||
local rule_val="${rule:--}"
|
local rule_val="${rule:--}"
|
||||||
local group_val="${group:--}"
|
local group_val="${group:--}"
|
||||||
|
|
||||||
# Pad name, ip, type — pure ASCII, safe for printf
|
|
||||||
local name_pad ip_pad type_pad status_pad
|
local name_pad ip_pad type_pad status_pad
|
||||||
name_pad=$(printf "%-${w_name}s" "$name")
|
name_pad=$(printf "%-${w_name}s" "$name")
|
||||||
ip_pad=$(printf "%-${w_ip}s" "$ip")
|
ip_pad=$(printf "%-${w_ip}s" "$ip")
|
||||||
type_pad=$(printf "%-${w_type}s" "$type")
|
type_pad=$(printf "%-${w_type}s" "$type")
|
||||||
status_pad=$(printf "%-8s" "$status")
|
status_pad=$(printf "%-8s" "$status")
|
||||||
|
|
||||||
# Padding for label+value fields — compute trailing spaces manually
|
|
||||||
# so ANSI codes in labels don't confuse printf width calculation
|
|
||||||
local rule_pad_n group_pad_n
|
local rule_pad_n group_pad_n
|
||||||
rule_pad_n=$(( w_rule - ${#rule_val} ))
|
rule_pad_n=$(( w_rule - ${#rule_val} ))
|
||||||
group_pad_n=$(( w_group - ${#group_val} ))
|
group_pad_n=$(( w_group - ${#group_val} ))
|
||||||
|
|
@ -130,12 +127,12 @@ function ui::peer::list_row_detailed() {
|
||||||
status_color="\033[1;32m"
|
status_color="\033[1;32m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local ls_color="\033[0;37m"
|
# Last seen mirrors status color
|
||||||
[[ "$status" == "online" ]] && ls_color="\033[1;32m"
|
local ls_color="$status_color"
|
||||||
|
|
||||||
local rule_val="${rule:-—}"
|
local rule_val="${rule:--}"
|
||||||
local group_val="${group:-—}"
|
local group_val="${group:--}"
|
||||||
local subnet_val="${subnet:-—}"
|
local subnet_val="${subnet:--}"
|
||||||
|
|
||||||
local name_pad ip_pad type_pad status_pad
|
local name_pad ip_pad type_pad status_pad
|
||||||
name_pad=$(printf "%-${w_name}s" "$name")
|
name_pad=$(printf "%-${w_name}s" "$name")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue