main
Anthony 2024-03-09 01:06:35 +08:00
parent 5cae4e2175
commit 4c8d37b602
1 changed files with 17 additions and 13 deletions

View File

@ -2,29 +2,33 @@ var resp = api.env.control.GetEnvs();
if (resp.result !== 0) return resp; if (resp.result !== 0) return resp;
var envs = []; var envs = [];
for (var i = 0, envInfo; envInfo = resp.infos[i]; i++) { for (var i = 0; i < resp.infos.length; i++) {
var envInfo = resp.infos[i];
var env = envInfo.env; var env = envInfo.env;
if (env.status == 1) { // Check if environment is active // Assuming an environment not part of any group has an empty or undefined envGroups array
var hasStorageNode = false; var isGroupless = !envInfo.envGroups || envInfo.envGroups.length === 0;
for (var j = 0, node; node = envInfo.nodes[j]; j++) {
// Correctly filter nodes by 'storage' nodeGroup if (env.status == 1 && isGroupless) { // Check if environment is active and not part of any envGroup
for (var j = 0; j < envInfo.nodes.length; j++) {
var node = envInfo.nodes[j];
// Filter nodes by 'storage' nodeGroup
if (node.nodeGroup === "storage") { if (node.nodeGroup === "storage") {
hasStorageNode = true; envs.push({
break; // Exit loop once a storage node is found value: env.envName,
caption: (env.displayName + " (" + env.envName + ")" || env.envName)
});
break; // Found a storage node, no need to check further nodes in this environment
} }
} }
if (hasStorageNode) {
envs.push({
value: env.envName,
caption: (env.displayName + " (" + env.envName + ")" || env.envName)
});
}
} }
} }
if (envs.length > 0) { if (envs.length > 0) {
jps.settings.main.fields[1].values = envs; jps.settings.main.fields[1].values = envs;
jps.settings.main.fields[1].default = envs[0].value; jps.settings.main.fields[1].default = envs[0].value;
} else {
// Handle the case where no environments match the criteria
console.log("No environments with storage nodes found that are not part of any envGroup.");
} }
import java.util.TimeZone; import java.util.TimeZone;