Highlight items that have problems.

This commit is contained in:
Tim Young 2024-05-10 15:03:52 -06:00
parent f3ed276ca9
commit 77b034f845
2 changed files with 31 additions and 3 deletions

View File

@ -32,7 +32,7 @@ function networkFromName(what)
if(allpuzzles[index].EduNetworkBuilder.Network.name == what) if(allpuzzles[index].EduNetworkBuilder.Network.name == what)
{ {
console.log("Found " + what + " at index " + index); console.log("Found " + what + " at index " + index);
return structuredClone(allpuzzles[index].EduNetworkBuilder.Network); return networkFromIndex(index);
} }
index++; index++;
} }
@ -40,11 +40,33 @@ function networkFromName(what)
function networkFromIndex(what) function networkFromIndex(what)
{ {
if(typeof(what)==="number" && what >= 0 && what < allpuzzles.length){ 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; 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) function networkNamesMatchingText(textToMatch)
{ {
var list = []; var list = [];

View File

@ -463,6 +463,10 @@ function PrintNetworkDevice(ToPrint)
MainCanvas_ctx.drawImage(imageFromName(dname), rect.spoint.x, rect.spoint.y, rect.width, rect.height); MainCanvas_ctx.drawImage(imageFromName(dname), rect.spoint.x, rect.spoint.y, rect.width, rect.height);
registerActionStruct("square", actionrect, ToPrint, device_clickOn, null, generic_mouseoverHighlight); 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.. //Now, we see if we need to print the name, or a list of IPs..
var xpoint = rect.center.x; var xpoint = rect.center.x;
var ystart = rect.epoint.y; //the bottom-most Y point var ystart = rect.epoint.y; //the bottom-most Y point
@ -509,6 +513,8 @@ function PrintAllNetworkDevices()
{ {
if (puzzle == null) return; //If the puzzle has not been set, exit if (puzzle == null) return; //If the puzzle has not been set, exit
removeHighlightsNamed("problem");
let index = 0; let index = 0;
while (index < puzzle.device.length) { while (index < puzzle.device.length) {
PrintNetworkDevice(puzzle.device[index]); PrintNetworkDevice(puzzle.device[index]);