Skip to content

Commit

Permalink
update to latest bytes, remove KB hack
Browse files Browse the repository at this point in the history
  • Loading branch information
trevj committed Feb 11, 2019
1 parent 8211a48 commit 8c522cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/server_manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions src/server_manager/ui_components/outline-server-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,13 @@ <h3>Create keys, share access</h3>
}
}
},
_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)) {
Expand All @@ -685,9 +686,7 @@ <h3>Create keys, share access</h3>
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);
Expand Down
14 changes: 10 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8c522cf

Please sign in to comment.