mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
Show the connection-status of all hints until we're connected to one
This commit is contained in:
parent
8b35fe9efe
commit
74209e643e
@ -6,12 +6,13 @@ from ..interfaces import IConnectionStatus
|
||||
class ConnectionStatus:
|
||||
def __init__(self, connected, summary,
|
||||
last_connection_description, last_connection_time,
|
||||
last_received_time):
|
||||
last_received_time, statuses):
|
||||
self.connected = connected
|
||||
self.last_connection_summary = summary
|
||||
self.last_connection_description = last_connection_description
|
||||
self.last_connection_time = last_connection_time
|
||||
self.last_received_time = last_received_time
|
||||
self.statuses = statuses
|
||||
|
||||
def _describe_statuses(hints, handlers, statuses):
|
||||
descriptions = []
|
||||
@ -77,5 +78,5 @@ def from_foolscap_reconnector(rc, last_received):
|
||||
last_connected = None
|
||||
|
||||
cs = ConnectionStatus(connected, summary, details,
|
||||
last_connected, last_received)
|
||||
last_connected, last_received, statuses)
|
||||
return cs
|
||||
|
@ -1,11 +1,14 @@
|
||||
import time, os
|
||||
from datetime import datetime
|
||||
|
||||
from twisted.web import http
|
||||
from nevow import rend, url, tags as T
|
||||
from nevow.inevow import IRequest
|
||||
from nevow.inevow import IRequest, IContainer
|
||||
from nevow.static import File as nevow_File # TODO: merge with static.File?
|
||||
from nevow.util import resource_filename
|
||||
|
||||
from zope.interface import implementer
|
||||
|
||||
import allmydata # to display import path
|
||||
from allmydata import get_package_versions_string
|
||||
from allmydata.util import log
|
||||
@ -14,6 +17,7 @@ from allmydata.web import filenode, directory, unlinked, status, operations
|
||||
from allmydata.web import storage, magic_folder
|
||||
from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
|
||||
get_arg, RenderMixin, get_format, get_mutable_type, render_time_delta, render_time, render_time_attr
|
||||
from allmydata.util.abbreviate import abbreviate_time
|
||||
|
||||
|
||||
class URIHandler(RenderMixin, rend.Page):
|
||||
@ -329,7 +333,40 @@ class Root(rend.Page):
|
||||
|
||||
def data_services(self, ctx, data):
|
||||
sb = self.client.get_storage_broker()
|
||||
return sorted(sb.get_known_servers(), key=lambda s: s.get_serverid())
|
||||
|
||||
@implementer(IContainer)
|
||||
class Wrapper(object):
|
||||
"""
|
||||
This provides IContainer to Nevow so we can provide a 'child' data
|
||||
at 'connections' and pass-through all the
|
||||
connection-status attributes to the rest of the renderers
|
||||
"""
|
||||
def __init__(self, server):
|
||||
self._server = server
|
||||
|
||||
def child(self, context, name):
|
||||
if name == 'connections':
|
||||
st = self._server.get_connection_status()
|
||||
if st.connected:
|
||||
# we don't want the list of all possible hints
|
||||
# when we're already connected; then we just
|
||||
# show the one connection
|
||||
return []
|
||||
return st.statuses.items()
|
||||
return None # or are we supposed to raise something?
|
||||
|
||||
def __getattr__(self, x):
|
||||
return getattr(self._server, x)
|
||||
|
||||
return [
|
||||
Wrapper(x)
|
||||
for x in sorted(sb.get_known_servers(), key=lambda s: s.get_serverid())
|
||||
]
|
||||
|
||||
def render_connection_item(self, ctx, server):
|
||||
ctx.tag.fillSlots('details', server[1])
|
||||
ctx.tag.fillSlots('summary', '{}: {}'.format(server[0], server[1]))
|
||||
return ctx.tag
|
||||
|
||||
def render_service_row(self, ctx, server):
|
||||
cs = server.get_connection_status()
|
||||
|
@ -72,7 +72,7 @@
|
||||
<input type="file" class="freeform-input-file" name="file" />
|
||||
<input type="hidden" name="t" value="upload" />
|
||||
|
||||
<label for="upload-chk" class="radio">
|
||||
<label for="upload-chk" class="radio">
|
||||
<input type="radio" checked="checked" id="upload-chk" value="chk" name="format" />
|
||||
Immutable
|
||||
</label>
|
||||
@ -95,7 +95,7 @@
|
||||
<div class="nav-header">Create Directory</div>
|
||||
<div class="nav-form">
|
||||
<form action="uri" method="post" enctype="multipart/form-data">
|
||||
<label for="mkdir-sdmf" class="radio">
|
||||
<label for="mkdir-sdmf" class="radio">
|
||||
<input type="radio" checked="checked" id="mkdir-sdmf" value="sdmf" name="format" />
|
||||
<acronym title="Small Distributed Mutable File">SDMF</acronym>
|
||||
</label>
|
||||
@ -189,12 +189,18 @@
|
||||
<div class="nodeid"><n:slot name="peerid"/></div>
|
||||
</td>
|
||||
<td class="connection-status">
|
||||
|
||||
<n:attr name="title"><n:slot name="details"/></n:attr>
|
||||
<n:slot name="summary"/>
|
||||
<a class="timestamp">
|
||||
<n:attr name="title"><n:slot name="service_connection_status_abs_time"/></n:attr>
|
||||
<n:slot name="service_connection_status_rel_time"/>
|
||||
</a>
|
||||
|
||||
<ul n:render="sequence" n:data="connections" class="details">
|
||||
<li n:pattern="item" n:render="connection_item"><n:attr name="title"><n:slot name="details"/></n:attr><n:slot name="summary"/></li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
<td class="service-last-received-data"><a class="timestamp"><n:attr name="title"><n:slot name="last_received_data_abs_time"/></n:attr><n:slot name="last_received_data_rel_time"/></a></td>
|
||||
<td class="service-version"><n:slot name="version"/></td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user