]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: add /status page to display current uploads/downloads
authorBrian Warner <warner@allmydata.com>
Tue, 12 Feb 2008 22:40:05 +0000 (15:40 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 12 Feb 2008 22:40:05 +0000 (15:40 -0700)
src/allmydata/web/status.xhtml [new file with mode: 0644]
src/allmydata/web/welcome.xhtml
src/allmydata/webish.py

diff --git a/src/allmydata/web/status.xhtml b/src/allmydata/web/status.xhtml
new file mode 100644 (file)
index 0000000..7b331ef
--- /dev/null
@@ -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>
index ecd35496d8816b87ba132e3f99cb793286ce13c4..485059a0d16d0a4c5ba0bcb60a09876889749fd9 100644 (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>
 
index 4c2c5abe2f2ff93d2eb4ef2a709084f644c2b2c4..e5abc8aa7b6556aa362ee7ca68148928906cf90d 100644 (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()