Skip to content

Commit

Permalink
Show more details on what salt is doing on about page
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronRP committed Feb 16, 2024
1 parent be0bd5e commit 05d1f5d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
27 changes: 26 additions & 1 deletion html/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,31 @@ <h3>Device<br></h3>
</label>
</div>

<div class="row">
<p class="col-2 text-left">Running Salt Command:</p>
<p id="running-salt-command" class="col-9 monospace"></p>
</div>
<div class="row">
<p class="col-2 text-left">Salt Arguments:</p>
<p id="running-salt-arguements" class="col-9 monospace"></p>
</div>
<div class="row">
<p class="col-2 text-left">Previous Run Arguments:</p>
<p id="previous-run-arguments" class="col-9 monospace"></p>
</div>
<div class="row">
<p class="col-2 text-left">Previous Output:</p>
<p id="previous-output" class="col-9 monospace"></p>
</div>
<div class="row">
<p class="col-2 text-left">Previous Success:</p>
<p id="previous-success" class="col-9 monospace"></p>
</div>
<div class="row">
<p class="col-2 text-left">Previous Nodegroup:</p>
<p id="previous-nodegroup" class="col-9 monospace"></p>
</div>

<div class="container pt-5 pb-4 pl-0">
<button id="upload-logs-button" type="button" onclick="uploadLogs()" class="btn btn-primary">Upload logs</button>
</div>
Expand Down Expand Up @@ -112,8 +137,8 @@ <h3>Installed Packages<br></h3>

</div>

<script type="text/javascript" src="/static/js/about.js"></script>
<script src="/static/js/jquery-3.3.1.slim.min.js"></script>
<script type="text/javascript" src="/static/js/about.js"></script>
<script src="/static/js/bootstrap.min.js"></script>

<script>
Expand Down
33 changes: 33 additions & 0 deletions static/js/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ authHeaders.append("Authorization", "Basic YWRtaW46ZmVhdGhlcnM=");

window.onload = async function () {
readAutoUpdate();
updateSaltState();
};

async function setAutoUpdate(autoUpdate) {
Expand Down Expand Up @@ -110,6 +111,38 @@ async function uploadLogs() {
$("#upload-logs-button").html("Upload logs");
}

async function updateSaltState() {
try {
const response = await fetch("/api/salt-update", {
method: "GET",
headers: {
"Authorization": "Basic " + btoa("admin:feathers"),
"Content-Type": "application/json"
}
});

if (response.ok) {
var jsonString = await response.text();

var data = JSON.parse(jsonString);

document.getElementById("running-salt-command").textContent = data.RunningUpdate ? "Yes" : "No";
document.getElementById("running-salt-arguements").textContent = data.RunningArgs ? data.RunningArgs.join(", ") : "None";
document.getElementById("previous-run-arguments").textContent = data.LastCallArgs ? data.LastCallArgs.join(", ") : "None";
document.getElementById("previous-output").textContent = data.LastCallOut;
document.getElementById("previous-success").textContent = data.LastCallSuccess ? "Yes" : "No";
document.getElementById("previous-nodegroup").textContent = data.LastCallNodegroup;

} else {
alert("Error updating salt");
console.error("Error with response:", await response.text());
}
} catch (error) {
alert("Error updating salt");
console.error("Error with fetching salt update:", error);
}
}

var runningSaltUpdate = true;
// Check salt update state. Returns true if it is no longer running
function checkSaltUpdateState() {
Expand Down

0 comments on commit 05d1f5d

Please sign in to comment.