Added user consent context menu options for terminal and files, #4032
Ylian Saint-Hilaire committed
May 23, 2022 at 11:08 UTC
b1e0ccbcb63599b1f0bcd6cf92c02c471b85ab62
1 file changed
+39
-15
views/default.handlebars
+39
-15
@@ -72,20 +72,27 @@
72
<div id="cxmmdesktop" class="cmtext" style="display:none" onclick="cmmeshaction(3,event)">Multi-Desktop</div>
73
-->
74
</div>
75
+ <div id="filesShellContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
76
+ <div class="cmtext" onclick="cmconnectfilesaction()">Ask Consent</div>
77
+ </div>
78
<div id="termShellContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
76
- <div class="cmtext" onclick="cmtermaction(1,event)"><b>Admin Shell</b></div>
77
- <div class="cmtext" onclick="cmtermaction(6,event)">Admin PowerShell</div>
78
- <div class="cmtext" onclick="cmtermaction(8,event)">User Shell</div>
79
- <div class="cmtext" onclick="cmtermaction(9,event)">User PowerShell</div>
79
+ <div class="cmtext" onclick="cmtermaction(1,0,event)"><b>Admin Shell</b></div>
80
+ <div class="cmtext" onclick="cmtermaction(6,0,event)">Admin PowerShell</div>
81
+ <div class="cmtext" onclick="cmtermaction(8,0,event)">User Shell</div>
82
+ <div class="cmtext" onclick="cmtermaction(9,0,event)">User PowerShell</div>
83
+ <div class="cmtext" onclick="cmtermaction(1,0x10,event)">Ask Consent + Admin Shell</div>
84
+ <div class="cmtext" onclick="cmtermaction(6,0x10,event)">Ask Consent + Admin PowerShell</div>
85
+ <div class="cmtext" onclick="cmtermaction(8,0x10,event)">Ask Consent + User Shell</div>
86
+ <div class="cmtext" onclick="cmtermaction(9,0x10,event)">Ask Consent + User PowerShell</div>
87
</div>
88
<div id="termShellContextMenu2" class="contextMenu noselect" style="display:none;min-width:0px">
82
- <div class="cmtext" onclick="cmtermaction(8,event)"><b>User Shell</b></div>
83
- <div class="cmtext" onclick="cmtermaction(9,event)">User PowerShell</div>
89
+ <div class="cmtext" onclick="cmtermaction(8,0,event)"><b>User Shell</b></div>
90
+ <div class="cmtext" onclick="cmtermaction(9,0,event)">User PowerShell</div>
91
</div>
92
<div id="termShellContextMenuLinux" class="contextMenu noselect" style="display:none;min-width:0px">
86
- <div class="cmtext" onclick="cmtermaction(1,event)"><b>Root Shell</b></div>
87
- <div class="cmtext" onclick="cmtermaction(8,event)">User Shell</div>
88
- <div class="cmtext" onclick="cmtermaction(100,event)">Login Shell</div>
93
+ <div class="cmtext" onclick="cmtermaction(1,0,event)"><b>Root Shell</b></div>
94
+ <div class="cmtext" onclick="cmtermaction(8,0,event)">User Shell</div>
95
+ <div class="cmtext" onclick="cmtermaction(100,0,event)">Login Shell</div>
96
</div>
97
<div id="deskConnectContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
98
<div class="cmtext" onclick="cmdeskaction(1,event)">Ask Consent + Bar</div>
@@ -800,7 +807,7 @@
807
</div>
808
<div>
809
<input id=p13AutoConnect value="AutoConnect" onclick=autoConnectFiles(event) type="button" style="display:none" />
803
- <input id=p13Connect value="Connect" onclick=connectFiles(event,1) type="button" />
810
+ <input id=p13Connect value="Connect" cmenu="filesConnectButton" onclick=connectFiles(event,1) type="button" />
811
<input id=p13Connects value="SFTP Connect" cmenu=sshPortContextMenu onclick=connectFiles(event,2) type="button" />
812
<input id=p13Disconnect value="Disconnect" onclick=connectFiles(event) type="button" />
813
<span id=p13Status>Disconnected</span>
@@ -5833,6 +5840,13 @@
5840
var cmenu = elem.attributes.cmenu.value;
5841
5842
switch (cmenu) {
5843
+ case 'filesConnectButton': {
5844
+ // Files connect button context menu
5845
+ if ((currentNode == null) || (currentNode.agent == null)) return true;
5846
+ contextelement = elem;
5847
+ showContextMenuDiv(document.getElementById('filesShellContextMenu'), event.pageX, event.pageY);
5848
+ break;
5849
+ }
5850
case 'termConnectButton': {
5851
// Terminal connect button context menu
5852
if ((currentNode == null) || (currentNode.agent == null) || (currentNode.mtype == 3)) return true;
@@ -5984,11 +5998,15 @@
5998
p1updateInfo();
5999
}
6000
5987
- function cmtermaction(action) {
6001
+ function cmconnectfilesaction() {
6002
+ connectFiles(null, 1, 0x0020);
6003
+ }
6004
+
6005
+ function cmtermaction(action, consent) {
6006
if (action < 100) {
5989
- connectTerminal(null, 1, { protocol: action });
6007
+ connectTerminal(null, 1, { protocol: action, consent: consent });
6008
} else if (action == 100) {
5991
- connectTerminal(null, 1, { protocol: 1, requireLogin: true });
6009
+ connectTerminal(null, 1, { protocol: 1, requireLogin: true, consent: consent });
6010
}
6011
}
6012
@@ -6119,6 +6137,7 @@
6137
function hideContextMenu() {
6138
QV('contextMenu', false);
6139
QV('meshContextMenu', false);
6140
+ QV('filesShellContextMenu', false);
6141
QV('termShellContextMenu', false);
6142
QV('termShellContextMenu2', false);
6143
QV('termShellContextMenuLinux', false);
@@ -9864,6 +9883,7 @@
9883
// Terminal setup
9884
var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number'))?options.protocol:1 };
9885
if (options && options.requireLogin) { termoptions.requireLogin = true; }
9886
+ if (options && options.consent) { termoptions.consent = options.consent; }
9887
if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) {
9888
if (Q('termSizeList').value == 1) { termoptions.cols = 80; termoptions.rows = 25; termoptions.xterm = true; }
9889
else if (Q('termSizeList').value == 2) { termoptions.cols = 100; termoptions.rows = 30; termoptions.xterm = true; }
@@ -9912,12 +9932,13 @@
9932
});
9933
9934
// Setup a terminal tunnel to the agent
9935
+ termoptions.cols = xterm.cols;
9936
+ termoptions.rows = xterm.rows;
9937
terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel((contype == 3)? sshTunnelUpdate : tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
9938
if (contype == 3) { terminal.urlname = 'sshterminalrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
9939
terminal.debugmode = debugmode;
9940
terminal.m.debugmode = debugmode;
9941
terminal.options = termoptions;
9920
- terminal.options = { cols: xterm.cols, rows: xterm.rows };
9942
if (termoptions.requireLogin) { terminal.options.requireLogin = true; }
9943
terminal.Start(terminalNode._id);
9944
terminal.onStateChanged = onTerminalStateChange;
@@ -10102,13 +10123,15 @@
10123
function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } }
10124
10125
// 1 = Agent, 2 = SFTP
10105
- function connectFiles(e, contype) {
10126
+ function connectFiles(e, contype, consent) {
10127
+ console.log('connectFiles', contype, consent);
10128
p13clearConsoleMsg();
10129
if (!files) {
10130
// Setup a mesh agent files
10131
files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
10132
if (contype == 2) { files.urlname = 'sshfilesrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
10133
files.contype = contype;
10134
+ files.options = { consent: consent }
10135
files.attemptWebRTC = attemptWebRTC;
10136
files.onStateChanged = onFilesStateChange;
10137
files.onConsoleMessageChange = function () {
@@ -10122,6 +10145,7 @@
10145
}
10146
}
10147
files.Start(filesNode._id);
10148
+ console.log(files.options);
10149
} else {
10150
//QH('Term', '');
10151
files.Stop();