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,22 +2,23 @@ var resp = api.env.control.GetEnvs();
if (resp.result !== 0) return resp;
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;
if (env.status == 1) { // Check if environment is active
var hasStorageNode = false;
for (var j = 0, node; node = envInfo.nodes[j]; j++) {
// Correctly filter nodes by 'storage' nodeGroup
// Assuming an environment not part of any group has an empty or undefined envGroups array
var isGroupless = !envInfo.envGroups || envInfo.envGroups.length === 0;
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") {
hasStorageNode = true;
break; // Exit loop once a storage node is found
}
}
if (hasStorageNode) {
envs.push({
value: env.envName,
caption: (env.displayName + " (" + env.envName + ")" || env.envName)
});
break; // Found a storage node, no need to check further nodes in this environment
}
}
}
}
@ -25,6 +26,9 @@ for (var i = 0, envInfo; envInfo = resp.infos[i]; i++) {
if (envs.length > 0) {
jps.settings.main.fields[1].values = envs;
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;