web: improve layout of storage status with a table
authorBrian Warner <warner@allmydata.com>
Fri, 27 Feb 2009 02:58:38 +0000 (19:58 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 27 Feb 2009 02:58:38 +0000 (19:58 -0700)
src/allmydata/test/test_storage.py
src/allmydata/web/storage.py
src/allmydata/web/storage_status.xhtml

index 770c6fd14d52be39e7750b860169cc5396a2f5cf..1d4b846e1798b5db2a2619eec2481547cf46b1ca 100644 (file)
@@ -1530,7 +1530,9 @@ class WebStatus(unittest.TestCase, pollmixin.PollMixin):
     def test_util(self):
         w = StorageStatus(None)
         self.failUnlessEqual(w.render_space(None, None), "?")
-        self.failUnlessEqual(w.render_space(None, 10e6), "10.00 MB (10000000)")
+        self.failUnlessEqual(w.render_space(None, 10e6), "10000000")
+        self.failUnlessEqual(w.render_abbrev_space(None, None), "?")
+        self.failUnlessEqual(w.render_abbrev_space(None, 10e6), "10.00 MB")
         self.failUnlessEqual(remove_prefix("foo.bar", "foo."), "bar")
         self.failUnlessEqual(remove_prefix("foo.bar", "baz."), None)
 
index c0ad5cbd0eb3455312d94be6b0216e3875146d2b..60774da11b2a7609f9230ad8296c579e37eb414c 100644 (file)
@@ -25,10 +25,15 @@ class StorageStatus(rend.Page):
     def render_bool(self, ctx, data):
         return {True: "Yes", False: "No"}[bool(data)]
 
+    def render_abbrev_space(self, ctx, size):
+        if size is None:
+            return "?"
+        return abbreviate_space(size)
+
     def render_space(self, ctx, size):
         if size is None:
             return "?"
-        return "%s (%d)" % (abbreviate_space(size), size)
+        return "%d" % size
 
     def data_stats(self, ctx, data):
         # FYI: 'data' appears to be self, rather than the StorageServer
index 379b23cd03453d12c94b676447f23dc0eb0f2bbd..2e570aaf2320d624d002aa30cbbaf957b9a5409a 100644 (file)
 
   <table n:data="stats">
     <tr><td>Total disk space:</td>
-        <td><span n:render="space" n:data="disk_total" /></td></tr>
+        <td><span n:render="abbrev_space" n:data="disk_total" /></td>
+        <td>(<span n:render="space" n:data="disk_total" />)</td>
+        <td />
+      </tr>
     <tr><td>Disk space used:</td>
-        <td>- <span n:render="space" n:data="disk_used" /></td></tr>
+        <td>- <span n:render="abbrev_space" n:data="disk_used" /></td>
+        <td>(<span n:render="space" n:data="disk_used" />)</td>
+        <td />
+      </tr>
     <tr><td />
-        <td>======</td></tr>
+        <td>======</td>
+        <td />
+        <td />
+      </tr>
     <tr><td>Disk space free (root):</td>
-        <td><span n:render="space" n:data="disk_free_for_root"/>
-          [see 1]</td></tr>
+        <td><span n:render="abbrev_space" n:data="disk_free_for_root"/></td>
+        <td>(<span n:render="space" n:data="disk_free_for_root"/>)</td>
+        <td>[see 1]</td>
+        </tr>
     <tr><td>Disk space free (non-root):</td>
-        <td><span n:render="space" n:data="disk_free_for_nonroot" />
-          [see 2]</td></tr>
+        <td><span n:render="abbrev_space" n:data="disk_free_for_nonroot" /></td>
+        <td>(<span n:render="space" n:data="disk_free_for_nonroot" />)</td>
+        <td>[see 2]</td>
+        </tr>
     <tr><td>Reserved space:</td>
-        <td>- <span n:render="space" n:data="reserved_space" /></td></tr>
+        <td>- <span n:render="abbrev_space" n:data="reserved_space" /></td>
+        <td>(<span n:render="space" n:data="reserved_space" />)</td>
+        <td />
+      </tr>
     <tr><td />
-        <td>======</td></tr>
+        <td>======</td>
+        <td />
+        <td />
+      </tr>
     <tr><td>Space Available to Tahoe:</td>
-        <td><span n:render="space" n:data="disk_avail" /></td></tr>
+        <td><span n:render="abbrev_space" n:data="disk_avail" /></td>
+        <td>(<span n:render="space" n:data="disk_avail" />)</td>
+        <td />
+      </tr>
   </table>
 
   <ul n:data="stats">