From 8c522cf99908894fb81f066c1d2c198b4527c1ee Mon Sep 17 00:00:00 2001 From: Trevor Johnston Date: Mon, 11 Feb 2019 13:46:23 -0500 Subject: [PATCH] update to latest bytes, remove KB hack --- src/server_manager/package.json | 4 ++-- .../ui_components/outline-server-view.html | 7 +++---- yarn.lock | 14 ++++++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/server_manager/package.json b/src/server_manager/package.json index 99cf13aec..5a71ea3b3 100644 --- a/src/server_manager/package.json +++ b/src/server_manager/package.json @@ -11,7 +11,7 @@ "dependencies": { "@sentry/electron": "^0.8.1", "body-parser": "^1.18.3", - "bytes": "^3.0.0", + "bytes": "^3.1.0", "clipboard-polyfill": "^2.4.6", "electron-updater": "3.2.3", "eventemitter3": "^2.0.3", @@ -22,7 +22,7 @@ "request-lite": "^2.40.1" }, "devDependencies": { - "@types/bytes": "^2.5.1", + "@types/bytes": "^3.0.0", "@types/node-forge": "^0.6.9", "@types/request": "^2.47.1", "@types/semver": "^5.5.0", diff --git a/src/server_manager/ui_components/outline-server-view.html b/src/server_manager/ui_components/outline-server-view.html index 5015cdb29..0f2b2c145 100644 --- a/src/server_manager/ui_components/outline-server-view.html +++ b/src/server_manager/ui_components/outline-server-view.html @@ -671,12 +671,13 @@

Create keys, share access

} } }, - _formatBytesTransferred: function(numBytes, emptyValue = '') { + _formatBytesTransferred: function (numBytes, emptyValue = '') { if (!numBytes) { // numBytes may not be set for manual servers, or may be 0 for // unused access keys. return emptyValue; } + // Show 0 decimals for < 1MB, 1 decimal for >= 1MB, 2 decimals for >= 1GB. let numDecimals = 0; if (numBytes >= Math.pow(2, 30)) { @@ -685,9 +686,7 @@

Create keys, share access

numDecimals = 1; } - const bytesOptions = {unitSeparator: ' ', decimalPlaces: numDecimals}; - // Use uppercase to convert kB to KB (kB incorrectly implies 1000B) - return this.bytes(numBytes, bytesOptions).toUpperCase(); + return this.bytes(numBytes, { unitSeparator: ' ', decimalPlaces: numDecimals }); }, _getFormattedTransferredUnit: function(numBytes, emptyValue = '') { const formattedTransfer = this._formatBytesTransferred(numBytes); diff --git a/yarn.lock b/yarn.lock index b54a1e066..389689988 100644 --- a/yarn.lock +++ b/yarn.lock @@ -174,9 +174,10 @@ "@types/events" "*" "@types/node" "*" -"@types/bytes@^2.5.1": - version "2.5.1" - resolved "https://registry.yarnpkg.com/@types/bytes/-/bytes-2.5.1.tgz#392c42adb65e16d32328b82b58fbc1611b75da89" +"@types/bytes@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/bytes/-/bytes-3.0.0.tgz#549eeacd0a8fecfaa459334583a4edcee738e6db" + integrity sha512-ZF43+CIIlzngQe8/Zo7L1kpY9W8O6rO006VDz3c5iM21ddtXWxCEyOXyft+q4pVF2tGqvrVuVrEDH1+gJEi1fQ== "@types/caseless@*": version "0.12.1" @@ -915,10 +916,15 @@ bunyan@^1.4.0: mv "~2" safe-json-stringify "~1" -bytes@3.0.0, bytes@^3.0.0: +bytes@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" +bytes@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" + integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== + cached-path-relative@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.1.tgz#d09c4b52800aa4c078e2dd81a869aac90d2e54e7"