mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Added run script run button to desktop tab and run dialog now saves state.
This commit is contained in:
		
							parent
							
								
									bb8b5fed82
								
							
						
					
					
						commit
						b54d0130f7
					
				
					 3 changed files with 16 additions and 9 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								public/images/icon-play.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								public/images/icon-play.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 570 B | 
|  | @ -2654,7 +2654,7 @@ a { | |||
|     -ms-grid-row: 4; | ||||
| } | ||||
| 
 | ||||
| #DeskChatButton, #DeskNotifyButton, #DeskOpenWebButton, #DeskBackgroundButton, #DeskSaveImageButton, #DeskRecordButton, #DeskClipboardInButton, #DeskClipboardOutButton, #DeskRefreshButton, #DeskLockButton, #DeskInputLockedButton, #DeskInputUnLockedButton, #DeskGuestShareButton, #DeskMonitorSelectionSpan { | ||||
| #DeskRunButton, #DeskChatButton, #DeskNotifyButton, #DeskOpenWebButton, #DeskBackgroundButton, #DeskSaveImageButton, #DeskRecordButton, #DeskClipboardInButton, #DeskClipboardOutButton, #DeskRefreshButton, #DeskLockButton, #DeskInputLockedButton, #DeskInputUnLockedButton, #DeskGuestShareButton, #DeskMonitorSelectionSpan { | ||||
|     float: right; | ||||
|     margin-top: 1px; | ||||
|     margin-right: 4px; | ||||
|  |  | |||
|  | @ -703,6 +703,7 @@ | |||
|                             <span id="DeskTimer" style="line-height:22px" title="Session time"></span> | ||||
|                             <input id=DeskToolsButton type=button value=Tools title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()" /> | ||||
|                             <span> </span> | ||||
|                             <span id=DeskRunButton class="deskarea" title="Run a script on this computer"><img class="desktopButtons" src='images/icon-play.png' onclick=runDeviceCmd() height=16 width=16 style=padding-top:2px /></span> | ||||
|                             <span id=DeskChatButton class="deskarea" title="Open chat window to this computer"><img class="desktopButtons" src='images/icon-chat.png' onclick=deviceChat(event) height=16 width=16 style=padding-top:2px /></span> | ||||
|                             <span id=DeskNotifyButton title="Display a notification on the remote computer"><img class="desktopButtons" src='images/icon-notify.png' onclick=deviceToastFunction() height=16 width=16 style=padding-top:2px /></span> | ||||
|                             <span id=DeskLockButton title="Lock the remote computer"><img src='images/icon-lock.png' class="desktopButtons" onclick=deviceLockFunction() height=16 width=16 /></span> | ||||
|  | @ -5717,17 +5718,21 @@ | |||
|                 if (n.agent) { if ((GetNodeRights(n) & 24) == 24) { agenttype = true; } if ((n.agent.id > 0) && (n.agent.id < 5)) { wintype = true; } else { linuxtype = true; } } | ||||
|             } | ||||
|             if ((wintype == true) || (linuxtype == true) || (agenttype == true)) { | ||||
|                 // Fetch run options | ||||
|                 var runopt = { type:1, runAs:0, source:1, cmd:'' }; | ||||
|                 try { runopt = JSON.parse(getstore('runopt', runopt)); } catch (ex) {} | ||||
| 
 | ||||
|                 var x = ''; | ||||
|                 if (options.title) { x += options.title + '<br />'; } | ||||
|                 x += '<select id=d2cmdtype onclick=d2runCommandValidate() style=width:100%;margin-bottom:4px;margin-top:4px>'; | ||||
|                 if (wintype == true) { x += '<option value=1>' + "Windows Command Prompt" + '</option><option value=2>' + "Windows PowerShell" + '</option>'; } | ||||
|                 if (linuxtype == true) { x += '<option value=3>' + "Linux/BSD/macOS Command Shell" + '</option>'; } | ||||
|                 if (agenttype == true) { x += '<option value=4>' + "Agent Console" + '</option>'; } // MESHRIGHT_REMOTECONTROL & MESHRIGHT_AGENTCONSOLE are needed | ||||
|                 if (wintype == true) { x += '<option value=1' + ((runopt.type == 1)?' selected':'') + '>' + "Windows Command Prompt" + '</option><option value=2' + ((runopt.type == 2)?' selected':'') + '>' + "Windows PowerShell" + '</option>'; } | ||||
|                 if (linuxtype == true) { x += '<option value=3' + ((runopt.type == 3)?' selected':'') + '>' + "Linux/BSD/macOS Command Shell" + '</option>'; } | ||||
|                 if (agenttype == true) { x += '<option value=4' + ((runopt.type == 4)?' selected':'') + '>' + "Agent Console" + '</option>'; } // MESHRIGHT_REMOTECONTROL & MESHRIGHT_AGENTCONSOLE are needed | ||||
|                 x += '</select>'; | ||||
|                 x += '<select id=d2cmduser style=width:100%;margin-bottom:4px><option value=0>' + "Run as agent" + '</option><option value=1>' + "Run as user, agent if no user" + '</option><option value=2>' + "Must run as user" + '</option></select>'; | ||||
|                 x += '<select id=d2cmdsource onclick=d2runCommandValidate() style=width:100%;margin-bottom:4px><option value=0>' + "Commands from text box" + '</option><option value=1>' + "Commands from file" + '</option>'; | ||||
|                 //if (userinfo.siteadmin & 8) { x += '<option value=2>' + "Commands from file on server" + '</option>'; } | ||||
|                 x += '</select><textarea id=d2runcmd onkeyup=d2runCommandValidate() style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll></textarea>'; | ||||
|                 x += '<select id=d2cmduser style=width:100%;margin-bottom:4px><option value=0' + ((runopt.runAs == 0)?' selected':'') + '>' + "Run as agent" + '</option><option value=1' + ((runopt.runAs == 1)?' selected':'') + '>' + "Run as user, agent if no user" + '</option><option value=2' + ((runopt.runAs == 2)?' selected':'') + '>' + "Must run as user" + '</option></select>'; | ||||
|                 x += '<select id=d2cmdsource onclick=d2runCommandValidate() style=width:100%;margin-bottom:4px><option value=0' + ((runopt.source == 0)?' selected':'') + '>' + "Commands from text box" + '</option><option value=1' + ((runopt.source == 1)?' selected':'') + '>' + "Commands from file" + '</option>'; | ||||
|                 //if (userinfo.siteadmin & 8) { x += '<option value=2' + ((runopt.source == 2)?' selected':'') + '>' + "Commands from file on server" + '</option>'; } | ||||
|                 x += '</select><textarea id=d2runcmd onkeyup=d2runCommandValidate() style=background-color:#fcf3cf;width:100%;height:200px;resize:none;overflow-y:scroll>' + (runopt.cmd ? EscapeHtml(decodeURIComponent(runopt.cmd)) : '') + '</textarea>'; | ||||
|                 x += '<div id=d2runfile style=display:none><input id=d2runfileex type=file onchange=d2runCommandValidate() id=d2localFile name=files onchange=d2runCommandValidate() /></div>'; | ||||
|                 x += '<div id=d2runsfile style=display:none>bb</div>'; | ||||
|                 setDialogMode(2, "Run Commands", 3, d2groupActionFunctionRunCommands, x, options); | ||||
|  | @ -5749,6 +5754,7 @@ | |||
|         function d2groupActionFunctionRunCommands(b, options) { | ||||
|             var type = 3; | ||||
|             try { type = parseInt(Q('d2cmdtype').value); } catch (ex) { } | ||||
|             putstore('runopt', JSON.stringify({ type: type, runAs: parseInt(Q('d2cmduser').value), source: parseInt(Q('d2cmdsource').value), cmd: encodeURIComponent(Q('d2runcmd').value) })); // Save run options | ||||
|             var cmd = { action: 'runcommands', nodeids: options.nodeids, type: type, runAsUser: parseInt(Q('d2cmduser').value) }; | ||||
|             if (Q('d2cmdsource').value == 0) { | ||||
|                 // From text box | ||||
|  | @ -7668,7 +7674,7 @@ | |||
|         } | ||||
| 
 | ||||
|         // Run commands on current device | ||||
|         function runDeviceCmd(nodeid) { if (xxdialogMode) return; d2runCommandDialog({ nodeids: [ decodeURIComponent(nodeid) ] }); } | ||||
|         function runDeviceCmd(nodeid) { if (xxdialogMode) return; d2runCommandDialog({ nodeids: [ decodeURIComponent(nodeid ? nodeid : currentNode._id) ] }); } | ||||
| 
 | ||||
|         function writeDeviceEvent(nodeid) { | ||||
|             if (xxdialogMode) return; | ||||
|  | @ -8602,6 +8608,7 @@ | |||
|             } | ||||
| 
 | ||||
|             // Display this only if we have Chat & Notify permissions | ||||
|             QV('DeskRunButton', ((rights & 131072) != 0) && online); | ||||
|             QV('DeskSaveImageButton', (deskState == 3) && (Q('Desk')['toBlob'] != null) && ((features2 & 0x400) == 0)); | ||||
|             QV('DeskRecordButton', (deskState == 3) && (Q('Desk')['toBlob'] != null) && (desktop.m.StartRecording != null) && ((features2 & 0x400) == 0)); | ||||
|             QV('DeskChatButton', ((rights & 16384) != 0) && (browserfullscreen == false) && (inputAllowed) && (currentNode.agent) && online); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue