Can select what devices can be in the multi-desktop view
Ylian Saint-Hilaire committed
Apr 2, 2018 at 11:13 UTC
7eb6626daa0de3837f21528cb58dd65d84455c2a
2 files changed
+35
-23
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.1.5-r",
3
+ "version": "0.1.5-s",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
views/default.handlebars
+34
-22
@@ -116,10 +116,10 @@
116
<input type=checkbox id=HostnameCheckBox onclick=onHostnameCheckBox() /><span title="Show device hostnames">Hostname</span>
117
</div>
118
<div id=kvmListToolbar class=style14 style=height:100%;float:left>
119
- <input type="button" onclick="connectAllKvmFunction();" value="Connect All" />
120
- <input type="button" onclick="disconnectAllKvmFunction();" value="Disconnect All" />
119
+ <input type="button" onclick="connectAllKvmFunction()" value="Connect All" />
120
+ <input type="button" onclick="disconnectAllKvmFunction()" value="Disconnect All" />
121
<input type="checkbox" id="autoConnectDesktopCheckbox" onclick="autoConnectDesktops(event)" />AutoConnect
122
- <input type="button" onclick="showMultiDesktopSettings();" value="Settings" />
122
+ <input type="button" onclick="showMultiDesktopSettings()" value="Settings" />
123
</div>
124
<div id=devMapToolbar class=style14 style=height:100%;float:left>
125
<input type=text id=mapSearchLocation placeholder="Search Location" onfocus=onMapSearchFocus(1) onblur=onMapSearchFocus(0) />
@@ -367,6 +367,7 @@
367
<div>
368
369
<input id="DeskCAD" type="button" value="Ctrl-Alt-Del" onkeypress="return false" onkeydown="return false" onclick="sendCAD()">
370
+ <span title="Toggle mouse and keyboard input"><input id="DeskControl" type="checkbox" onkeypress="return false" onkeydown="return false" onclick="toggleKvmControl()">Input</span>
371
</div>
372
</td>
373
</tr>
@@ -659,6 +660,7 @@
660
var debugLevel = {{{debuglevel}}};
661
var features = {{{features}}};
662
var multiDesktop = {};
663
+ var multiDesktopFilter = null;
664
var serverPublicNamePort = "{{{serverDnsName}}}:{{{serverPublicPort}}}";
665
var amtScanResults = null;
666
var debugmode = false;
@@ -721,6 +723,7 @@
723
showHostnames = (getstore("showHostnames", 0) == 1);
724
Q('HostnameCheckBox').checked = showHostnames;
725
Q('viewselect').value = getstore("deviceView", 1);
726
+ Q('DeskControl').checked = (getstore('DeskControl', 1) == 1);
727
728
// Display the page devices
729
onSortSelectChange();
@@ -1288,7 +1291,7 @@
1291
}
1292
1293
function ondockeypress(e) {
1291
- if (!xxdialogMode && xxcurrentView == 11 && desktop) return desktop.m.handleKeys(e);
1294
+ if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) return desktop.m.handleKeys(e);
1295
if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) return terminal.m.TermHandleKeys(e);
1296
if (!xxdialogMode && xxcurrentView == 15) return agentConsoleHandleKeys(e);
1297
if (xxdialogMode || xxcurrentView != 1) return;
@@ -1324,7 +1327,7 @@
1327
}
1328
1329
function ondockeydown(e) {
1327
- if (!xxdialogMode && xxcurrentView == 11 && desktop) { return desktop.m.handleKeyDown(e); }
1330
+ if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) { return desktop.m.handleKeyDown(e); }
1331
if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) { return terminal.m.TermHandleKeyDown(e); }
1332
if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { haltEvent(e); return false; } // F5 Refresh on files
1333
if (!xxdialogMode && xxcurrentView == 15) { return agentConsoleHandleKeys(e); }
@@ -1342,7 +1345,7 @@
1345
}
1346
1347
function ondockeyup(e) {
1345
- if (!xxdialogMode && xxcurrentView == 11 && desktop) return desktop.m.handleKeyUp(e);
1348
+ if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) return desktop.m.handleKeyUp(e);
1349
if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) return terminal.m.TermHandleKeyUp(e);
1350
if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { p13folderup(9999); haltEvent(e); return false; } // F5 Refresh on files
1351
if (xxdialogMode && e.keyCode == 27) { dialogclose(0); }
@@ -1354,6 +1357,7 @@
1357
var deviceHeaderId = 0;
1358
var deviceHeaderCount;
1359
var deviceHeaders = {};
1360
+ var oldviewmode = 0;
1361
function updateDevices() {
1362
var r = '', c = 0, current = null, count = 0, displayedMeshes = {}, view = Q('viewselect').value;
1363
QV('xdevices', view < 4);
@@ -1382,6 +1386,8 @@
1386
// Save the list of currently checked nodeid's
1387
var checkedNodeids = [], elements = document.getElementsByClassName("DeviceCheckbox"), checkcount = 0;
1388
for (var i in elements) { if (elements[i].checked) { checkedNodeids.push(elements[i].value); } }
1389
+ if ((oldviewmode < 3) && (view == 3)) { multiDesktopFilter = checkedNodeids; }
1390
+ else if ((oldviewmode == 3) && (view < 3)) { checkedNodeids = multiDesktopFilter; }
1391
1392
// Go thru the list of nodes and display them
1393
for (var i in nodes) {
@@ -1439,12 +1445,14 @@
1445
r += '<div class=g1 style=height:18px;float:left></div><div class=g2 style=height:18px;float:right></div>';
1446
r += '<div style=cursor:pointer;font-size:14px title="' + title + '" onclick=gotoDevice(\'' + nodes[i]._id + '\')><span style=float:right>' + nodestate + '</span><span style=width:300px>' + name + '</span></div></div></td></tr>';
1447
} else if ((view == 3) && (nodes[i].conn & 1) && ((meshrights & 8) != 0)) {
1442
- r += '<div id=devs style=display:inline-block;margin:1px;background-color:lightgray;border-radius:5px;position:relative><div style=padding:3px;cursor:pointer onclick=gotoDevice(\'' + nodes[i]._id + '\',11)>';
1443
- //r += '<input class="' + nodes[i].meshid + ' DeviceCheckbox" onclick=p1updateInfo() value=devid_' + nodes[i]._id + ' type=checkbox style=float:left>';
1444
- r += '<div class="j' + icon + '" style=width:16px;float:left></div> ' + name + '</div>';
1445
- r += '<span onclick=gotoDevice(\'' + nodes[i]._id + '\')></span><div id=xkvmid_' + nodes[i]._id.split('/')[2] + '><div id=skvmid_' + nodes[i]._id.split('/')[2] + ' style="position:absolute;color:white;left:5px;top:27px;text-shadow:0px 0px 5px #000;z-index:1000;cursor:default" onclick=toggleKvmDevice(\'' + nodes[i]._id + '\')>Disconnected</div></div>';
1446
- r += '</div>';
1447
- kvmDivs.push(nodes[i]._id);
1448
+ if ((multiDesktopFilter.length == 0) || (multiDesktopFilter.indexOf('devid_' + nodes[i]._id) >= 0)) {
1449
+ r += '<div id=devs style=display:inline-block;margin:1px;background-color:lightgray;border-radius:5px;position:relative><div style=padding:3px;cursor:pointer onclick=gotoDevice(\'' + nodes[i]._id + '\',11)>';
1450
+ //r += '<input class="' + nodes[i].meshid + ' DeviceCheckbox" onclick=p1updateInfo() value=devid_' + nodes[i]._id + ' type=checkbox style=float:left>';
1451
+ r += '<div class="j' + icon + '" style=width:16px;float:left></div> ' + name + '</div>';
1452
+ r += '<span onclick=gotoDevice(\'' + nodes[i]._id + '\')></span><div id=xkvmid_' + nodes[i]._id.split('/')[2] + '><div id=skvmid_' + nodes[i]._id.split('/')[2] + ' style="position:absolute;color:white;left:5px;top:27px;text-shadow:0px 0px 5px #000;z-index:1000;cursor:default" onclick=toggleKvmDevice(\'' + nodes[i]._id + '\')>Disconnected</div></div>';
1453
+ r += '</div>';
1454
+ kvmDivs.push(nodes[i]._id);
1455
+ }
1456
}
1457
1458
deviceHeaderTotal++;
@@ -1553,8 +1561,8 @@
1561
disconnectAllKvmFunction();
1562
Q('autoConnectDesktopCheckbox').checked = false;
1563
}
1556
-
1564
}
1565
+ oldviewmode = view;
1566
}
1567
1568
function toggleKvmDevice(nodeid) {
@@ -1588,14 +1596,15 @@
1596
}
1597
1598
function connectMultiDesktop(node, contype) {
1591
- var nodeid = node._id;
1599
+ var nodeid = node._id, shortid = nodeid.split('/')[2];
1600
var desk = multiDesktop[nodeid];
1601
if (desk == null) {
1602
+ if (Q('kvmid_' + shortid) == null) return; // Check if this device is being displayed, if not, exit now.
1603
if (contype == 2) {
1604
// Setup the Intel AMT remote desktop
1605
if ((node.intelamt.user == null) || (node.intelamt.user == '')) { return; }
1597
- desk = CreateAmtRedirect(CreateAmtRemoteDesktop('kvmid_' + nodeid.split('/')[2]));
1598
- desk.shortid = nodeid.split('/')[2];
1606
+ desk = CreateAmtRedirect(CreateAmtRemoteDesktop('kvmid_' + shortid));
1607
+ desk.shortid = shortid;
1608
//desk.debugmode = debugmode;
1609
desk.onStateChanged = onMultiDesktopStateChange;
1610
desk.m.bpp = 1;
@@ -1607,8 +1616,8 @@
1616
multiDesktop[nodeid] = desk;
1617
} else if (contype == 1) {
1618
// Setup the Mesh Agent remote desktop
1610
- desk = CreateAgentRedirect(meshserver, CreateAgentRemoteDesktop('kvmid_' + nodeid.split('/')[2]), serverPublicNamePort);
1611
- desk.shortid = nodeid.split('/')[2];
1619
+ desk = CreateAgentRedirect(meshserver, CreateAgentRemoteDesktop('kvmid_' + shortid), serverPublicNamePort);
1620
+ desk.shortid = shortid;
1621
desk.attemptWebRTC = attemptWebRTC;
1622
desk.onStateChanged = onMultiDesktopStateChange;
1623
desk.m.CompressionLevel = multidesktopsettings.quality;
@@ -3333,6 +3342,9 @@
3342
desktop.m.sendcad();
3343
}
3344
3345
+ // Toggle mouse and keyboard input
3346
+ function toggleKvmControl() { putstore('DeskControl', (Q("DeskControl").checked?1:0)); }
3347
+
3348
// Save the desktop image to file
3349
function deskSaveImage() {
3350
if (xxdialogMode || desktop == null || desktop.State != 3) return;
@@ -3354,10 +3366,10 @@
3366
desktop.m.SetDisplay(display);
3367
}
3368
3357
- function dmousedown(e) { if (!xxdialogMode && desktop != null) desktop.m.mousedown(e) }
3358
- function dmouseup(e) { if (!xxdialogMode && desktop != null) desktop.m.mouseup(e) }
3359
- function dmousemove(e) { if (!xxdialogMode && desktop != null) desktop.m.mousemove(e) }
3360
- function dmousewheel(e) { if (!xxdialogMode && desktop != null) { desktop.m.mousewheel(e); haltEvent(e); return true; } return false; }
3369
+ function dmousedown(e) { if (!xxdialogMode && desktop != null && Q('DeskControl').checked) desktop.m.mousedown(e) }
3370
+ function dmouseup(e) { if (!xxdialogMode && desktop != null && Q('DeskControl').checked) desktop.m.mouseup(e) }
3371
+ function dmousemove(e) { if (!xxdialogMode && desktop != null && Q('DeskControl').checked) desktop.m.mousemove(e) }
3372
+ function dmousewheel(e) { if (!xxdialogMode && desktop != null && Q('DeskControl').checked) { desktop.m.mousewheel(e); haltEvent(e); return true; } return false; }
3373
function drotate(x) { if (!xxdialogMode && desktop != null) { desktop.m.setRotation(desktop.m.rotation + x); deskAdjust(); deskAdjust(); } }
3374
3375
//