feat(taglist): show size with a decimal for images between 1 and 10

fixes #276
This commit is contained in:
Joxit 2022-11-26 22:41:29 +01:00
parent ee93d5bba8
commit 017f6620f0
No known key found for this signature in database
GPG key ID: F526592B8E012263
4 changed files with 10 additions and 4 deletions

View file

@ -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)

File diff suppressed because one or more lines are too long

View file

@ -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 {} \\;",

View file

@ -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) {