Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwin Dondorp authored and erwindon committed May 12, 2024
1 parent f3eedea commit b5cc4d1
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 111 deletions.
11 changes: 4 additions & 7 deletions saltgui/static/scripts/panels/Beacons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* global */

import {DropDownMenu} from "../DropDown.js";
import {Panel} from "./Panel.js";
import {Utils} from "../Utils.js";

Expand All @@ -11,7 +10,7 @@ export class BeaconsPanel extends Panel {

this.addTitle("Beacons");
this.addSearchButton();
this.addTable(["Minion", "Status", "Beacons", "-menu-"]);
this.addTable(["-menu-", "Minion", "Status", "Beacons"]);
this.setTableSortable("Minion", "asc");
this.setTableClickable("page");
this.addMsg();
Expand Down Expand Up @@ -90,11 +89,10 @@ export class BeaconsPanel extends Panel {

const minionIds = keys.minions.sort();
for (const minionId of minionIds) {
const minionTr = this.addMinion(minionId, 1);
const minionTr = this.addMinion(minionId);

// preliminary dropdown menu
const menu = new DropDownMenu(minionTr, true);
this._addMenuItemShowBeacons(menu, minionId);
this._addMenuItemShowBeacons(minionTr.dropdownmenu, minionId);

minionTr.addEventListener("click", (pClickEvent) => {
this.router.goTo("beacons-minion", {"minionid": minionId}, undefined, pClickEvent);
Expand Down Expand Up @@ -139,8 +137,7 @@ export class BeaconsPanel extends Panel {
minionTr.appendChild(beaconInfoTd);
}

const menu = new DropDownMenu(minionTr, true);
this._addMenuItemShowBeacons(menu, pMinionId);
this._addMenuItemShowBeacons(minionTr.dropdownmenu, pMinionId);
}

_addMenuItemShowBeacons (pMenu, pMinionId) {
Expand Down
5 changes: 3 additions & 2 deletions saltgui/static/scripts/panels/BeaconsMinion.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class BeaconsMinionPanel extends Panel {
"Note that some beacons produce multiple values, e.g. one per disk.",
"In that case, effectively only one of the values is visible here."
]);
this.addTable(["Name", "-menu-", "Config", "Timestamp", "Value", "-help-"]);
this.addTable(["-menu-", "Name", "Config", "Timestamp", "Value", "-help-"]);
this.setTableSortable("Name", "asc");
this.setTableClickable("cmd");
this.addMsg();
Expand Down Expand Up @@ -141,6 +141,8 @@ export class BeaconsMinionPanel extends Panel {
for (const beaconName of keys) {
const tr = Utils.createTr("", "", "beacon-" + beaconName);

const beaconMenu = new DropDownMenu(tr, true);

const nameTd = Utils.createTd("beacon-name", beaconName);
tr.appendChild(nameTd);

Expand All @@ -154,7 +156,6 @@ export class BeaconsMinionPanel extends Panel {
delete beacon.enabled;
}

const beaconMenu = new DropDownMenu(tr, true);
this._addMenuItemBeaconsDisableBeaconWhenNeeded(beaconMenu, pMinionId, beaconName, beacon);
this._addMenuItemBeaconsEnableBeaconWhenNeeded(beaconMenu, pMinionId, beaconName, beacon);
this._addMenuItemBeaconsDelete(beaconMenu, pMinionId, beaconName);
Expand Down
11 changes: 4 additions & 7 deletions saltgui/static/scripts/panels/Grains.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* global jsonPath */

import {DropDownMenu} from "../DropDown.js";
import {Output} from "../output/Output.js";
import {Panel} from "./Panel.js";
import {Utils} from "../Utils.js";
Expand All @@ -18,7 +17,7 @@ export class GrainsPanel extends Panel {
"See README.md for more details."
]);
this.addWarningField();
this.addTable(["Minion", "Status", "Salt version", "OS version", "Grains", "-menu-"]);
this.addTable(["-menu-", "Minion", "Status", "Salt version", "OS version", "Grains"]);

// cannot initialize sorting before all columns are present
// this.setTableSortable("Minion", "asc");
Expand Down Expand Up @@ -83,11 +82,10 @@ export class GrainsPanel extends Panel {

const minionIds = keys.minions.sort();
for (const minionId of minionIds) {
const minionTr = this.addMinion(minionId, 1 + this.previewGrains.length);
const minionTr = this.addMinion(minionId, this.previewGrains.length);

// preliminary dropdown menu
const menu = new DropDownMenu(minionTr, true);
this._addMenuItemShowGrains(menu, minionId);
this._addMenuItemShowGrains(minionTr.dropdownmenu, minionId);

for (let i = 0; i < this.previewGrains.length; i++) {
minionTr.appendChild(Utils.createTd());
Expand Down Expand Up @@ -134,8 +132,7 @@ export class GrainsPanel extends Panel {
minionTr.appendChild(grainInfoTd);
}

const menu = new DropDownMenu(minionTr, true);
this._addMenuItemShowGrains(menu, pMinionId);
this._addMenuItemShowGrains(minionTr.dropdownmenu, pMinionId);

// add the preview columns
/* eslint-disable max-depth */
Expand Down
5 changes: 3 additions & 2 deletions saltgui/static/scripts/panels/GrainsMinion.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class GrainsMinionPanel extends Panel {
this.addCloseButton();
}
this.addWarningField();
this.addTable(["Name", "-menu-", "Value"]);
this.addTable(["-menu-", "Name", "Value"]);
this.setTableSortable("Name", "asc");
this.setTableClickable("cmd");
this.addMsg();
Expand Down Expand Up @@ -69,12 +69,13 @@ export class GrainsMinionPanel extends Panel {
for (const grainName of grainNames) {
const grainTr = Utils.createTr();

const grainMenu = new DropDownMenu(grainTr, true);

const grainNameTd = Utils.createTd("grain-name", grainName);
grainTr.appendChild(grainNameTd);

const grainValue = Output.formatObject(grains[grainName]);

const grainMenu = new DropDownMenu(grainTr, true);
this._addMenuItemGrainsSetValUpdate(grainMenu, pMinionId, grainName, grains);
this._addMenuItemGrainsAppendWhenNeeded(grainMenu, pMinionId, grainName, grainValue);
this._addMenuItemGrainsDelKey(grainMenu, pMinionId, grainName, grains[grainName]);
Expand Down
19 changes: 7 additions & 12 deletions saltgui/static/scripts/panels/HighState.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global */

import {Character} from "../Character.js";
import {DropDownMenu} from "../DropDown.js";
import {JobPanel} from "./Job.js";
import {JobsPanel} from "./Jobs.js";
import {Output} from "../output/Output.js";
Expand Down Expand Up @@ -36,7 +35,7 @@ export class HighStatePanel extends Panel {
"Click on an individual state to re-apply only that state."
]);
this.addWarningField();
this.addTable(["Minion", "State", "Latest JID", "Target", "Function", "Start Time", "-menu-", "States"]);
this.addTable(["-menu-", "Minion", "State", "Latest JID", "Target", "Function", "Start Time", "States"]);
this.setTableSortable("Minion", "asc");
this.setTableClickable("cmd");
this.addMsg();
Expand Down Expand Up @@ -138,14 +137,11 @@ export class HighStatePanel extends Panel {
this.nrUnaccepted = keys.minions_pre.length;

for (const minionId of minionIds) {
const minionTr = this.addMinion(minionId, 2);
const minionTr = this.addMinion(minionId);

// preliminary dropdown menu
const menu = new DropDownMenu(minionTr, true);
this._addMenuItemStateApply(menu, minionId);
this._addMenuItemStateApplyTest(menu, minionId);

minionTr.appendChild(Utils.createTd());
this._addMenuItemStateApply(minionTr.dropdownmenu, minionId);
this._addMenuItemStateApplyTest(minionTr.dropdownmenu, minionId);

minionTr.addEventListener("click", (pClickEvent) => {
const functionField = minionTr.querySelector(".function");
Expand Down Expand Up @@ -402,10 +398,9 @@ export class HighStatePanel extends Panel {
startTimeTd.appendChild(startTimeSpan);
minionTr.appendChild(startTimeTd);

const menu = new DropDownMenu(minionTr, true);
this._addMenuItemStateApply(menu, minionId);
this._addMenuItemStateApplyTest(menu, minionId);
this._addJobsMenuItemShowDetails(menu, jobData, minionId);
this._addMenuItemStateApply(minionTr.dropdownmenu, minionId);
this._addMenuItemStateApplyTest(minionTr.dropdownmenu, minionId);
this._addJobsMenuItemShowDetails(minionTr.dropdownmenu, jobData, minionId);

const minionResult = jobData.Result[minionId];
const tasksTd = Utils.createTd("tasks");
Expand Down
8 changes: 5 additions & 3 deletions saltgui/static/scripts/panels/JobsDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class JobsDetailsPanel extends JobsPanel {
"It is possible to define exceptions on that, and also to define additions to that.",
"See README.md for more details."
]);
this.addTable(["JID", "Target", "Function", "Start Time", "-menu-", "Status", "Details"], "data-list-jobs");
this.addTable(["-menu-", "JID", "Target", "Function", "Start Time", "Status", "Details"], "data-list-jobs");
this.setTableSortable("JID", "desc");
this.setTableClickable("page");
this.addMsg();
Expand Down Expand Up @@ -176,7 +176,7 @@ export class JobsDetailsPanel extends JobsPanel {

if (this.nrErrors >= 3) {
// don't bother getting more data
// may show more then 3 errors when some are stil in-flight
// may show more then 3 errors when some are still in-flight
this._handleJobsRunnerJobsListJob(jobId, "skipped");
continue;
}
Expand Down Expand Up @@ -336,6 +336,9 @@ export class JobsDetailsPanel extends JobsPanel {
const tr = Utils.createTr();
tr.id = Utils.getIdFromJobId(job.id);
tr.dataset.jobid = job.id;

const menu = new DropDownMenu(tr, true);

tr.appendChild(Utils.createTd("", job.id));

let targetText = TargetType.makeTargetText(job);
Expand All @@ -360,7 +363,6 @@ export class JobsDetailsPanel extends JobsPanel {
startTimeTd.appendChild(startTimeSpan);
tr.appendChild(startTimeTd);

const menu = new DropDownMenu(tr, true);
this._addJobsMenuItemShowDetails(menu, job);
this._addMenuItemJobsRerunJob(menu, job, argumentsText);

Expand Down
5 changes: 4 additions & 1 deletion saltgui/static/scripts/panels/JobsSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class JobsSummaryPanel extends JobsPanel {
const tr = Utils.createTr();
tr.id = Utils.getIdFromJobId(job.id);

// menu on left side to prevent it from going past end of window
const menu = new DropDownMenu(tr, true);

const td = Utils.createTd();

let targetText = TargetType.makeTargetText(job);
Expand Down Expand Up @@ -70,7 +73,7 @@ export class JobsSummaryPanel extends JobsPanel {

tr.appendChild(td);

const menu = new DropDownMenu(tr, true);
// complete the menu
this._addMenuItemShowDetails(menu, job);
this._addMenuItemUpdateStatus(menu, statusSpan);

Expand Down
17 changes: 7 additions & 10 deletions saltgui/static/scripts/panels/Keys.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global */

import {Character} from "../Character.js";
import {DropDownMenu} from "../DropDown.js";
import {Panel} from "./Panel.js";
import {Utils} from "../Utils.js";

Expand All @@ -28,7 +27,7 @@ export class KeysPanel extends Panel {
"automatically refreshed."
]);
this.addWarningField();
this.addTable(["Minion", "Status", "-menu-", "Fingerprint"], "data-list-keys");
this.addTable(["-menu-", "Minion", "Status", "Fingerprint"], "data-list-keys");
this.setTableSortable("Status", "asc");
this.addMsg();

Expand Down Expand Up @@ -255,7 +254,7 @@ export class KeysPanel extends Panel {
}
}

const minionIdTd = pMinionTr.querySelector("td");
const minionIdTd = pMinionTr.querySelectorAll("td")[1];
const minionIdSpan = minionIdTd.querySelector("span");

if (txt) {
Expand Down Expand Up @@ -399,12 +398,10 @@ export class KeysPanel extends Panel {

_addDropDownMenu (pMinionTr, pMinionId, pStatusField) {
// final dropdownmenu
const menu = new DropDownMenu(pMinionTr, true);
this._addMenuItemWheelKeyAccept1(menu, pMinionId, pStatusField);
this._addMenuItemWheelKeyReject(menu, pMinionId, pStatusField);
this._addMenuItemWheelKeyDelete(menu, pMinionId, pStatusField);
this._addMenuItemWheelKeyAccept2(menu, pMinionId, pStatusField);
pMinionTr.saltguidropdownmenu = menu;
this._addMenuItemWheelKeyAccept1(pMinionTr.dropdownmenu, pMinionId, pStatusField);
this._addMenuItemWheelKeyReject(pMinionTr.dropdownmenu, pMinionId, pStatusField);
this._addMenuItemWheelKeyDelete(pMinionTr.dropdownmenu, pMinionId, pStatusField);
this._addMenuItemWheelKeyAccept2(pMinionTr.dropdownmenu, pMinionId, pStatusField);
}

_addMenuItemWheelKeyAccept1 (pMenu, pMinionId, pStatusField) {
Expand Down Expand Up @@ -648,7 +645,7 @@ export class KeysPanel extends Panel {
}
// keep the fingerprint
// update the menu because it may be in a hidden state
tr.saltguidropdownmenu.verifyAll();
tr.dropdownmenu.verifyAll();
this.panelMenu.verifyAll();
} else if (this.table.querySelector("tr") === null) {
// only when the full list is already available
Expand Down
31 changes: 14 additions & 17 deletions saltgui/static/scripts/panels/Minions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global */

import {Character} from "../Character.js";
import {DropDownMenu} from "../DropDown.js";
import {Panel} from "./Panel.js";
import {Utils} from "../Utils.js";

Expand All @@ -23,7 +22,7 @@ export class MinionsPanel extends Panel {
this._addMenuItemStateApplyTest(this.panelMenu, "*");
this.addSearchButton();
this.addWarningField();
this.addTable(["Minion", "Status", "Salt version", "OS version", "-menu-"]);
this.addTable(["-menu-", "Minion", "Status", "Salt version", "OS version"]);
this.setTableSortable("Minion", "asc");
this.setTableClickable("cmd");
this.addMsg();
Expand Down Expand Up @@ -91,16 +90,15 @@ export class MinionsPanel extends Panel {

const minionIds = keys.minions.sort();
for (const minionId of minionIds) {
const minionTr = this.addMinion(minionId, 1);
const minionTr = this.addMinion(minionId);

// preliminary dropdown menu
const menu = new DropDownMenu(minionTr, true);
this._addMenuItemStateApply(menu, minionId);
this._addMenuItemStateApplyTest(menu, minionId);
this._addMenuItemShowGrains(menu, minionId);
this._addMenuItemShowPillars(menu, minionId);
this._addMenuItemShowSchedules(menu, minionId);
this._addMenuItemShowBeacons(menu, minionId);
this._addMenuItemStateApply(minionTr.dropdownmenu, minionId);
this._addMenuItemStateApplyTest(minionTr.dropdownmenu, minionId);
this._addMenuItemShowGrains(minionTr.dropdownmenu, minionId);
this._addMenuItemShowPillars(minionTr.dropdownmenu, minionId);
this._addMenuItemShowSchedules(minionTr.dropdownmenu, minionId);
this._addMenuItemShowBeacons(minionTr.dropdownmenu, minionId);
}

this.updateFooter();
Expand Down Expand Up @@ -190,13 +188,12 @@ export class MinionsPanel extends Panel {
super.updateMinion(pMinionData, pMinionId, pAllMinionsGrains);

const minionTr = this.table.querySelector("#" + Utils.getIdFromMinionId(pMinionId));
const menu = new DropDownMenu(minionTr, true);
this._addMenuItemStateApply(menu, pMinionId);
this._addMenuItemStateApplyTest(menu, pMinionId);
this._addMenuItemShowGrains(menu, pMinionId);
this._addMenuItemShowPillars(menu, pMinionId);
this._addMenuItemShowSchedules(menu, pMinionId);
this._addMenuItemShowBeacons(menu, pMinionId);
this._addMenuItemStateApply(minionTr.dropdownmenu, pMinionId);
this._addMenuItemStateApplyTest(minionTr.dropdownmenu, pMinionId);
this._addMenuItemShowGrains(minionTr.dropdownmenu, pMinionId);
this._addMenuItemShowPillars(minionTr.dropdownmenu, pMinionId);
this._addMenuItemShowSchedules(minionTr.dropdownmenu, pMinionId);
this._addMenuItemShowBeacons(minionTr.dropdownmenu, pMinionId);

minionTr.addEventListener("click", (pClickEvent) => {
const cmdArr = ["state.apply"];
Expand Down
Loading

0 comments on commit b5cc4d1

Please sign in to comment.