Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwin Dondorp committed Apr 27, 2024
1 parent c1c090c commit 580946f
Showing 1 changed file with 47 additions and 20 deletions.
67 changes: 47 additions & 20 deletions saltgui/static/scripts/output/Output.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,49 @@ export class Output {
return false;
}

static _getTaskInfo (pTask) {
if (!pTask.changes) {
return {
"nrChanges": 0,
"character": Character.BLACK_CIRCLE
};
}
if (typeof pTask.changes !== "object") {
return {
"nrChanges": 1,
"txt": "'changes' has type " + typeof pTask.changes,
"character": Character.BLACK_CIRCLE
};
}
if (Array.isArray(pTask.changes)) {
if (pTask.changes.length) {
return {
"nrChanges": pTask.changes.length,
"txt": "'changes' is an array" + Utils.txtZeroOneMany(nrChanges, "", "\n" + nrChanges + " change", "\n" + nrChanges + " changes"),
"character": Character.BLACK_DIAMOND
};
} else {
return {
"nrChanges": pTask.changes.length,
"txt": "'changes' is an array",
"character": Character.BLACK_CIRCLE
};
}
}
if (Object.keys(pTask.changes).length === 0) {
// empty changes object does not count as real change
return {
"nrChanges": 0,
"character": Character.BLACK_CIRCLE
};
}
return {
"nrChanges": 1,
"txt": "changed",
"character": Character.BLACK_DIAMOND
};
}

static _setTaskToolTip (pSpan, pTask) {

if (typeof pTask !== "object") {
Expand All @@ -362,23 +405,9 @@ export class Output {
txt += "\n" + functionName;
}

let nrChanges;
if (!pTask.changes) {
nrChanges = 0;
} else if (typeof pTask.changes !== "object") {
nrChanges = 1;
txt += "\n'changes' has type " + typeof pTask.changes;
} else if (Array.isArray(pTask.changes)) {
nrChanges = pTask.changes.length;
txt += "\n'changes' is an array";
txt += Utils.txtZeroOneMany(nrChanges, "", "\n" + nrChanges + " change", "\n" + nrChanges + " changes");
} else if (typeof pTask.changes === "object" && Object.keys(pTask.changes).length === 0) {
// empty changes object does not count as real change
nrChanges = 0;
} else {
nrChanges = 1;
txt += "\nchanged";
}
const taskInfo = Output._getTaskInfo(pTask);
const nrChanges = taskInfo.nrChanges;
txt += taskInfo.txt;

if (Output.isHiddenTask(pTask)) {
txt += "\nhidden";
Expand All @@ -396,9 +425,7 @@ export class Output {
} else {
pSpan.classList.add("task-failure");
}
if (nrChanges) {
pSpan.innerText = Character.BLACK_DIAMOND;
}
pSpan.innerText = taskInfo.character;

for (const key in pTask) {
/* eslint-disable curly */
Expand Down

0 comments on commit 580946f

Please sign in to comment.