Skip to content

Commit d51866a

Browse files
committed
Don't send workergroups with an empty name (Dashboard - Worker group configuration UI)
1 parent 026592e commit d51866a

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

mrq/dashboard/static/js/views/workergroups.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,38 @@ define(["jquery", "underscore", "models", "views/generic/page", "quicksettings"]
9090
}
9191
},
9292

93+
// Check for "continue" usage instead of nested ifs
9394
save: function() {
9495
this.commandPanel._controls["Status"].setValue("<font color=\"orange\">Saving...</font>");
9596

9697
data = {};
9798
_.forEach(this.workergroupPanels, function(panel) {
98-
if (panel != null && panel != undefined)
99+
// Equivalent of python's "not in"
100+
if ($.inArray(panel, [null, undefined]) == -1)
99101
{
100102
panelJSON = panel.getValuesAsJSON();
101-
workergroup = {
102-
"profiles" : {},
103-
"process_termination_timeout": parseInt(panelJSON["Process Termination Timeout"], 10)
104-
}
105-
_.forEach(_.range(1, panel.profilesNumber + 1), function(index) {
106-
header = "Profile " + String(index) + " - ";
107-
console.log(panelJSON[header + "Profile Name"])
108-
if (panelJSON[header + "Profile Name"] != null && panelJSON[header + "Profile Name"] != "")
109-
{
110-
profile = {};
111-
profile["memory"] = parseInt(panelJSON[header + "Memory"], 10);
112-
profile["cpu"] = parseInt(panelJSON[header + "CPU"], 10);
113-
profile["min_count"] = parseInt(panelJSON[header + "MinCount"], 10);
114-
profile["max_count"] = parseInt(panelJSON[header + "MaxCount"], 10);
115-
profile["command"] = panelJSON[header + "Command"];
116-
workergroup["profiles"][panelJSON[header + "Profile Name"]] = profile;
103+
if ($.inArray(panelJSON["Workgroup Name"], [null, ""]) == -1)
104+
{
105+
workergroup = {
106+
"profiles" : {},
107+
"process_termination_timeout": parseInt(panelJSON["Process Termination Timeout"], 10)
117108
}
118-
})
119-
data[panelJSON["Workgroup Name"]] = workergroup;
109+
_.forEach(_.range(1, panel.profilesNumber + 1), function(index) {
110+
header = "Profile " + String(index) + " - ";
111+
console.log(panelJSON[header + "Profile Name"])
112+
if ($.inArray(panelJSON[header + "Profile Name"], [null, ""]) == -1)
113+
{
114+
profile = {};
115+
profile["memory"] = parseInt(panelJSON[header + "Memory"], 10);
116+
profile["cpu"] = parseInt(panelJSON[header + "CPU"], 10);
117+
profile["min_count"] = parseInt(panelJSON[header + "MinCount"], 10);
118+
profile["max_count"] = parseInt(panelJSON[header + "MaxCount"], 10);
119+
profile["command"] = panelJSON[header + "Command"];
120+
workergroup["profiles"][panelJSON[header + "Profile Name"]] = profile;
121+
}
122+
})
123+
data[panelJSON["Workgroup Name"]] = workergroup;
124+
}
120125
}
121126
})
122127
console.log(data)

0 commit comments

Comments
 (0)