Improved web application URL changing.
Ylian Saint-Hilaire committed
Jan 23, 2020 at 17:11 UTC
50e1c0e34872ca125d2c5339af02f4a4c8c50ab5
2 files changed
+47
-8
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.7-q",
3
+ "version": "0.4.7-s",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
views/default.handlebars
+46
-7
@@ -1772,11 +1772,27 @@
1772
masterUpdate(1 | 2 | 4 | 64);
1773
1774
if (xxcurrentView == -1) { if ('{{viewmode}}' != '') { go(parseInt('{{viewmode}}')); } else { setDialogMode(0); go(1); } }
1775
- if ('{{currentNode}}' != '') { gotoDevice('{{currentNode}}',parseInt('{{viewmode}}'));}
1775
+ if ('{{currentNode}}' != '') { gotoDevice('{{currentNode}}', parseInt('{{viewmode}}'));}
1776
else if (args.gotonode != null) {
1777
goBackStack.push(1);
1778
gotoDevice('node/' + domain + '/' + args.gotonode, parseInt('{{viewmode}}'));
1779
- delete args.gotonode; }
1779
+ } else if (args.gotomesh != null) {
1780
+ goBackStack.push(2);
1781
+ gotoMesh('mesh/' + domain + '/' + args.gotomesh);
1782
+ go(parseInt('{{viewmode}}'));
1783
+ } else if (args.gotouser != null) {
1784
+ goBackStack.push(4);
1785
+ gotoUser('user/' + domain + '/' + args.gotouser);
1786
+ go(parseInt('{{viewmode}}'));
1787
+ } else if (args.gotougrp != null) {
1788
+ goBackStack.push(50);
1789
+ gotoUserGroup('ugrp/' + domain + '/' + args.gotougrp);
1790
+ go(parseInt('{{viewmode}}'));
1791
+ }
1792
+ delete args.gotonode;
1793
+ delete args.gotomesh;
1794
+ delete args.gotouser;
1795
+ delete args.gotougrp;
1796
break;
1797
}
1798
case 'powertimeline': {
@@ -4805,7 +4821,6 @@
4821
x += ' <a href=# onclick=p10showDeleteNodeDialog("' + node._id + '") title=\"' + "Remove this device" + '\">' + "Delete Device" + '</a>';
4822
}
4823
x += '</div><div class="p10html3left">';
4808
- //x += '<img title=\"' + "Place link to this device in the clipboard" + '\" src="images/link1.png" style=cursor:pointer onclick=p10deviceLinkToClipboard() /> ';
4824
if (mesh.mtype == 2) x += '<a href=# onclick=p10showNodeNetInfoDialog("' + node._id + '") title=\"' + "Show device network interface information" + '\">' + "Interfaces" + '</a> ';
4825
if (xxmap != null) x += '<a href=# onclick=p10showNodeLocationDialog("' + node._id + '") title=\"' + "Show device locations information" + '\">' + "Location" + '</a> ';
4826
if ((terminalAccess) && ((meshrights & 8) != 0) && (mesh.mtype == 2)) x += '<a href=# onclick=p10showMeshCmdDialog(1,"' + node._id + '") title=\"' + "Traffic router used to connect to a device thru this server" + '.\">' + "Router" + '</a> ';
@@ -5276,9 +5291,6 @@
5291
// Request MQTT login credentials
5292
function p10showMqttLoginDialog(nodeid) { meshserver.send({ action: 'getmqttlogin', nodeid: nodeid }); }
5293
5279
- // Place a device link URL in the clipboard
5280
- //function p10deviceLinkToClipboard() { copyTextToClip2(document.URL.split('?')[0].split('#')[0] + '?gotonode=' + currentNode._id.split('/')[2] + '&viewmode=10'); }
5281
-
5294
// Open XTerm
5295
function p10openxterm(e, nodeid) {
5296
haltEvent(e);
@@ -7767,6 +7779,13 @@
7779
if (meshrights == 0xFFFFFFFF) { x += '<div style=font-size:x-small;text-align:right><span><a href=# onclick=p20showDeleteMeshDialog() style=cursor:pointer>' + "Delete Group" + '</a></span></div>'; }
7780
7781
QH('p20info', x);
7782
+
7783
+ // Change the URL
7784
+ var urlviewmode = '';
7785
+ if ((xxcurrentView >= 20) && (xxcurrentView <= 29) && (currentMesh != null)) {
7786
+ urlviewmode = '?viewmode=' + xxcurrentView + '&gotomesh=' + currentMesh._id.split('/')[2];
7787
+ try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { }
7788
+ }
7789
}
7790
7791
function p20editMeshAmt() {
@@ -9301,6 +9320,13 @@
9320
9321
QH('p51group2', x);
9322
go(51);
9323
+
9324
+ // Change the URL
9325
+ var urlviewmode = '';
9326
+ if ((xxcurrentView >= 51) && (xxcurrentView <= 59) && (currentUserGroup != null)) {
9327
+ urlviewmode = '?viewmode=' + xxcurrentView + '&gotougrp=' + currentUserGroup._id.split('/')[2];
9328
+ try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { }
9329
+ }
9330
}
9331
9332
function p51removeMeshFromUserGroup(e, meshid) {
@@ -9535,6 +9561,13 @@
9561
// Update user events (TODO: do this only if we change users)
9562
QH('p31events', '');
9563
refreshUsersEvents();
9564
+
9565
+ // Change the URL
9566
+ var urlviewmode = '';
9567
+ if ((xxcurrentView >= 30) && (xxcurrentView <= 39) && (currentUser != null)) {
9568
+ urlviewmode = '?viewmode=' + xxcurrentView + '&gotouser=' + currentUser._id.split('/')[2];
9569
+ try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { }
9570
+ }
9571
}
9572
9573
// Display the user's email change dialog box
@@ -10338,8 +10371,14 @@
10371
// Change the URL
10372
if (xxcurrentView > 0) {
10373
var urlviewmode = '';
10341
- if ((xxcurrentView >= 10) && (xxcurrentView <= 19)) {
10374
+ if ((xxcurrentView >= 10) && (xxcurrentView <= 19)) { // Device Link
10375
if (currentNode != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotonode=' + currentNode._id.split('/')[2]; }
10376
+ } else if ((xxcurrentView >= 20) && (xxcurrentView <= 29)) { // Device Group Link
10377
+ if (currentMesh != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotomesh=' + currentMesh._id.split('/')[2]; }
10378
+ } else if ((xxcurrentView >= 30) && (xxcurrentView <= 39)) { // User Link
10379
+ if (currentUser != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotouser=' + currentUser._id.split('/')[2]; }
10380
+ } else if ((xxcurrentView >= 51) && (xxcurrentView <= 59)) { // User Group Link
10381
+ if (currentUserGroup != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotougrp=' + currentUserGroup._id.split('/')[2]; }
10382
} else if (xxcurrentView > 1) { urlviewmode = '?viewmode=' + xxcurrentView; }
10383
try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { }
10384
}