Skip to content

Commit 017f662

Browse files
committed
feat(taglist): show size with a decimal for images between 1 and 10
fixes #276
1 parent ee93d5b commit 017f662

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

CONTRIBUTORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@
4141
- Enrico [@Enrico204](https://github.com/Enrico204)
4242
- [@clyvari](https://github.com/clyvari)
4343
- Laszlo Boros [@Semmu](https://github.com/Semmu)
44-
- [@JKDingwall](https://github.com/JKDingwall)
44+
- [@JKDingwall](https://github.com/JKDingwall)
45+
- Martin Herren [@MartinHerren](https://github.com/MartinHerren)

dist/docker-registry-ui.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docker-registry-ui",
3-
"version": "2.3.2",
3+
"version": "2.3.3",
44
"scripts": {
55
"format": "npm run format-html && npm run format-js && npm run format-riot",
66
"format-html": "find src rollup rollup.config.js -name '*.html' -exec prettier --config .prettierrc -w --parser html {} \\;",

src/scripts/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ export function bytesToSize(bytes) {
88
return '0 Byte';
99
}
1010
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
11-
return Math.ceil(bytes / Math.pow(1024, i)) + ' ' + sizes[i];
11+
const number = bytes / Math.pow(1024, i);
12+
if (number < 10) {
13+
const decimal = (bytes - Math.floor(number) * Math.pow(1024, i)) / Math.pow(1024, i);
14+
return `${Math.floor(number)}.${Math.floor(decimal * 10)} ${sizes[i]}`;
15+
}
16+
return Math.ceil(number) + ' ' + sizes[i];
1217
}
1318

1419
export function dateFormat(date) {

0 commit comments

Comments
 (0)