From 8251572e016b5f9049f845891a82c6a93589ea9a Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Thu, 26 Feb 2009 19:58:38 -0700
Subject: [PATCH] web: improve layout of storage status with a table

---
 src/allmydata/test/test_storage.py     |  4 ++-
 src/allmydata/web/storage.py           |  7 ++++-
 src/allmydata/web/storage_status.xhtml | 42 ++++++++++++++++++++------
 3 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py
index 770c6fd1..1d4b846e 100644
--- a/src/allmydata/test/test_storage.py
+++ b/src/allmydata/test/test_storage.py
@@ -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)
 
diff --git a/src/allmydata/web/storage.py b/src/allmydata/web/storage.py
index c0ad5cbd..60774da1 100644
--- a/src/allmydata/web/storage.py
+++ b/src/allmydata/web/storage.py
@@ -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
diff --git a/src/allmydata/web/storage_status.xhtml b/src/allmydata/web/storage_status.xhtml
index 379b23cd..2e570aaf 100644
--- a/src/allmydata/web/storage_status.xhtml
+++ b/src/allmydata/web/storage_status.xhtml
@@ -12,23 +12,45 @@
 
   <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">
-- 
2.45.2