Render introducers table using SlotsSequenceElement

This commit is contained in:
Sajith Sasidharan 2020-05-01 16:12:52 -04:00
parent 1ddf07d59d
commit 029c99a241
2 changed files with 29 additions and 13 deletions

View File

@ -426,12 +426,6 @@ class RootElement(Element):
tag.fillSlots(summary=[cs.summary, details])
tag.fillSlots(details="")
@renderer
def introducers_row(self, req, tag):
for cs in self._get_introducers():
self._render_connection_status(tag, cs)
return tag
@renderer
def helper_furl_prefix(self, req, tag):
try:
@ -487,6 +481,12 @@ class RootElement(Element):
rows = [ self._describe_server(server) for server in self._services() ]
return SlotsSequenceElement(tag, rows)
@renderer
def introducers_table(self, req, tag):
rows = [ self._describe_connection_status(cs)
for cs in self._get_introducers() ]
return SlotsSequenceElement(tag, rows)
def _services(self):
sb = self._client.get_storage_broker()
return sorted(sb.get_known_servers(), key=lambda s: s.get_serverid())
@ -502,7 +502,19 @@ class RootElement(Element):
else:
available_space = "N/A"
srvstat = {
"peerid": peerid,
"nickname": nickname,
"version": version,
"available_space": available_space,
}
cs = server.get_connection_status()
constat = self._describe_connection_status(cs)
return dict(srvstat.items() + constat.items())
def _describe_connection_status(self, cs):
others = cs.non_connected_statuses
if cs.connected:
@ -541,10 +553,6 @@ class RootElement(Element):
last_received_data_rel_time = "N/A"
return {
"peerid": peerid,
"nickname": nickname,
"version": version,
"available_space": available_space,
"summary": summary,
"details": details,
"service_connection_status": connected,

View File

@ -231,14 +231,17 @@
<div class="row-fluid">
<h2>Connected to <span t:render="connected_introducers" /> of <span t:render="total_introducers" /> introducers</h2>
</div>
<table class="table table-striped table-bordered peer-status" t:render="introducers">
<!-- table with introducers status -->
<table class="table table-striped table-bordered peer-status" t:render="introducers_table">
<thead>
<tr t:pattern="header">
<td><h3>Connection</h3></td>
<td><h3>Last RX</h3></td>
</tr>
</thead>
<tr t:pattern="item" t:render="introducers_row">
<tr t:render="item">
<!-- Connection -->
<td class="nickname-and-peerid">
<div class="status-indicator">
<img>
@ -257,6 +260,7 @@
<t:slot name="summary"/>
</div>
</td>
<!-- Last RX -->
<td class="service-last-received-data">
<a class="timestamp">
<t:attr name="title"><t:slot name="last_received_data_abs_time"/></t:attr>
@ -264,7 +268,11 @@
</a>
</td>
</tr>
<tr t:pattern="empty"><td colspan="2">No introducers are configured.</td></tr>
<tr t:render="empty">
<td colspan="2">
No introducers are configured.
</td>
</tr>
</table>
</div><!--/span-->
</div><!--/row-->