webish: add /status page to display current uploads/downloads

This commit is contained in:
Brian Warner 2008-02-12 15:40:05 -07:00
parent e6af3b845c
commit b17b7695a4
3 changed files with 101 additions and 1 deletions

View File

@ -0,0 +1,59 @@
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
<head>
<title>AllMyData - Tahoe - Current Uploads/Downloads</title>
<!-- <link href="http://www.allmydata.com/common/css/styles.css"
rel="stylesheet" type="text/css"/> -->
<link href="/webform_css" rel="stylesheet" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Current Uploads and Downloads</h1>
<h2>Current Uploads:</h2>
<table n:render="sequence" n:data="uploads" border="1">
<tr n:pattern="header">
<td>Storage Index</td>
<td>Helper?</td>
<td>Total Size</td>
<td>Progress (Hash)</td>
<td>Progress (Ciphertext)</td>
<td>Progress (Encode+Push)</td>
<td>Status</td>
</tr>
<tr n:pattern="item" n:render="row_upload">
<td><n:slot name="si"/></td>
<td><n:slot name="helper"/></td>
<td><n:slot name="total_size"/></td>
<td><n:slot name="progress_hash"/></td>
<td><n:slot name="progress_ciphertext"/></td>
<td><n:slot name="progress_encode"/></td>
<td><n:slot name="status"/></td>
</tr>
<tr n:pattern="empty"><td>No current uploads!</td></tr>
</table>
<h2>Current Downloads:</h2>
<table n:render="sequence" n:data="downloads" border="1">
<tr n:pattern="header">
<td>Storage Index</td>
<td>Helper?</td>
<td>Total Size</td>
<td>Progress</td>
<td>Status</td>
</tr>
<tr n:pattern="item" n:render="row_download">
<td><n:slot name="si"/></td>
<td><n:slot name="helper"/></td>
<td><n:slot name="total_size"/></td>
<td><n:slot name="progress"/></td>
<td><n:slot name="status"/></td>
</tr>
<tr n:pattern="empty"><td>No current uploads!</td></tr>
</table>
<div>Return to the <a href="/">Welcome Page</a></div>
</body>
</html>

View File

@ -12,7 +12,8 @@
<div>Please visit the <a href="http://allmydata.org">Tahoe home page</a> for
code updates and bug reporting. The <a href="provisioning">provisioning
tool</a> may also be useful.</div>
tool</a> may also be useful. <a href="status">Current Uploads and
Downloads</a></div>
<h2>Grid Status</h2>

View File

@ -1493,6 +1493,45 @@ class UnlinkedPOSTCreateDirectory(rend.Page):
d.addCallback(lambda dirnode: dirnode.get_uri())
return d
class Status(rend.Page):
docFactory = getxmlfile("status.xhtml")
def data_uploads(self, ctx, data):
return IClient(ctx).list_uploads()
def data_downloads(self, ctx, data):
return IClient(ctx).list_downloads()
def _render_common(self, ctx, data):
s = data
si_s = idlib.b2a_or_none(s.get_storage_index())
if si_s is None:
si_s = "(None)"
ctx.fillSlots("si", si_s)
ctx.fillSlots("helper", {True: "Yes",
False: "No"}[s.using_helper()])
size = s.get_size()
if size is None:
size = "(unknown)"
ctx.fillSlots("total_size", size)
ctx.fillSlots("status", s.get_status())
def render_row_upload(self, ctx, data):
self._render_common(ctx, data)
(chk, ciphertext, encandpush) = data.get_progress()
# TODO: make an ascii-art bar
ctx.fillSlots("progress_hash", "%.1f%%" % (100.0 * chk))
ctx.fillSlots("progress_ciphertext", "%.1f%%" % (100.0 * ciphertext))
ctx.fillSlots("progress_encode", "%.1f%%" % (100.0 * encandpush))
return ctx.tag
def render_row_download(self, ctx, data):
self._render_common(ctx, data)
progress = data.get_progress()
# TODO: make an ascii-art bar
ctx.fillSlots("progress", "%.1f%%" % (100.0 * progress))
return ctx.tag
class Root(rend.Page):
@ -1569,6 +1608,7 @@ class Root(rend.Page):
child_tahoe_css = nevow_File(resource_filename('allmydata.web', 'tahoe.css'))
child_provisioning = provisioning.ProvisioningTool()
child_status = Status()
def data_version(self, ctx, data):
return get_package_versions_string()