1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Added file context menu for device files.

This commit is contained in:
Ylian Saint-Hilaire 2020-02-14 11:20:06 -08:00
parent ff9d87dddf
commit 0be2a1026f
9 changed files with 2208 additions and 1695 deletions

View file

@ -72,6 +72,11 @@
<div id="altPortContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
<div id="cxaltport" class="cmtext" onclick="cmaltportaction(1,event)"><b>Alternate Port</b></div>
</div>
<div id="filesContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
<div id="cxfilerename" class="cmtext" onclick="cmfilesaction(1,event)"><b>Rename</b></div>
<div id="cxfileedit" class="cmtext" onclick="cmfilesaction(2,event)"><b>Edit</b></div>
<div id="cxfiledelete" class="cmtext" onclick="cmfilesaction(3,event)"><b>Delete</b></div>
</div>
<!--
<div id="pluginTabContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
<div id="cxclose" class="cmtext" onclick="pluginTabClose(event)">Close Tab</div>
@ -4000,6 +4005,12 @@
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);
//console.log('handleContextMenu', scrollLeft, scrollTop, elem, elem.parentElement, elem.parentElement.parentElement);
// Look for a file entry element
var fileElement = null, elx = elem;
while (elx && elx != null && elx.id != 'fileEntry') { elx = elx.parentElement; }
if (elx && (elx.id == 'fileEntry')) { fileElement = elx; }
if (elem && elem != null && elem.id == 'rdpClickOnceLink' && currentNode && currentNode.agent && (currentNode.agent.id > 0) && (currentNode.agent.id < 5)) {
contextelement = elem;
@ -4013,6 +4024,10 @@
contextelement = elem;
var contextmenudiv = document.getElementById('termShellContextMenuLinux');
showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
} else if (fileElement && currentNode) {
contextelement = fileElement;
var contextmenudiv = document.getElementById('filesContextMenu');
showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
} else if (elem && elem != null && elem.id == 'MxMESH') {
contextelement = elem;
var contextmenudiv = document.getElementById('meshContextMenu');
@ -4113,6 +4128,28 @@
Q('d10rdpport').focus();
}
function cmfilesaction(action) {
if (xxdialogMode) return;
var filetreexx = p13sort_files(p13filetree.dir);
var file = filetreexx[parseInt(contextelement.attributes.fileindex.nodeValue)];
if (action == 1) { // Rename the file
setDialogMode(2, "Rename", 3, p13renamefileEx, '<input type=text id=p13renameinput maxlength=64 onkeyup=p13fileNameCheck(event) style=width:100% value="' + file.n + '" />', { action: 'rename', path: p13filetreelocation.join('/'), oldname: file.n});
focusTextBox('p13renameinput');
p13fileNameCheck();
} else if (action == 2) { // Edit the file
if (file.s <= 204800) {
p13downloadfile(encodeURIComponent(p13filetreelocation.join('/') + '/' + file.n), encodeURIComponent(file.n), file.s, 'viewer');
} else { messagebox("File Editor", "Only files less than 200k can be edited."); }
} else if (action == 3) { // Delete the file
setDialogMode(2, "Delete", 3, p13deletefileCm, "Delete item?", file);
}
}
function p13deletefileCm(b, file) {
files.sendText({ action: 'rm', reqid: 1, path: p13filetreelocation.join('/'), delfiles: [ file.n ], rec: false });
p13folderup(999);
}
/*
function pluginTabClose() {
var pluginTab = contextelement;
@ -4131,6 +4168,7 @@
QV('termShellContextMenu', false);
QV('termShellContextMenuLinux', false);
QV('altPortContextMenu', false);
QV('filesContextMenu', false);
//QV('pluginTabContextMenu', false);
contextelement = null;
}
@ -6811,7 +6849,7 @@
} else {
var link = shortname;
if (f.s > 0) { link = '<a hrf=# rel=\"noreferrer noopener\" target=\"_blank\" style=cursor:pointer onclick=\"return p13downloadfile(\'' + encodeURIComponent(newlinkpath + '/' + name) + '\',\'' + encodeURIComponent(name) + '\',' + f.s + ')\">' + shortname + '</a>'; }
h = '<div class=filelist file=3><input file=3 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value=\'' + f.nx + '\'>&nbsp;<span class=fsize>' + fdatestr + '</span><span style=float:right>' + fsize + '</span><span><div class=fileIcon' + f.t + '></div>' + link + '</span></div>';
h = '<div id=fileEntry fileIndex=' + i + ' class=filelist file=3><input file=3 style=float:left name=fd class=fcb type=checkbox onchange=p13setActions() value=\'' + f.nx + '\'>&nbsp;<span class=fsize>' + fdatestr + '</span><span style=float:right>' + fsize + '</span><span><div class=fileIcon' + f.t + '></div>' + link + '</span></div>';
}
if (f.t < 3) { html1 += h; } else { html2 += h; }
@ -7023,7 +7061,7 @@
QS('dialog').width = 'auto';
QS('dialog').bottom = '80px';
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
Q('d4editorarea').value = EscapeHtml(downloadFile.data);
Q('d4editorarea').value = downloadFile.data;
downloadFile = null;
} else {
// Save the file to disk