mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2026-05-25 04:52:45 +00:00
feat(taglist): show size with a decimal for images between 1 and 10
fixes #276
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user