mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-24 06:05:53 -05:00
Added context menu connection options to xterm.
This commit is contained in:
parent
9d3ac34ef9
commit
195c869ab5
@ -389,7 +389,7 @@
|
||||
"default.handlebars->23->597",
|
||||
"default.handlebars->23->627",
|
||||
"default.handlebars->23->639",
|
||||
"xterm.handlebars->3->6"
|
||||
"xterm.handlebars->9->6"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1863,7 +1863,8 @@
|
||||
"nl": "Beheerder PowerShell",
|
||||
"ru": "Админ PowerShell",
|
||||
"xloc": [
|
||||
"default.handlebars->termShellContextMenu->cxtermps"
|
||||
"default.handlebars->termShellContextMenu->cxtermps",
|
||||
"xterm.handlebars->termShellContextMenu->cxtermps"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1886,7 +1887,8 @@
|
||||
"nl": "Beheerder Shell",
|
||||
"ru": "Админ Shell",
|
||||
"xloc": [
|
||||
"default.handlebars->termShellContextMenu->cxtermnorm->0"
|
||||
"default.handlebars->termShellContextMenu->cxtermnorm->0",
|
||||
"xterm.handlebars->termShellContextMenu->cxtermnorm->0"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -3998,7 +4000,7 @@
|
||||
"xloc": [
|
||||
"default-mobile.handlebars->9->4",
|
||||
"default.handlebars->23->11",
|
||||
"xterm.handlebars->3->4"
|
||||
"xterm.handlebars->9->4"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -4048,7 +4050,7 @@
|
||||
"default.handlebars->23->220",
|
||||
"default.handlebars->23->678",
|
||||
"default.handlebars->23->9",
|
||||
"xterm.handlebars->3->2"
|
||||
"xterm.handlebars->9->2"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -5482,7 +5484,7 @@
|
||||
"default.handlebars->container->column_l->p11->deskarea0->deskarea1->3->deskstatus",
|
||||
"default.handlebars->container->column_l->p12->termTable->1->1->0->1->3->termstatus",
|
||||
"default.handlebars->container->column_l->p13->p13toolbar->1->0->1->3->p13Status",
|
||||
"xterm.handlebars->3->1"
|
||||
"xterm.handlebars->9->1"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -8154,7 +8156,7 @@
|
||||
"xloc": [
|
||||
"default-mobile.handlebars->9->5",
|
||||
"default.handlebars->23->12",
|
||||
"xterm.handlebars->3->5"
|
||||
"xterm.handlebars->9->5"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -13851,7 +13853,8 @@
|
||||
"nl": "Root Shell",
|
||||
"ru": "Root Shell",
|
||||
"xloc": [
|
||||
"default.handlebars->termShellContextMenuLinux->cxtermnorm->0"
|
||||
"default.handlebars->termShellContextMenuLinux->cxtermnorm->0",
|
||||
"xterm.handlebars->termShellContextMenuLinux->cxtermnorm->0"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -14782,7 +14785,7 @@
|
||||
"default.handlebars->23->212",
|
||||
"default.handlebars->23->215",
|
||||
"default.handlebars->23->221",
|
||||
"xterm.handlebars->3->3"
|
||||
"xterm.handlebars->9->3"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -17379,7 +17382,8 @@
|
||||
"nl": "Gebruiker PowerShell",
|
||||
"ru": "Пользовательский PowerShell",
|
||||
"xloc": [
|
||||
"default.handlebars->termShellContextMenu->cxtermups"
|
||||
"default.handlebars->termShellContextMenu->cxtermups",
|
||||
"xterm.handlebars->termShellContextMenu->cxtermups"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -17404,7 +17408,9 @@
|
||||
"ru": "Пользовательская оболочка",
|
||||
"xloc": [
|
||||
"default.handlebars->termShellContextMenu->cxtermunorm",
|
||||
"default.handlebars->termShellContextMenuLinux->cxtermps"
|
||||
"default.handlebars->termShellContextMenuLinux->cxtermps",
|
||||
"xterm.handlebars->termShellContextMenu->cxtermunorm",
|
||||
"xterm.handlebars->termShellContextMenuLinux->cxtermps"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -5297,7 +5297,7 @@
|
||||
var url = '/xterm?nodeid=' + encodeURIComponent(nodeid) + '&auto=1';
|
||||
var node = getNodeFromId(nodeid);
|
||||
if (node == null) return;
|
||||
//if ([1, 2, 3, 4, 21, 22].indexOf(node.agent.id) >= 0) { url += '&fixsize=1'; }
|
||||
if ([1, 2, 3, 4, 21, 22].indexOf(node.agent.id) >= 0) { url += '&os=win'; } else { url += '&os=linux'; }
|
||||
window.open(url, 'xterm:' + nodeid);
|
||||
return false;
|
||||
}
|
||||
|
@ -16,7 +16,18 @@
|
||||
<script type="text/javascript" src="scripts/xterm-addon-fit.js"></script>
|
||||
<title>{{{name}}}</title>
|
||||
</head>
|
||||
<body style="overflow:hidden;background-color:black">
|
||||
<body style="overflow:hidden;background-color:black" oncontextmenu="handleContextMenu(event)">
|
||||
<!-- right click menu -->
|
||||
<div id="termShellContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
|
||||
<div id="cxtermnorm" class="cmtext" onclick="cmtermaction(1,event)"><b>Admin Shell</b></div>
|
||||
<div id="cxtermps" class="cmtext" onclick="cmtermaction(6,event)">Admin PowerShell</div>
|
||||
<div id="cxtermunorm" class="cmtext" onclick="cmtermaction(8,event)">User Shell</div>
|
||||
<div id="cxtermups" class="cmtext" onclick="cmtermaction(9,event)">User PowerShell</div>
|
||||
</div>
|
||||
<div id="termShellContextMenuLinux" class="contextMenu noselect" style="display:none;min-width:0px">
|
||||
<div id="cxtermnorm" class="cmtext" onclick="cmtermaction(1,event)"><b>Root Shell</b></div>
|
||||
<div id="cxtermps" class="cmtext" onclick="cmtermaction(8,event)">User Shell</div>
|
||||
</div>
|
||||
<div id=p11 class="noselect" style="overflow:hidden">
|
||||
<div id=deskarea0 style="position:relative">
|
||||
<div id=deskarea1 class="areaHead">
|
||||
@ -89,9 +100,10 @@
|
||||
meshserver.Start();
|
||||
|
||||
// When the user resizes the window, re-fit
|
||||
window.onresize = function () {
|
||||
if (termfit != null) { termfit.fit(); }
|
||||
}
|
||||
window.onresize = function () { if (termfit != null) { termfit.fit(); } }
|
||||
|
||||
// Hide the context menu
|
||||
document.onclick = function (e) { hideContextMenu(); }
|
||||
|
||||
// Update the terminal status and buttons
|
||||
QH('termstatus', StatusStrs[0]);
|
||||
@ -117,8 +129,9 @@
|
||||
function onMessage(server, message) { }
|
||||
|
||||
// Handles a tunnel to a remote shell
|
||||
function CreateRemoteTunnel(onTunnelUpdate) {
|
||||
function CreateRemoteTunnel(onTunnelUpdate, options) {
|
||||
var obj = { protocol: 1 };
|
||||
if ((options != null) && (typeof options.protocol == 'number')) { obj.protocol = options.protocol; }
|
||||
obj.onTunnelUpdate = onTunnelUpdate;
|
||||
obj.xxStateChange = function (state) { }
|
||||
obj.ProcessBinaryData = function (data) { obj.onTunnelUpdate(data); }
|
||||
@ -133,7 +146,7 @@
|
||||
}
|
||||
|
||||
// Called when the connect/disconnect button is pressed
|
||||
function connectButton() {
|
||||
function connectButton(options) {
|
||||
if (!tunnel) {
|
||||
// Setup the terminal with auto-fit
|
||||
if (term != null) { term.dispose(); }
|
||||
@ -150,7 +163,7 @@
|
||||
});
|
||||
|
||||
// Setup a terminal tunnel to the agent
|
||||
tunnel = CreateAgentRedirect(meshserver, CreateRemoteTunnel(tunnelUpdate), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
|
||||
tunnel = CreateAgentRedirect(meshserver, CreateRemoteTunnel(tunnelUpdate, options), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
|
||||
tunnel.options = { cols: term.cols, rows: term.rows };
|
||||
tunnel.Start(args.nodeid);
|
||||
tunnel.onStateChanged = onTunnelStateChange;
|
||||
@ -197,6 +210,52 @@
|
||||
function clearConsoleMsg() { QV('TermConsoleMsg', false); if (termConsoleMsgTimer) { clearTimeout(termConsoleMsgTimer); termConsoleMsgTimer = null; } }
|
||||
function setConsoleMsg(msg) { QH('TermConsoleMsg', EscapeHtml(msg).split('\n').join('<br />')); QV('TermConsoleMsg', true); termConsoleMsgTimer = setTimeout(clearConsoleMsg, 8000); }
|
||||
|
||||
//
|
||||
// CONTEXT MENU
|
||||
//
|
||||
|
||||
var contextelement = null;
|
||||
function handleContextMenu(event) {
|
||||
hideContextMenu();
|
||||
var scrollLeft = (window.pageXOffset !== null) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
|
||||
var scrollTop = (window.pageYOffset !== null) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
|
||||
var elem = document.elementFromPoint(event.pageX - scrollLeft, event.pageY - scrollTop);
|
||||
if (elem && elem != null && elem.id == 'ConnectButton') {
|
||||
contextelement = elem;
|
||||
var contextmenudiv;
|
||||
if (args.os == 'win') {
|
||||
contextmenudiv = document.getElementById('termShellContextMenu');
|
||||
} else {
|
||||
contextmenudiv = document.getElementById('termShellContextMenuLinux');
|
||||
}
|
||||
showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
|
||||
}
|
||||
return haltEvent(event);
|
||||
}
|
||||
|
||||
function showContextMenuDiv(element, x, y) {
|
||||
var clientRect = document.documentElement.getBoundingClientRect();
|
||||
var docHeight = clientRect.height;
|
||||
var docWidth = clientRect.width;
|
||||
element.style.left = element.style.right = element.style.top = element.style.bottom = null;
|
||||
if (x > (docWidth / 2)) { element.style.right = (docWidth - event.pageX) + 'px'; } else { element.style.left = event.pageX + 'px'; }
|
||||
if (y > (docHeight / 2)) { element.style.bottom = (docHeight - event.pageY) + 'px'; } else { element.style.top = event.pageY + 'px'; }
|
||||
element.style.display = 'block';
|
||||
}
|
||||
|
||||
function cmtermaction(action) {
|
||||
//console.log('cmtermaction', action);
|
||||
connectButton({ protocol: action })
|
||||
//connectTerminal(null, 1, { protocol: action });
|
||||
}
|
||||
|
||||
function hideContextMenu() {
|
||||
QV('contextMenu', false);
|
||||
QV('termShellContextMenu', false);
|
||||
QV('termShellContextMenuLinux', false);
|
||||
contextelement = null;
|
||||
}
|
||||
|
||||
//
|
||||
// POPUP DIALOG
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user