improve acessibility
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
e3bf24c885
commit
96ab6791b2
@ -20,7 +20,7 @@
|
|||||||
<legend>Disks</legend>
|
<legend>Disks</legend>
|
||||||
<div class="input-grid" id="disks" style="grid-template-columns: auto auto auto auto auto 1fr auto;"></div>
|
<div class="input-grid" id="disks" style="grid-template-columns: auto auto auto auto auto 1fr auto;"></div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="center-div"><img id="disk-add" src="images/actions/create.svg"></div>
|
<div class="center-div"><img id="disk-add" src="images/actions/create.svg" class="clickable" alt="Add New Disk"></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="fieldset-no-border">
|
<fieldset class="fieldset-no-border">
|
||||||
<div class="btn-group" id="form-actions">
|
<div class="btn-group" id="form-actions">
|
||||||
|
@ -84,4 +84,15 @@ img.clickable {
|
|||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.visuallyhidden {
|
||||||
|
border: 0;
|
||||||
|
clip: rect(0 0 0 0);
|
||||||
|
height: 1px;
|
||||||
|
margin: -1px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0;
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
}
|
@ -5,12 +5,12 @@ window.addEventListener("DOMContentLoaded", init);
|
|||||||
let diskConfig = {
|
let diskConfig = {
|
||||||
lxc: {
|
lxc: {
|
||||||
prefixOrder: ["mp"],
|
prefixOrder: ["mp"],
|
||||||
mp: {name: "MP", limit: 255, used: {}, icon: "images/resources/drive.svg", storageContent: "rootdir",resizable: true, hasPath: true, hasDiskImage: false}
|
mp: {name: "MP", limit: 255, disks: {}, icon: "images/resources/drive.svg", storageContent: "rootdir",resizable: true, hasPath: true, hasDiskImage: false}
|
||||||
},
|
},
|
||||||
qemu: {
|
qemu: {
|
||||||
prefixOrder: ["sata", "ide"],
|
prefixOrder: ["sata", "ide"],
|
||||||
ide: {name: "IDE", limit: 3, used: {}, icon: "images/resources/disk.svg", storageContent: "iso", reziable: false, hasPath: false, hasDiskImage: true},
|
ide: {name: "IDE", limit: 3, disks: {}, icon: "images/resources/disk.svg", storageContent: "iso", reziable: false, hasPath: false, hasDiskImage: true},
|
||||||
sata: {name: "SATA", limit: 5, used: {}, icon: "images/resources/drive.svg", storageContent: "images", resizable: true, hasPath: false, hasDiskImage: false}
|
sata: {name: "SATA", limit: 5, disks: {}, icon: "images/resources/drive.svg", storageContent: "images", resizable: true, hasPath: false, hasDiskImage: false}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +34,8 @@ async function init () {
|
|||||||
cancelButton.addEventListener("click", () => {
|
cancelButton.addEventListener("click", () => {
|
||||||
goToPage("index.html");
|
goToPage("index.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(diskConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function populateResources () {
|
async function populateResources () {
|
||||||
@ -58,12 +60,12 @@ async function populateResources () {
|
|||||||
let busName = entry.name;
|
let busName = entry.name;
|
||||||
Object.keys(config.data).forEach(element => {
|
Object.keys(config.data).forEach(element => {
|
||||||
if (element.startsWith(prefix)) {
|
if (element.startsWith(prefix)) {
|
||||||
entry.used[element.replace(prefix, "")] = config.data[element];
|
entry.disks[element.replace(prefix, "")] = parseDisk(config.data[element]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let ordered_keys = getOrderedUsed(entry);
|
let ordered_keys = getOrderedUsed(entry.disks);
|
||||||
ordered_keys.forEach(element => {
|
ordered_keys.forEach(element => {
|
||||||
let disk = parseDisk(entry.used[element]);
|
let disk = entry.disks[element];
|
||||||
addDiskLine("disks", prefix, busName, element, disk, storageOptions);
|
addDiskLine("disks", prefix, busName, element, disk, storageOptions);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,15 +101,24 @@ function addResourceLine (fieldset, iconHref, labelText, inputAttr, unitText=nul
|
|||||||
async function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed, storageOptions) {
|
async function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed, storageOptions) {
|
||||||
let field = document.querySelector(`#${fieldset}`);
|
let field = document.querySelector(`#${fieldset}`);
|
||||||
|
|
||||||
|
// Set the disk icon, either drive.svg or disk.svg
|
||||||
let icon = document.createElement("img");
|
let icon = document.createElement("img");
|
||||||
icon.src = diskConfig[type][busPrefix].icon;
|
icon.src = diskConfig[type][busPrefix].icon;
|
||||||
icon.alt = `${busName} ${device}`;
|
icon.alt = `${busName} ${device}`;
|
||||||
field.append(icon);
|
field.append(icon);
|
||||||
|
|
||||||
|
// Add a label for the disk bus
|
||||||
let busLabel = document.createElement("label");
|
let busLabel = document.createElement("label");
|
||||||
busLabel.innerHTML = busName;
|
busLabel.innerHTML = busName;
|
||||||
field.append(busLabel);
|
field.append(busLabel);
|
||||||
|
|
||||||
|
// Create device number input and hidden label
|
||||||
|
let deviceLabel = document.createElement("label");
|
||||||
|
deviceLabel.classList.add("visuallyhidden");
|
||||||
|
deviceLabel.innerText = "Device Number";
|
||||||
|
deviceLabel.htmlFor = `${busPrefix}_${device}_device`;
|
||||||
|
field.append(deviceLabel);
|
||||||
|
|
||||||
let deviceInput = document.createElement("input");
|
let deviceInput = document.createElement("input");
|
||||||
deviceInput.type = "number";
|
deviceInput.type = "number";
|
||||||
deviceInput.min = 0;
|
deviceInput.min = 0;
|
||||||
@ -120,8 +131,16 @@ async function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed
|
|||||||
// for now, disable disk device reassignment
|
// for now, disable disk device reassignment
|
||||||
deviceInput.disabled = true;
|
deviceInput.disabled = true;
|
||||||
//
|
//
|
||||||
|
deviceInput.id = `${busPrefix}_${device}_device`;
|
||||||
deviceInput.addEventListener("change", handleDeviceChange);
|
deviceInput.addEventListener("change", handleDeviceChange);
|
||||||
field.append(deviceInput);
|
field.append(deviceInput);
|
||||||
|
|
||||||
|
// Create storage selector and hidden storage label
|
||||||
|
let storageLabel = document.createElement("label");
|
||||||
|
storageLabel.classList.add("visuallyhidden");
|
||||||
|
storageLabel.innerText = "Storage Target";
|
||||||
|
storageLabel.htmlFor = `${busPrefix}_${device}_storage`;
|
||||||
|
field.append(storageLabel);
|
||||||
|
|
||||||
let storage = diskDataParsed.storage;
|
let storage = diskDataParsed.storage;
|
||||||
let storageSelect = document.createElement("select");
|
let storageSelect = document.createElement("select");
|
||||||
@ -135,7 +154,13 @@ async function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed
|
|||||||
storageSelect.addEventListener("change", handleStorageChange);
|
storageSelect.addEventListener("change", handleStorageChange);
|
||||||
field.append(storageSelect);
|
field.append(storageSelect);
|
||||||
|
|
||||||
if (diskConfig[type][busPrefix].resizable) {
|
if (diskConfig[type][busPrefix].resizable) { // If resizable, then add a size input and hidden label
|
||||||
|
let sizeLabel = document.createElement("label");
|
||||||
|
sizeLabel.classList.add("visuallyhidden");
|
||||||
|
sizeLabel.innerText = "Size in GiB";
|
||||||
|
sizeLabel.htmlFor = `${busPrefix}_${device}_size`;
|
||||||
|
field.append(sizeLabel);
|
||||||
|
|
||||||
let size = diskDataParsed.size;
|
let size = diskDataParsed.size;
|
||||||
let sizeInput = document.createElement("input");
|
let sizeInput = document.createElement("input");
|
||||||
sizeInput.type = "number";
|
sizeInput.type = "number";
|
||||||
@ -150,7 +175,13 @@ async function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed
|
|||||||
sizeUnit.innerText = "GiB";
|
sizeUnit.innerText = "GiB";
|
||||||
field.append(sizeUnit);
|
field.append(sizeUnit);
|
||||||
}
|
}
|
||||||
else if (diskConfig[type][busPrefix].hasPath) {
|
else if (diskConfig[type][busPrefix].hasPath) { // if disk has a mount path, then add a path input and hidden label
|
||||||
|
let pathLabel = document.createElement("label");
|
||||||
|
pathLabel.classList.add("visuallyhidden");
|
||||||
|
pathLabel.innerText = "Mount Point Path";
|
||||||
|
pathLabel.htmlFor = `${busPrefix}_${device}_path`;
|
||||||
|
field.append(pathLabel);
|
||||||
|
|
||||||
let pathInput = document.createElement("input");
|
let pathInput = document.createElement("input");
|
||||||
pathInput.value = diskDataParsed.mp;
|
pathInput.value = diskDataParsed.mp;
|
||||||
pathInput.id = `${busPrefix}_${device}_path`;
|
pathInput.id = `${busPrefix}_${device}_path`;
|
||||||
@ -160,7 +191,13 @@ async function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed
|
|||||||
let blank = document.createElement("div");
|
let blank = document.createElement("div");
|
||||||
field.append(blank);
|
field.append(blank);
|
||||||
}
|
}
|
||||||
else if (diskConfig[type][busPrefix].hasDiskImage) {
|
else if (diskConfig[type][busPrefix].hasDiskImage) { // if disk has a disk image, then add a image selector and hidden label
|
||||||
|
let imgLabel = document.createElement("label");
|
||||||
|
imgLabel.classList.add("visuallyhidden");
|
||||||
|
imgLabel.innerText = "Disk Image";
|
||||||
|
imgLabel.htmlFor = `${busPrefix}_${device}_img`;
|
||||||
|
field.append(imgLabel);
|
||||||
|
|
||||||
let diskImageSelect = document.createElement("select");
|
let diskImageSelect = document.createElement("select");
|
||||||
let diskImageOptions = await request(`/nodes/${node}/storage/${storage}/content?content=iso`);
|
let diskImageOptions = await request(`/nodes/${node}/storage/${storage}/content?content=iso`);
|
||||||
diskImageOptions.data.forEach((element) => {
|
diskImageOptions.data.forEach((element) => {
|
||||||
@ -206,8 +243,8 @@ async function handleStorageChange () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOrderedUsed(entry){
|
function getOrderedUsed(disks){
|
||||||
let ordered_keys = Object.keys(entry.used).sort((a,b) => {parseInt(a) - parseInt(b)}); // ordered integer list
|
let ordered_keys = Object.keys(disks).sort((a,b) => {parseInt(a) - parseInt(b)}); // ordered integer list
|
||||||
return ordered_keys;
|
return ordered_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user