couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [18/47] couchdb commit: updated refs/heads/Update-Sidebar-Ui to c173e52
Date Mon, 19 May 2014 16:17:36 GMT
remove duplicated code

use the central viewhelper which even renders bytes


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a8ddf6ce
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a8ddf6ce
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a8ddf6ce

Branch: refs/heads/Update-Sidebar-Ui
Commit: a8ddf6ce4fd4158992aa8bbb528c498cd98225a5
Parents: 97d4a34
Author: Robert Kowalski <rok@kowalski.gd>
Authored: Wed Apr 30 13:38:40 2014 +0200
Committer: Robert Kowalski <rok@kowalski.gd>
Committed: Wed Apr 30 13:42:51 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/databases/resources.js     | 18 ------------------
 .../app/addons/databases/templates/item.html      |  2 +-
 2 files changed, 1 insertion(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a8ddf6ce/src/fauxton/app/addons/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/resources.js b/src/fauxton/app/addons/databases/resources.js
index f8aab96..e9e68a4 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -142,24 +142,6 @@ function(app, FauxtonAPI, Documents) {
       }
     },
 
-    humanSize: function() {
-      // cribbed from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable
-      var i = -1;
-      var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
-      var fileSizeInBytes = this.dataSize();
-
-      if (!fileSizeInBytes) {
-        return 0;
-      }
-
-      do {
-          fileSizeInBytes = fileSizeInBytes / 1024;
-          i++;
-      } while (fileSizeInBytes > 1024);
-
-      return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
-    },
-
     dataSize: function () {
       if (this.get("other")){
         return this.get("other").data_size;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a8ddf6ce/src/fauxton/app/addons/databases/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/templates/item.html b/src/fauxton/app/addons/databases/templates/item.html
index 304ab78..62cfb77 100644
--- a/src/fauxton/app/addons/databases/templates/item.html
+++ b/src/fauxton/app/addons/databases/templates/item.html
@@ -15,7 +15,7 @@ the License.
 <td>
   <a href="#/database/<%=encoded%>/_all_docs"><%= database.get("name") %></a>
 </td>
-<td><%= database.status.humanSize() %></td>
+<td><%= formatSize(database.status.dataSize()) %></td>
 <td>
   <%= database.status.numDocs() %>
   <% if (database.status.isGraveYard()) { %>


Mime
View raw message