diff --git a/scripts/config.js b/scripts/config.js
index 0d440cd..3c44663 100644
--- a/scripts/config.js
+++ b/scripts/config.js
@@ -405,4 +405,65 @@ async function handleDiskAdd () {
dialog.show();
}
-async function handleCDAdd () {}
\ No newline at end of file
+async function handleCDAdd () {
+ let content = "iso";
+ let storage = await requestPVE(`/nodes/${node}/storage`, "GET", null);
+ let dialog = document.createElement("dialog-form");
+ document.body.append(dialog);
+
+ dialog.header = `Add a CDROM`;
+
+ let storageOptions = "";
+ storage.data.forEach((element) => {
+ if (element.content.includes(content)){
+ storageOptions += `"`;
+ }
+ });
+ let storageSelect = ``;
+
+ dialog.formBody = `
+
+ ${storageSelect}
+
+ `;
+
+ dialog.shadowRoot.querySelector("#storage-select").selectedIndex = -1;
+
+ dialog.shadowRoot.querySelector("#storage-select").addEventListener("change", async () => {
+ let storage = dialog.shadowRoot.querySelector("#storage-select").value;
+ let ISOSelect = dialog.shadowRoot.querySelector("#iso-select");
+ let isos = await requestPVE(`/nodes/${node}/storage/${storage}/content`, "GET", {content: content});
+ isos.data.forEach((element) => {
+ if (element.content.includes(content)) {
+ ISOSelect.append(new Option(element.volid.replace(`${storage}:${content}/`, ""), element.volid));
+ }
+ });
+ });
+
+ dialog.callback = async (result, form) => {
+ if (result === "confirm") {
+ let device = form.get("device");
+ let iso = form.get("iso-select");
+
+ let action = {};
+ action[`ide${device}`] = `${iso},media=cdrom`;
+
+ let body = {
+ node: node,
+ type: type,
+ vmid: vmid,
+ action: JSON.stringify(action)
+ };
+ let result = await requestAPI("/disk/create", "POST", body);
+ if (result.status === 200) {
+ await getConfig();
+ populateDisk();
+ }
+ else {
+ console.error(result);
+ }
+ }
+ };
+
+ dialog.show();
+}
\ No newline at end of file