@@ -1631,7 +1633,7 @@
for (var j = 1; j < 5; j++) { Q('devViewButton' + j).classList.remove('viewSelectorSel'); }
Q('devViewButton' + Q('viewselect').value).classList.add('viewSelectorSel');
- // Setup upload drag & drop
+ // Setup upload drag & drop for server files
Q('p5filetable').addEventListener('drop', p5fileDragDrop, false);
Q('p5filetable').addEventListener('dragover', p5fileDragOver, false);
Q('p5filetable').addEventListener('dragleave', p5fileDragLeave, false);
@@ -1639,7 +1641,12 @@
//Q('p5fileCatchAllInput').addEventListener('dragover', p5fileDragOver, false);
//Q('p5fileCatchAllInput').addEventListener('dragleave', p5fileDragLeave, false);
- // Setup upload drag & drop
+ // Setup drag & drop for device desktop
+ Q('deskarea0').addEventListener('drop', p11fileDragDrop, false);
+ Q('deskarea0').addEventListener('dragover', p11fileDragOver, false);
+ Q('deskarea0').addEventListener('dragleave', p11fileDragLeave, false);
+
+ // Setup upload drag & drop for device files
Q('p13filetable').addEventListener('drop', p13fileDragDrop, false);
Q('p13filetable').addEventListener('dragover', p13fileDragOver, false);
Q('p13filetable').addEventListener('dragleave', p13fileDragLeave, false);
@@ -5731,13 +5738,23 @@
var wintype = false, linuxtype = false, agenttype = false;
for (var i in options.nodeids) {
var n = getNodeFromId(options.nodeids[i]);
- 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 (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) {}
+ if (options.selectedFile) {
+ var filename = options.selectedFile.name.toLowerCase();
+ console.log('filename', filename);
+ if (filename.endsWith('.bat')) { runopt.type = 1; }
+ if (filename.endsWith('.ps1')) { runopt.type = 2; }
+ if (filename.endsWith('.sh')) { runopt.type = 3; }
+ if (filename.endsWith('.agentconsole')) { runopt.type = 4; }
+ }
+
var x = '';
if (options.title) { x += options.title + '
'; }
x += '
';
x += '
';
- x += '
';
- x += '
';
- if (userinfo.siteadmin & 8) { x += '
'; }
+ if (options.selectedFile == null) {
+ x += '
';
+ x += '
';
+ if (userinfo.siteadmin & 8) { x += '
'; }
+ }
setDialogMode(2, "Run Commands", 3, d2groupActionFunctionRunCommands, x, options);
- Q('d2runcmd').focus();
+ if (options.selectedFile == null) {
+ Q('d2runcmd').focus();
+ if (userinfo.siteadmin & 8) { d3fileoptions = { dialog: 2, files: 'd2serverfiles', folderup: 'p2FolderUp', currentFolder: 'p2CurrentFolder', func: null }; d3updatefiles(); } // Update the server files
+ }
d2runCommandValidate();
- if (userinfo.siteadmin & 8) { d3fileoptions = { dialog: 2, files: 'd2serverfiles', folderup: 'p2FolderUp', currentFolder: 'p2CurrentFolder', func: null }; d3updatefiles(); } // Update the server files
}
}
function d2runCommandValidate() {
QV('d2cmduser', Q('d2cmdtype').value < 4);
- QV('d2runcmd', Q('d2cmdsource').value == 0);
- QV('d2runfile', Q('d2cmdsource').value == 1);
- QV('d2runsfile', Q('d2cmdsource').value == 2);
- var ok = false;
- if (Q('d2cmdsource').value == 0) { if (Q('d2runcmd').value.length > 0) { ok = true; } } // From text box
- if (Q('d2cmdsource').value == 1) { if (Q('d2runfileex').files.length == 1) { ok = true; } } // From file
- if (Q('d2cmdsource').value == 2) { ok = false; } // From server file
- QE('idx_dlgOkButton', ok);
+ if (xxdialogTag.selectedFile == null) {
+ QV('d2runcmd', Q('d2cmdsource').value == 0);
+ QV('d2runfile', Q('d2cmdsource').value == 1);
+ QV('d2runsfile', Q('d2cmdsource').value == 2);
+ var ok = false;
+ if (Q('d2cmdsource').value == 0) { if (Q('d2runcmd').value.length > 0) { ok = true; } } // From text box
+ if (Q('d2cmdsource').value == 1) { if (Q('d2runfileex').files.length == 1) { ok = true; } } // From file
+ if (Q('d2cmdsource').value == 2) { ok = false; } // From server file
+ QE('idx_dlgOkButton', ok);
+ } else {
+ QE('idx_dlgOkButton', true);
+ }
}
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
+ if (options.selectedFile == null) { 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) {
+ if (options.selectedFile) {
+ // Drag & drop file
+ var reader = new FileReader();
+ reader.onload = function (e) { cmd.cmds = e.target.result; meshserver.send(cmd); if (options.func) { options.func(); } }
+ reader.readAsText(options.selectedFile);
+ } else if (Q('d2cmdsource').value == 0) {
// From text box
cmd.cmds = Q('d2runcmd').value;
meshserver.send(cmd);
if (options.func) { options.func(); }
- }
- if (Q('d2cmdsource').value == 1) {
+ } else if (Q('d2cmdsource').value == 1) {
// From file
var reader = new FileReader();
reader.onload = function (e) { cmd.cmds = e.target.result; meshserver.send(cmd); if (options.func) { options.func(); } }
reader.readAsText(Q('d2runfileex').files[0]);
- }
- if (Q('d2cmdsource').value == 2) {
+ } else if (Q('d2cmdsource').value == 2) {
// From server file
var files = d3getFileSel();
if (files.length != 1) return;
@@ -7706,7 +7734,7 @@
}
// Run commands on current device
- function runDeviceCmd(nodeid) { if (xxdialogMode) return; d2runCommandDialog({ nodeids: [ decodeURIComponent(nodeid ? nodeid : currentNode._id) ] }); }
+ function runDeviceCmd(nodeid) { if (xxdialogMode) return; d2runCommandDialog({ nodeids: [ nodeid ? decodeURIComponent(nodeid) : currentNode._id ] }); }
function writeDeviceEvent(nodeid) {
if (xxdialogMode) return;
@@ -9312,6 +9340,42 @@
}
}
+ function p11fileDragDrop(e) {
+ haltEvent(e);
+ QV('p11bigfail', false);
+ QV('p11bigok', false);
+ if ((xxdialogMode != null) || (desktop == null) || (desktop.State != 3) || (e.dataTransfer == null) || (e.dataTransfer.files.length == 0)) return;
+
+ var file = e.dataTransfer.files[0];
+ var filename = file.name.toLowerCase();
+ if (filename.endsWith('.bat') || filename.endsWith('.ps1') || filename.endsWith('.sh') || filename.endsWith('.agentconsole')) {
+ d2runCommandDialog({ nodeids: [ currentNode._id ], selectedFile: file });
+ } else if (filename.endsWith('.txt')) {
+ var reader = new FileReader();
+ reader.onload = function (e) { showDeskType(e.target.result); }
+ reader.readAsText(file);
+ }
+ }
+
+ var p11dragtimer = null;
+ function p11fileDragOver(e) {
+ haltEvent(e);
+ if (p11dragtimer != null) { clearTimeout(p11dragtimer); p11dragtimer = null; }
+ var ac = ((xxdialogMode == null) && (desktop != null) && (desktop.State == 3));
+ QV('p11bigok', ac);
+ QV('p11bigfail', !ac);
+ }
+
+ function p11fileDragLeave(e) {
+ haltEvent(e);
+ if (e.target.id != 'Desk') {
+ QV('p11bigfail', false);
+ QV('p11bigok', false);
+ } else {
+ p11dragtimer = setTimeout(function () { QV('p11bigfail',false); QV('p11bigok',false); p11dragtimer = null; }, 10);
+ }
+ }
+
//
// Desktop Shortcut Keys
//
@@ -9557,11 +9621,11 @@
}
// Remote desktop typing
- function showDeskType() {
+ function showDeskType(text) {
if (xxdialogMode || desktop == null || desktop.State != 3) return;
Q('DeskType').blur();
var x = '
' + "Enter text and click OK to remotely type it. Make sure to place the remote cursor at the correct position before proceeding." + '
';
- x += '';
+ x += '';
setDialogMode(2, "Remote Keyboard Entry", 3, showDeskTypeEx, x);
Q('d2typeText').focus();
}