mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-09 05:34:54 -05:00
Completed work on WebPowerSwitch support.
This commit is contained in:
@@ -4367,10 +4367,16 @@
|
||||
} else if (view == 2) {
|
||||
var states = [];
|
||||
if (node.conn) {
|
||||
if (node.mtype == 4) {
|
||||
if ((node.conn & 1) != 0) { states.push('<span title="' + "IP-KVM port is connected and ready for use." + '">' + "IP-KVM" + '</span>'); }
|
||||
} else {
|
||||
if ((node.conn & 1) != 0) { states.push('<span title="' + "Mesh agent is connected and ready for use." + '">' + "Agent" + '</span>'); }
|
||||
if ((node.conn & 1) != 0) {
|
||||
if (node.mtype == 4) {
|
||||
if (node.porttype == 'PDU') {
|
||||
states.push('<span title="' + "Switch port is ready for use." + '">' + "Switch" + '</span>');
|
||||
} else {
|
||||
states.push('<span title="' + "IP-KVM port is connected and ready for use." + '">' + "IP-KVM" + '</span>');
|
||||
}
|
||||
} else {
|
||||
states.push('<span title="' + "Mesh agent is connected and ready for use." + '">' + "Agent" + '</span>');
|
||||
}
|
||||
}
|
||||
if ((node.conn & 2) != 0) { states.push('<span title="' + "Intel® AMT CIRA is connected and ready for use." + '">' + "CIRA" + '</span>'); }
|
||||
else if ((node.conn & 4) != 0) { states.push('<span title="' + "Intel® AMT is routable." + '">' + "AMT" + '</span>'); }
|
||||
@@ -5132,8 +5138,8 @@
|
||||
deviceHeaderTotal = 0;
|
||||
}
|
||||
|
||||
var powerStateStrings = ['', '<span title="' + "Device is powered on." + '">' + "Powered" + '</span>', '<span title="' + "Device is in sleep state (S1)." + '">' + "Sleeping" + '</span>', '<span title="' + "Device is in sleep state (S2)." + '">' + "Sleeping" + '</span>', '<span title="' + "Device is in deep sleep state (S3)." + '">' + "Deep Sleep" + '</span>', '<span title="' + "Device is in hibernating state (S4)." + '">' + "Hibernating" + '</span>', '<span title="' + "Device is in powered off state (S5)." + '">' + "Soft-Off" + '</span>', '<span title="' + "Device is detected but power state could not be obtained." + '">' + "Present" + '</span>'];
|
||||
var powerStateStrings2 = ['', "Device is powered", "Device is in sleep state (S1)", "Device is in sleep state (S2)", "Device is in deep sleep state (S3)", "Device is hibernating (S4)", "Device is in soft-off state (S5)", "Device is present, but power state cannot be determined"];
|
||||
var powerStateStrings = ['', '<span title="' + "Device is powered on." + '">' + "Powered" + '</span>', '<span title="' + "Device is in sleep state (S1)." + '">' + "Sleeping" + '</span>', '<span title="' + "Device is in sleep state (S2)." + '">' + "Sleeping" + '</span>', '<span title="' + "Device is in deep sleep state (S3)." + '">' + "Deep Sleep" + '</span>', '<span title="' + "Device is in hibernating state (S4)." + '">' + "Hibernating" + '</span>', '<span title="' + "Device is in powered off state (S5)." + '">' + "Soft-Off" + '</span>', '<span title="' + "Device is detected but power state could not be obtained." + '">' + "Present" + '</span>', '<span title="' + "Device is powered off." + '">' + "Off" + '</span>'];
|
||||
var powerStateStrings2 = ['', "Device is powered", "Device is in sleep state (S1)", "Device is in sleep state (S2)", "Device is in deep sleep state (S3)", "Device is hibernating (S4)", "Device is in soft-off state (S5)", "Device is present, but power state cannot be determined", "The device is powered off"];
|
||||
var powerColorTable = ['pwsTransparent', 'pwsBlack', 'pwsBlue', 'pwsBlue2', 'pwsLightblue', 'pwsBlueviolet', 'pwsDarkgreen', 'pwsLightseagreen', 'pwsLightseagreen2'];
|
||||
function NodeStateStr(node) {
|
||||
var states = [];
|
||||
@@ -5141,7 +5147,11 @@
|
||||
if (node.conn) {
|
||||
if ((node.conn & 1) != 0) {
|
||||
if (node.mtype == 4) {
|
||||
states.push('<span title="' + "IP KVM port is up and ready for use." + '">' + "IP-KVM" + '</span>');
|
||||
if (node.porttype == 'PDU') {
|
||||
states.push('<span title="' + "Power switch is ready for use." + '">' + "Switch" + '</span>');
|
||||
} else {
|
||||
states.push('<span title="' + "IP KVM port is up and ready for use." + '">' + "IP-KVM" + '</span>');
|
||||
}
|
||||
} else {
|
||||
states.push('<span title="' + "Mesh agent is connected and ready for use." + '">' + "Agent" + '</span>');
|
||||
}
|
||||
@@ -6686,10 +6696,10 @@
|
||||
x += addDeviceAttribute("Description", description);
|
||||
}
|
||||
|
||||
// IP-KVM information
|
||||
// IP-KVM / PDU information
|
||||
if (node.mtype == 4) {
|
||||
if (node.portnum) { x += addDeviceAttribute("Port Number", node.portnum); }
|
||||
if (node.porttype) { x += addDeviceAttribute("Port Type", node.porttype); }
|
||||
if (node.portnum != null) { x += addDeviceAttribute("Port Number", node.portnum); }
|
||||
if (node.porttype != null) { x += addDeviceAttribute("Port Type", node.porttype); }
|
||||
}
|
||||
|
||||
// Attribute: Mesh Agent
|
||||
@@ -6893,7 +6903,15 @@
|
||||
}
|
||||
}
|
||||
if ((node.mtype == 4) && (meshrights & 8) && (connectivity & 1)) {
|
||||
x += '<input type=button value="' + "Remote Control" + '" title="' + "Remote Control" + '" onclick=openIpKvmRemoteControl("' + encodeURIComponentEx(node._id) + '") />';
|
||||
if (node.porttype == 'PDU') {
|
||||
if (node.pwr == 1) {
|
||||
x += '<input type=button value="' + "Turn off" + '" title="' + "Turn off" + '" onclick=setIpPduState(0) />';
|
||||
} else if (node.pwr == 8) {
|
||||
x += '<input type=button value="' + "Turn on" + '" title="' + "Turn on" + '" onclick=setIpPduState(1) />';
|
||||
}
|
||||
} else {
|
||||
x += '<input type=button value="' + "Remote Control" + '" title="' + "Remote Control" + '" onclick=openIpKvmRemoteControl("' + encodeURIComponentEx(node._id) + '") />';
|
||||
}
|
||||
}
|
||||
|
||||
// Custom UI
|
||||
@@ -7007,7 +7025,11 @@
|
||||
if ((connectivity & 1) != 0) {
|
||||
if (powerstate.length > 0) { powerstate += '<br/>'; }
|
||||
if (node.mtype == 4) {
|
||||
powerstate += '<span style=font-size:12px title="' + "IP-KVM port connected" + '">' + "IP-KVM port connected" + '</span>' + agentPrivilages;
|
||||
if (node.porttype == 'PDU') {
|
||||
powerstate += '<span style=font-size:12px title="' + "Switch port connected" + '">' + "Switch port connected" + '</span>' + agentPrivilages;
|
||||
} else {
|
||||
powerstate += '<span style=font-size:12px title="' + "IP-KVM port connected" + '">' + "IP-KVM port connected" + '</span>' + agentPrivilages;
|
||||
}
|
||||
} else {
|
||||
powerstate += '<span style=font-size:12px title="' + "Agent connected" + '">' + "Agent connected" + '</span>' + agentPrivilages;
|
||||
}
|
||||
@@ -7016,7 +7038,10 @@
|
||||
else if ((connectivity & 4) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="' + "Intel® AMT detected" + '">' + "Intel® AMT detected" + '</span>'; }
|
||||
if ((connectivity & 16) != 0) { if (powerstate.length > 0) { powerstate += '<br/>'; } powerstate += '<span style=font-size:12px title="' + "MQTT connected" + '">' + "MQTT channel connected" + '</span>'; }
|
||||
if ((powerstate == '') && node.lastconnect) { powerstate = '<span style=font-size:12px>' + "Last seen:" + '<br />' + printDateTime(new Date(node.lastconnect)) + '</span>'; }
|
||||
else { if ((node.pwr > 1) && (node.pwr != 7)) { powerstate += ('<br/>' + powerStateStrings[node.pwr]); } }
|
||||
else {
|
||||
if (node.porttype == 'PDU') { powerstate += ('<br/>' + powerStateStrings[node.pwr]); }
|
||||
else if ((node.pwr > 1) && (node.pwr != 7)) { powerstate += ('<br/>' + powerStateStrings[node.pwr]); }
|
||||
}
|
||||
QH('MainComputerState', powerstate);
|
||||
|
||||
// Set the node icon
|
||||
@@ -7193,6 +7218,14 @@
|
||||
go(panel);
|
||||
}
|
||||
|
||||
function setIpPduState(op) {
|
||||
if (op == 0) {
|
||||
setDialogMode(2, "Power Operation", 3, function() { meshserver.send({ action: 'poweraction', nodeids: [ currentNode._id ], actiontype: 2 }); }, "Perform power off?"); // Turn off
|
||||
} else {
|
||||
setDialogMode(2, "Power Operation", 3, function() { meshserver.send({ action: 'wakedevices', nodeids: [ currentNode._id ] }); }, "Perform power on?"); // Turn on
|
||||
}
|
||||
}
|
||||
|
||||
function p20editDeviceNotify() {
|
||||
if (xxdialogMode) return false;
|
||||
var devNotify = 0, fx = ((features2 & 0x00004000) && (userinfo.emailVerified))?1:0;
|
||||
|
||||
Reference in New Issue
Block a user