mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 04:57:54 +00:00
webish: show vdrive and introducer connectedness separately
Also don't offer a link to the vdrive webpages if we don't have a vdrive.furl
This commit is contained in:
parent
956d5ae256
commit
363ed1264a
@ -36,7 +36,7 @@ class Client(node.Node, Referenceable):
|
||||
node.Node.__init__(self, basedir)
|
||||
self.my_furl = None
|
||||
self.introducer_client = None
|
||||
self.connected_to_vdrive = False
|
||||
self._connected_to_vdrive = False
|
||||
self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR)))
|
||||
self.add_service(Uploader())
|
||||
self.add_service(Downloader())
|
||||
@ -113,12 +113,12 @@ class Client(node.Node, Referenceable):
|
||||
def _got_vdrive(self, vdrive_root):
|
||||
# vdrive_root implements RIMutableDirectoryNode
|
||||
self.log("connected to vdrive")
|
||||
self.connected_to_vdrive = True
|
||||
self._connected_to_vdrive = True
|
||||
self.getServiceNamed("vdrive").set_root(vdrive_root)
|
||||
if "webish" in self.namedServices:
|
||||
self.getServiceNamed("webish").set_root_dirnode(vdrive_root)
|
||||
def _disconnected():
|
||||
self.connected_to_vdrive = False
|
||||
self._connected_to_vdrive = False
|
||||
vdrive_root.notifyOnDisconnect(_disconnected)
|
||||
|
||||
def remote_get_versions(self):
|
||||
@ -137,6 +137,8 @@ class Client(node.Node, Referenceable):
|
||||
|
||||
|
||||
def get_all_peerids(self):
|
||||
if not self.introducer_client:
|
||||
return []
|
||||
return self.introducer_client.connections.iterkeys()
|
||||
|
||||
def get_permuted_peers(self, key):
|
||||
@ -150,3 +152,11 @@ class Client(node.Node, Referenceable):
|
||||
results.append((permuted, peerid, connection))
|
||||
results.sort()
|
||||
return results
|
||||
|
||||
def connected_to_vdrive(self):
|
||||
return self._connected_to_vdrive
|
||||
|
||||
def connected_to_introducer(self):
|
||||
if self.introducer_client:
|
||||
return self.introducer_client.connected_to_introducer()
|
||||
return False
|
||||
|
@ -39,6 +39,7 @@ class IntroducerClient(service.Service, Referenceable):
|
||||
|
||||
self.connections = {} # k: nodeid, v: ref
|
||||
self.reconnectors = {} # k: FURL, v: reconnector
|
||||
self._connected = False
|
||||
|
||||
self.connection_observers = observer.ObserverList()
|
||||
|
||||
@ -94,12 +95,19 @@ class IntroducerClient(service.Service, Referenceable):
|
||||
|
||||
def _got_introducer(self, introducer):
|
||||
self.log(" introducing ourselves: %s, %s" % (self, self.my_furl))
|
||||
self._connected = True
|
||||
d = introducer.callRemote("hello",
|
||||
node=self,
|
||||
furl=self.my_furl)
|
||||
introducer.notifyOnDisconnect(self._disconnected)
|
||||
|
||||
def _disconnected(self):
|
||||
self._connected = False
|
||||
|
||||
def notify_on_new_connection(self, cb):
|
||||
"""Register a callback that will be fired (with nodeid, rref) when
|
||||
a new connection is established."""
|
||||
self.connection_observers.subscribe(cb)
|
||||
|
||||
def connected_to_introducer(self):
|
||||
return self._connected
|
||||
|
@ -10,13 +10,14 @@
|
||||
|
||||
<h1>Welcome To AllMyData! (tahoe2)</h1>
|
||||
|
||||
<p>To view the global shared filestore, <a href="../vdrive">Click Here!</a></p>
|
||||
<div n:render="vdrive" />
|
||||
|
||||
<h2>Grid Status</h2>
|
||||
|
||||
<div>My nodeid: <span n:render="string" n:data="my_nodeid" /></div>
|
||||
<div>Introducer: <span n:render="string" n:data="introducer_furl" /></div>
|
||||
<div>Connected to introducer?: <span n:render="string" n:data="connected_to_introducer" /></div>
|
||||
<div>Connected to vdrive?: <span n:render="string" n:data="connected_to_vdrive" /></div>
|
||||
<div>Known+Connected Peers: <span n:render="string" n:data="num_peers" /></div>
|
||||
|
||||
<div>
|
||||
|
@ -33,7 +33,11 @@ class Welcome(rend.Page):
|
||||
def data_introducer_furl(self, ctx, data):
|
||||
return IClient(ctx).introducer_furl
|
||||
def data_connected_to_introducer(self, ctx, data):
|
||||
if IClient(ctx).connected_to_vdrive:
|
||||
if IClient(ctx).connected_to_introducer():
|
||||
return "yes"
|
||||
return "no"
|
||||
def data_connected_to_vdrive(self, ctx, data):
|
||||
if IClient(ctx).connected_to_vdrive():
|
||||
return "yes"
|
||||
return "no"
|
||||
def data_num_peers(self, ctx, data):
|
||||
@ -54,6 +58,13 @@ class Welcome(rend.Page):
|
||||
ctx.fillSlots("peerid", nodeid_a)
|
||||
return ctx.tag
|
||||
|
||||
def render_vdrive(self, ctx, data):
|
||||
if IClient(ctx).connected_to_vdrive():
|
||||
return T.p["To view the global shared filestore, ",
|
||||
T.a(href="../vdrive")["Click Here!"],
|
||||
]
|
||||
return T.p["vdrive.furl not specified, no vdrive available."]
|
||||
|
||||
# this is a form where users can download files by URI
|
||||
|
||||
def bind_download(self, ctx):
|
||||
|
Loading…
Reference in New Issue
Block a user