mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 07:23:03 +03:00
Completed work on WebPowerSwitch support.
This commit is contained in:
parent
1567594ef3
commit
ad3dc5fbed
@ -2203,9 +2203,9 @@ function CreateMeshCentralServer(config, args) {
|
||||
// nodeId: node identifier of format node/domain/nodeidhex
|
||||
// connectTime: time of connection, milliseconds elapsed since the UNIX epoch.
|
||||
// connectType: Bitmask, 1 = MeshAgent, 2 = Intel AMT CIRA, 4 = Intel AMT local, 8 = Intel AMT Relay, 16 = MQTT
|
||||
// powerState: Value, 0 = Unknown, 1 = S0 power on, 2 = S1 Sleep, 3 = S2 Sleep, 4 = S3 Sleep, 5 = S4 Hibernate, 6 = S5 Soft-Off, 7 = Present
|
||||
// powerState: Value, 0 = Unknown, 1 = S0 power on, 2 = S1 Sleep, 3 = S2 Sleep, 4 = S3 Sleep, 5 = S4 Hibernate, 6 = S5 Soft-Off, 7 = Present, 8 = Off
|
||||
//var connectTypeStrings = ['', 'MeshAgent', 'Intel AMT CIRA', '', 'Intel AMT local', '', '', '', 'Intel AMT Relay', '', '', '', '', '', '', '', 'MQTT'];
|
||||
//var powerStateStrings = ['Unknown', 'Powered', 'Sleep', 'Sleep', 'Deep Sleep', 'Hibernating', 'Soft-Off', 'Present'];
|
||||
//var powerStateStrings = ['Unknown', 'Powered', 'Sleep', 'Sleep', 'Deep Sleep', 'Hibernating', 'Soft-Off', 'Present', 'Off'];
|
||||
obj.SetConnectivityState = function (meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo) {
|
||||
//console.log('SetConnectivity for ' + nodeid.substring(0, 16) + ', Type: ' + connectTypeStrings[connectType] + ', Power: ' + powerStateStrings[powerState] + (serverid == null ? ('') : (', ServerId: ' + serverid)));
|
||||
if ((serverid == null) && (obj.multiServer != null)) { obj.multiServer.DispatchMessage({ action: 'SetConnectivityState', meshid: meshid, nodeid: nodeid, connectTime: connectTime, connectType: connectType, powerState: powerState, extraInfo: extraInfo }); }
|
||||
|
29
meshipkvm.js
29
meshipkvm.js
@ -37,14 +37,19 @@ function CreateIPKVMManager(parent) {
|
||||
const MESHRIGHT_ADMIN = 0xFFFFFFFF;
|
||||
|
||||
// Subscribe for mesh creation events
|
||||
parent.AddEventDispatch(['server-createmesh', 'server-deletemesh'], obj);
|
||||
parent.AddEventDispatch(['server-createmesh', 'server-deletemesh', 'devport-operation'], obj);
|
||||
obj.HandleEvent = function (source, event, ids, id) {
|
||||
if ((event != null) && (event.action == 'createmesh') && (event.mtype == 4)) {
|
||||
if ((event == null) || (event.mtype != 4)) return;
|
||||
if (event.action == 'createmesh') {
|
||||
// Start managing this new device group
|
||||
startManagement(parent.webserver.meshes[event.meshid]);
|
||||
} else if ((event != null) && (event.action == 'deletemesh') && (event.mtype == 4)) {
|
||||
} else if (event.action == 'deletemesh') {
|
||||
// Stop managing this device group
|
||||
stopManagement(event.meshid);
|
||||
} else if ((event.action == 'turnon') || (event.action == 'turnoff')) {
|
||||
// Perform power operation
|
||||
const manager = obj.managedGroups[event.meshid];
|
||||
if ((manager) && (manager.powerOperation)) { manager.powerOperation(event); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,7 +125,7 @@ function CreateIPKVMManager(parent) {
|
||||
const mesh = parent.webserver.meshes[sender.meshid];
|
||||
if (nodes.length == 0) {
|
||||
// The device does not exist, create it
|
||||
const device = { type: 'node', mtype: 4, _id: nodeid, icon: 1, meshid: sender.meshid, name: port.Name, rname: port.Name, domain: sender.domainid, portid: port.PortId, portnum: port.PortNumber };
|
||||
const device = { type: 'node', mtype: 4, _id: nodeid, icon: 4, meshid: sender.meshid, name: port.Name, rname: port.Name, domain: sender.domainid, portid: port.PortId, portnum: port.PortNumber, porttype: 'PDU' };
|
||||
parent.db.Set(device);
|
||||
|
||||
// Event the new node
|
||||
@ -140,13 +145,13 @@ function CreateIPKVMManager(parent) {
|
||||
|
||||
// Set the connectivity state if needed
|
||||
if (obj.managedPorts[nodeid] == null) {
|
||||
parent.SetConnectivityState(sender.meshid, nodeid, Date.now(), 1, port.State?1:6, null, null);
|
||||
parent.SetConnectivityState(sender.meshid, nodeid, Date.now(), 1, port.State ? 1 : 8, null, null);
|
||||
obj.managedPorts[nodeid] = { name: port.Name, meshid: sender.meshid, portid: port.PortId, portType: port.PortType, portNo: port.PortIndex };
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Update connectivity state
|
||||
parent.SetConnectivityState(sender.meshid, nodeid, Date.now(), 1, port.State ? 1 : 6, null, null);
|
||||
parent.SetConnectivityState(sender.meshid, nodeid, Date.now(), 1, port.State ? 1 : 8, null, null);
|
||||
}
|
||||
} else if ((port.Status == 1) && (port.Class == 'KVM')) {
|
||||
//console.log(port.PortNumber + ', ' + port.PortId + ', ' + port.Name + ', ' + port.Type + ', ' + ((port.StatAvailable == 0) ? 'Idle' : 'Connected'));
|
||||
@ -765,7 +770,7 @@ function CreateWebPowerSwitch(parent, hostname, port, username, password) {
|
||||
obj.update();
|
||||
}
|
||||
|
||||
obj.update = function() {
|
||||
obj.update = function () {
|
||||
obj.fetch('/restapi/relay/outlets/all;/=name,physical_state/', 'GET', null, null, function (sender, tag, rdata, res) {
|
||||
if (res.statusCode == 207) {
|
||||
var rdata2 = null;
|
||||
@ -780,7 +785,7 @@ function CreateWebPowerSwitch(parent, hostname, port, username, password) {
|
||||
var portchanged = false;
|
||||
if (obj.ports[i] == null) {
|
||||
// Add the port
|
||||
obj.ports[i] = { PortNumber: i, PortId: 'p' + i, Name: portname, Status: 1, State: portstate, Class: 'PDU' };
|
||||
obj.ports[i] = { PortNumber: i + 1, PortId: 'p' + i, Name: portname, Status: 1, State: portstate, Class: 'PDU' };
|
||||
portchanged = true;
|
||||
} else {
|
||||
// Update the port
|
||||
@ -800,9 +805,15 @@ function CreateWebPowerSwitch(parent, hostname, port, username, password) {
|
||||
});
|
||||
}
|
||||
|
||||
obj.powerOperation = function (event) {
|
||||
if (typeof event.portnum != 'number') return;
|
||||
if (event.action == 'turnon') { setPowerState(event.portnum - 1, true); }
|
||||
else if (event.action == 'turnoff') { setPowerState(event.portnum - 1, false); }
|
||||
}
|
||||
|
||||
function setPowerState(port, state, func) {
|
||||
obj.fetch('/restapi/relay/outlets/' + port + '/state/', 'PUT', 'value=' + state, null, function (sender, tag, rdata, res) {
|
||||
console.log('DATA:', res.statusCode, rdata.toString());
|
||||
if (res.statusCode == 204) { obj.update(); }
|
||||
});
|
||||
}
|
||||
|
||||
|
22
meshuser.js
22
meshuser.js
@ -2889,7 +2889,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// Get the node and the rights for this node
|
||||
parent.GetNodeWithRights(domain, user, nodeid, function (node, rights, visible) {
|
||||
// Check we have the rights to delete this device
|
||||
// Check we have the rights to wake this device
|
||||
if ((node == null) || (visible == false) || (rights & MESHRIGHT_WAKEDEVICE) == 0) {
|
||||
if (command.nodeids.length == 1) { try { ws.send(JSON.stringify({ action: 'wakedevices', responseid: command.responseid, result: 'Invalid nodeid' })); } catch (ex) { } }
|
||||
return;
|
||||
@ -2898,6 +2898,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
// If this device is connected on MQTT, send a wake action.
|
||||
if (parent.parent.mqttbroker != null) { parent.parent.mqttbroker.publish(node._id, 'powerAction', 'wake'); }
|
||||
|
||||
// If this is a IP-KVM or Power Distribution Unit (PDU), dispatch an action event
|
||||
if (node.mtype == 4) {
|
||||
// Send out an event to perform turn off command on the port
|
||||
//var targets = parent.CreateNodeDispatchTargets(node.meshid, node._id, ['devport-operation', 'server-users', user._id]);
|
||||
var event = { etype: 'node', userid: user._id, username: user.name, nodeid: node._id, action: 'turnon', domain: domain.id, nolog: 1, portid: node.portid, porttype: node.porttype, portnum: node.portnum, meshid: node.meshid, mtype: node.mtype };
|
||||
parent.parent.DispatchEvent([ 'devport-operation' ], obj, event);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the device interface information
|
||||
db.Get('if' + node._id, function (err, nodeifs) {
|
||||
if ((nodeifs != null) && (nodeifs.length == 1)) {
|
||||
@ -3054,11 +3063,20 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if ((command.actiontype == 401) && common.validateInt(command.time, 1, 30000)) { routeCommandToNode({ action: 'msg', type: 'console', nodeid: node._id, value: 'vibrate ' + command.time }, MESHRIGHT_ADMIN, 0); }
|
||||
} else {
|
||||
// Check we have the rights to delete this device
|
||||
if ((rights & MESHRIGHT_RESETOFF) == 0) return;
|
||||
if ((rights & MESHRIGHT_RESETOFF) == 0) return;
|
||||
|
||||
// If this device is connected on MQTT, send a power action.
|
||||
if ((parent.parent.mqttbroker != null) && (command.actiontype >= 0) && (command.actiontype <= 4)) { parent.parent.mqttbroker.publish(node._id, 'powerAction', ['', '', 'poweroff', 'reset', 'sleep'][command.actiontype]); }
|
||||
|
||||
// If this is a IP-KVM or Power Distribution Unit (PDU), dispatch an action event
|
||||
if (node.mtype == 4) {
|
||||
// Send out an event to perform turn off command on the port
|
||||
//var targets = parent.CreateNodeDispatchTargets(node.meshid, node._id, ['devport-operation', 'server-users', user._id]);
|
||||
var event = { etype: 'node', userid: user._id, username: user.name, nodeid: node._id, action: 'turnoff', domain: domain.id, nolog: 1, portid: node.portid, porttype: node.porttype, portnum: node.portnum, meshid: node.meshid, mtype: node.mtype };
|
||||
parent.parent.DispatchEvent([ 'devport-operation' ], obj, event);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((command.actiontype >= 300) && (command.actiontype < 400)) {
|
||||
if ((command.actiontype != 302) && (command.actiontype != 308) && (command.actiontype != 310)) return; // Invalid action type.
|
||||
// Intel AMT power command, actiontype: 2 = Power on, 8 = Power down, 10 = reset
|
||||
|
@ -3214,15 +3214,15 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
var powerStatetable = ['', "Powered", "Sleep", "Sleep", "Sleep", "Hibernating", "Power off", "Present"];
|
||||
var powerStateStrings = ['', "Powered", "Sleeping", "Sleeping", "Deep Sleep", "Hibernating", "Soft-Off", "Present"];
|
||||
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 powerStatetable = ['', "Powered", "Sleep", "Sleep", "Sleep", "Hibernating", "Power off", "Present", "Off"];
|
||||
var powerStateStrings = ['', "Powered", "Sleeping", "Sleeping", "Deep Sleep", "Hibernating", "Soft-Off", "Present", "Off"];
|
||||
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 = ['#00000000', 'black', 'blue', 'blue', 'lightblue', 'blueviolet', 'darkgreen', 'lightseagreen', 'lightseagreen'];
|
||||
function NodeStateStr(node) {
|
||||
var states = [];
|
||||
if (node.state > 0 && node.state < powerStatetable.length) state.push(powerStatetable[node.state]);
|
||||
if (node.conn) {
|
||||
if ((node.conn & 1) != 0) { states.push('<span>' + ((node.mtype == 4)?"IP-KVM":"Agent") + '</span>'); }
|
||||
if ((node.conn & 1) != 0) { states.push('<span>' + ((node.mtype == 4) ? ((node.porttype == 'PDU') ? "Switch" : "IP-KVM") : "Agent") + '</span>'); }
|
||||
if ((node.conn & 2) != 0) { states.push('<span>' + "CIRA" + '</span>'); }
|
||||
else if ((node.conn & 4) != 0) { states.push('<span>' + "Intel® AMT" + '</span>'); }
|
||||
if ((node.conn & 8) != 0) { states.push('<span>' + "Relay" + '</span>'); }
|
||||
@ -3382,8 +3382,8 @@
|
||||
|
||||
// IP-KVM 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
|
||||
@ -3486,7 +3486,7 @@
|
||||
var connectivity = node.conn;
|
||||
if (connectivity && connectivity > 1) {
|
||||
var cstate = [];
|
||||
if ((node.conn & 1) != 0) cstate.push('<span>' + ((node.mtype == 4) ? "IP-KVM" : "Agent") + '</span>');
|
||||
if ((node.conn & 1) != 0) cstate.push('<span>' + ((node.mtype == 4) ? ((node.porttype == 'PDU') ? "Switch" : "IP-KVM") : "Agent") + '</span>');
|
||||
if ((node.conn & 2) != 0) cstate.push('<span>' + "Intel® AMT CIRA" + '</span>');
|
||||
else if ((node.conn & 4) != 0) cstate.push('<span>' + "Intel® AMT" + '</span>');
|
||||
if ((node.conn & 8) != 0) cstate.push('<span>' + "Agent Relay" + '</span>');
|
||||
@ -3519,9 +3519,21 @@
|
||||
x += '</table><br />';
|
||||
// Show action button, only show if we have permissions 4, 8, 64
|
||||
if (((meshrights & (4 + 8 + 64)) != 0) && (node.mtype < 3)) { x += '<input type=button value="' + "Actions" + '" onclick=deviceActionFunction() />'; }
|
||||
x += '<input type=button value=Notes onclick=showNotes(' + ((meshrights & 128) == 0) + ',"' + encodeURIComponent(node._id) + '") />';
|
||||
x += '<input type=button value="' + "Notes" + '" onclick=showNotes(' + ((meshrights & 128) == 0) + ',"' + encodeURIComponent(node._id) + '") />';
|
||||
//if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast onclick=deviceToastFunction() />'; }
|
||||
|
||||
if ((node.mtype == 4) && (meshrights & 8) && (connectivity & 1)) {
|
||||
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) + '") />';
|
||||
}
|
||||
}
|
||||
|
||||
QH('p10html', x);
|
||||
|
||||
// If we are looking at a local non-windows device, enable terminal and files capability.
|
||||
@ -3546,11 +3558,11 @@
|
||||
// Set the node power state
|
||||
var powerstate = PowerStateStr(node.state);
|
||||
//if (node.state == 0) { powerstate = 'Unknown State'; }
|
||||
if ((connectivity & 1) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += ((node.mtype == 4) ? "IP-KVM" : "Mesh Agent"); }
|
||||
if ((connectivity & 1) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += ((node.mtype == 4) ? ((node.porttype == 'PDU') ? "Switch" : "IP-KVM") : "Mesh Agent"); }
|
||||
if ((connectivity & 2) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += "Intel® AMT connected"; }
|
||||
else if ((connectivity & 4) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += "Intel® AMT detected"; }
|
||||
if ((connectivity & 16) != 0) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += "MQTT channel connected"; }
|
||||
if ((node.pwr > 1) && (node.pwr != 7)) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += powerStateStrings[node.pwr]; }
|
||||
if ((node.porttype == 'PDU') || ((node.pwr > 1) && (node.pwr != 7))) { if (powerstate.length > 0) { powerstate += ', '; } powerstate += powerStateStrings[node.pwr]; }
|
||||
QH('MainComputerState', '<span style=font-size:12px>' + powerstate + '</span>');
|
||||
|
||||
// Set the node icon
|
||||
@ -3585,6 +3597,20 @@
|
||||
if (xxcurrentView == 10) { setupDeviceMenu(); }
|
||||
}
|
||||
|
||||
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 openIpKvmRemoteControl(nodeid) {
|
||||
if (xxdialogMode) return;
|
||||
var nid = decodeURIComponent(nodeid).split('/')[2];
|
||||
safeNewWindow('/ipkvm.ashx/' + nid + '/', 'ipkvm:' + nid);
|
||||
}
|
||||
|
||||
function deviceToastFunction() {
|
||||
if (xxdialogMode) return;
|
||||
setDialogMode(2, "Device Toast", 3, deviceToastFunctionEx, '<textarea id=d2devToast style=width:100%;height:80px;resize:none;overflow-y:scroll></textarea>');
|
||||
@ -5956,7 +5982,7 @@
|
||||
x += addHtmlValue("Username", currentMesh.kvm.user);
|
||||
}
|
||||
|
||||
x += '<br><input type=button value=Notes onclick=showNotes(false,"' + encodeURIComponent(currentMesh._id) + '") />';
|
||||
x += '<br><input type=button value="' + "Notes" + '" onclick=showNotes(false,"' + encodeURIComponent(currentMesh._id) + '") />';
|
||||
|
||||
x += '<br style=clear:both><br>';
|
||||
var currentMeshLinks = currentMesh.links[userinfo._id];
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user