From 354d3159bdb4da18e2e627882b84cf30267044e4 Mon Sep 17 00:00:00 2001 From: Joxit Date: Fri, 15 Jun 2018 21:31:48 +0200 Subject: [PATCH 1/2] [feat #42] Add copy to clipboard for images with tag --- gulpfile.js | 2 +- src/index.html | 1 + src/style.css | 47 +++++++++++++++++++++++----------- src/tags/app.tag | 7 +++++ src/tags/copy-to-clipboard.tag | 34 ++++++++++++++++++++++++ src/tags/remove-image.tag | 2 +- src/tags/taglist.tag | 4 +++ 7 files changed, 80 insertions(+), 17 deletions(-) create mode 100644 src/tags/copy-to-clipboard.tag diff --git a/gulpfile.js b/gulpfile.js index 3314658..b5eea2f 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/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']) .pipe(concat('tags-static.js')) .pipe(riot()) .pipe(minifier({}, uglify)) diff --git a/src/index.html b/src/index.html index bb1d78b..0f81872 100644 --- a/src/index.html +++ b/src/index.html @@ -41,6 +41,7 @@ + diff --git a/src/style.css b/src/style.css index 1bc9041..8d4192d 100644 --- a/src/style.css +++ b/src/style.css @@ -15,9 +15,10 @@ * along with this program. If not, see . */ -html > body { +html>body { font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif !important; } + html, body { margin: 0; height: 100%; @@ -64,9 +65,11 @@ material-spinner { display: flex; flex-direction: column; } + material-navbar { height: 64px; } + .logo { padding: 0 16px 0 72px; text-decoration: none; @@ -75,6 +78,7 @@ material-navbar { letter-spacing: .02em; font-weight: 400; } + h2 { padding: 16px; margin: auto; @@ -83,15 +87,18 @@ h2 { line-height: normal; overflow: hidden; } + .list { display: block; padding: 8px 0; list-style: none; } + .list.highlight>li:hover { background-color: #eee; cursor: pointer; } + .list>li { box-sizing: border-box; line-height: 1; @@ -99,6 +106,7 @@ h2 { padding: 0 16px; overflow: hidden; } + .list>li i.material-icons { margin-right: 32px; height: 24px; @@ -107,6 +115,7 @@ h2 { box-sizing: border-box; color: #757575; } + .list>li>span { height: 100%; text-decoration: none; @@ -138,7 +147,7 @@ material-card table { width: 100%; border: none; position: relative; - border: 1px solid rgba(0,0,0,.12); + border: 1px solid rgba(0, 0, 0, .12); border-collapse: collapse; white-space: nowrap; font-size: 13px; @@ -151,7 +160,7 @@ material-card table th { vertical-align: bottom; line-height: 24px; height: 48px; - color: rgba(0,0,0,.54); + color: rgba(0, 0, 0, .54); box-sizing: border-box; padding: 0 18px 12px 18px; text-align: right; @@ -169,7 +178,7 @@ material-card table tbody tr { position: relative; height: 48px; transition-duration: .28s; - transition-timing-function: cubic-bezier(.4,0,.2,1); + transition-timing-function: cubic-bezier(.4, 0, .2, 1); transition-property: background-color; } @@ -177,24 +186,23 @@ material-card table td { font-size: 16px; position: relative; height: 48px; - border-top: 1px solid rgba(0,0,0,.12); - border-bottom: 1px solid rgba(0,0,0,.12); + border-top: 1px solid rgba(0, 0, 0, .12); + border-bottom: 1px solid rgba(0, 0, 0, .12); padding: 12px 18px; box-sizing: border-box; vertical-align: middle; text-align: right; } -material-card table th.material-card-th-sorted-ascending:hover, -material-card table th.material-card-th-sorted-descending:hover { + +material-card table th.material-card-th-sorted-ascending:hover, material-card table th.material-card-th-sorted-descending:hover { cursor: pointer; } -material-card table th.material-card-th-sorted-ascending:hover:before, -material-card table th.material-card-th-sorted-descending:hover:before { - color: rgba(0,0,0,.26); + +material-card table th.material-card-th-sorted-ascending:hover:before, material-card table th.material-card-th-sorted-descending:hover:before { + color: rgba(0, 0, 0, .26); } -material-card table th.material-card-th-sorted-ascending:before, -material-card table th.material-card-th-sorted-descending:before { +material-card table th.material-card-th-sorted-ascending:before, material-card table th.material-card-th-sorted-descending:before { font-family: 'Material Icons'; font-weight: 400; font-style: normal; @@ -204,6 +212,7 @@ material-card table th.material-card-th-sorted-descending:before { margin-right: 5px; vertical-align: sub; } + material-card table th.material-card-th-sorted-descending:before { content: "\e5db"; } @@ -233,7 +242,7 @@ menu .overlay { } #menu-control-button { - background: rgba(255,255,255,0); + background: rgba(255, 255, 255, 0); float: right; } @@ -275,7 +284,7 @@ material-popup material-button { } material-popup material-button:hover material-waves { - background-color: hsla(0,0%,75%,.2); + background-color: hsla(0, 0%, 75%, .2); } material-popup .popup { @@ -307,4 +316,12 @@ select { appearance: none; -moz-appearance: none; -webkit-appearance: none; +} + +.copy-to-clipboard { + padding: 12px 5px; +} + +.copy-to-clipboard a { + cursor: pointer; } \ No newline at end of file diff --git a/src/tags/app.tag b/src/tags/app.tag index d306032..84011ac 100644 --- a/src/tags/app.tag +++ b/src/tags/app.tag @@ -77,6 +77,13 @@ registryUI.errorSnackbar = function (message) { return registryUI.snackbar(message, true); } + registryUI.cleanName = function() { + var url = registryUI.url() || registryUI.name(); + if (url) { + return url.startsWith('http') ? url.replace(/https?:\/\//, '') : url; + } + return ''; + } route.parser(null, function(path, filter) { const f = filter .replace(/\?/g, '\\?') diff --git a/src/tags/copy-to-clipboard.tag b/src/tags/copy-to-clipboard.tag new file mode 100644 index 0000000..6330f16 --- /dev/null +++ b/src/tags/copy-to-clipboard.tag @@ -0,0 +1,34 @@ + + + + + content_copy + + + \ No newline at end of file diff --git a/src/tags/remove-image.tag b/src/tags/remove-image.tag index a6d7c1f..d1de211 100644 --- a/src/tags/remove-image.tag +++ b/src/tags/remove-image.tag @@ -15,7 +15,7 @@ along with this program. If not, see . --> - + delete + 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