Skip to content

Commit

Permalink
completed task-icon changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwin Dondorp authored and erwindon committed May 25, 2024
1 parent dd7ceb0 commit 562167e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 106 deletions.
29 changes: 13 additions & 16 deletions saltgui/static/scripts/output/Output.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class Output {
return false;
}

static _getTaskNrChanges (pTask) {
static getTaskNrChanges (pTask) {
if (!pTask.changes) {
return 0;
}
Expand Down Expand Up @@ -393,24 +393,21 @@ export class Output {
}

static getTaskClass (pTask) {
let className;

if (pTask.result === null) {
return "task-skipped";
}
if (pTask.result === false) {
return "task-failure";
}
if (Array.isArray(pTask.changes)) {
return pTask.changes.length ? "task-changes" : "task-success";
}
if (typeof pTask.changes !== "object") {
// pretend 1 change
return "task-changes";
className = "task-skipped";
} else if (pTask.result === false) {
className = "task-failure";
} else {
className = "task-success";
}
if (Object.keys(pTask.changes).length === 0) {
// empty changes object does not count as real change
return "task-success";

if (Output.getTaskNrChanges(pTask) > 0) {
className += "-changes";
}
return "task-changes";

return className;
}

static _setTaskToolTip (pSpan, pTask) {
Expand Down
28 changes: 7 additions & 21 deletions saltgui/static/scripts/output/OutputHighstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,8 @@ export class OutputHighstate {

const functionName = components[0] + "." + components[3];

let hasChanges = false;
let chgs = null;
if (task["changes"] !== undefined) {
chgs = task.changes;
const keys = Object.keys(chgs);
if (keys.length === 2 && keys[0] === "out" && keys[1] === "ret") {
chgs = chgs["ret"];
}
const str = JSON.stringify(chgs);
if (str !== "{}") {
hasChanges = true;
}
changesDetail += Object.keys(chgs).length;
}
const nrChanges = Output.getTaskNrChanges(task);
changesDetail += nrChanges;

const taskId = components[1];
let taskName = components[2];
Expand All @@ -156,23 +144,21 @@ export class OutputHighstate {
taskSpan = OutputHighstateTaskTerse.getStateOutput(task, taskName, functionName);
} else if (Output.isStateOutputSelected("mixed") && task.result) {
taskSpan = OutputHighstateTaskTerse.getStateOutput(task, taskName, functionName);
} else if (Output.isStateOutputSelected("changes") && task.result && hasChanges) {
} else if (Output.isStateOutputSelected("changes") && task.result && nrChanges) {
taskSpan = OutputHighstateTaskTerse.getStateOutput(task, taskName, functionName);
} else if (Output.isOutputFormatAllowed("saltguihighstate")) {
taskSpan = OutputHighstateTaskSaltGui.getStateOutput(task, taskId, taskName, functionName, pMinionId, pJobId);
} else {
taskSpan = OutputHighstateTaskFull.getStateOutput(task, taskId, taskName, functionName);
}

taskSpan.classList.add(Output.getTaskClass(task));
if (task.result === null) {
taskSpan.classList.add("task-skipped");
// VOID
} else if (!task.result) {
taskSpan.classList.add("task-failure");
} else if (hasChanges) {
taskSpan.classList.add("task-changes");
// VOID
} else if (nrChanges) {
changesSummary += 1;
} else {
taskSpan.classList.add("task-success");
}
const taskDiv = Utils.createDiv("", "", Utils.getIdFromMinionId(pMinionId + "." + nr));
taskDiv.append(taskSpan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class OutputHighstateSummaryOriginal {
pDiv.append(oSpan);

txt = "changed=" + pChangesSummary;
const changedSpan = Utils.createSpan("task-changes", txt);
const changedSpan = Utils.createSpan("task-success-changes", txt);
pDiv.append(changedSpan);

txt = ")";
Expand Down
63 changes: 34 additions & 29 deletions saltgui/static/scripts/panels/HighState.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export class HighStatePanel extends Panel {
// we may use it for presentation (keys.length <= this._maxHighstateStates); or
// for information (keys.length > this._maxHighstateStates)

const span = Utils.createSpan("task", Character.BLACK_CIRCLE);
const span = Utils.createSpan("task");
span.style.backgroundColor = "black";

// this also sets the span's class(es)
Expand All @@ -438,32 +438,38 @@ export class HighStatePanel extends Panel {
span.classList.add("task");

if (keys.length > this._maxHighstateStates) {
let statKey = "";
let prio = 0;

// statkeys are sortable on their priority
if (span.classList.contains("task-skipped")) {
statKey = "task-skipped";
prio = 31;
} else if (span.classList.contains("task-success")) {
statKey = "task-success";
prio = 41;
} else if (span.classList.contains("task-failure")) {
statKey = "task-failure";
prio = 21;
} else {
statKey = "task-unknown";
prio = 11;
}

if (span.classList.contains("task-changes")) {
prio -= 1;
statKey += " task-changes";
span.innerText = Character.BLACK_DIAMOND;
const taskClass = Output.getTaskClass(data);
const taskChar = Output.getTaskCharacter(data);

// priority must always be a 2-digit value (i.e. 10..99)
let priority;

// taskClass is to be sorted on its priority (low to high)
switch (taskClass) {
case "task-success":
priority = 41;
break;
case "task-success-changes":
priority = 40;
break;
case "task-skipped":
priority = 31;
break;
case "task-skipped-changes":
priority = 30;
break;
case "task-failure":
priority = 21;
break;
case "task-failure-changes":
priority = 20;
break;
default:
priority = 11;
}

// allow keys to be sortable
statKey = prio + statKey;
const statKey = priority + taskClass + taskChar;

if (statKey in stats) {
stats[statKey] += 1;
Expand Down Expand Up @@ -491,18 +497,17 @@ export class HighStatePanel extends Panel {

// show the summary when one was build up
for (const statKey of Object.keys(stats).sort()) {
const character = statKey.substring(statKey.length - 1);
const className = statKey.substring(2, statKey.length - 1);
const sepSpan = Utils.createSpan("", sep + stats[statKey] + Character.MULTIPLICATION_SIGN);
summarySpan.append(sepSpan);
sep = " ";

// remove the priority indicator from the key
const itemSpan = Utils.createSpan(["tasksummary", "taskcircle"], Character.BLACK_CIRCLE);
itemSpan.classList.add(...statKey.substring(2).split(" "));
if(itemSpan.classList.contains("task-changes")) {
itemSpan.innerText = Character.BLACK_DIAMOND;
}
const itemSpan = Utils.createSpan(["tasksummary", className], character);
itemSpan.style.backgroundColor = "black";
summarySpan.append(itemSpan);
Utils.addToolTip(itemSpan, className.replace("task-", "").replace("-", " with "));
}

// allow similar navigation, but just only to the job level
Expand Down
58 changes: 19 additions & 39 deletions saltgui/static/stylesheets/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,52 +73,17 @@ td.tasks span.tasksummary {
padding-right: 2px;
}

td .task-failure {
color: red;
}

pre .task-failure {
cursor: pointer;
color: red;
}

pre .minion-id.host-skips,
pre #summary-jobs-active .host-skips,
pre .minion-id.host-no-response,
pre #summary-jobs-active .host-no-response {
color: yellow;
}

td .task-skipped {
color: yellow;
}

pre .task-skipped {
cursor: pointer;
color: yellow;
}

pre .minion-id {
color: #4caf50;
}

td .task-success {
color: lime;
}

pre .task-success {
cursor: pointer;
color: lime;
}

td .task-changes {
color: aqua;
}

pre .task-changes {
color: aqua;
}

.task-summary {
word-break: break-all;
line-height: 2em;
Expand Down Expand Up @@ -311,20 +276,35 @@ table tr td:last-of-type {
}
}

/* taskcircle */
/* tasks */

.taskcircle.task-success {
.task-success {
color: lime;
}

.taskcircle.task-failure {
.task-success-changes {
color: aqua;
}

.task-failure,
.task-failure-changes {
color: red;
}

.taskcircle.task-skipped {
.task-skipped,
.task-skipped-changes {
color: yellow;
}

pre .task-success,
pre .task-success-changes,
pre .task-skipped,
pre .task-skipped-changes,
pre .task-failure,
pre .task-failure-changes {
cursor: pointer;
}

@media print {
.no-print,
.no-print * {
Expand Down

0 comments on commit 562167e

Please sign in to comment.