Skip to content

Commit 71fb8fc

Browse files
author
Erwin Dondorp
committed
use only one helper function for cmdbox; and simplified calling it
1 parent 01a0720 commit 71fb8fc

11 files changed

Lines changed: 111 additions & 73 deletions

File tree

saltgui/static/scripts/panels/BeaconsMinion.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ export class BeaconsMinionPanel extends Panel {
179179
// run the command with the original beacon definition
180180
tr.addEventListener("click", (pClickEvent) => {
181181
const beacon0 = beacons0[beaconName];
182-
this.runCommand(pMinionId, ["beacons.modify", beaconName, beacon0]);
182+
const cmdArr = ["beacons.modify", beaconName, beacon0];
183+
this.runCommand("", pMinionId, cmdArr);
183184
pClickEvent.stopPropagation();
184185
});
185186

@@ -204,7 +205,8 @@ export class BeaconsMinionPanel extends Panel {
204205
return "Disable beacons...";
205206
}, () => {
206207
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
207-
this.runCommand(minionId, ["beacons.disable"]);
208+
const cmdArr = ["beacons.disable"];
209+
this.runCommand("", minionId, cmdArr);
208210
});
209211
}
210212

@@ -216,28 +218,32 @@ export class BeaconsMinionPanel extends Panel {
216218
return "Enable beacons...";
217219
}, () => {
218220
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
219-
this.runCommand(minionId, ["beacons.enable"]);
221+
const cmdArr = ["beacons.enable"];
222+
this.runCommand("", minionId, cmdArr);
220223
});
221224
}
222225

223226
_addPanelMenuItemBeaconsAdd () {
224227
this.panelMenu.addMenuItem("Add beacon...", () => {
225228
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
226-
this.runCommand(minionId, ["beacons.add", "<name>", "<data>"]);
229+
const cmdArr = ["beacons.add", "<name>", "<data>"];
230+
this.runCommand("", minionId, cmdArr);
227231
});
228232
}
229233

230234
_addPanelMenuItemBeaconsReset () {
231235
this.panelMenu.addMenuItem("Reset beacons...", () => {
232236
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
233-
this.runCommand(minionId, ["beacons.reset"]);
237+
const cmdArr = ["beacons.reset"];
238+
this.runCommand("", minionId, cmdArr);
234239
});
235240
}
236241

237242
_addPanelMenuItemBeaconsSave () {
238243
this.panelMenu.addMenuItem("Save beacons...", () => {
239244
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
240-
this.runCommand(minionId, ["beacons.save"]);
245+
const cmdArr = ["beacons.save"];
246+
this.runCommand("", minionId, cmdArr);
241247
});
242248
}
243249

@@ -246,7 +252,8 @@ export class BeaconsMinionPanel extends Panel {
246252
return;
247253
}
248254
pMenu.addMenuItem("Disable beacon...", () => {
249-
this.runCommand(pMinionId, ["beacons.disable_beacon", key]);
255+
const cmdArr = ["beacons.disable_beacon", key];
256+
this.runCommand("", pMinionId, cmdArr);
250257
});
251258
}
252259

@@ -255,13 +262,15 @@ export class BeaconsMinionPanel extends Panel {
255262
return;
256263
}
257264
pMenu.addMenuItem("Enable beacon...", () => {
258-
this.runCommand(pMinionId, ["beacons.enable_beacon", key]);
265+
const cmdArr = ["beacons.enable_beacon", key];
266+
this.runCommand("", pMinionId, cmdArr);
259267
});
260268
}
261269

262270
_addMenuItemBeaconsDelete (pMenu, pMinionId, key) {
263271
pMenu.addMenuItem("Delete beacon...", () => {
264-
this.runCommand(pMinionId, ["beacons.delete", key]);
272+
const cmdArr = ["beacons.delete", key];
273+
this.runCommand("", pMinionId, cmdArr);
265274
});
266275
}
267276

saltgui/static/scripts/panels/GrainsMinion.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export class GrainsMinionPanel extends Panel {
7878
tbody.appendChild(grainTr);
7979

8080
grainTr.addEventListener("click", (pClickEvent) => {
81-
this.runCommand(pMinionId, ["grains.setval", grainName, grains[grainName]]);
81+
const cmdArr = ["grains.setval", grainName, grains[grainName]];
82+
this.runCommand("", pMinionId, cmdArr);
8283
pClickEvent.stopPropagation();
8384
});
8485
}
@@ -92,20 +93,23 @@ export class GrainsMinionPanel extends Panel {
9293
this.panelMenu.addMenuItem("Add grain...", () => {
9394
// use placeholders for name and value
9495
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
95-
this.runCommand(minionId, ["grains.setval", "<name>", "<value>"]);
96+
const cmdArr = ["grains.setval", "<name>", "<value>"];
97+
this.runCommand("", minionId, cmdArr);
9698
});
9799
}
98100

99101
_addPanelMenuItemSaltUtilRefreshGrains () {
100102
this.panelMenu.addMenuItem("Refresh grains...", () => {
101103
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
102-
this.runCommand(minionId, ["saltutil.refresh_grains"]);
104+
const cmdArr = ["saltutil.refresh_grains"];
105+
this.runCommand("", minionId, cmdArr);
103106
});
104107
}
105108

106109
_addMenuItemGrainsSetValUpdate (pMenu, pMinionId, key, grains) {
107110
pMenu.addMenuItem("Edit grain...", () => {
108-
this.runCommand(pMinionId, ["grains.setval", key, grains[key]]);
111+
const cmdArr = ["grains.setval", key, grains[key]];
112+
this.runCommand("", pMinionId, cmdArr);
109113
});
110114
}
111115

@@ -114,7 +118,8 @@ export class GrainsMinionPanel extends Panel {
114118
return;
115119
}
116120
pMenu.addMenuItem("Add value...", () => {
117-
this.runCommand(pMinionId, ["grains.append", key, "<value>"]);
121+
const cmdArr = ["grains.append", key, "<value>"];
122+
this.runCommand("", pMinionId, cmdArr);
118123
});
119124
}
120125

@@ -125,7 +130,7 @@ export class GrainsMinionPanel extends Panel {
125130
}
126131
cmdArr.push(pKey);
127132
pMenu.addMenuItem("Delete key...", () => {
128-
this.runCommand(pMinionId, cmdArr);
133+
this.runCommand("", pMinionId, cmdArr);
129134
});
130135
}
131136

@@ -136,7 +141,7 @@ export class GrainsMinionPanel extends Panel {
136141
}
137142
cmdArr.push(pKey);
138143
pMenu.addMenuItem("Delete value...", () => {
139-
this.runCommand(pMinionId, cmdArr);
144+
this.runCommand("", pMinionId, cmdArr);
140145
});
141146
}
142147
}

saltgui/static/scripts/panels/HighState.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ export class HighStatePanel extends Panel {
5656

5757
_addMenuItemStateApply (pMenu, pMinionId) {
5858
pMenu.addMenuItem("Apply state...", () => {
59-
this.runCommand(pMinionId, ["state.apply"]);
59+
const cmdArr = ["state.apply"];
60+
this.runCommand("", pMinionId, cmdArr);
6061
});
6162
}
6263

6364
_addMenuItemStateApplyTest (pMenu, pMinionId) {
6465
pMenu.addMenuItem("Test state...", () => {
65-
this.runCommand(pMinionId, ["state.apply", "test=", true]);
66+
const cmdArr = ["state.apply", "test=", true];
67+
this.runCommand("", pMinionId, cmdArr);
6668
});
6769
}
6870

@@ -88,9 +90,10 @@ export class HighStatePanel extends Panel {
8890
minionTr.addEventListener("click", (pClickEvent) => {
8991
const functionField = minionTr.querySelector(".function");
9092
if (functionField && functionField.cmd) {
91-
this.runFullCommand("", minionId, functionField.cmd);
93+
this.runCommand("", minionId, functionField.cmd);
9294
} else {
93-
this.runCommand(minionId, ["state.apply"]);
95+
const cmdArr = ["state.apply"];
96+
this.runCommand("", minionId, cmdArr);
9497
}
9598
pClickEvent.stopPropagation();
9699
});
@@ -308,7 +311,8 @@ export class HighStatePanel extends Panel {
308311
continue;
309312
}
310313
span.addEventListener("click", (pClickEvent) => {
311-
this.runCommand(minionId, ["state.sls_id", data.__id__, "mods=", data.__sls__]);
314+
const cmdArr = ["state.sls_id", data.__id__, "mods=", data.__sls__];
315+
this.runCommand("", minionId, cmdArr);
312316
pClickEvent.stopPropagation();
313317
});
314318
Output._setTaskToolTip(span, data);

saltgui/static/scripts/panels/Job.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class JobPanel extends Panel {
104104
return pObj;
105105
}
106106
if (pObj.match(/^[a-z_][a-z0-9_]*(?:[.][a-z0-9_]+)*$/i)) {
107-
// simple string that cannot be confuses with
107+
// simple string that cannot be confused with
108108
// another object type
109109
return pObj;
110110
}
@@ -267,7 +267,7 @@ export class JobPanel extends Panel {
267267
}
268268
return "Re-run job...";
269269
}, () => {
270-
this.runFullCommand(this.targettype, this.target, this.commandtext);
270+
this.runCommand(this.targettype, this.target, this.commandtext);
271271
});
272272
}
273273

@@ -303,7 +303,7 @@ export class JobPanel extends Panel {
303303
return "Re-run job on all minions...";
304304
}, () => {
305305
const lst = this._listForRerunJobOnAllMinions();
306-
this.runFullCommand("list", lst, this.commandtext);
306+
this.runCommand("list", lst, this.commandtext);
307307
});
308308
}
309309

@@ -350,7 +350,7 @@ export class JobPanel extends Panel {
350350
return "Re-run job on unsuccessful minions...";
351351
}, () => {
352352
const lst = this._listForRerunJobOnUnsuccessfulMinions();
353-
this.runFullCommand("list", lst, this.commandtext);
353+
this.runCommand("list", lst, this.commandtext);
354354
});
355355
}
356356

@@ -383,7 +383,7 @@ export class JobPanel extends Panel {
383383
return "Re-run job on failed minions...";
384384
}, () => {
385385
const lst = this._listForRerunJobOnFailedMinions();
386-
this.runFullCommand("list", lst, this.commandtext);
386+
this.runCommand("list", lst, this.commandtext);
387387
});
388388
}
389389

@@ -416,7 +416,7 @@ export class JobPanel extends Panel {
416416
return "Re-run job on non responding minions...";
417417
}, () => {
418418
const lst = this._listForRerunJobOnNonRespondingMinions();
419-
this.runFullCommand("list", lst, this.commandtext);
419+
this.runCommand("list", lst, this.commandtext);
420420
});
421421
}
422422

@@ -427,7 +427,8 @@ export class JobPanel extends Panel {
427427
}
428428
return "Terminate job...";
429429
}, () => {
430-
this.runFullCommand(this.targettype, this.target, "saltutil.term_job " + this.jobid);
430+
const cmdArr = ["saltutil.term_job", this.jobid];
431+
this.runCommand(this.targettype, this.target, cmdArr);
431432
});
432433
}
433434

@@ -438,7 +439,8 @@ export class JobPanel extends Panel {
438439
}
439440
return "Kill job...";
440441
}, () => {
441-
this.runFullCommand(this.targettype, this.target, "saltutil.kill_job " + this.jobid);
442+
const cmdArr = ["saltutil.kill_job", this.jobid];
443+
this.runCommand(this.targettype, this.target, cmdArr);
442444
});
443445
}
444446

@@ -449,7 +451,8 @@ export class JobPanel extends Panel {
449451
}
450452
return "Signal job...";
451453
}, () => {
452-
this.runFullCommand(this.targettype, this.target, "saltutil.signal_job " + this.jobid + " signal=<signalnumber>");
454+
const cmdArr = ["saltutil.signal_job", this.jobid, "signal=", "<signalnumber>"];
455+
this.runCommand(this.targettype, this.target, cmdArr);
453456
});
454457
}
455458

@@ -501,16 +504,20 @@ export class JobPanel extends Panel {
501504

502505
const menu = new DropDownMenu(noResponseSpan, true);
503506
menu.addMenuItem("Show process info...", () => {
504-
this.runFullCommand("list", minionId, "ps.proc_info " + pid);
507+
const cmdArr = ["ps.proc_info", pid];
508+
this.runCommand("", minionId, cmdArr);
505509
});
506510
menu.addMenuItem("Terminate process...", () => {
507-
this.runFullCommand("list", minionId, "ps.kill_pid " + pid + " signal=15");
511+
const cmdArr = ["ps.kill_pid", pid, "signal=", 15];
512+
this.runCommand("", minionId, cmdArr);
508513
});
509514
menu.addMenuItem("Kill process...", () => {
510-
this.runFullCommand("list", minionId, "ps.kill_pid " + pid + " signal=9");
515+
const cmdArr = ["ps.kill_pid", pid, "signal=", 9];
516+
this.runCommand("", minionId, cmdArr);
511517
});
512518
menu.addMenuItem("Signal process...", () => {
513-
this.runFullCommand("list", minionId, "ps.kill_pid " + pid + " signal=<signalnumber>");
519+
const cmdArr = ["ps.kill_pid", pid, "signal=", "<signalnumber>"];
520+
this.runCommand("", minionId, cmdArr);
514521
});
515522

516523
noResponseSpan.classList.remove("noresponse");

saltgui/static/scripts/panels/JobsDetails.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ export class JobsDetailsPanel extends JobsPanel {
380380

381381
_addMenuItemJobsRerunJob (pMenu, job, argumentsText) {
382382
pMenu.addMenuItem("Re-run job...", () => {
383-
this.runFullCommand(job["Target-type"], job.Target, job.Function + argumentsText);
383+
const cmdStr = job.Function + argumentsText;
384+
this.runCommand(job["Target-type"], job.Target, cmdStr);
384385
});
385386
}
386387

0 commit comments

Comments
 (0)