`;
@@ -269,7 +364,7 @@ async function populateGroups () {
for (const groupName of Object.keys(allGroups)) {
const group = allGroups[groupName];
const item = document.createElement("draggable-item");
- item.data = group;
+ item.value = group;
item.innerHTML = `
@@ -291,30 +386,48 @@ async function populateResources () {
const field = document.querySelector("#resources");
for (const resourceName of Object.keys(userData.resources)) {
const resource = userData.resources[resourceName];
- if (resourcesConfigPage[resourceName]) {
- const resourceConfig = resourcesConfigPage[resourceName];
- let resourceLine;
+ let resourceLine;
+ let resourceConfig;
- if (resourceName === "cpu" || resourceName === "pci") {
- resourceLine = addResourceLine(resourcesConfigPage, field, resourceName, { value: resource.global }, "(Global)");
+ if (resourcesConfigPage[resourceName]) {
+ resourceConfig = resourcesConfigPage[resourceName];
+ resourceConfig.id = `${resourceName}-global`;
+
+ if (resourceConfig.type === "list") {
+ resourceLine = addResourceLine(resourceConfig, field, { value: resource.global }, "(Global)");
}
else {
- resourceLine = addResourceLine(resourcesConfigPage, field, resourceName, { value: resource.global.max }, "(Global)");
+ resourceLine = addResourceLine(resourceConfig, field, { value: resource.global.max }, "(Global)");
}
postPopulateResourceLine(field, resourceName, "global", resourceConfig, resourceLine);
for (const nodeSpecificName of Object.keys(resource.nodes)) { // for each node specific, add a line with the node name as a prefix
- if (resourceName === "cpu" || resourceName === "pci") {
- resourceLine = addResourceLine(resourcesConfigPage, field, resourceName, { value: resource.nodes[nodeSpecificName] }, `(${nodeSpecificName})`);
+ resourceConfig.id = `${resourceName}-${nodeSpecificName}`;
+ if (resourceConfig.type === "list") {
+ resourceLine = addResourceLine(resourceConfig, field, { value: resource.nodes[nodeSpecificName] }, `(${nodeSpecificName})`);
}
else {
- resourceLine = addResourceLine(resourcesConfigPage, field, resourceName, { value: resource.nodes[nodeSpecificName].max }, `(${nodeSpecificName})`);
+ resourceLine = addResourceLine(resourceConfig, field, { value: resource.nodes[nodeSpecificName].max }, `(${nodeSpecificName})`);
}
postPopulateResourceLine(field, resourceName, nodeSpecificName, resourceConfig, resourceLine);
}
}
+ else {
+ resourceConfig = resourcesConfigPage.storage;
+ resourceConfig.id = `${resourceName}-global`;
+ resourceConfig.name = resourceName;
+ resourceLine = addResourceLine(resourceConfig, field, { value: resource.global.max }, "(Global)");
+
+ postPopulateResourceLine(field, resourceName, "global", resourceConfig, resourceLine);
+
+ for (const nodeSpecificName of Object.keys(resource.nodes)) { // for each node specific, add a line with the node name as a prefix
+ resourceConfig.id = `${resourceName}-${nodeSpecificName}`;
+ resourceLine = addResourceLine(resourceConfig, field, { value: resource.nodes[nodeSpecificName].max }, `(${nodeSpecificName})`);
+ postPopulateResourceLine(field, resourceName, nodeSpecificName, resourceConfig, resourceLine);
+ }
+ }
}
document.querySelector("#resource-add").addEventListener("click", handleResourceAdd);
}
@@ -338,6 +451,9 @@ function postPopulateResourceLine (field, resourceName, resourceScope, resourceC
resourceLine.resourceName = resourceName;
resourceLine.resourceScope = resourceScope;
+ resourceLine.resourceType = resourceConfig.type;
+
+ resourceRulesLines[resourceLine.element.id] = resourceLine;
}
async function handleResourceAdd () {
@@ -351,7 +467,7 @@ async function handleResourceAdd () {
- `;
+ `;
const d = dialog(header, body, async (result, form) => {
if (result === "confirm") {
@@ -359,8 +475,6 @@ async function handleResourceAdd () {
const type = clusterResourceConfig[name].type;
const scope = form.get("scope");
- console.log(name, type, scope);
-
// check if the resource name is not in the cluster config resources
if (!clusterResourceConfig[name]) {
alert(`${name} is not an allowed resource name`);
@@ -384,23 +498,24 @@ async function handleResourceAdd () {
}
const field = document.querySelector("#resources");
+ const resourceConfig = resourcesConfigPage[name];
let resourceLine;
if (scope === "global" && type === "numeric") {
userData.resources[name].global = { max: 0 };
- resourceLine = addResourceLine(resourcesConfigPage, field, name, { value: userData.resources[name].global.max }, "(Global)");
+ resourceLine = addResourceLine(resourceConfig, field, { value: userData.resources[name].global.max }, "(Global)");
}
else if (scope === "global" && type === "list") {
userData.resources[name].global = [];
- resourceLine = addResourceLine(resourcesConfigPage, field, name, { value: userData.resources[name].global }, "(Global)");
+ resourceLine = addResourceLine(resourceConfig, field, { value: userData.resources[name].global }, "(Global)");
}
else if (scope !== "global" && type === "numeric") {
userData.resources[name].nodes[scope] = { max: 0 };
- resourceLine = addResourceLine(resourcesConfigPage, field, name, { value: userData.resources[name].nodes[scope].max }, `(${scope})`);
+ resourceLine = addResourceLine(resourceConfig, field, { value: userData.resources[name].nodes[scope].max }, `(${scope})`);
}
else if (scope !== "global" && type === "list") {
userData.resources[name].nodes[scope] = [];
- resourceLine = addResourceLine(resourcesConfigPage, field, name, { value: userData.resources[name].nodes[scope] }, `(${scope})`);
+ resourceLine = addResourceLine(resourceConfig, field, { value: userData.resources[name].nodes[scope] }, `(${scope})`);
}
postPopulateResourceLine(field, name, scope, resourcesConfigPage[name], resourceLine);
@@ -437,6 +552,8 @@ async function handleResourceDelete () {
else {
userData.resources[this.resourceName].nodes[this.resourceScope] = false;
}
+
+ delete resourceRulesLines[this.element.id];
}
});
}
@@ -449,7 +566,7 @@ async function populateCluster () {
for (const node of allNodes) { // for each node of all cluster nodes
const item = document.createElement("draggable-item");
- item.data = node;
+ item.value = node;
item.innerHTML = `
@@ -466,7 +583,7 @@ async function populateCluster () {
for (const pool of allPools) { // for each pool of all cluster pools
const item = document.createElement("draggable-item");
- item.data = pool;
+ item.value = pool;
item.innerHTML = `