improved various error messages
This commit is contained in:
parent
510da85c02
commit
e73e494f65
@ -73,4 +73,8 @@ input[type="radio"] {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
dialog {
|
||||
max-width: calc(min(50%, 80ch));
|
||||
}
|
@ -52,7 +52,7 @@
|
||||
<svg class="small" role="img" style="height: 1lh; width: 1lh;" aria-label="Add New Disk"><use href="images/actions/disk/add-disk.svg#symb"></use></svg>
|
||||
</button>
|
||||
<button type="button" id="cd-add" class="w3-button none" aria-label="Add New CD">
|
||||
<span class="large" style="margin: 0;">Add CD</span>
|
||||
<span class="large" style="margin: 0;">Mount CD</span>
|
||||
<svg class="small" role="img" style="height: 1lh; width: 1lh;" aria-label="Add New CDROM"><use href="images/actions/disk/add-cd.svg#symb"></use></svg>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -250,7 +250,7 @@ function handlePasswordChangeForm () {
|
||||
if (result === "confirm") {
|
||||
const result = await requestAPI("/access/password", "POST", { password: form.get("new-password") });
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to change password but got: ${result.error}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -196,7 +196,7 @@ class InstanceCard extends HTMLElement {
|
||||
}
|
||||
else if (taskStatus.data.status === "stopped") { // task stopped but was not successful
|
||||
this.status = prevStatus;
|
||||
alert(`attempted to ${targetAction} ${this.vmid} but process returned stopped:${result.data.exitstatus}`);
|
||||
alert(`Attempted to ${targetAction} ${this.vmid} but got: ${taskStatus.data.exitstatus}`);
|
||||
this.update();
|
||||
this.actionLock = false;
|
||||
break;
|
||||
@ -246,7 +246,7 @@ class InstanceCard extends HTMLElement {
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert(result.error);
|
||||
alert(`Attempted to delete ${this.vmid} but got: ${result.error}`);
|
||||
this.status = this.prevStatus;
|
||||
this.update();
|
||||
this.actionLock = false;
|
||||
@ -430,7 +430,7 @@ async function handleInstanceAdd () {
|
||||
populateInstances();
|
||||
}
|
||||
else {
|
||||
alert(result.error);
|
||||
alert(`Attempted to create new instance ${vmid} but got: ${result.error}`);
|
||||
populateInstances();
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ async function handleDiskDetach () {
|
||||
setSVGSrc(document.querySelector(`svg[data-disk="${disk}"]`), "images/status/loading.svg");
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/disk/${disk}/detach`, "POST");
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to detach ${disk} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDisk();
|
||||
@ -249,7 +249,7 @@ async function handleDiskAttach () {
|
||||
const disk = `${prefix}${device}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/disk/${disk}/attach`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to attach ${this.dataset.disk} to ${disk} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDisk();
|
||||
@ -276,7 +276,7 @@ async function handleDiskResize () {
|
||||
};
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/disk/${disk}/resize`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to resize ${disk} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDisk();
|
||||
@ -317,7 +317,7 @@ async function handleDiskMove () {
|
||||
};
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/disk/${disk}/move`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to move ${disk} to ${body.storage} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDisk();
|
||||
@ -336,7 +336,7 @@ async function handleDiskDelete () {
|
||||
setSVGSrc(document.querySelector(`svg[data-disk="${disk}"]`), "images/status/loading.svg");
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/disk/${disk}/delete`, "DELETE");
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to delete ${disk} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDisk();
|
||||
@ -378,7 +378,7 @@ async function handleDiskAdd () {
|
||||
const disk = `${prefix}${id}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/disk/${disk}/create`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to create ${disk} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDisk();
|
||||
@ -390,7 +390,7 @@ async function handleDiskAdd () {
|
||||
async function handleCDAdd () {
|
||||
const isos = await requestAPI("/user/vm-isos", "GET");
|
||||
|
||||
const header = "Add a CDROM";
|
||||
const header = "Mount a CDROM";
|
||||
|
||||
const body = `
|
||||
<form method="dialog" class="input-grid" style="grid-template-columns: auto 1fr;" id="form">
|
||||
@ -407,7 +407,7 @@ async function handleCDAdd () {
|
||||
const disk = `ide${form.get("device")}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/disk/${disk}/create`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to mount ${body.iso} to ${disk} but got: result.error`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDisk();
|
||||
@ -503,14 +503,14 @@ async function handleNetworkConfig () {
|
||||
const body = {
|
||||
rate: form.get("rate")
|
||||
};
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/net/net${netID}/modify`, "POST", body);
|
||||
const net = `net${netID}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/net/${net}/modify`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to change ${net} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateNetworks();
|
||||
const id = `net${netID}`;
|
||||
updateBootLine(`boot-net${netID}`, { id, prefix: "net", value: id, detail: config.data[`net${netID}`] });
|
||||
updateBootLine(`boot-net${netID}`, { id: net, prefix: "net", value: net, detail: config.data[`net${netID}`] });
|
||||
}
|
||||
});
|
||||
|
||||
@ -525,13 +525,14 @@ async function handleNetworkDelete () {
|
||||
dialog(header, body, async (result, form) => {
|
||||
if (result === "confirm") {
|
||||
setSVGSrc(document.querySelector(`svg[data-network="${netID}"]`), "images/status/loading.svg");
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/net/net${netID}/delete`, "DELETE");
|
||||
const net = `net${netID}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/net/${net}/delete`, "DELETE");
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to delete ${net} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateNetworks();
|
||||
deleteBootLine(`boot-net${netID}`);
|
||||
deleteBootLine(`boot-${net}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -557,9 +558,10 @@ async function handleNetworkAdd () {
|
||||
body.name = form.get("name");
|
||||
}
|
||||
const netID = form.get("netid");
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/net/net${netID}/create`, "POST", body);
|
||||
const net = `net${netID}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/net/${net}/create`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to create ${net} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateNetworks();
|
||||
@ -653,9 +655,10 @@ async function handleDeviceConfig () {
|
||||
device: form.get("device"),
|
||||
pcie: form.get("pcie") ? 1 : 0
|
||||
};
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/pci/hostpci${deviceID}/modify`, "POST", body);
|
||||
const device = `hostpci${deviceID}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/pci/${device}/modify`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to add ${device} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDevices();
|
||||
@ -665,7 +668,7 @@ async function handleDeviceConfig () {
|
||||
const availDevices = await requestAPI(`/cluster/${node}/pci`, "GET");
|
||||
d.querySelector("#device").append(new Option(deviceName, deviceDetails.split(",")[0]));
|
||||
for (const availDevice of availDevices) {
|
||||
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.id));
|
||||
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.device_id));
|
||||
}
|
||||
d.querySelector("#pcie").checked = deviceDetails.includes("pcie=1");
|
||||
}
|
||||
@ -678,9 +681,10 @@ async function handleDeviceDelete () {
|
||||
dialog(header, body, async (result, form) => {
|
||||
if (result === "confirm") {
|
||||
setSVGSrc(document.querySelector(`svg[data-device="${deviceID}"]`), "images/status/loading.svg");
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/pci/hostpci${deviceID}/delete`, "DELETE");
|
||||
const device = `hostpci${deviceID}`;
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/pci/${device}/delete`, "DELETE");
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to delete ${device} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDevices();
|
||||
@ -704,7 +708,7 @@ async function handleDeviceAdd () {
|
||||
};
|
||||
const result = await requestAPI(`/cluster/${node}/${type}/${vmid}/pci/create`, "POST", body);
|
||||
if (result.status !== 200) {
|
||||
alert(result.error);
|
||||
alert(`Attempted to add ${body.device} but got: ${result.error}`);
|
||||
}
|
||||
await getConfig();
|
||||
populateDevices();
|
||||
@ -713,7 +717,7 @@ async function handleDeviceAdd () {
|
||||
|
||||
const availDevices = await requestAPI(`/cluster/${node}/pci`, "GET");
|
||||
for (const availDevice of availDevices) {
|
||||
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.id));
|
||||
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.device_id));
|
||||
}
|
||||
d.querySelector("#pcie").checked = true;
|
||||
}
|
||||
@ -835,6 +839,6 @@ async function handleFormExit () {
|
||||
goToPage("index.html");
|
||||
}
|
||||
else {
|
||||
alert(result.error);
|
||||
alert(`Attempted to set basic resources but got: ${result.error}`);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ async function init () {
|
||||
}
|
||||
else {
|
||||
alert("An error occured.");
|
||||
console.error(ticket);
|
||||
formSubmitButton.innerText = "LOGIN";
|
||||
console.error(ticket.error);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user