Skip to content

Commit

Permalink
Improved propagation peer list display
Browse files Browse the repository at this point in the history
  • Loading branch information
markqvist committed Sep 19, 2023
1 parent 92c3c55 commit da348c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions nomadnet/ui/TextUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
("list_normal", "dark gray", "default", "default", "#bbb", "default"),
("list_untrusted", "dark red", "default", "default", "#a22", "default"),
("list_focus_untrusted", "black", "light gray", "standout", "#810", "#aaa"),
("list_unresponsive", "yellow", "default", "default", "#b92", "default"),
("list_focus_unresponsive", "black", "light gray", "standout", "#530", "#aaa"),
("topic_list_normal", "light gray", "default", "default", "#ddd", "default"),
("browser_controls", "light gray", "default", "default", "#bbb", "default"),
("progress_full", "black", "light gray", "standout", "#111", "#bbb"),
Expand Down Expand Up @@ -78,6 +80,8 @@
("list_normal", "dark gray", "default", "default", "#444", "default"),
("list_untrusted", "dark red", "default", "default", "#a22", "default"),
("list_focus_untrusted", "black", "dark gray", "standout", "#810", "#aaa"),
("list_unresponsive", "yellow", "default", "default", "#b92", "default"),
("list_focus_unresponsive", "black", "light gray", "standout", "#530", "#aaa"),
("topic_list_normal", "dark gray", "default", "default", "#222", "default"),
("browser_controls", "dark gray", "default", "default", "#444", "default"),
("progress_full", "black", "dark gray", "standout", "#111", "#bbb"),
Expand Down
16 changes: 12 additions & 4 deletions nomadnet/ui/textui/Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,11 @@ def __init__(self, app):
self.pile = urwid.Pile([urwid.Text(("warning_text", g["info"]+"\n"), align="center"), SelectText(("warning_text", "Currently, no LXMF nodes are peered\n\n"), align="center")])
self.display_widget = urwid.Filler(self.pile, valign="top", height="pack")

urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title="LXMF Propagation Peers"), widget_style))
if hasattr(self, "peer_list") and self.peer_list:
pl = len(self.peer_list)
else:
pl = 0
urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title=f"LXMF Propagation Peers ({pl})"), widget_style))

def keypress(self, size, key):
if key == "up" and (self.no_content or self.ilb.first_item_is_selected()):
Expand Down Expand Up @@ -1611,13 +1615,13 @@ def rebuild_widget_list(self):

def make_peer_widgets(self):
widget_list = []
for peer_id in self.peer_list:
sorted_peers = sorted(self.peer_list, key=lambda pid: self.peer_list[pid].link_establishment_rate, reverse=True)
for peer_id in sorted_peers:
peer = self.peer_list[peer_id]
pe = LXMFPeerEntry(self.app, peer, self)
pe.destination_hash = peer.destination_hash
widget_list.append(pe)

# TODO: Sort list
return widget_list

class LXMFPeerEntry(urwid.WidgetWrap):
Expand All @@ -1633,7 +1637,7 @@ def __init__(self, app, peer, delegate):
node_hash = RNS.Destination.hash_from_name_and_identity("nomadnetwork.node", node_identity)
display_name = self.app.directory.alleged_display_str(node_hash)
if display_name != None:
display_str += " "+str(display_name)
display_str = str(display_name)+"\n "+display_str

sym = g["sent"]
style = "list_unknown"
Expand All @@ -1643,8 +1647,12 @@ def __init__(self, app, peer, delegate):
if hasattr(peer, "alive"):
if peer.alive:
alive_string = "Available"
style = "list_normal"
focus_style = "list_focus"
else:
alive_string = "Unresponsive"
style = "list_unresponsive"
focus_style = "list_focus_unresponsive"

widget = ListEntry(sym+" "+display_str+"\n "+alive_string+", last heard "+pretty_date(int(peer.last_heard))+"\n "+str(len(peer.unhandled_messages))+" unhandled LXMs, "+RNS.prettysize(peer.link_establishment_rate/8, "b")+"/s LER")
# urwid.connect_signal(widget, "click", delegate.connect_node, node)
Expand Down

0 comments on commit da348c3

Please sign in to comment.