Skip to content

Commit 2cfc7a8

Browse files
authored
Merge pull request #578 from erwindon/auto-update-jobinfo
Showing output automatically upon completion and animated icon
2 parents 3a20dfb + f478f1f commit 2cfc7a8

13 files changed

Lines changed: 63 additions & 17 deletions

File tree

saltgui/static/scripts/DropDown.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class DropDownMenu {
2424

2525
// Creates an empty dropdown menu
2626
// The visual clue for the menu is added to the given element
27-
constructor (pParentElement, pIsSmall) {
27+
constructor (pParentElement, pStyle) {
2828

2929
// allow reduced code on the caller side
3030
if (pParentElement.tagName === "TR") {
@@ -48,8 +48,8 @@ export class DropDownMenu {
4848
this.menuButton = Utils.createDiv("", Character.CH_HAMBURGER);
4949
}
5050
this.menuButton.classList.add("small-button", "small-button-for-hover", "menu-dropdown");
51-
if (pIsSmall) {
52-
this.menuButton.classList.add("small-small-button");
51+
if (pStyle) {
52+
this.menuButton.classList.add(pStyle + "-small-button");
5353
}
5454
this.menuButton.addEventListener("click", (pClickEvent) => {
5555
// better support for touch screens where user touch

saltgui/static/scripts/Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export class Utils {
257257

258258
const menuAndFieldDiv = Utils.createDiv("search-menu-and-field", "");
259259

260-
const searchOptionsMenu = new DropDownMenu(menuAndFieldDiv, true);
260+
const searchOptionsMenu = new DropDownMenu(menuAndFieldDiv, "smaller");
261261

262262
const input = Utils.createElem("input", "filter-text");
263263
input.type = "text";

saltgui/static/scripts/issues/Issues.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class Issues {
4949

5050
const theTr = Utils.createTr();
5151

52-
const menu = new DropDownMenu(theTr, true);
52+
const menu = new DropDownMenu(theTr, "smaller");
5353
theTr.menu = menu;
5454

5555
const descTd = Utils.createTd();

saltgui/static/scripts/panels/BeaconsMinion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class BeaconsMinionPanel extends Panel {
141141
for (const beaconName of keys) {
142142
const tr = Utils.createTr("", "", "beacon-" + beaconName);
143143

144-
const beaconMenu = new DropDownMenu(tr, true);
144+
const beaconMenu = new DropDownMenu(tr, "smaller");
145145

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

saltgui/static/scripts/panels/GrainsMinion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class GrainsMinionPanel extends Panel {
6969
for (const grainName of grainNames) {
7070
const grainTr = Utils.createTr();
7171

72-
const grainMenu = new DropDownMenu(grainTr, true);
72+
const grainMenu = new DropDownMenu(grainTr, "smaller");
7373

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

saltgui/static/scripts/panels/Job.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class JobPanel extends Panel {
1919
}
2020
this.addPanelMenu();
2121
this.addSearchButton();
22+
this.addPlayPauseButton();
2223

2324
// 1: re-run with original target pattern
2425
this._addPanelMenuItemJobRerunJob();
@@ -57,6 +58,31 @@ export class JobPanel extends Panel {
5758
this.div.append(this.output);
5859
}
5960

61+
updateFooter () {
62+
// PlayPause uses this as call-back
63+
if (this.playOrPause === "play" || this.playOrPause === "pause") {
64+
// store the user preference for next time
65+
Utils.setStorageItem("local", "jobrefresh", this.playOrPause);
66+
}
67+
}
68+
69+
_scheduleRefreshJob () {
70+
const jobsActiveSpan = document.getElementById("summary-jobs-active");
71+
if (jobsActiveSpan && jobsActiveSpan.innerText === "done") {
72+
// no updates after "done"
73+
this.setPlayPauseButton("none");
74+
return;
75+
}
76+
77+
window.setTimeout(() => {
78+
if (this.playOrPause === "play") {
79+
this.onShow();
80+
} else {
81+
this._scheduleRefreshJob();
82+
}
83+
}, 5000);
84+
}
85+
6086
onShow () {
6187
const jobId = decodeURIComponent(Utils.getQueryParam("id"));
6288
const minionId = decodeURIComponent(Utils.getQueryParam("minionid"));
@@ -70,17 +96,26 @@ export class JobPanel extends Panel {
7096
this._handleJobRunnerJobsListJob(pRunnerJobsListJobData, jobId, minionId);
7197
runnerJobsActivePromise.then((pRunnerJobsActiveData) => {
7298
this._handleRunnerJobsActive(jobId, pRunnerJobsActiveData);
99+
this._scheduleRefreshJob();
73100
return true;
74101
}, (pRunnerJobsActiveMsg) => {
75102
this._handleRunnerJobsActive(jobId, JSON.stringify(pRunnerJobsActiveMsg));
103+
this.setPlayPauseButton("none");
76104
return false;
77105
});
78106
return true;
79107
}, (pRunnerJobsListJobsMsg) => {
80108
this._handleJobRunnerJobsListJob(JSON.stringify(pRunnerJobsListJobsMsg), jobId, undefined);
81109
Utils.ignorePromise(runnerJobsActivePromise);
110+
this.setPlayPauseButton("none");
82111
return false;
83112
});
113+
114+
let jobRefresh = Utils.getStorageItem("local", "jobrefresh", "pause");
115+
if (jobRefresh !== "play" && jobRefresh !== "pause") {
116+
jobRefresh = "pause";
117+
}
118+
this.setPlayPauseButton(jobRefresh);
84119
}
85120

86121
static _isResultOk (result) {
@@ -488,6 +523,7 @@ export class JobPanel extends Panel {
488523
if (typeof pData !== "object") {
489524
summaryJobsActiveSpan.innerText = "(error)";
490525
Utils.addToolTip(summaryJobsActiveSpan, pData, "bottom-left");
526+
this.setPlayPauseButton("none");
491527
return;
492528
}
493529

@@ -497,6 +533,7 @@ export class JobPanel extends Panel {
497533
if (!info) {
498534
summaryJobsActiveSpan.innerText = "done";
499535
this.jobIsTerminated = true;
536+
this.setPlayPauseButton("none");
500537
return;
501538
}
502539
this.jobIsTerminated = false;
@@ -525,7 +562,7 @@ export class JobPanel extends Panel {
525562
// show that this minion is still active on the request
526563
noResponseSpan.innerText = "(active) ";
527564

528-
const menu = new DropDownMenu(noResponseSpan, true);
565+
const menu = new DropDownMenu(noResponseSpan, "verysmall");
529566
menu.addMenuItem("Show process info...", () => {
530567
const cmdArr = ["ps.proc_info", pid];
531568
this.runCommand("", minionId, cmdArr);

saltgui/static/scripts/panels/JobsDetails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ export class JobsDetailsPanel extends JobsPanel {
337337
tr.id = Utils.getIdFromJobId(job.id);
338338
tr.dataset.jobid = job.id;
339339

340-
const menu = new DropDownMenu(tr, true);
340+
const menu = new DropDownMenu(tr, "smaller");
341341

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

saltgui/static/scripts/panels/JobsSummary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class JobsSummaryPanel extends JobsPanel {
3737
tr.id = Utils.getIdFromJobId(job.id);
3838

3939
// menu on left side to prevent it from going past end of window
40-
const menu = new DropDownMenu(tr, true);
40+
const menu = new DropDownMenu(tr, "smaller");
4141

4242
const td = Utils.createTd();
4343

saltgui/static/scripts/panels/Nodegroups.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class NodegroupsPanel extends Panel {
148148
oldMenuButton.parentElement.remove();
149149
const newMenuButton = Utils.createTd();
150150
minionTr2.insertBefore(newMenuButton, minionTr2.firstChild);
151-
minionTr2.dropdownmenu = new DropDownMenu(newMenuButton, true);
151+
minionTr2.dropdownmenu = new DropDownMenu(newMenuButton, "smaller");
152152
if (minionIsOk) {
153153
this._addMenuItemStateApplyMinion(minionTr2.dropdownmenu, pMinionId);
154154
this._addMenuItemStateApplyTestMinion(minionTr2.dropdownmenu, pMinionId);
@@ -300,7 +300,7 @@ export class NodegroupsPanel extends Panel {
300300
tr.style.borderTop = "4px double #ddd";
301301

302302
const menuTd = Utils.createTd();
303-
tr.dropdownmenu = new DropDownMenu(menuTd, true);
303+
tr.dropdownmenu = new DropDownMenu(menuTd, "smaller");
304304
tr.appendChild(menuTd);
305305

306306
const titleTd = Utils.createTd();

saltgui/static/scripts/panels/Panel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export class Panel {
394394

395395
// drop down menu
396396
const menuTd = Utils.createTd();
397-
const menu = new DropDownMenu(menuTd, true);
397+
const menu = new DropDownMenu(menuTd, "smaller");
398398
minionTr.dropdownmenu = menu;
399399
minionTr.appendChild(menuTd);
400400

@@ -434,7 +434,7 @@ export class Panel {
434434

435435
// drop down menu
436436
const menuTd = Utils.createTd();
437-
const menu = new DropDownMenu(menuTd, true);
437+
const menu = new DropDownMenu(menuTd, "smaller");
438438
minionTr.dropdownmenu = menu;
439439
minionTr.appendChild(menuTd);
440440

0 commit comments

Comments
 (0)