KYLIN-1423 fix HBase size precision issue

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

Branch: refs/heads/1.4-rc
Commit: 04d468681bd1578892d331e17a3e6cd4d0b2cd33
Parents: e3e82a6
Author: janzhongi <[email protected]>
Authored: Wed Feb 17 16:08:57 2016 +0800
Committer: janzhongi <[email protected]>
Committed: Wed Feb 17 16:09:18 2016 +0800

----------------------------------------------------------------------
 webapp/app/js/filters/filter.js            | 16 ++++++++++++++--
 webapp/app/partials/cubes/cube_detail.html |  4 ++--
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/04d46868/webapp/app/js/filters/filter.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/filters/filter.js b/webapp/app/js/filters/filter.js
index 1b0590c..3f1d8d3 100755
--- a/webapp/app/js/filters/filter.js
+++ b/webapp/app/js/filters/filter.js
@@ -83,7 +83,7 @@ KylinApp
   .filter('bytes', function () {
     return function (bytes, precision) {
       if (bytes === 0) {
-        return '0 bytes'
+        return 'N/A'
       }
       ;
       if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) {
@@ -96,7 +96,19 @@ KylinApp
 
       var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
         number = Math.floor(Math.log(bytes) / Math.log(1024));
-      return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + 
' ' + units[number];
+      switch(number){
+        case 0:
+          precision = 0;
+          break;
+        case 1:
+        case 2:
+          precision = 3;
+          break;
+        default:
+          precision = 5;
+      }
+
+      return Math.round((bytes / Math.pow(1024, 
Math.floor(number)))*Math.pow(10,precision))/Math.pow(10,precision) + ' ' + 
units[number];
     }
   }).filter('resizePieHeight', function () {
     return function (item) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/04d46868/webapp/app/partials/cubes/cube_detail.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubes/cube_detail.html 
b/webapp/app/partials/cubes/cube_detail.html
index 0a94ea8..1788870 100755
--- a/webapp/app/partials/cubes/cube_detail.html
+++ b/webapp/app/partials/cubes/cube_detail.html
@@ -98,14 +98,14 @@
                 <h5><b>HTable:</b> {{table.tableName}}</h5>
                 <ul>
                     <li>Region Count: <span 
class="red">{{table.regionCount}}</span></li>
-                    <li>Size: <span class="red">{{table.tableSize | 
bytes:5}}</span></li>
+                    <li>Size: <span class="red">{{table.tableSize | 
bytes}}</span></li>
                     <li>Start Time: <span class="red">{{table.dateRangeStart | 
reverseToGMT0}}</span></li>
                     <li>End Time: <span class="red">{{table.dateRangeEnd | 
reverseToGMT0}}</span></li>
                 </ul>
             </div>
             <div ng-if="cube.hbase">
                 <div class="hr hr8 hr-double hr-dotted"></div>
-                <h5><b>Total Size:</b> <span class="red">{{cube.totalSize | 
bytes:5}}</span></h5>
+                <h5><b>Total Size:</b> <span class="red">{{cube.totalSize | 
bytes}}</span></h5>
                 <h5><b>Total Number:</b> <span 
class="red">{{cube.hbase.length}}</span></h5>
             </div>
             <div ng-if="cube.hbase.length == 0">

Reply via email to