Get basic problem translations. Ping only for now
This commit is contained in:
parent
0859bffc23
commit
98733d1ad5
@ -81,6 +81,68 @@ function deviceHasProblem(Device) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function problemString(nettest) {
|
||||||
|
if (nettest == null) return "";
|
||||||
|
//The structure of a nettest
|
||||||
|
//"shost": "pc0",
|
||||||
|
//"dhost": "laptop0",
|
||||||
|
//"thetest": "SuccessfullyPings"
|
||||||
|
|
||||||
|
//if (ui_helplevel == 0) setStatus("There is a disturbance in the force. Guessing...");
|
||||||
|
//if (ui_helplevel == 1) setStatus("Service check detected a problem.");
|
||||||
|
//if (ui_helplevel == 2) setStatus("Someone submitted a trouble ticket.");
|
||||||
|
//if (ui_helplevel == 3) setStatus("Interviewed users for detailed info.");
|
||||||
|
|
||||||
|
|
||||||
|
switch (nettest.thetest) {
|
||||||
|
case "DHCPServerEnabled":
|
||||||
|
case "DeviceBlowsUpWithPower":
|
||||||
|
case "DeviceIsFrozen":
|
||||||
|
case "DeviceNeedsUPS":
|
||||||
|
case "FailedPing":
|
||||||
|
case "HelpRequest":
|
||||||
|
case "LockAll":
|
||||||
|
case "LockLocation":
|
||||||
|
case "LockNic":
|
||||||
|
case "LockVLANNames":
|
||||||
|
case "LockVLANsOnHost":
|
||||||
|
case "NeedsDefaultGW":
|
||||||
|
case "NeedsLinkToDevice":
|
||||||
|
case "NeedsLocalIPTo":
|
||||||
|
case "NeedsRouteToNet":
|
||||||
|
case "NeedsTaggedVLAN":
|
||||||
|
case "ReadContextHelp":
|
||||||
|
break;
|
||||||
|
case "SuccessfullyPings":
|
||||||
|
//level 0 is handled elsewhere
|
||||||
|
if (ui_helplevel == 2) return translator.getStr("NT_TstDiscriptPing");
|
||||||
|
if (ui_helplevel == 3) return translator.getStr("NT_TstDiscriptPing2") + nettest.dhost;
|
||||||
|
case "SuccessfullyPingsWithoutLoop":
|
||||||
|
case "SuccessfullyTraceroutes":
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnProblemStrings(Device) {
|
||||||
|
var hostname = Device.hostname;
|
||||||
|
var errors = [];
|
||||||
|
//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: " + JSON.stringify(puzzle.nettest));
|
||||||
|
if (puzzle.nettest[index].shost == hostname) {
|
||||||
|
if (puzzle.nettest[index].solved == null) {
|
||||||
|
//It has not yet been solved.
|
||||||
|
var error = problemString(puzzle.nettest[index]);
|
||||||
|
//console.log("We got a problem string:" + JSON.stringify(error));
|
||||||
|
if (error != "");
|
||||||
|
errors.push(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
function networkNamesMatchingText(textToMatch)
|
function networkNamesMatchingText(textToMatch)
|
||||||
{
|
{
|
||||||
var list = [];
|
var list = [];
|
||||||
|
36
Web/ui.js
36
Web/ui.js
@ -858,7 +858,33 @@ function device_clickOn(point, actionrec) {
|
|||||||
if (actionrec.theObject !== null && actionrec.theObject.name !== null) {
|
if (actionrec.theObject !== null && actionrec.theObject.name !== null) {
|
||||||
ui_selectRect = structuredClone(actionrec.shapePoints);
|
ui_selectRect = structuredClone(actionrec.shapePoints);
|
||||||
//console.log("Setting select rect:" + JSON.stringify(ui_selectRect));
|
//console.log("Setting select rect:" + JSON.stringify(ui_selectRect));
|
||||||
setStatus(actionrec.theObject.hostname);
|
var ipaddresses = ipsFromDevice(actionrec.theObject);
|
||||||
|
var additional = "";
|
||||||
|
for (var x = 0; x < ipaddresses.length; x++) {
|
||||||
|
//Print the IP address if the type is correct.
|
||||||
|
//console.log(JSON.stringify(ipaddresses[x]));
|
||||||
|
switch (ipaddresses[x].nictype) {
|
||||||
|
case "eth":
|
||||||
|
case "management_interface":
|
||||||
|
//console.log("Found a " + ipaddresses[x].nictype)
|
||||||
|
additional += " " + ipaddresses[x].cidrip;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceHasProblem(actionrec.theObject)) {
|
||||||
|
//If we know nothing, we change nothing
|
||||||
|
if (ui_helplevel > 0) {
|
||||||
|
if (ui_helplevel == 1) additional = " " + translator.getStr("NT_TstDscriptProblem");
|
||||||
|
else {
|
||||||
|
//here we get all the problem statements and combine them
|
||||||
|
errors = returnProblemStrings(actionrec.theObject);
|
||||||
|
additional = " " + errors.join(' - ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatus(actionrec.theObject.hostname + additional);
|
||||||
//We probably do not want to do printecreen here, but we are doing it here now...
|
//We probably do not want to do printecreen here, but we are doing it here now...
|
||||||
PrintScreen();
|
PrintScreen();
|
||||||
}
|
}
|
||||||
@ -874,14 +900,18 @@ function Language(lang) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
this.getStr = function (str, defaultStr) {
|
this.getStr = function (str, defaultStr) {
|
||||||
var retStr = eval('eval(ui_language).' + str);
|
var toget = ui_language + "." + str + ".value";
|
||||||
|
//console.log("Translating: " + toget);
|
||||||
|
var retStr = eval(toget);
|
||||||
if (typeof retStr != 'undefined') {
|
if (typeof retStr != 'undefined') {
|
||||||
return retStr;
|
return retStr;
|
||||||
} else {
|
} else {
|
||||||
if (typeof defaultStr != 'undefined') {
|
if (typeof defaultStr != 'undefined') {
|
||||||
return defaultStr;
|
return defaultStr;
|
||||||
} else {
|
} else {
|
||||||
return eval('ui_language.' + str);
|
toget = "language.en." + str;
|
||||||
|
//console.log("First translation failed, falling back to en: " + toget);
|
||||||
|
return eval(toget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user