[riot-mui] Add riot-mui in remove-image (#17)

This commit is contained in:
Joxit 2017-09-22 20:26:17 +02:00
parent c1f9d02afb
commit d4b99b2cb2
3 changed files with 19 additions and 8 deletions

View file

@ -212,3 +212,11 @@ material-card table th.material-card-th-sorted-descending:before {
material-card table th.material-card-th-sorted-descending:before { material-card table th.material-card-th-sorted-descending:before {
content: "\e5db"; content: "\e5db";
} }
.material-icons {
color: #777;
}
material-snackbar .toast {
height: auto;
}

View file

@ -52,6 +52,9 @@
registryUI.snackbar = function (message, isError) { registryUI.snackbar = function (message, isError) {
registryUI.appTag.tags['material-snackbar'].addToast({'message': message, 'isError': isError}); registryUI.appTag.tags['material-snackbar'].addToast({'message': message, 'isError': isError});
}; };
registryUI.errorSnackbar = function(message) {
return registryUI.snackbar(message, true);
}
this.router.start(); this.router.start();
</script> </script>
</app> </app>

View file

@ -16,7 +16,7 @@
--> -->
<remove-image> <remove-image>
<a href="#" onclick="registryUI.removeImage.remove('{ opts.name }', '{ opts.tag }')"> <a href="#" onclick="registryUI.removeImage.remove('{ opts.name }', '{ opts.tag }')">
<i class="material-icons mdl-list__item-icon">delete</i> <i class="material-icons">delete</i>
</a> </a>
<script type="text/javascript"> <script type="text/javascript">
registryUI.removeImage = registryUI.removeImage || {} registryUI.removeImage = registryUI.removeImage || {}
@ -28,7 +28,7 @@
registryUI.taglist.refresh(); registryUI.taglist.refresh();
if (this.status == 200) { if (this.status == 200) {
if (!this.hasHeader('Docker-Content-Digest')) { if (!this.hasHeader('Docker-Content-Digest')) {
registryUI.taglist.createSnackbar('You need to add Access-Control-Expose-Headers: [\'Docker-Content-Digest\'] in your server configuration.'); registryUI.errorSnackbar('You need to add Access-Control-Expose-Headers: [\'Docker-Content-Digest\'] in your server configuration.');
return; return;
} }
var digest = this.getResponseHeader('Docker-Content-Digest'); var digest = this.getResponseHeader('Docker-Content-Digest');
@ -36,23 +36,23 @@
oReq.addEventListener('loadend', function () { oReq.addEventListener('loadend', function () {
if (this.status == 200 || this.status == 202) { if (this.status == 200 || this.status == 202) {
registryUI.taglist.refresh(); registryUI.taglist.refresh();
registryUI.taglist.createSnackbar('Deleting ' + name + ':' + tag + ' image. Run `registry garbage-collect config.yml` on your registry'); registryUI.snackbar('Deleting ' + name + ':' + tag + ' image. Run `registry garbage-collect config.yml` on your registry');
} else if (this.status == 404) { } else if (this.status == 404) {
registryUI.taglist.createSnackbar('Digest not found'); registryUI.errorSnackbar('Digest not found');
} else { } else {
registryUI.taglist.createSnackbar(this.responseText); registryUI.snackbar(this.responseText);
} }
}); });
oReq.open('DELETE', registryUI.url() + '/v2/' + name + '/manifests/' + digest); oReq.open('DELETE', registryUI.url() + '/v2/' + name + '/manifests/' + digest);
oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json'); oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json');
oReq.addEventListener('error', function () { oReq.addEventListener('error', function () {
registryUI.taglist.createSnackbar('An error occurred when deleting image. Check if your server accept DELETE methods Access-Control-Allow-Methods: [\'DELETE\'].'); registryUI.errorSnackbar('An error occurred when deleting image. Check if your server accept DELETE methods Access-Control-Allow-Methods: [\'DELETE\'].');
}); });
oReq.send(); oReq.send();
} else if (this.status == 404) { } else if (this.status == 404) {
registryUI.taglist.createSnackbar('Manifest for' + name + ':' + tag + 'not found'); registryUI.errorSnackbar('Manifest for ' + name + ':' + tag + ' not found');
} else { } else {
registryUI.taglist.createSnackbar(this.responseText); registryUI.snackbar(this.responseText);
} }
}); });
oReq.open('HEAD', registryUI.url() + '/v2/' + name + '/manifests/' + tag); oReq.open('HEAD', registryUI.url() + '/v2/' + name + '/manifests/' + tag);