add tools resizable (#5665)

Signed-off-by: si458 <simonsmith5521@gmail.com>

Simon Smith committed Jan 8, 2024 at 06:21 UTC c38cb3d46c29166c3bb5d37669369903ee05a2c1
1 file changed +32 -5
views/default.handlebars
+32 -5
@@ -10057,7 +10057,28 @@
10057 if (sel == 1) meshserver.send({ action: 'msg', type: 'services', nodeid: currentNode._id });
10058 }
10059 function refreshDeskToolsEx() { QV('DeskToolsRefreshButton', true); }
10060 - var deskTools = { sort: 1, ssort: 1, msg: null, smsg: null };
10060 + var deskTools = { sort: 1, ssort: 1, msg: null, smsg: null, resizing: false };
10061 + Q('DeskTools').addEventListener('mousemove', function (event) {
10062 + var mouseX = event.clientX - Q('DeskTools').getBoundingClientRect().left;
10063 + var borderThickness = 5; // Assuming a 5px border
10064 + if (mouseX < borderThickness) {
10065 + Q('DeskTools').style.cursor = 'col-resize';
10066 + } else {
10067 + Q('DeskTools').style.cursor = 'default';
10068 + }
10069 + });
10070 + Q('DeskTools').addEventListener('mousedown', function (event) {
10071 + if (Q('DeskTools').style.cursor === 'col-resize') deskTools.resizing = true;
10072 + });
10073 + document.addEventListener('mouseup', function () {
10074 + if(deskTools.resizing===true && Q('DeskTools').style.cursor === 'col-resize') deskTools.resizing = false;
10075 + });
10076 + document.addEventListener('mousemove', function (event) {
10077 + if (deskTools.resizing) {
10078 + var newWidth = Q('DeskTools').getBoundingClientRect().right - event.clientX;
10079 + if(newWidth < (Q('DeskParent').clientWidth-10)) Q('DeskTools').style.width = newWidth + 'px';
10080 + }
10081 + });
10082 function sortProcess(sort) { deskTools.sort = sort; showDeskToolsProcesses(deskTools.msg); }
10083 function sortService(sort) { deskTools.ssort = sort; showDeskToolsServices(deskTools.smsg); }
10084 function sortProcessPid(a, b) { if (a.p > b.p) return 1; if (a.p < b.p) return (-1); return sortProcessName(a, b); }
@@ -10075,8 +10096,12 @@
10096 for (var i in p) {
10097 if (p[i].p != 0) {
10098 var c = p[i].c;
10078 - if (c.length > 30) { c = '<span onclick=showProcessDetails(' + p[i].p + ') title="' + EscapeHtml(c) + '">' + EscapeHtml(c.substring(0,30)) + '...</span>' } else { c = EscapeHtml(c); }
10079 - x += '<div onclick=showProcessDetails(' + p[i].p + ') class=deskToolsBar><div style=width:50px;float:left;text-align:right;padding-right:5px>' + EscapeHtml(p[i].p) + '</div><a href=# style=float:right;padding-right:5px;cursor:pointer title="' + "Stop process" + '" onclick=\'return stopProcess(' + EscapeHtml(p[i].p) + ',"' + EscapeHtml(p[i].c) + '")\'><img width=10 height=10 src="images/trash.png"></a><div style=float:right;padding-right:5px>' + (p[i].u ? EscapeHtml(p[i].u) : '') + '</div><div>' + c + '</div></div>';
10099 + x += '<div onclick=showProcessDetails(' + p[i].p + ') class=deskToolsBar>';
10100 + x += '<div style=width:50px;float:left;text-align:right;padding-right:5px>' + EscapeHtml(p[i].p) + '</div>';
10101 + x += '<a href=# style=float:right;padding-right:5px;cursor:pointer title="' + "Stop process" + '" onclick=\'return stopProcess(' + EscapeHtml(p[i].p) + ',"' + EscapeHtml(p[i].c) + '")\'><img width=10 height=10 src="images/trash.png"></a>';
10102 + x += '<div style=float:right;padding-right:5px>' + (p[i].u ? EscapeHtml(p[i].u) : '') + '</div>';
10103 + x += '<div style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:5px" title="' + EscapeHtml(c) + '">' + c + '</div>';
10104 + x += '</div>';
10105 }
10106 }
10107 QH('DeskToolsProcesses', x);
@@ -10110,10 +10135,12 @@
10135 for (var i in s) {
10136 if (s[i].p != 0) {
10137 var c = s[i].d, ss = s[i].p;
10113 - if (c.length > 30) { c = '<span title="' + c + '">' + c.substring(0, 30) + '...</span>' } else { c = EscapeHtml(c); }
10138 if (ss == 'Stopped') { ss = "Stopped"; } // TODO: Add all other states for translation
10139 else if (ss == 'Running') { ss = "Running"; }
10116 - x += '<div onclick=showServiceDetailsDialog(' + s[i].i + ') class=deskToolsBar><div style=width:70px;float:left;padding-right:5px>' + EscapeHtml(ss) + '</div><div>' + c + '</div></div>';
10140 + x += '<div onclick=showServiceDetailsDialog(' + s[i].i + ') class=deskToolsBar>';
10141 + x += '<div style=width:70px;float:left;padding-right:5px>' + EscapeHtml(ss) + '</div>';
10142 + x += '<div style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis" title="' + c + '">' + EscapeHtml(c) + '</div>';
10143 + x += '</div>';
10144 }
10145 }
10146 QH('DeskToolsServices', x);