More mobile site improvements, MeshCmd fix

This commit is contained in:
Ylian Saint-Hilaire 2018-06-06 16:52:21 -07:00
parent 53c7eae4d2
commit b87eeee0f0
4 changed files with 470 additions and 50 deletions

View File

@ -1305,8 +1305,10 @@ function removeItemFromArray(array, element) {
// Run MeshCmd, but before we do, we need to see if what type of service we are going to be // Run MeshCmd, but before we do, we need to see if what type of service we are going to be
var serviceName = null; var serviceName = null;
var serviceOpSpecified = 0; var serviceOpSpecified = 0;
var serviceInstall = 0;
for (var i in process.argv) { for (var i in process.argv) {
if (process.argv[i].toLowerCase() == 'install') { serviceInstall = 1 } else if (process.argv[i].toLowerCase() == 'uninstall') { serviceInstall = -1 }
if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; break; } if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; break; }
if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; break; } if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; break; }
} }
@ -1323,6 +1325,9 @@ if (serviceName == null) {
else { serviceName = 'not_a_service'; } else { serviceName = 'not_a_service'; }
} }
if (serviceInstall == 0) {
run(process.argv);
} else {
var serviceHost = require('serviceHost'); var serviceHost = require('serviceHost');
var meshcmdService = new serviceHost({ name: serviceName, startType: 'AUTO_START' }); var meshcmdService = new serviceHost({ name: serviceName, startType: 'AUTO_START' });
@ -1340,5 +1345,4 @@ meshcmdService.on('serviceStop', function onStop() { console.log('Stopping servi
// Called when the executable is not running as a service, run normally. // Called when the executable is not running as a service, run normally.
meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } }); meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } });
meshcmdService.run(); meshcmdService.run();
}

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.1.8-a", "version": "0.1.8-b",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -8,23 +8,20 @@
<meta name="format-detection" content="telephone=no" /> <meta name="format-detection" content="telephone=no" />
<script type="text/javascript" src="scripts/common-0.0.1.js"></script> <script type="text/javascript" src="scripts/common-0.0.1.js"></script>
<script type="text/javascript" src="scripts/meshcentral.js"></script> <script type="text/javascript" src="scripts/meshcentral.js"></script>
<script type="text/javascript" src="scripts/agent-redir-ws-0.1.0.js"></script>
<script type="text/javascript" src="scripts/agent-desktop-0.0.2.js"></script>
<script type="text/javascript" src="scripts/amt-0.2.0.js"></script>
<script type="text/javascript" src="scripts/amt-redir-ws-0.1.0.js"></script>
<script type="text/javascript" src="scripts/amt-desktop-0.0.2.js"></script>
<script type="text/javascript" src="scripts/zlib.js"></script>
<script type="text/javascript" src="scripts/zlib-inflate.js"></script>
<script type="text/javascript" src="scripts/zlib-adler32.js"></script>
<script type="text/javascript" src="scripts/zlib-crc32.js"></script>
<title>MeshCentral - Login</title> <title>MeshCentral - Login</title>
<style> <style>
a { a { color: #036; text-decoration: underline }
color: #036; #footer a { color: #fff; text-decoration: underline }
text-decoration: underline; #footer a:hover { color: #fff; text-decoration: none }
}
#footer a {
color: #fff;
text-decoration: underline;
}
#footer a:hover {
color: #fff;
text-decoration: none;
}
.i1 {background:url(../images/icons50.png) 0px 0px;height:50px;width:50px;border:none;} .i1 {background:url(../images/icons50.png) 0px 0px;height:50px;width:50px;border:none;}
.i2 {background:url(../images/icons50.png) -50px 0px;height:50px;width:50px;border:none;} .i2 {background:url(../images/icons50.png) -50px 0px;height:50px;width:50px;border:none;}
.i3 {background:url(../images/icons50.png) -100px 0px;height:50px;width:50px;border:none;} .i3 {background:url(../images/icons50.png) -100px 0px;height:50px;width:50px;border:none;}
@ -148,11 +145,64 @@
</td> </td>
</tr> </tr>
</table> </table>
<div style="overflow-y:scroll;position:absolute;top:55px;bottom:0px;width:100%"> <div id=p10general style="overflow-y:scroll;position:absolute;top:55px;bottom:0px;width:100%">
<div id=p10html style="margin-left:8px;margin-right:8px"></div> <div id=p10html style="margin-left:8px;margin-right:8px"></div>
<div id=p10html2></div> <div id=p10html2></div>
<div id=p10html3></div> <div id=p10html3></div>
</div> </div>
<div id=p10desktop style="overflow-y:scroll;position:absolute;top:55px;bottom:0px;width:100%;display:none">
<div id=deskarea1>
<div style="padding-top:2px;padding-bottom:2px;background:#C0C0C0">
<div style="float:right;text-align:right">
<span id="p14power"></span>&nbsp;
</div>
<div style="margin-left:3px">
<input type=button id=connectbutton1 value="Connect" onclick=connectDesktop(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled">
<input type=button id=connectbutton1h value="HW Connect" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled">
<input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false">
<span id="deskstatus">Disconnected</span>
</div>
</div>
</div>
<div id=deskarea2>
<div>
<div style=background-color:gray><div id=progressbar style=height:2px;width:0%;background-color:red></div></div>
</div>
</div>
<div id=deskarea3 style="height:calc(100% - 56px)">
<div id=deskarea3x style="background:black;text-align:center;height:100%;position:relative">
<div id=DeskParent style="height:100%">
<canvas id=Desk width=640 height=200 style="width:100%;-ms-touch-action:none;margin-left:0px" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event) onmousewheel=dmousewheel(event)></canvas>
</div>
<div id=DeskTools style="position:absolute;width:400px;height:100%;background-color:gray;top:0;right:0;border-left:2px solid lightgray;display:none">
<a id=DeskToolsRefreshButton style="float:right;padding:3px;cursor:pointer" onclick="refreshDeskTools()">Refresh</a>
<div id=DeskToolsBar style="position:absolute;padding:3px;border-radius: 3px 3px 0px 0px;top:5px;left:4px;bottom:26px;background-color:lightgray;cursor:pointer">Processes</div>
<div style="position:absolute;top:26px;left:4px;right:4px;bottom:4px;background-color:lightgray;text-align:left">
<div style="border-bottom:1px solid darkgray;padding:3px"><a style=width:50px;padding-right:5px;float:left;cursor:pointer title="Sort by process id" onclick=sortProcess(0)>PID</a><a style=cursor:pointer title="Sort by name" onclick=sortProcess(1)>Name</a></div>
<div id="DeskToolsProcesses" style="overflow-y:scroll;position:absolute;top:24px;bottom:0px;width:100%"></div>
</div>
</div>
</div>
</div>
<div id=deskarea4>
<div style=padding-top:2px;padding-bottom:2px;background:#C0C0C0>
<div style=float:right;text-align:right>
<select id=termdisplays style=display:none onchange=deskSetDisplay(event) onclick=deskGetDisplayNumbers(event)></select>&nbsp;
<input id=DeskToastButton type=button value=Toast title="Display a notification message on the remote computer" onkeypress="return false" onkeydown="return false" onclick="deviceToastFunction()">&nbsp;
<!--<input id=DeskToolsButton type=button value=Tools title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()">&nbsp;-->
</div>
<div>
<input id="deskActionsBtn" type=button style="margin-left:3px" title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction() />
<input type="button" value="Settings..." title="Edit remote desktop settings" onkeypress="return false" onkeydown="return false" onclick="showDesktopSettings()">
<input type="button" title="Change the power state of the remote machine" onkeypress="return false" onkeydown="return false" value="Power Actions..." onclick="showPowerActionDlg()" style="display:none">
<input id="DeskCAD" type="button" value="Ctrl-Alt-Del" onkeypress="return false" onkeydown="return false" onclick="sendCAD()">
</div>
</div>
</div>
</div>
<div id=p10files style="overflow-y:scroll;position:absolute;top:55px;bottom:0px;width:100%;display:none">
</div>
</div> </div>
<div id=p20 style=display:none;position:absolute;bottom:0;top:0;width:100%> <div id=p20 style=display:none;position:absolute;bottom:0;top:0;width:100%>
<table cellspacing=0 style="margin:0;padding:0;border-spacing:0;border:0;"> <table cellspacing=0 style="margin:0;padding:0;border-spacing:0;border:0;">
@ -178,12 +228,7 @@
</div> </div>
</div> </div>
<div id=footer style="height:32px;width:100%;text-align:center;background-color:#113962;position:absolute;bottom:0px"> <div id=footer style="height:32px;width:100%;text-align:center;background-color:#113962;position:absolute;bottom:0px">
<table cellpadding=0 cellspacing=6 style=width:100%> <table id=footerMenu cellpadding=0 cellspacing=0 style="height:32px;width:100%;color:white;cursor:pointer;table-layout:fixed"></table>
<tr>
<td style=text-align:left;color:white>{{{footer}}}</td>
<td style=text-align:right>{{{rootCertLink}}}&nbsp;<a href=terms>Terms &amp; Privacy</a></td>
</tr>
</table>
</div> </div>
</div> </div>
<div id=dialog style="z-index:1000;background-color:#EEE;box-shadow:0px 0px 15px #666;font-family:Arial,Helvetica,sans-serif;border-radius:5px;position:fixed;top:90px;width:300px;display:none"> <div id=dialog style="z-index:1000;background-color:#EEE;box-shadow:0px 0px 15px #666;font-family:Arial,Helvetica,sans-serif;border-radius:5px;position:fixed;top:90px;width:300px;display:none">
@ -221,6 +266,11 @@
var serverinfo = null; var serverinfo = null;
var users = null; var users = null;
var nodeShortIdent = 0; var nodeShortIdent = 0;
var serverPublicNamePort = "{{{serverDnsName}}}:{{{serverPublicPort}}}";
var debugmode = false;
var features = {{{features}}};
var attemptWebRTC = ((features & 128) != 0);
var StatusStrs = ['Disconnected', 'Connecting...', 'Setup...', 'Connected', 'Intel&reg; AMT Connected'];
function startup() { function startup() {
if ((features & 32) == 0) { if ((features & 32) == 0) {
@ -240,6 +290,11 @@
meshserver.onStateChanged = onStateChanged; meshserver.onStateChanged = onStateChanged;
meshserver.onMessage = onMessage; meshserver.onMessage = onMessage;
meshserver.Start(); meshserver.Start();
// Load desktop settings
var t = localStorage.getItem('desktopsettings');
if (t != null) { desktopsettings = JSON.parse(t); }
applyDesktopSettings();
} }
function onStateChanged(server, state) { function onStateChanged(server, state) {
@ -555,12 +610,18 @@
function goStack() { function goStack() {
if (backStack.length == 0) { go(2); return; } if (backStack.length == 0) { go(2); return; }
var id = backStack[backStack.length - 1], idtype = id.split('/')[0]; var id = backStack[backStack.length - 1], idtype = id.split('/')[0];
if (idtype == 'node') { gotoDevice(id); } if (idtype == 'node') { setupDeviceMenu(0); gotoDevice(id); }
if (idtype == 'mesh') { gotoMesh(id); } if (idtype == 'mesh') { gotoMesh(id); }
if (idtype == 'account') { go(3); } if (idtype == 'account') { go(3); }
if (idtype == 'devices') { go(2); } if (idtype == 'devices') { go(2); }
} }
function updateFooterMenu(options) {
var x = '', count = 0;
if (options != null) { for (var i in options) { x += '<td style="cursor:pointer' + (count == 0?'':';border-left:solid 1px white') + '" onclick="' + options[i].f + '">' + options[i].n; count++; } }
QH('footerMenu', '<tr>' + x);
}
// //
// MY ACCOUNT // MY ACCOUNT
// //
@ -688,6 +749,7 @@
function gotoMesh(meshid) { function gotoMesh(meshid) {
currentMesh = meshes[meshid]; currentMesh = meshes[meshid];
if (currentMesh == null) { goBack(); }
p20updateMesh(); p20updateMesh();
go(20); go(20);
} }
@ -904,6 +966,7 @@
return mesh.links['user/{{{domain}}}/' + userinfo.name.toLowerCase()].rights; return mesh.links['user/{{{domain}}}/' + userinfo.name.toLowerCase()].rights;
} }
var currentDevicePanel = 0;
var currentNode; var currentNode;
var powerTimelineNode = null; var powerTimelineNode = null;
var powerTimelineReq = null; var powerTimelineReq = null;
@ -911,7 +974,10 @@
var powerTimeline = null; var powerTimeline = null;
function getCurrentNode() { return currentNode; }; function getCurrentNode() { return currentNode; };
function gotoDevice(nodeid, panel, refresh) { function gotoDevice(nodeid, panel, refresh) {
var node = getNodeFromId(nodeid), mesh = meshes[node.meshid]; var node = getNodeFromId(nodeid);
if (node == null) { goBack(); }
var mesh = meshes[node.meshid];
if (mesh == null) { goBack(); }
var meshrights = mesh.links['user/{{{domain}}}/' + userinfo.name.toLowerCase()].rights; var meshrights = mesh.links['user/{{{domain}}}/' + userinfo.name.toLowerCase()].rights;
if (!currentNode || currentNode._id != node._id || refresh == true) { if (!currentNode || currentNode._id != node._id || refresh == true) {
currentNode = node; currentNode = node;
@ -921,14 +987,6 @@
if (nname.length == 0) { nname = '<i>None</i>'; } if (nname.length == 0) { nname = '<i>None</i>'; }
if ((meshrights & 4) != 0) { nname = '<span onclick=showEditNodeValueDialog(0) style=cursor:pointer>' + nname + '</span>'; } if ((meshrights & 4) != 0) { nname = '<span onclick=showEditNodeValueDialog(0) style=cursor:pointer>' + nname + '</span>'; }
QH('p10deviceName', nname); QH('p10deviceName', nname);
/*
QH('p11deviceName', nname);
QH('p12deviceName', nname);
QH('p13deviceName', nname);
QH('p14deviceName', nname);
QH('p15deviceName', nname);
QH('p16deviceName', nname);
*/
// Node attributes // Node attributes
var x = '<table style=width:100%>'; var x = '<table style=width:100%>';
@ -979,7 +1037,7 @@
else if ((node.intelamt.ver == null) || (node.intelamt.state == null)) { str += '<i>Unknown Version & State</i>'; } else if ((node.intelamt.ver == null) || (node.intelamt.state == null)) { str += '<i>Unknown Version & State</i>'; }
else { else {
str += provisioningStates[node.intelamt.state]; str += provisioningStates[node.intelamt.state];
if (node.intelamt.flags) { if (node.intelamt.flags & 2) { str += ' <span title="Intel AMT is activated in Client Control Mode">CCM</span>'; } else if (node.intelamt.flags & 4) { str += ' <span title="Intel AMT is activated in Admin Control Mode">ACM</span>'; } } if (node.intelamt.flags) { if (node.intelamt.flags & 2) { str = ' <span title="Intel AMT is activated in Client Control Mode">CCM</span>'; } else if (node.intelamt.flags & 4) { str = ' <span title="Intel AMT is activated in Admin Control Mode">ACM</span>'; } }
str += (', v' + node.intelamt.ver); str += (', v' + node.intelamt.ver);
} }
@ -1060,8 +1118,33 @@
// Request the power timeline // Request the power timeline
if ((powerTimelineNode != currentNode._id) && (powerTimelineReq != currentNode._id)) { QH('p10html2', ''); powerTimelineReq = currentNode._id; meshserver.send({ action: 'powertimeline', nodeid: currentNode._id }); } if ((powerTimelineNode != currentNode._id) && (powerTimelineReq != currentNode._id)) { QH('p10html2', ''); powerTimelineReq = currentNode._id; meshserver.send({ action: 'powertimeline', nodeid: currentNode._id }); }
} }
setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
if (!panel) panel = 10; if (!panel) panel = 10;
go(panel); go(panel);
// Update the footer menu
setupDeviceMenu();
}
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>');
}
function deviceToastFunctionEx() {
meshserver.send({ action: 'toast', nodeids: [ currentNode._id ], title: 'MeshCentral', msg: Q('d2devToast').value });
}
function setupDeviceMenu(op) {
if (op != null) { currentDevicePanel = op; }
QV('p10general', currentDevicePanel == 0);
QV('p10desktop', currentDevicePanel == 1);
QV('p10files', currentDevicePanel == 2);
var menus = [];
if (currentDevicePanel != 0) { menus.push( { n:'General', f:'setupDeviceMenu(0)' } ); }
if (currentDevicePanel != 1) { menus.push( { n:'Desktop', f:'setupDeviceMenu(1)' } ); }
if (currentDevicePanel != 2) { menus.push( { n:'Files', f:'setupDeviceMenu(2)' } ); }
updateFooterMenu(menus);
} }
function deviceActionFunction() { function deviceActionFunction() {
@ -1255,6 +1338,337 @@
if ((e != null) && (x == true) && (e.keyCode == 13)) { dialogclose(1); } if ((e != null) && (x == true) && (e.keyCode == 13)) { dialogclose(1); }
} }
//
// DESKTOP
//
var desktop;
var desktopNode;
var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50 };
function setupDesktop() {
// Setup the remote desktop
if ((desktopNode != currentNode) && (desktop != null)) { desktop.Stop(); delete desktop; desktopNode = null; desktop = null; }
// If the device desktop is already connected in multi-desktop, use that.
if ((desktopNode != currentNode) || (desktop == null)) {
// Device is not already connected, just setup a blank canvas
QH('DeskParent', '<canvas id=Desk width=640 height=200 style="width:100%;-ms-touch-action:none;margin-left:0px" oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>');
desktopNode = currentNode;
// Setup the mouse wheel
Q('Desk').addEventListener('DOMMouseScroll', function (e) { return dmousewheel(e); });
Q('Desk').addEventListener('mousewheel', function (e) { return dmousewheel(e); });
}
desktopNode = currentNode;
updateDesktopButtons();
// On some browsers like IE, we can't save screen shots. Hide the scheenshot/capture buttons.
if (!Q('Desk')['toBlob']) { QV('deskSaveBtn', false); }
}
// Show and enable the right buttons
function updateDesktopButtons() {
var mesh = meshes[currentNode.meshid];
var deskState = 0;
if (desktop != null) { deskState = desktop.State; }
// Show the right buttons
QV('disconnectbutton1', (deskState != 0));
QV('connectbutton1', (deskState == 0) && (mesh.mtype == 2));
QV('connectbutton1h', (deskState == 0) && ((currentNode.intelamt != null) && (mesh.mtype == 1 || currentNode.intelamt.state == 2) && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
// Show the right settings
QV('d7amtkvm', (currentNode.intelamt != null && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))) && ((deskState == 0) || (desktop.contype == 2)));
QV('d7meshkvm', (mesh.mtype == 2) && ((deskState == false) || (desktop.contype == 1)));
// Enable buttons
var online = ((currentNode.conn & 1) != 0); // If Agent (1) connected, enable remote desktop
QE('connectbutton1', online);
var hwonline = ((currentNode.conn & 6) != 0); // If CIRA (2) or AMT (4) connected, enable hardware terminal
QE('connectbutton1h', hwonline);
//QE('deskSaveBtn', deskState == 3);
QE('DeskCAD', deskState == 3);
QE('DeskWD', deskState == 3);
QE('deskkeys', deskState == 3);
QV('DeskWD', (currentNode.agent) && (currentNode.agent.id < 5));
QV('deskkeys', (currentNode.agent) && (currentNode.agent.id < 5));
QE('DeskToolsButton', online);
QV('DeskToastButton', (currentNode.agent) && (currentNode.agent.id < 5));
QE('DeskToastButton', online);
if (online == false) QV('DeskTools', false);
}
function connectDesktop(e, contype) {
if (desktop == null) {
desktopNode = currentNode;
if (contype == 2) {
// Setup the Intel AMT remote desktop
if ((desktopNode.intelamt.user == null) || (desktopNode.intelamt.user == '')) { editDeviceAmtSettings(desktopNode._id, connectDesktop); return; }
desktop = CreateAmtRedirect(CreateAmtRemoteDesktop('Desk'));
desktop.debugmode = debugmode;
desktop.onStateChanged = onDesktopStateChange;
desktop.m.bpp = (desktopsettings.encoding == 1 || desktopsettings.encoding == 3) ? 1 : 2;
desktop.m.useZRLE = (desktopsettings.encoding < 3);
desktop.m.showmouse = desktopsettings.showmouse;
desktop.m.onScreenSizeChange = deskAdjust;
desktop.Start(desktopNode._id, 16994, '*', '*', 0);
desktop.contype = 2;
} else {
// Setup the Mesh Agent remote desktop
desktop = CreateAgentRedirect(meshserver, CreateAgentRemoteDesktop('Desk'), serverPublicNamePort);
desktop.debugmode = debugmode;
desktop.m.debugmode = debugmode;
desktop.attemptWebRTC = attemptWebRTC;
desktop.onStateChanged = onDesktopStateChange;
desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
desktop.m.ScalingLevel = desktopsettings.scaling;
desktop.m.FrameRateTimer = desktopsettings.framerate;
desktop.m.onDisplayinfo = deskDisplayInfo;
desktop.m.onScreenSizeChange = deskAdjust;
desktop.Start(desktopNode._id);
desktop.contype = 1;
}
} else {
// Disconnect and clean up the remote desktop
desktop.Stop();
delete desktop;
desktopNode = desktop = null;
}
}
function onDesktopStateChange(xdesktop, state) {
var xstate = state;
if ((xstate == 3) && (xdesktop.contype == 2)) { xstate++; }
var str = StatusStrs[xstate];
if ((desktop != null) && (desktop.webRtcActive == true)) { str += ', WebRTC'; }
//if (desktop.m.stopInput == true) { str += ', Loopback'; }
QH('deskstatus', str);
switch (state) {
case 0:
// Disconnect and clean up the remote desktop
desktop.Stop();
delete desktop;
desktopNode = desktop = null;
QV('termdisplays', false);
if (fullscreen == true) { deskToggleFull(); }
break;
case 2:
break;
}
updateDesktopButtons();
deskAdjust();
setTimeout(deskAdjust, 50);
}
function showDesktopSettings() {
if (xxdialogMode) return;
applyDesktopSettings();
updateDesktopButtons();
setDialogMode(7, "Remote Desktop Settings", 3, showDesktopSettingsChanged);
}
function showDesktopSettingsChanged() {
desktopsettings.encoding = d7desktopmode.value;
desktopsettings.showfocus = d7showfocus.checked;
desktopsettings.showmouse = d7showcursor.checked;
desktopsettings.quality = d7bitmapquality.value;
desktopsettings.scaling = d7bitmapscaling.value;
desktopsettings.framerate = d7framelimiter.value;
localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
applyDesktopSettings();
if (desktop) {
if (desktop.contype == 1) {
if (desktop.State != 0) { desktop.m.SendCompressionLevel(1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
}
if (desktop.contype == 2) {
if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); }
}
}
}
function applyDesktopSettings() {
/*
var r = '', ops = (features & 512)?[90,70,50,40,30,20,10,5,1]:[50,40,30,20,10,5,1];
for (var i in ops) { r += '<option value=' + ops[i] + '>' + ops[i] + '%</option>'; }
QH('d7bitmapquality', r);
d7desktopmode.value = desktopsettings.encoding;
d7showfocus.checked = desktopsettings.showfocus;
d7showcursor.checked = desktopsettings.showmouse;
d7bitmapquality.value = 40; // Default value
if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
d7bitmapscaling.value = desktopsettings.scaling;
if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; }
*/
}
var fullscreen = false;
/*
function deskToggleFull() {
fullscreen = !fullscreen;
QV('mastheadx', !fullscreen);
QV('masthead', !fullscreen);
QV('topbar', !fullscreen);
QV('p11deviceNameHeader', !fullscreen);
QV('footer', !fullscreen);
QV('column_l_bottomgap', !fullscreen);
QV('idx_deskFullBtn2', fullscreen);
QV('deskFullBtn', !fullscreen);
if (fullscreen) {
QS('container').width = '100%';
QS('container')['border-right'] = '0';
QS('container')['border-left'] = '0';
QS('column_l').padding = '0';
QS('column_l').width = '100%';
} else {
QS('container').width = '960px';
QS('container')['border-right'] = '1px solid #b7b7b7';
QS('container')['border-left'] = '1px solid #b7b7b7';
QS('column_l').padding = '0 15px';
QS('column_l').width = '930px';
toggleFullScreen();
}
deskAdjust();
}
*/
function deskAdjust() {
var x = (Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - (Q('deskarea1').clientHeight + Q('deskarea2').clientHeight + Q('Desk').clientHeight + Q('deskarea4').clientHeight + 2)) / 2;
if (fullscreen) {
document.documentElement.style.overflow = 'hidden';
//QS('deskarea3x').height = null;
if (x < 0) {
var mh = (Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - (Q('deskarea1').clientHeight + Q('deskarea2').clientHeight + Q('deskarea4').clientHeight));
var mw = 9999;
if (desktop) { mw = (desktop.m.width / desktop.m.height) * mh; }
QS('Desk')['max-height'] = mh + 'px';
QS('Desk')['max-width'] = mw + 'px';
x = 0;
} else {
QS('Desk')['max-height'] = null;
QS('Desk')['max-width'] = null;
}
QS('Desk')['margin-top'] = x + 'px';
QS('Desk')['margin-bottom'] = x + 'px';
} else {
document.documentElement.style.overflow = 'auto';
//QS('deskarea3x').height = (desktop)?'40px':'400px';
QS('Desk')['max-height'] = null;
QS('Desk')['max-width'] = null;
QS('Desk')['margin-top'] = '0';
QS('Desk')['margin-bottom'] = '0';
}
}
// Remote desktop special key combos for Windows
function deskSendKeys() {
if (xxdialogMode || desktop == null || desktop.State != 3) return;
var ks = Q('deskkeys').value;
if (ks == 0) { // WIN+Down arrow
if (desktop.contype == 2) {
desktop.m.sendkey([[0xffe7,1],[0xff54,1],[0xff54,0],[0xffe7,0]]); // Intel AMT: Meta-left down, Down arrow press, Down arrow release, Meta-left release
} else {
desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,40],[desktop.m.KeyAction.UP,40],[desktop.m.KeyAction.EXUP,0x5B]]); // Agent: L-Winkey press, Down arrow press, Down arrow release, L-Winkey release
}
} else if (ks == 1) { // WIN+Up arrow
if (desktop.contype == 2) {
desktop.m.sendkey([[0xffe7,1],[0xff52,1],[0xff52,0],[0xffe7,0]]); // Intel AMT: Meta-left down, Up arrow press, Up arrow release, Meta-left release
} else {
desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,38],[desktop.m.KeyAction.UP,38],[desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, Up arrow press, Up arrow release, L-Winkey release
}
} else if (ks == 2) { // WIN+L arrow
if (desktop.contype == 2) {
desktop.m.sendkey([[0xffe7,1],[0x6c,1],[0x6c,0],[0xffe7,0]]); // Intel AMT: Meta-left down, 'l' press, 'l' release, Meta-left release
} else {
desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,76],[desktop.m.KeyAction.UP,76],[desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, 'L' press, 'L' release, L-Winkey release
}
} else if (ks == 3) { // WIN+M arrow
if (desktop.contype == 2) {
desktop.m.sendkey([[0xffe7,1],[0x6d,1],[0x6d,0],[0xffe7,0]]); // Intel AMT: Meta-left down, 'm' press, 'm' release, Meta-left release
} else {
desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, 'M' press, 'M' release, L-Winkey release
}
} else if (ks == 4) { // Shift+WIN+M arrow
if (desktop.contype == 2) {
desktop.m.sendkey([[0xffe1,1],[0xffe7,1],[0x6d,1],[0x6d,0],[0xffe7,0],[0xffe1,0]]); // Intel AMT: Shift-left down, Meta-left down, 'm' press, 'm' release, Meta-left release, Shift-left release
} else {
desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.DOWN,16],[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,77],[desktop.m.KeyAction.UP,77],[desktop.m.KeyAction.EXUP,0x5B],[desktop.m.KeyAction.UP, 16]]); // MeshAgent: L-shift press, L-Winkey press, 'M' press, 'M' release, L-Winkey release, L-shift release
}
}
}
// Send CTRL-ALT-DEL
function sendCAD() {
if (xxdialogMode || desktop == null || desktop.State != 3) return;
desktop.m.sendcad();
}
// Show process dialogs
function toggleDeskTools() {
if (xxdialogMode) return;
if (QS('DeskTools').display == 'none') {
QV('DeskTools', true);
Q('DeskTools').nodeid = currentNode._id;
refreshDeskTools();
} else {
QV('DeskTools', false);
}
}
// Refresh all of the desktop tool panels
function refreshDeskTools() {
QV('DeskToolsRefreshButton', false);
setTimeout(refreshDeskToolsEx, 500);
meshserver.send({ action: 'msg', type:'ps', nodeid: currentNode._id });
}
function refreshDeskToolsEx() { QV('DeskToolsRefreshButton', true); }
var deskTools = { sort: 1, msg: null };
function sortProcess(sort) { deskTools.sort = sort; showDeskToolsProcesses(deskTools.msg); }
function sortProcessPid(a, b) { if (a.p > b.p) return 1; if (a.p < b.p) return (-1); return 0; }
function sortProcessName(a, b) { if (a.d > b.d) return 1; if (a.d < b.d) return (-1); return 0; }
function showDeskToolsProcesses(message) {
deskTools.msg = message;
if (message == null) { QH('DeskToolsProcesses', ''); return; }
if (Q('DeskTools').nodeid != message.nodeid) return;
var p = [], processes = null;
try { processes = JSON.parse(message.value); } catch (e) { }
console.log(processes);
if (processes != null) {
for (var pid in processes) { p.push( { p:parseInt(pid), c:processes[pid].cmd, d:processes[pid].cmd.toLowerCase(), u: processes[pid].user } ); }
if (deskTools.sort == 0) { p.sort(sortProcessPid); } else if (deskTools.sort == 1) { p.sort(sortProcessName); }
var x = '';
for (var i in p) { if (p[i].p != 0) { x += '<div class=deskToolsBar><div style=width:50px;float:left;text-align:right;padding-right:5px>' + p[i].p + '</div><a style=float:right;padding-right:5px;cursor:pointer title="Stop process" onclick=stopProcess(' + p[i].p + ',"' + p[i].c + '")><img width=10 height=10 src="images/trash.png"></a><div style=float:right;padding-right:5px>' + (p[i].u?p[i].u:'') + '</div><div>' + p[i].c + '</div></div>'; } }
QH('DeskToolsProcesses', x);
}
}
// Save the desktop image to file
function deskSaveImage() {
if (xxdialogMode || desktop == null || desktop.State != 3) return;
var d = new Date(), n = 'Desktop-' + currentNode.name + '-' + d.getFullYear() + "-" + ("0" + (d.getMonth() + 1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2) + "-" + ("0" + d.getHours()).slice(-2) + "-" + ("0" + d.getMinutes()).slice(-2);
Q("Desk")['toBlob'](function (blob) { saveAs(blob, n + ".jpg"); });
}
function deskDisplayInfo(sender, info, selDisplay, selItem) {
var txt = Q('termdisplays').value;
if (info.length > 0) { var options = ''; for (var x in info) { options += '<option' + ((txt == info[x])?' selected':'') + '>' + info[x] + '</option>'; } QH('termdisplays', options); }
QV('termdisplays', info.length > 0);
}
function deskGetDisplayNumbers(e) { desktop.m.GetDisplayNumbers(); }
function deskSetDisplay(e) {
var display = 0, txt = Q('termdisplays').value;
if (txt == "All Displays") display = 65535; else display = parseInt(txt.substring(8));
desktop.m.SetDisplay(display);
}
function dmousedown(e) { if (!xxdialogMode && desktop != null) desktop.m.mousedown(e) }
function dmouseup(e) { if (!xxdialogMode && desktop != null) desktop.m.mouseup(e) }
function dmousemove(e) { if (!xxdialogMode && desktop != null) desktop.m.mousemove(e) }
function dmousewheel(e) { if (!xxdialogMode && desktop != null && desktop.m.mousewheel) { desktop.m.mousewheel(e); haltEvent(e); return true; } return false; }
function drotate(x) { if (!xxdialogMode && desktop != null) { desktop.m.setRotation(desktop.m.rotation + x); deskAdjust(); deskAdjust(); } }
function stopProcess(id, name) { setDialogMode(2, "Process Control", 3, stopProcessEx, 'Stop process #' + id + ' "' + name + '"?', id); }
function stopProcessEx(buttons, tag) { meshserver.send({ action: 'msg', type:'pskill', nodeid: currentNode._id, value: tag }); setTimeout(refreshDeskTools, 300); }
// //
// MY MESHS // MY MESHS
// //
@ -1450,6 +1864,7 @@
var xxcurrentView = -1; var xxcurrentView = -1;
function go(x) { function go(x) {
if (xxdialogMode || xxcurrentView == x) return; if (xxdialogMode || xxcurrentView == x) return;
updateFooterMenu();
setDialogMode(0); setDialogMode(0);
// Edit this line when adding a new screen // Edit this line when adding a new screen
for (var i = 0; i < 32; i++) { QV('p' + i, i == x); } for (var i = 0; i < 32; i++) { QV('p' + i, i == x); }

View File

@ -3475,6 +3475,7 @@
} }
function showDesktopSettings() { function showDesktopSettings() {
if (xxdialogMode) return;
applyDesktopSettings(); applyDesktopSettings();
updateDesktopButtons(); updateDesktopButtons();
setDialogMode(7, "Remote Desktop Settings", 3, showDesktopSettingsChanged); setDialogMode(7, "Remote Desktop Settings", 3, showDesktopSettingsChanged);