Updated web page to allow agent relay for IP-KVM / Power device group.
Ylian Saint-Hilaire committed
Apr 18, 2022 at 14:07 UTC
2a2e0038c12faa906d0cfeda5f5165db2012f25b
3 files changed
+18
-15
meshuser.js
+4
-4
@@ -1926,8 +1926,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1926
else if (common.validateString(command.meshname, 1, 128) == false) { err = 'Invalid group name'; } // Meshname is between 1 and 128 characters
1927
else if ((command.desc != null) && (common.validateString(command.desc, 0, 1024) == false)) { err = 'Invalid group description'; } // Mesh description is between 0 and 1024 characters
1928
else if ((command.meshtype < 1) || (command.meshtype > 4)) { err = 'Invalid group type'; } // Device group types are 1 = AMT, 2 = Agent, 3 = Local
1929
- else if ((command.meshtype == 3) && (parent.args.wanonly == true) && (typeof command.relayid != 'string')) { err = 'Invalid group type'; } // Local device group type wihtout relay is not allowed in WAN mode
1930
- else if ((command.meshtype == 3) && (parent.args.lanonly == true) && (typeof command.relayid == 'string')) { err = 'Invalid group type'; } // Local device group type with relay is not allowed in WAN mode
1929
+ else if (((command.meshtype == 3) || (command.meshtype == 4)) && (parent.args.wanonly == true) && (typeof command.relayid != 'string')) { err = 'Invalid group type'; } // Local device group type wihtout relay is not allowed in WAN mode
1930
+ else if (((command.meshtype == 3) || (command.meshtype == 4)) && (parent.args.lanonly == true) && (typeof command.relayid == 'string')) { err = 'Invalid group type'; } // Local device group type with relay is not allowed in WAN mode
1931
else if ((domain.ipkvm == null) && (command.meshtype == 4)) { err = 'Invalid group type'; } // IP KVM device group type is not allowed unless enabled
1932
if ((err == null) && (command.meshtype == 4)) {
1933
if ((command.kvmmodel < 1) || (command.kvmmodel > 2)) { err = 'Invalid KVM model'; }
@@ -1961,7 +1961,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1961
if (command.meshtype == 4) { mesh.kvm = { model: command.kvmmodel, host: command.kvmhost, user: command.kvmuser, pass: command.kvmpass }; }
1962
1963
// If this is device group that requires a relay device, store that now
1964
- if ((parent.args.lanonly != true) && (command.meshtype == 3) && (typeof command.relayid == 'string')) {
1964
+ if ((parent.args.lanonly != true) && ((command.meshtype == 3) || (command.meshtype == 4)) && (typeof command.relayid == 'string')) {
1965
// Check the relay id
1966
var relayIdSplit = command.relayid.split('/');
1967
if ((relayIdSplit[0] == 'node') && (relayIdSplit[1] == domain.id)) { mesh.relayid = command.relayid; }
@@ -2155,7 +2155,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2155
if ((common.validateInt(command.expireDevs, 0, 2000) == true) && (command.expireDevs != mesh.expireDevs)) { if (change != '') change += ' and auto-remove changed'; else change += 'Device group "' + mesh.name + '" auto-remove changed'; changesids.push(5); if (command.expireDevs == 0) { delete mesh.expireDevs; } else { mesh.expireDevs = command.expireDevs; } }
2156
2157
var oldRelayNodeId = null, newRelayNodeId = null;
2158
- if ((typeof command.relayid == 'string') && (mesh.mtype == 3) && (mesh.relayid != null) && (command.relayid != mesh.relayid)) {
2158
+ if ((typeof command.relayid == 'string') && ((mesh.mtype == 3) || (mesh.mtype == 4)) && (mesh.relayid != null) && (command.relayid != mesh.relayid)) {
2159
var relayIdSplit = command.relayid.split('/');
2160
if ((relayIdSplit.length == 3) && (relayIdSplit[0] = 'node') && (relayIdSplit[1] == domain.id)) {
2161
if (change != '') { change += ' and device relay changed'; } else { change = 'Device relay changed'; }
views/default-mobile.handlebars
+2
-2
@@ -6045,7 +6045,7 @@
6045
if (currentMesh.mtype == 1) meshtype = "Intel® AMT only, no agent";
6046
if (currentMesh.mtype == 2) meshtype = "Managed using a software agent";
6047
if (currentMesh.mtype == 3) { if (currentMesh.relayid == null) { meshtype = "Local devices, no agent"; } else { meshtype = "No agent devices relayed thru agent"; } }
6048
- if (currentMesh.mtype == 4) { meshtype = "IP-KVM device"; if (currentMesh.kvm.model == 1) { meshtype += ', ' + 'Raritan KX III'; } }
6048
+ if (currentMesh.mtype == 4) { if (currentMesh.relayid == null) { meshtype = "IP-KVM device"; } else { meshtype = "IP-KVM device relayed thru agent"; } if (currentMesh.kvm.model == 1) { meshtype += ', ' + 'Raritan KX III'; } }
6049
6050
var x = '';
6051
x += addHtmlValue("Name", addLinkConditional(EscapeHtml(currentMesh.name), 'p20editmesh(1)', (meshrights & 1) != 0));
@@ -6054,7 +6054,7 @@
6054
//x += addHtmlValue('Identifier', currentMesh._id.split('/')[2]);
6055
6056
// Display the relay device if applicable
6057
- if ((currentMesh.mtype == 3) && (currentMesh.relayid != null)) {
6057
+ if (((currentMesh.mtype == 3) || (currentMesh.mtype == 4)) && (currentMesh.relayid != null)) {
6058
var relayName = '<i>' + "Unknown" + '</i>';
6059
var relayNode = getNodeFromId(currentMesh.relayid);
6060
if (relayNode != null) { relayName = EscapeHtml(relayNode.name); }
views/default.handlebars
+12
-9
@@ -11591,8 +11591,11 @@
11591
var x = "Create a new device group using the options below." + '<br /><br />', localGroupType = '';
11592
x += addHtmlValue("Name", '<input id=dp2meshname style=width:230px maxlength=128 onchange=account_validateMeshCreate() onkeyup=account_validateMeshCreate(event,1) />');
11593
if ((features & 1) == 0) { localGroupType += '<option value=3>' + "Local devices, no agent" + '</option>'; }
11594
- if (((features & 2) == 0) && (relayDevices.length > 0)) { localGroupType += '<option value=5>' + "No agent devices relayed thru agent" + '</option>'; }
11595
- if (features2 & 0x10000) { localGroupType += '<option value=4>' + "IP-KVM / Power device" + '</option>'; }
11594
+ if (((features & 2) == 0) && (relayDevices.length > 0)) { localGroupType += '<option value=103>' + "No agent devices relayed thru agent" + '</option>'; }
11595
+ if (features2 & 0x10000) {
11596
+ if ((features & 1) == 0) { localGroupType += '<option value=4>' + "IP-KVM / Power device" + '</option>'; }
11597
+ if (((features & 2) == 0) && (relayDevices.length > 0)) { localGroupType += '<option value=104>' + "IP-KVM / Power device relayed thru agent" + '</option>'; }
11598
+ }
11599
x += addHtmlValue("Type", '<div style=width:230px;margin:0;padding:0><select id=dp2meshtype style=width:100% onchange=account_validateMeshCreate() onkeyup=account_validateMeshCreate(event,2) ><option value=2>' + "Manage using a software agent" + '</option><option value=1>' + "Intel® AMT only, no agent" + '</option>' + localGroupType + '</select></div>');
11600
if (relayDevices.length > 0) {
11601
x += '<div id=d2devrelaydiv style=display:none>';
@@ -11620,8 +11623,8 @@
11623
if ((x == 1) && (e != null) && (e.key == "Enter") && (Q('dp2meshname').value.length > 0)) { Q('dp2meshtype').focus(); }
11624
if ((x == 2) && (e != null) && (e.key == "Enter")) { Q('dp2meshdesc').focus(); }
11625
var ok = (Q('dp2meshname').value.length > 0);
11623
- QV('d2ipkvm', meshtype == 4);
11624
- try { QV('d2devrelaydiv', meshtype == 5); } catch (ex) {}
11626
+ QV('d2ipkvm', (meshtype == 4) || (meshtype == 104));
11627
+ try { QV('d2devrelaydiv', meshtype > 100); } catch (ex) {}
11628
if (meshtype == 4) { if ((Q('dp2ipkvmhost').value.length == 0) && (Q('dp2ipkvmuser').value.length == 0) && (Q('dp2ipkvmpass').value.length == 0)) { ok = false; } }
11629
QE('idx_dlgOkButton', ok);
11630
}
@@ -11629,14 +11632,14 @@
11632
function account_createMeshEx(button, tag) {
11633
var meshtype = parseInt(Q('dp2meshtype').value);
11634
var cmd = { action: 'createmesh', meshname: Q('dp2meshname').value, meshtype: meshtype, desc: Q('dp2meshdesc').value };
11632
- if (meshtype == 4) {
11635
+ if ((meshtype == 4) || (meshtype == 104)) {
11636
cmd.kvmmodel = parseInt(Q('dp2ipkvmmodel').value);
11637
cmd.kvmhost = Q('dp2ipkvmhost').value;
11638
cmd.kvmuser = Q('dp2ipkvmuser').value;
11639
cmd.kvmpass = Q('dp2ipkvmpass').value;
11640
}
11638
- if (meshtype == 5) {
11639
- cmd.meshtype = 3;
11641
+ if (meshtype > 100) {
11642
+ cmd.meshtype = (meshtype - 100);
11643
cmd.relayid = Q('d2devrelay').value;
11644
}
11645
meshserver.send(cmd);
@@ -11855,7 +11858,7 @@
11858
if (currentMesh.mtype == 1) meshtype = "Intel® AMT only, no agent";
11859
if (currentMesh.mtype == 2) meshtype = "Managed using a software agent";
11860
if (currentMesh.mtype == 3) { if (currentMesh.relayid == null) { meshtype = "Local devices, no agent"; } else { meshtype = "No agent devices relayed thru agent"; } }
11858
- if (currentMesh.mtype == 4) { meshtype = "IP-KVM device"; if (currentMesh.kvm.model == 1) { meshtype += ', ' + 'Raritan KX III'; } }
11861
+ if (currentMesh.mtype == 4) { if (currentMesh.relayid == null) { meshtype = "IP-KVM device"; } else { meshtype = "IP-KVM device relayed thru agent"; } if (currentMesh.kvm.model == 1) { meshtype += ', ' + 'Raritan KX III'; } }
11862
11863
var x = '';
11864
if ((args.hide & 8) != 0) { x += addHtmlValue("Name", mname); } // If title bar is hidden, display the mesh name here
@@ -11866,7 +11869,7 @@
11869
//x += addHtmlValue('Identifier', currentMesh._id.split('/')[2]);
11870
11871
// Display the relay device if applicable
11869
- if ((currentMesh.mtype == 3) && (currentMesh.relayid != null)) {
11872
+ if (((currentMesh.mtype == 3) || (currentMesh.mtype == 4)) && (currentMesh.relayid != null)) {
11873
var relayName = '<i>' + "Unknown" + '</i>';
11874
var relayNode = getNodeFromId(currentMesh.relayid);
11875
if (relayNode != null) { relayName = EscapeHtml(relayNode.name); }