add restore function to backups
This commit is contained in:
@@ -47,6 +47,17 @@ class BackupCard extends HTMLElement {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const restoreButton = this.shadowRoot.querySelector("#restore-btn");
|
||||
if (restoreButton.classList.contains("clickable")) {
|
||||
restoreButton.onclick = this.handleRestoreButton.bind(this);
|
||||
restoreButton.onkeydown = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
this.handleRestoreButton();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
get volid () {
|
||||
@@ -85,6 +96,22 @@ class BackupCard extends HTMLElement {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async handleRestoreButton () {
|
||||
const template = this.shadowRoot.querySelector("#restore-dialog");
|
||||
dialog(template, async (result, form) => {
|
||||
if (result === "confirm") {
|
||||
const body = {
|
||||
volid: this.volid
|
||||
};
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/backup/restore`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(`Attempted to delete backup but got: ${result.error}`);
|
||||
}
|
||||
refreshBackups();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("backup-card", BackupCard);
|
||||
|
Reference in New Issue
Block a user