nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

View File

@@ -7,12 +7,18 @@
const SizeFormatHelpers = exports;
SizeFormatHelpers.formatSize = size => {
if(size <= 0) {
if (typeof size !== "number" || Number.isNaN(size) === true) {
return "unknown size";
}
if (size <= 0) {
return "0 bytes";
}
const abbreviations = ["bytes", "kB", "MB", "GB"];
const index = Math.floor(Math.log(size) / Math.log(1000));
const abbreviations = ["bytes", "KiB", "MiB", "GiB"];
const index = Math.floor(Math.log(size) / Math.log(1024));
return `${+(size / Math.pow(1000, index)).toPrecision(3)} ${abbreviations[index]}`;
return `${+(size / Math.pow(1024, index)).toPrecision(3)} ${
abbreviations[index]
}`;
};