From ffd0a7c628c307cb60dc1c975fdd1674f3d555f3 Mon Sep 17 00:00:00 2001 From: Joxit Date: Fri, 14 Dec 2018 21:57:42 +0100 Subject: [PATCH] [fix-image-history] Move byteToSize in app.tag and use it in image history. Better render for created_by --- src/tags/app.tag | 11 +++++++++++ src/tags/image-size.tag | 12 +----------- src/tags/tag-history.tag | 9 ++++++++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/tags/app.tag b/src/tags/app.tag index c825e42..4cd772c 100644 --- a/src/tags/app.tag +++ b/src/tags/app.tag @@ -222,6 +222,17 @@ along with this program. If not, see . oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json'); oReq.send(); }; + + registryUI.bytesToSize = function (bytes) { + var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; + if (bytes == undefined || isNaN(bytes)) { + return '?'; + } else if (bytes == 0) { + return '0 Byte'; + } + var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); + return Math.ceil(bytes / Math.pow(1024, i)) + ' ' + sizes[i]; + }; route.start(true); \ No newline at end of file diff --git a/src/tags/image-size.tag b/src/tags/image-size.tag index bd3443a..0f7d1cd 100644 --- a/src/tags/image-size.tag +++ b/src/tags/image-size.tag @@ -15,19 +15,9 @@ along with this program. If not, see . --> -
{ this.bytesToSize(this.size) }
+
{ registryUI.bytesToSize(this.size) }