mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2025-04-29 08:29:54 +03:00
[delete image] Add request for deleting a manifest/image.
Add setRequestHeader in Http class.
This commit is contained in:
parent
70f860f813
commit
7150fe3245
2 changed files with 43 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
function Http() {
|
function Http() {
|
||||||
this.oReq = new XMLHttpRequest();
|
this.oReq = new XMLHttpRequest();
|
||||||
this._events = {};
|
this._events = {};
|
||||||
|
this._headers = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Http.prototype.addEventListener = function(e, f) {
|
Http.prototype.addEventListener = function(e, f) {
|
||||||
|
@ -31,6 +32,9 @@ Http.prototype.addEventListener = function(e, f) {
|
||||||
for (key in this.http._events) {
|
for (key in this.http._events) {
|
||||||
req.addEventListener(key, this.http._events[key]);
|
req.addEventListener(key, this.http._events[key]);
|
||||||
}
|
}
|
||||||
|
for (key in this.http._headers) {
|
||||||
|
req.setRequestHeader(key, this.http._headers[key]);
|
||||||
|
}
|
||||||
req.withCredentials = true;
|
req.withCredentials = true;
|
||||||
req.open(this.http._method, this.http._url);
|
req.open(this.http._method, this.http._url);
|
||||||
req.send();
|
req.send();
|
||||||
|
@ -50,6 +54,11 @@ Http.prototype.addEventListener = function(e, f) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Http.prototype.setRequestHeader = function(header, value) {
|
||||||
|
this.oReq.setRequestHeader(header, value);
|
||||||
|
this._headers[header] = value;
|
||||||
|
};
|
||||||
|
|
||||||
Http.prototype.open = function(m, u) {
|
Http.prototype.open = function(m, u) {
|
||||||
this._method = m;
|
this._method = m;
|
||||||
this._url = u;
|
this._url = u;
|
||||||
|
|
|
@ -36,6 +36,11 @@
|
||||||
<tr each="{ item in registryUI.taglist.tags }">
|
<tr each="{ item in registryUI.taglist.tags }">
|
||||||
<td class="mdl-data-table__cell--non-numeric">{ registryUI.taglist.name }</td>
|
<td class="mdl-data-table__cell--non-numeric">{ registryUI.taglist.name }</td>
|
||||||
<td>{ item }</td>
|
<td>{ item }</td>
|
||||||
|
<td>
|
||||||
|
<a href="#" onclick="registryUI.taglist.remove('{ registryUI.taglist.name }', '{ item }')">
|
||||||
|
<i class="material-icons mdl-list__item-icon">delete</i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -110,6 +115,35 @@
|
||||||
registryUI.taglist.back = function () {
|
registryUI.taglist.back = function () {
|
||||||
rg.router.go('home');
|
rg.router.go('home');
|
||||||
};
|
};
|
||||||
|
registryUI.taglist.remove = function (name, tag) {
|
||||||
|
var oReq = new Http();
|
||||||
|
oReq.addEventListener('load', function () {
|
||||||
|
if (this.status == 200) {
|
||||||
|
var digest = JSON.parse(this.responseText).config.digest;
|
||||||
|
var oReq = new Http();
|
||||||
|
oReq.addEventListener('load', function () {
|
||||||
|
if (this.status == 200) {
|
||||||
|
registryUI.taglist.instance.update();
|
||||||
|
} else if (this.status == 404) {
|
||||||
|
registryUI.taglist.createSnackbar('Server not found');
|
||||||
|
} else {
|
||||||
|
registryUI.taglist.createSnackbar(this.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
oReq.open('DELETE', registryUI.url() + '/v2/' + name + '/manifests/' + digest);
|
||||||
|
oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json');
|
||||||
|
oReq.send();
|
||||||
|
} else if (this.status == 404) {
|
||||||
|
registryUI.taglist.createSnackbar('Server not found');
|
||||||
|
} else {
|
||||||
|
registryUI.taglist.createSnackbar(this.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(name, tag);
|
||||||
|
oReq.open('GET', registryUI.url() + '/v2/' + name + '/manifests/' + tag);
|
||||||
|
oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json');
|
||||||
|
oReq.send();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<!-- End of tag -->
|
<!-- End of tag -->
|
||||||
</taglist>
|
</taglist>
|
Loading…
Add table
Add a link
Reference in a new issue