mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Added remote process control
This commit is contained in:
parent
d05f086a0e
commit
fb55e44edf
14 changed files with 448 additions and 47 deletions
|
@ -360,12 +360,21 @@
|
|||
<div id="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>
|
||||
</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>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id=deskarea4>
|
||||
<td 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>
|
||||
<input id="DeskToolsButton" type="button" value="Tools" title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()">
|
||||
</div>
|
||||
<div>
|
||||
|
||||
|
@ -969,11 +978,13 @@
|
|||
if (index != -1) {
|
||||
// Node was found, dispatch the message
|
||||
if (message.type == 'console') { p15consoleReceive(nodes[index], message.value); } // This is a console message.
|
||||
if (message.type == 'notify') { // This is a notification message.
|
||||
else if (message.type == 'notify') { // This is a notification message.
|
||||
var n = { text:message.value };
|
||||
if (message.nodeid != null) { n.nodeid = message.nodeid; }
|
||||
if (message.tag != null) { n.tag = message.tag; }
|
||||
addNotification(n);
|
||||
} else if (message.type == 'ps') {
|
||||
showDeskToolsProcesses(message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2823,6 +2834,10 @@
|
|||
|
||||
// Request the power timeline
|
||||
if ((powerTimelineNode != currentNode._id) && (powerTimelineReq != currentNode._id)) { powerTimelineReq = currentNode._id; meshserver.send({ action: 'powertimeline', nodeid: currentNode._id }); }
|
||||
|
||||
// Reset the desktop tools
|
||||
QV('DeskTools', false);
|
||||
showDeskToolsProcesses();
|
||||
}
|
||||
setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching.
|
||||
if (!panel) panel = 10;
|
||||
|
@ -3168,15 +3183,16 @@
|
|||
// Show and enable the right buttons
|
||||
function updateDesktopButtons() {
|
||||
var mesh = meshes[currentNode.meshid];
|
||||
var deskState = ((desktop != null) && (desktop.state != 0));
|
||||
var deskState = 0;
|
||||
if (desktop != null) { deskState = desktop.State; }
|
||||
|
||||
// Show the right buttons
|
||||
QV('disconnectbutton1span', (deskState == true));
|
||||
QV('connectbutton1span', (deskState == false) && (mesh.mtype == 2));
|
||||
QV('connectbutton1hspan', (deskState == false) && (currentNode.intelamt != null && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
|
||||
QV('disconnectbutton1span', (deskState != 0));
|
||||
QV('connectbutton1span', (deskState == 0) && (mesh.mtype == 2));
|
||||
QV('connectbutton1hspan', (deskState == 0) && (currentNode.intelamt != null && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))));
|
||||
|
||||
// Show the right settings
|
||||
QV('d7amtkvm', (currentNode.intelamt != null && ((currentNode.intelamt.ver != null) || (mesh.mtype == 1))) && ((deskState == false) || (desktop.contype == 2)));
|
||||
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
|
||||
|
@ -3184,6 +3200,11 @@
|
|||
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);
|
||||
QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (deskState != 0) && (desktopsettings.showfocus));
|
||||
QE('DeskCAD', deskState == 3);
|
||||
QE('DeskToolsButton', online);
|
||||
if (online == false) QV('DeskTools', false);
|
||||
}
|
||||
|
||||
// Debug
|
||||
|
@ -3232,12 +3253,9 @@
|
|||
var xstate = state;
|
||||
if ((xstate == 3) && (xdesktop.contype == 2)) { xstate++; }
|
||||
var str = StatusStrs[xstate];
|
||||
if (desktop.webRtcActive == true) { str += ', WebRTC'; }
|
||||
if ((desktop != null) && (desktop.webRtcActive == true)) { str += ', WebRTC'; }
|
||||
//if (desktop.m.stopInput == true) { str += ', Loopback'; }
|
||||
QH('deskstatus', str);
|
||||
QE('deskSaveBtn', state == 3);
|
||||
QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (state != 0) && (desktopsettings.showfocus));
|
||||
QE('DeskCAD', state == 3);
|
||||
switch (state) {
|
||||
case 0:
|
||||
// Disconnect and clean up the remote desktop
|
||||
|
@ -3364,6 +3382,44 @@
|
|||
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) { }
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle mouse and keyboard input
|
||||
function toggleKvmControl() { putstore('DeskControl', (Q("DeskControl").checked?1:0)); }
|
||||
|
||||
|
@ -3393,6 +3449,8 @@
|
|||
function dmousemove(e) { if (!xxdialogMode && desktop != null && Q('DeskControl').checked) desktop.m.mousemove(e) }
|
||||
function dmousewheel(e) { if (!xxdialogMode && desktop != null && Q('DeskControl').checked) { 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); }
|
||||
|
||||
//
|
||||
// TERMINAL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue