mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2026-07-10 08:29:17 +00:00
[fix-image-history] Move byteToSize in app.tag and use it in image history. Better render for created_by
This commit is contained in:
@@ -222,6 +222,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
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);
|
||||
</script>
|
||||
</app>
|
||||
@@ -15,19 +15,9 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<image-size>
|
||||
<div title="Compressed size of your image.">{ this.bytesToSize(this.size) }</div>
|
||||
<div title="Compressed size of your image.">{ registryUI.bytesToSize(this.size) }</div>
|
||||
<script type="text/javascript">
|
||||
var self = this;
|
||||
this.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];
|
||||
};
|
||||
opts.image.on('size', function(size) {
|
||||
self.size = size;
|
||||
self.update();
|
||||
|
||||
@@ -55,9 +55,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
default: return 10;
|
||||
}
|
||||
};
|
||||
|
||||
registryUI.taghistory.eltSort = function(e1, e2) {
|
||||
return registryUI.taghistory.eltIdx(e1.key) - registryUI.taghistory.eltIdx(e2.key);
|
||||
};
|
||||
|
||||
registryUI.taghistory.display = function() {
|
||||
registryUI.taghistory.elements = []
|
||||
let oReq = new Http();
|
||||
@@ -68,6 +70,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
switch (attribute) {
|
||||
case "created":
|
||||
return new Date(value).toLocaleString();
|
||||
case "created_by":
|
||||
const cmd = value.match(/\/bin\/sh *-c *#\(nop\) *([A-Z]+)/);
|
||||
return (cmd && cmd [1]) || 'RUN'
|
||||
case 'size':
|
||||
return registryUI.bytesToSize(value);
|
||||
case "container_config":
|
||||
case "config":
|
||||
return "";
|
||||
@@ -90,7 +97,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
registryUI.taghistory.elements.push(guiElements);
|
||||
}
|
||||
exec(blobs)
|
||||
blobs.history.forEach(function(elt) { exec(elt) });
|
||||
blobs.history.reverse().forEach(function(elt) { exec(elt) });
|
||||
registryUI.taghistory.loadend = true;
|
||||
registryUI.taghistory.instance.update();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user