More work on local device groups.

Ylian Saint-Hilaire committed Apr 27, 2021 at 14:48 UTC 84980251753689309ae14f4e23df66e608662fe4
2 files changed +25 -15
views/default-mobile.handlebars
+3 -2
@@ -3064,7 +3064,7 @@
3064
3065 // Node
3066 var icon = node.icon, nodestate = NodeStateStr(node);
3067 - if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
3067 + if (((!node.conn) || (node.conn == 0)) && (node.mtype != 3)) { icon += ' gray'; }
3068 div.innerHTML = '<div>' + devNotify + '<div class="i' + icon + ' devList2"></div><div class=devList3><div class=devList4><b>' + name + '</b></div><div class=devList5>' + nodestate + '</div></div></div>';
3069 } else {
3070 div.innerHTML = ''; // Hide
@@ -3654,12 +3654,13 @@
3654
3655 // Look to see if we need to update the device timeline
3656 function updateDeviceTimeline() {
3657 - if ((meshserver.State != 2) || (powerTimelineNode == null) || (powerTimelineUpdate == null) || (currentNode == null)) return;
3657 + if ((meshserver.State != 2) || (powerTimelineNode == null) || (powerTimelineUpdate == null) || (currentNode == null) || (currentNode.mtype == 3)) return;
3658 if ((powerTimelineNode == powerTimelineReq) && (currentNode._id == powerTimelineNode) && (powerTimelineUpdate < Date.now())) { powerTimelineUpdate = null; meshserver.send({ action: 'powertimeline', nodeid: currentNode._id }); }
3659 }
3660
3661 // Draw device power bars. The bars are 766px wide.
3662 function drawDeviceTimeline() {
3663 + if (currentNode.mtype == 3) return;
3664 var timeline = null, now = Date.now();
3665 if (currentNode._id == powerTimelineNode) { timeline = powerTimeline; }
3666
views/default.handlebars
+22 -13
@@ -558,6 +558,7 @@
558 <div id=p10html2></div>
559 <div id=p10html3></div>
560 <div id=p10html4></div>
561 + <div id=p10html5></div>
562 </div>
563 </div>
564 <div id=p11 class="noselect" style="display:none">
@@ -4106,7 +4107,7 @@
4107
4108 // Node
4109 var icon = node.icon;
4109 - if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
4110 + if (((!node.conn) || (node.conn == 0)) && (node.mtype != 3)) { icon += ' gray'; }
4111
4112 if (view == 1) {
4113 div.innerHTML = '<table id=devs cmenu=devsContentMenu onmouseover=devMouseHover(this,1) onmouseout=devMouseHover(this,0) style=width:100%;height:100%><tr><td style=width:22px><input class="' + node.meshid + ' DeviceCheckbox" onchange=p1devcheck(event) value=devid_' + node._id + ' type=checkbox ' + (checkedNodeids[node._id]?' checked':'') + '></td><td><table onclick=gotoDevice(\'' + node._id + '\',null,null,event) border=0 cellspacing=0 style=width:100%;height:100%;cursor:pointer><tr><td style=width:50px tabindex=0 onkeypress="if (event.key==\'Enter\') gotoDevice(\'' + node._id + '\',null,null,event)"><div class="i' + icon + '" style=width:50px></div></td><td class=g1t></td><td class=e2t><div class=e1t style=width:' + ((div.clientWidth) - 120) + 'px title="' + title + '">' + name + '</div><div>' + NodeStateStr(node) + '</div></td><td class=g2t></td></tr></table></td></tr></table>' + devNotify;
@@ -5255,7 +5256,6 @@
5256 nodeid = contextelement.children[1].attributes.onclick.value;
5257 }
5258 var node = getNodeFromId(nodeid.substring(12, nodeid.length - 18));
5258 - var mesh = meshes[node.meshid];
5259 var rights = GetNodeRights(node);
5260 var consoleRights = ((rights & 16) != 0);
5261
@@ -5264,11 +5264,12 @@
5264 var terminalAccess = ((rights == 0xFFFFFFFF) || ((rights & 512) == 0));
5265 var fileAccess = ((rights == 0xFFFFFFFF) || ((rights & 1024) == 0));
5266
5267 - QV('cxdesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((rights & 8) || (rights & 256)) && desktopAccess);
5268 - QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (rights & 8) && terminalAccess);
5269 - QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (rights & 8) && fileAccess);
5267 + QV('cxdesktop', ((node.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((rights & 8) || (rights & 256)) && desktopAccess);
5268 + QV('cxterminal', ((node.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (rights & 8) && terminalAccess);
5269 + QV('cxfiles', ((node.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (rights & 8) && fileAccess);
5270 QV('cxevents', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (rights & 8));
5271 - QV('cxconsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (rights & 8));
5271 + QV('cxdetails', node.mtype != 3);
5272 + QV('cxconsole', (consoleRights && (node.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (rights & 8));
5273 QV('cxmgroupsplit', true);
5274 QV('cxstar', true);
5275 break;
@@ -6401,7 +6402,7 @@
6402 if ((args.xterm === 0) && (node.agent) && ((node.agent.caps & 2) != 0) && ((meshrights & 8) != 0) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0))) { x += '<a href=# onclick=p10openxterm(event,"' + node._id + '") title="' + "Open XTerm terminal" + '">' + "XTerm" + '</a>&nbsp;'; }
6403
6404 // RDP link, show this link only of the remote machine is Windows.
6404 - if (((connectivity & 1) != 0) && (node.agent) && ((meshrights & 8) != 0) && (node.agent.id != 14)) {
6405 + if ((((connectivity & 1) != 0) || (node.mtype == 3)) && (node.agent) && ((meshrights & 8) != 0) && (node.agent.id != 14)) {
6406 if ((node.agent.id > 0) && (node.agent.id < 5)) {
6407 if (navigator.platform.toLowerCase() == 'win32') {
6408 if ((serverinfo.devicemeshrouterlinks == null) || (serverinfo.devicemeshrouterlinks.rdp != false)) {
@@ -6435,12 +6436,12 @@
6436 }
6437
6438 // noVNC link
6438 - if (((connectivity & 1) != 0) && (node.agent) && ((meshrights & 8) != 0) && ((features & 0x20000000) == 0) && (node.agent.id != 14)) {
6439 + if ((((connectivity & 1) != 0) || (node.mtype == 3)) && (node.agent) && ((meshrights & 8) != 0) && ((features & 0x20000000) == 0) && (node.agent.id != 14)) {
6440 x += '<a href=# cmenu=rfbPortContextMenu id=rfbLink onclick=p10rfb("' + node._id + '") title="' + "Launch noVNC session to this device" + '.">' + "noVNC" + '</a>&nbsp;';
6441 }
6442
6443 // MSTSC.js link
6443 - if (((connectivity & 1) != 0) && (node.agent) && ((meshrights & 8) != 0) && ((features & 0x40000000) == 0) && (node.agent.id != 14)) {
6444 + if ((((connectivity & 1) != 0) || (node.mtype == 3)) && (node.agent) && ((meshrights & 8) != 0) && ((features & 0x40000000) == 0) && (node.agent.id != 14)) {
6445 x += '<a href=# cmenu=altPortContextMenu id=mstscLink onclick=p10mstsc("' + node._id + '") title="' + "Launch web-based RDP session to this device" + '.">' + "Web-RDP" + '</a>&nbsp;';
6446 }
6447
@@ -6448,7 +6449,15 @@
6449 if ((meshrights == 0xFFFFFFFF) && (features & 0x00400000)) { x += '<a href=# onclick=p10showMqttLoginDialog("' + node._id + '") title="' + "Get MQTT login credentials for this device." + '">' + "MQTT Login" + '</a>&nbsp;'; }
6450 x += '</div><br>'
6451
6451 - QH('p10html3', x);
6452 + if (node.mtype == 3) {
6453 + // If this is a local device, there is no power timeline so display the links below the user rights.
6454 + QH('p10html3', '');
6455 + QH('p10html5', x);
6456 + } else {
6457 + // This is a normal device, display the links below the power timeline.
6458 + QH('p10html3', x);
6459 + QH('p10html5', '');
6460 + }
6461
6462 // Set the node power state
6463 var powerstate = PowerStateStr(node.state);
@@ -6465,7 +6474,7 @@
6474
6475 // Set the node icon
6476 Q('MainComputerImage').setAttribute('src', 'images/icons256-' + node.icon + '-1.png');
6468 - Q('MainComputerImage').className = ((!node.conn) || (node.conn == 0)?'gray':'');
6477 + Q('MainComputerImage').className = ((((!node.conn) || (node.conn == 0)) && (node.mtype != 3))?'gray':'');
6478
6479 // Setup/Refresh the desktop tab
6480 if (terminalAccess) { setupTerminal(); }
@@ -7000,7 +7009,7 @@
7009
7010 // Look to see if we need to update the device timeline
7011 function updateDeviceTimeline() {
7003 - if ((meshserver.State != 2) || (powerTimelineNode == null) || (powerTimelineUpdate == null) || (currentNode == null)) return;
7012 + if ((meshserver.State != 2) || (powerTimelineNode == null) || (powerTimelineUpdate == null) || (currentNode == null) || (currentNode.mtype == 3)) return;
7013 if ((powerTimelineNode == powerTimelineReq) && (currentNode._id == powerTimelineNode) && (powerTimelineUpdate < Date.now())) {
7014 powerTimelineUpdate = null;
7015 meshserver.send({ action: 'powertimeline', nodeid: currentNode._id });
@@ -7010,7 +7019,7 @@
7019
7020 // Draw device power bars. The bars are 766px wide.
7021 function drawDeviceTimeline() {
7013 - if ((currentNode == null) || (xxcurrentView < 10) || (xxcurrentView > 19)) return;
7022 + if ((currentNode == null) || (xxcurrentView < 10) || (xxcurrentView > 19) || (currentNode.mtype == 3)) return;
7023 var timeline = null, now = Date.now();
7024 if (currentNode._id == powerTimelineNode) { timeline = powerTimeline; }
7025