Commit 2dd41162 by kevalbhatt

ATLAS-3795:- UI: statistics Memory Section should have suffix like Bytes /KB /MB

parent 2228d752
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment