Skip to content

Commit

Permalink
feat(taglist): show size with a decimal for images between 1 and 10
Browse files Browse the repository at this point in the history
fixes #276
  • Loading branch information
Joxit committed Nov 26, 2022
1 parent ee93d5b commit 017f662
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
- Enrico [@Enrico204](https://github.com/Enrico204)
- [@clyvari](https://github.com/clyvari)
- Laszlo Boros [@Semmu](https://github.com/Semmu)
- [@JKDingwall](https://github.com/JKDingwall)
- [@JKDingwall](https://github.com/JKDingwall)
- Martin Herren [@MartinHerren](https://github.com/MartinHerren)
2 changes: 1 addition & 1 deletion dist/docker-registry-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docker-registry-ui",
"version": "2.3.2",
"version": "2.3.3",
"scripts": {
"format": "npm run format-html && npm run format-js && npm run format-riot",
"format-html": "find src rollup rollup.config.js -name '*.html' -exec prettier --config .prettierrc -w --parser html {} \\;",
Expand Down
7 changes: 6 additions & 1 deletion src/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export function bytesToSize(bytes) {
return '0 Byte';
}
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.ceil(bytes / Math.pow(1024, i)) + ' ' + sizes[i];
const number = bytes / Math.pow(1024, i);
if (number < 10) {
const decimal = (bytes - Math.floor(number) * Math.pow(1024, i)) / Math.pow(1024, i);
return `${Math.floor(number)}.${Math.floor(decimal * 10)} ${sizes[i]}`;
}
return Math.ceil(number) + ' ' + sizes[i];
}

export function dateFormat(date) {
Expand Down

0 comments on commit 017f662

Please sign in to comment.