You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by kb...@apache.org on 2020/05/21 16:49:23 UTC

[atlas] 03/05: ATLAS-3795:- UI: statistics Memory Section should have suffix like Bytes /KB /MB

This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 2dd41162b1832a1f574a28567289772fa21d65af
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Thu May 21 14:43:56 2020 +0530

    ATLAS-3795:- UI: statistics Memory Section should have suffix like Bytes /KB /MB
---
 dashboardv2/public/js/utils/Helper.js          | 14 ++++++++++++++
 dashboardv2/public/js/views/site/Statistics.js |  3 ++-
 dashboardv3/public/js/utils/Helper.js          | 14 ++++++++++++++
 dashboardv3/public/js/views/site/Statistics.js |  3 ++-
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/dashboardv2/public/js/utils/Helper.js b/dashboardv2/public/js/utils/Helper.js
index dc36766..931c45d 100644
--- a/dashboardv2/public/js/utils/Helper.js
+++ b/dashboardv2/public/js/utils/Helper.js
@@ -26,6 +26,20 @@ define(['require',
         numberFormatWithComa: function(number) {
             return d3.format(',')(number);
         },
+        numberFormatWithBytes: function(number) {
+            if (number > -1) {
+                if (number === 0) {
+                    return "0 Bytes";
+                }
+                var i = number == 0 ? 0 : Math.floor(Math.log(number) / Math.log(1024));
+                if (i > 8) {
+                    return _.numberFormatWithComa(number);
+                }
+                return Number((number / Math.pow(1024, i)).toFixed(2)) + " " + ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][i];
+            } else {
+                return number;
+            }
+        },
         isEmptyArray: function(val) {
             if (val && _.isArray(val)) {
                 return _.isEmpty(val);
diff --git a/dashboardv2/public/js/views/site/Statistics.js b/dashboardv2/public/js/views/site/Statistics.js
index 8fef47d..db8c92f 100644
--- a/dashboardv2/public/js/views/site/Statistics.js
+++ b/dashboardv2/public/js/views/site/Statistics.js
@@ -477,7 +477,8 @@ define(['require',
                     var memoryTable = CommonViewFunction.propertyTable({
                         scope: this,
                         formatStringVal: true,
-                        valueObject: systemMemoryData
+                        valueObject: systemMemoryData,
+                        numberFormat: _.numberFormatWithBytes
                     });
                     that.ui.memoryCard.html(
                         memoryTable);
diff --git a/dashboardv3/public/js/utils/Helper.js b/dashboardv3/public/js/utils/Helper.js
index 9c4bc73..8f97a84 100644
--- a/dashboardv3/public/js/utils/Helper.js
+++ b/dashboardv3/public/js/utils/Helper.js
@@ -27,6 +27,20 @@ define(['require',
         numberFormatWithComa: function(number) {
             return d3.format(',')(number);
         },
+        numberFormatWithBytes: function(number) {
+            if (number > -1) {
+                if (number === 0) {
+                    return "0 Bytes";
+                }
+                var i = number == 0 ? 0 : Math.floor(Math.log(number) / Math.log(1024));
+                if (i > 8) {
+                    return _.numberFormatWithComa(number);
+                }
+                return Number((number / Math.pow(1024, i)).toFixed(2)) + " " + ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][i];
+            } else {
+                return number;
+            }
+        },
         isEmptyArray: function(val) {
             if (val && _.isArray(val)) {
                 return _.isEmpty(val);
diff --git a/dashboardv3/public/js/views/site/Statistics.js b/dashboardv3/public/js/views/site/Statistics.js
index 2b8bd1f..75e11b0 100644
--- a/dashboardv3/public/js/views/site/Statistics.js
+++ b/dashboardv3/public/js/views/site/Statistics.js
@@ -384,7 +384,8 @@ define(['require',
                     var memoryTable = CommonViewFunction.propertyTable({
                         scope: this,
                         formatStringVal: true,
-                        valueObject: systemMemoryData
+                        valueObject: systemMemoryData,
+                        numberFormat: _.numberFormatWithBytes
                     });
                     that.ui.memoryCard.html(
                         memoryTable);