import * as DataGrid from "./DataGrid.js";
import { ConsoleFrame } from "./UI.js";
import { FormatScriptOutput, FormatScriptOutputArray } from "./Utilities.js";
export function CreateCommandHarness(context) {
var collapseClass = context.TargetDeviceIDs.length > 1 ? "collapse" : "collapse show";
var commandHarness = document.createElement("div");
var contextID = "c" + context.ID;
commandHarness.id = contextID;
commandHarness.classList.add("command-harness");
commandHarness.innerHTML = `
Host Output:
${FormatScriptOutput(result.HostOutput)}
Debug Output:
${FormatScriptOutputArray(result.DebugOutput)}
Verbose Output:
${FormatScriptOutputArray(result.VerboseOutput)}
Information Output:
${FormatScriptOutputArray(result.InformationOutput)}
Error Output:
${FormatScriptOutputArray(result.ErrorOutput)}
`;
if (result.ErrorOutput.length > 0) {
var errorSpan = document.getElementById(contextID + "-errors");
var currentErrors = parseInt(errorSpan.innerText);
currentErrors += 1;
errorSpan.innerText = String(currentErrors);
}
resultsWrapper.appendChild(resultDiv);
ConsoleFrame.scrollTop = ConsoleFrame.scrollHeight;
}
export function AddCommandResultsHarness(result) {
var contextID = "c" + result.CommandContextID;
var deviceName = DataGrid.DataSource.find(x => x.ID == result.DeviceID).DeviceName;
var resultsWrapper = document.getElementById(contextID + "-results");
var totalDevices = parseInt(document.getElementById(contextID + "-totaldevices").innerText);
var collapseClass = totalDevices > 1 ? "collapse" : "collapse show";
var resultDiv = document.createElement("div");
resultDiv.innerHTML = `
Standard Output:
${FormatScriptOutput(result.StandardOutput)}
Error Output:
${FormatScriptOutput(result.ErrorOutput)}
`;
if (result.ErrorOutput.length > 0) {
var errorSpan = document.getElementById(`${contextID}-errors`);
var currentErrors = parseInt(errorSpan.innerText);
currentErrors += 1;
errorSpan.innerText = String(currentErrors);
}
resultsWrapper.appendChild(resultDiv);
ConsoleFrame.scrollTop = ConsoleFrame.scrollHeight;
}
export function UpdateResultsCount(commandContextID) {
var contextID = "c" + commandContextID;
var totalDevices = parseInt(document.getElementById(`${contextID}-totaldevices`).innerText);
var percentComplete = Math.round(document.getElementById(`${contextID}-results`).children.length / totalDevices * 100);
document.getElementById(`${contextID}-completed`).innerText = String(percentComplete) + "%";
}
//# sourceMappingURL=ResultsParser.js.map