From 77b034f845e07e919a4a123c5b794c55335a3c13 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Fri, 10 May 2024 15:03:52 -0600 Subject: [PATCH] Highlight items that have problems. --- Web/network.js | 26 ++++++++++++++++++++++++-- Web/ui.js | 8 +++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Web/network.js b/Web/network.js index caa152d..3b4819f 100644 --- a/Web/network.js +++ b/Web/network.js @@ -32,7 +32,7 @@ function networkFromName(what) if(allpuzzles[index].EduNetworkBuilder.Network.name == what) { console.log("Found " + what + " at index " + index); - return structuredClone(allpuzzles[index].EduNetworkBuilder.Network); + return networkFromIndex(index); } index++; } @@ -40,11 +40,33 @@ function networkFromName(what) function networkFromIndex(what) { if(typeof(what)==="number" && what >= 0 && what < allpuzzles.length){ - return structuredClone(allpuzzles[what].EduNetworkBuilder.Network); + var newitem = structuredClone(allpuzzles[what].EduNetworkBuilder.Network); + if (typeof (newitem.nettest) == "object") { + var oneitem = newitem.nettest; //this is an object + newitem.nettest = []; + newitem.nettest.push(oneitem); //make it an one-item array. + } + return newitem; } return null; } +function deviceHasProblem(Device) { + var hostname = Device.hostname; + console.log("Looking for tests on " + hostname + " and have: " + puzzle.nettest.length) + for (var index = 0; index < puzzle.nettest.length; index++) { + console.log("Found test: " + puzzle.nettest[index].shost) + if (puzzle.nettest[index].shost == hostname) { + if (puzzle.nettest[index].solved == null) { + //It has not yet been solved. + console.log("Found problem on device: " + hostname) + return true; + } + } + } + return false; +} + function networkNamesMatchingText(textToMatch) { var list = []; diff --git a/Web/ui.js b/Web/ui.js index 5ac640e..4501b5a 100644 --- a/Web/ui.js +++ b/Web/ui.js @@ -463,6 +463,10 @@ function PrintNetworkDevice(ToPrint) MainCanvas_ctx.drawImage(imageFromName(dname), rect.spoint.x, rect.spoint.y, rect.width, rect.height); registerActionStruct("square", actionrect, ToPrint, device_clickOn, null, generic_mouseoverHighlight); + if (deviceHasProblem(ToPrint)) { + registerHighlightShape("square", actionrect, "red", "problem", 0.2); + } + //Now, we see if we need to print the name, or a list of IPs.. var xpoint = rect.center.x; var ystart = rect.epoint.y; //the bottom-most Y point @@ -509,7 +513,9 @@ function PrintAllNetworkDevices() { if (puzzle == null) return; //If the puzzle has not been set, exit - let index=0; + removeHighlightsNamed("problem"); + + let index = 0; while (index < puzzle.device.length) { PrintNetworkDevice(puzzle.device[index]); index++;