diff --git a/Makefile b/Makefile index 2e407f6..84750f6 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ GOBIN := /usr/bin BUILD_DIR = build BINARY = $(BUILD_DIR)/$(APP_NAME) -.PHONY: all build help clean install uninstall #build-static +.PHONY: all build help clean install uninstall test #build-static all: build @@ -28,6 +28,10 @@ uninstall: clean ## Remove build artifacts @echo "Removing installed binary..." rm -f $(GOBIN)/$(APP_NAME) +test: build + @echo "Executing tests..." + go test ./... -v -race -cover + clean: ## Remove installed application @echo "Cleaning up build artifacts..." $(GO_CLEAN) diff --git a/src/server/webapp/static/agents-graph.js b/src/server/webapp/static/agents-graph.js index 2b030b5..4c71970 100644 --- a/src/server/webapp/static/agents-graph.js +++ b/src/server/webapp/static/agents-graph.js @@ -182,7 +182,7 @@ async function loadGraphData() { agentData = await fetchData(); // Check if the data is valid - console.log('Extracted agent data:', agentData); + // console.log('Extracted agent data:', agentData); // Only update the graph if agent data is available if (agentData && agentData.length > 0) { diff --git a/src/server/webapp/static/gontrol-helper.js b/src/server/webapp/static/gontrol-helper.js index 8ba7eb7..aeed333 100644 --- a/src/server/webapp/static/gontrol-helper.js +++ b/src/server/webapp/static/gontrol-helper.js @@ -14,6 +14,10 @@ document.addEventListener('DOMContentLoaded', () => { updateAgentDropdown(); bindRowClicks(); } + + // Stylize the results inside commandOutput + const commandOutput = document.getElementById('commandOutput'); + styleCommandOutput(); }); bindRowClicks(); @@ -22,34 +26,6 @@ document.addEventListener('DOMContentLoaded', () => { themeToggle(); }); -// function prepareAgentNames(event) { -// // Determine which form was submitted -// const form = event.target; - -// // Collect selected agent names -// const selected = Array.from(document.querySelectorAll('.agent-checkbox')) -// .filter(cb => cb.checked) -// .map(cb => cb.dataset.agentName); - -// // Get the hidden input and select within the submitted form -// const hiddenInput = form.querySelector('[name="agentNames"]'); -// const agentSelect = form.querySelector('select[name="agentName"], select#agentName, select#modalAgentName'); - -// if (selected.length > 0) { -// // Remove the name from the if no checkboxes selected -// if (agentSelect) { -// agentSelect.setAttribute('name', 'agentName'); -// } -// hiddenInput.value = ''; -// } -// } - let cachedAgentNames = ''; function prepareAgentNames(event) { @@ -179,3 +155,30 @@ function themeToggle() { applyTheme(newTheme); }); } + +//////////////////////////////////////////////////////////////////////////////// +// +// Colorize CommandOutput +// +//////////////////////////////////////////////////////////////////////////////// + + +function styleCommandOutput() { + // Split lines by newline character, since
 preserves formatting
+  // let lines = document.getElementById('commandOutput').innerHTML.split('\n');
+    let lines = commandOutput.innerHTML.split(/|\n/);
+
+  // Map lines: if contains "Error", wrap in red span, else plain text
+  lines = lines.map(line => {
+    if (line.includes("ERROR")) {
+      return `${line}`;
+    } else if (/^\[\S*\]$/.test(line)) {
+      return `${line}`;
+    } else {
+        return `${line}`;
+    }
+  });
+
+  // Replace innerHTML with the joined lines, joined by 
for line breaks in HTML + commandOutput.innerHTML = lines.join('
'); +} diff --git a/src/server/webapp/templates/index.html b/src/server/webapp/templates/index.html index 696abea..77c6516 100644 --- a/src/server/webapp/templates/index.html +++ b/src/server/webapp/templates/index.html @@ -101,7 +101,7 @@