1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Added guest sharing list to device group panel.

This commit is contained in:
Ylian Saint-Hilaire 2021-12-01 14:53:28 -08:00
parent 2d3b1fe68a
commit e199c0c073
2 changed files with 137 additions and 10 deletions

View file

@ -2359,7 +2359,14 @@
if (message.nodeid != deviceSharesReq) break;
deviceSharesNode = message.nodeid;
deviceShares = message.deviceShares;
if (currentNode._id == message.nodeid) { gotoDevice(currentNode._id, xxcurrentView, true); }
if ((currentNode != null) && (currentNode._id == message.nodeid)) { gotoDevice(currentNode._id, xxcurrentView, true); }
break;
}
case 'deviceMeshShares': {
if (message.meshid != deviceSharesReq) break;
deviceSharesNode = message.meshid;
deviceShares = message.deviceShares;
if ((currentMesh != null) && (currentMesh._id == message.meshid)) { p20updateMesh(); }
break;
}
case 'getsysinfo': {
@ -11701,6 +11708,37 @@
x += '</tbody></table>';
// Show device shares
if ((deviceShares != null) && (deviceSharesNode == currentMesh._id) && (deviceShares.length > 0)) {
x += '<p></p><table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:left;width:430px>' + "Active Device Sharing" + '</th><th scope=col style=text-align:left></th></tr>';
count = 1;
for (var i = 0; i < deviceShares.length; i++) {
var dshare = deviceShares[i], trash = '';
if (dshare.url != null) { trash += '<a href="' + dshare.url + '" rel="noreferrer noopener" target=_blank title="' + "Device Sharing Link" + '" style=cursor:pointer><img src=images/link2.png border=0 height=10 width=10></a> '; }
trash += '<a href=# onclick=\'return p30removeDeviceSharing(event,"' + encodeURIComponentEx(dshare.nodeid) + '","' + encodeURIComponentEx(dshare.publicid) + '","' + encodeURIComponentEx(dshare.guestName) + '")\' title="' + "Remove device sharing" + '" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>';
var type = ['', "Terminal", "Desktop", "Desktop + Terminal", "Files", "Terminal + Files", "Desktop + Files", "Desktop + Terminal + Files"][dshare.p];
var details = type;
if ((dshare.startTime != null) && (dshare.expireTime != null)) { details = format("{0}, {1} to {2}", type, printFlexDateTime(new Date(dshare.startTime)), printFlexDateTime(new Date(dshare.expireTime))); }
if (((dshare.p & 2) != 0) && (dshare.viewOnly === true)) { details += ", View only desktop"; }
if (dshare.consent != null) {
if (dshare.consent == 0) { details += ", No Consent"; } else {
if ((dshare.consent & 0x0038) != 0) { details += ", Prompt for consent"; }
if ((dshare.consent & 0x0040) != 0) { details += ", Toolbar"; }
}
}
var guestName = EscapeHtml(dshare.guestName);
if (dshare.publicid.startsWith('AS:node/')) { guestName = '<i>' + "Agent Self-Share" + '</i>'; }
x += '<tr ' + (((++count % 2) == 0) ? 'style=background-color:#DDD' : '') + '><td style=width:30%><div class=m' + 2 + '></div><div>&nbsp;' + guestName + '<div></div></div></td><td style=width:70%><div style=float:right>' + trash + '</div><div>' + details + '</div></td></tr>';
}
x += '</tbody></table>';
} else {
// Request device sharing
if ((deviceSharesNode != currentMesh._id) && (deviceSharesReq != currentMesh._id)) {
deviceSharesReq = currentMesh._id;
meshserver.send({ action: 'deviceMeshShares', meshid: currentMesh._id });
}
}
// Display list of devices in this device group
count = 0;
nodes.sort(deviceSort);
@ -11717,7 +11755,7 @@
y += '<tr style=' + (((count % 2) == 0) ? ';background-color:#DDD' : '') + '><td style=width:30%><div onclick=\'gotoDevice("' + node._id + '",10);haltEvent(event);\' style=float:left class="j' + node.icon + gray + '"></div>&nbsp;<a onclick=\'gotoDevice("' + node._id + '",10);haltEvent(event);\'>' + EscapeHtml(node.name) + '</a></div></div></td><td style=width:70%><div style=float:right>' + PowerStateStr(node.pwr) + '&nbsp;</div><div>' + (node.osdesc ? EscapeHtml(node.osdesc) : '') + '</div></td></tr>';
++count;
}
if (count == 0) { y += '<tr><td><i>' + "None " + '</i></td></tr>'; }
if (count == 0) { y += '<tr><td><i>' + "None" + '</i></td></tr>'; }
y += '</tbody></table>';
// If we are full administrator on this mesh, allow deletion of the mesh