diff --git a/README.md b/README.md index f44dfe2..5c87921 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ This web user interface uses [Riot](https://github.com/Riot/riot) the react-like - Display image size (see #30) - Add Title when using REGISTRY_URL (see #28) - Alpine and Debian based images with supports for arm32v7 +- Copy `docker pull` command to clipbloard +- Show sha256 for specific tag (hover image tag) ## Getting Started diff --git a/gulpfile.js b/gulpfile.js index b5eea2f..2820088 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -49,7 +49,7 @@ gulp.task('riot-tag', ['html'], function() { }); gulp.task('riot-static-tag', ['html'], function() { - return gulp.src(['src/tags/catalog.tag', 'src/tags/app.tag', 'src/tags/taglist.tag', 'src/tags/copy-to-clipboard.tag', 'src/tags/remove-image.tag', 'src/tags/image-size.tag']) + return gulp.src(['src/tags/catalog.tag', 'src/tags/app.tag', 'src/tags/taglist.tag', 'src/tags/copy-to-clipboard.tag', 'src/tags/remove-image.tag', 'src/tags/image-size.tag', 'src/tags/image-tag.tag']) .pipe(concat('tags-static.js')) .pipe(riot()) .pipe(minifier({}, uglify)) diff --git a/package.json b/package.json index 8426f63..1a5a70a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "del": "^3.0.0", "gulp": "^3.9", - "gulp-clean-css": "^3.9.3", + "gulp-clean-css": "^3.9.4", "gulp-concat": "^2.6.0", "gulp-filter": "^5.1.0", "gulp-htmlmin": "^3.0.0", @@ -27,7 +27,7 @@ "riot": "^3.10.0", "riot-mui": "^0.1.1", "riot-route": "^3.1.3", - "uglify-js": "^3.3.16", + "uglify-js": "^3.4.0", "uglify-js-harmony": "^2.7.7" } } diff --git a/src/index.html b/src/index.html index 0f81872..add7347 100644 --- a/src/index.html +++ b/src/index.html @@ -40,6 +40,7 @@ + diff --git a/src/style.css b/src/style.css index 8d4192d..9942654 100644 --- a/src/style.css +++ b/src/style.css @@ -322,6 +322,6 @@ select { padding: 12px 5px; } -.copy-to-clipboard a { +.copy-to-clipboard a:hover { cursor: pointer; } \ No newline at end of file diff --git a/src/tags/app.tag b/src/tags/app.tag index 84011ac..6e6b0eb 100644 --- a/src/tags/app.tag +++ b/src/tags/app.tag @@ -93,6 +93,55 @@ const args = path.match(re) if (args) return args.slice(1) }); + + registryUI.DockerImage = function (name, tag) { + this.name = name; + this.tag = tag; + riot.observable(this); + this.on('get-size', function() { + if (this.size !== undefined) { + return this.trigger('size', this.size); + } + return this.fillInfo(); + }); + this.on('get-sha256', function() { + if (this.size !== undefined) { + return this.trigger('sha256', this.sha256); + } + return this.fillInfo(); + }); + }; + + registryUI.DockerImage.compare = function(e1, e2) { + return e1.tag.localeCompare(e2); + }; + + registryUI.DockerImage.prototype.fillInfo = function() { + if (this._fillInfoWaiting) { + return; + } + this._fillInfoWaiting = true; + var oReq = new Http(); + var self = this; + oReq.addEventListener('loadend', function () { + if (this.status == 200 || this.status == 202) { + var response = JSON.parse(this.responseText); + self.size = response.layers.reduce(function (acc, e) { + return acc + e.size; + }, 0); + self.sha256 = response.config.digest; + self.trigger('size', self.size); + self.trigger('sha256', self.sha256); + } else if (this.status == 404) { + registryUI.errorSnackbar('Manifest for ' + self.name + ':' + self.tag + ' not found'); + } else { + registryUI.snackbar(this.responseText); + } + }); + oReq.open('GET', registryUI.url() + '/v2/' + self.name + '/manifests/' + self.tag); + oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json'); + oReq.send(); + } route.start(true); \ No newline at end of file diff --git a/src/tags/copy-to-clipboard.tag b/src/tags/copy-to-clipboard.tag index 6330f16..69ef2e4 100644 --- a/src/tags/copy-to-clipboard.tag +++ b/src/tags/copy-to-clipboard.tag @@ -20,7 +20,7 @@ content_copy \ No newline at end of file diff --git a/src/tags/image-tag.tag b/src/tags/image-tag.tag new file mode 100644 index 0000000..83cdc9e --- /dev/null +++ b/src/tags/image-tag.tag @@ -0,0 +1,27 @@ + + +
{ opts.image.tag }
+ +
\ No newline at end of file diff --git a/src/tags/remove-image.tag b/src/tags/remove-image.tag index d1de211..c136d01 100644 --- a/src/tags/remove-image.tag +++ b/src/tags/remove-image.tag @@ -15,13 +15,12 @@ along with this program. If not, see . --> - + delete