From 50e1c0e34872ca125d2c5339af02f4a4c8c50ab5 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 23 Jan 2020 17:11:07 -0800 Subject: [PATCH] Improved web application URL changing. --- package.json | 2 +- views/default.handlebars | 53 ++++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 7911263f..554c528a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.7-q", + "version": "0.4.7-s", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default.handlebars b/views/default.handlebars index 23b714e1..f07d105a 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1772,11 +1772,27 @@ masterUpdate(1 | 2 | 4 | 64); if (xxcurrentView == -1) { if ('{{viewmode}}' != '') { go(parseInt('{{viewmode}}')); } else { setDialogMode(0); go(1); } } - if ('{{currentNode}}' != '') { gotoDevice('{{currentNode}}',parseInt('{{viewmode}}'));} + if ('{{currentNode}}' != '') { gotoDevice('{{currentNode}}', parseInt('{{viewmode}}'));} else if (args.gotonode != null) { goBackStack.push(1); gotoDevice('node/' + domain + '/' + args.gotonode, parseInt('{{viewmode}}')); - delete args.gotonode; } + } else if (args.gotomesh != null) { + goBackStack.push(2); + gotoMesh('mesh/' + domain + '/' + args.gotomesh); + go(parseInt('{{viewmode}}')); + } else if (args.gotouser != null) { + goBackStack.push(4); + gotoUser('user/' + domain + '/' + args.gotouser); + go(parseInt('{{viewmode}}')); + } else if (args.gotougrp != null) { + goBackStack.push(50); + gotoUserGroup('ugrp/' + domain + '/' + args.gotougrp); + go(parseInt('{{viewmode}}')); + } + delete args.gotonode; + delete args.gotomesh; + delete args.gotouser; + delete args.gotougrp; break; } case 'powertimeline': { @@ -4805,7 +4821,6 @@ x += ' ' + "Delete Device" + ''; } x += '
'; - //x += ' '; if (mesh.mtype == 2) x += '' + "Interfaces" + ' '; if (xxmap != null) x += '' + "Location" + ' '; if ((terminalAccess) && ((meshrights & 8) != 0) && (mesh.mtype == 2)) x += '' + "Router" + ' '; @@ -5276,9 +5291,6 @@ // Request MQTT login credentials function p10showMqttLoginDialog(nodeid) { meshserver.send({ action: 'getmqttlogin', nodeid: nodeid }); } - // Place a device link URL in the clipboard - //function p10deviceLinkToClipboard() { copyTextToClip2(document.URL.split('?')[0].split('#')[0] + '?gotonode=' + currentNode._id.split('/')[2] + '&viewmode=10'); } - // Open XTerm function p10openxterm(e, nodeid) { haltEvent(e); @@ -7767,6 +7779,13 @@ if (meshrights == 0xFFFFFFFF) { x += '
' + "Delete Group" + '
'; } QH('p20info', x); + + // Change the URL + var urlviewmode = ''; + if ((xxcurrentView >= 20) && (xxcurrentView <= 29) && (currentMesh != null)) { + urlviewmode = '?viewmode=' + xxcurrentView + '&gotomesh=' + currentMesh._id.split('/')[2]; + try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { } + } } function p20editMeshAmt() { @@ -9301,6 +9320,13 @@ QH('p51group2', x); go(51); + + // Change the URL + var urlviewmode = ''; + if ((xxcurrentView >= 51) && (xxcurrentView <= 59) && (currentUserGroup != null)) { + urlviewmode = '?viewmode=' + xxcurrentView + '&gotougrp=' + currentUserGroup._id.split('/')[2]; + try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { } + } } function p51removeMeshFromUserGroup(e, meshid) { @@ -9535,6 +9561,13 @@ // Update user events (TODO: do this only if we change users) QH('p31events', ''); refreshUsersEvents(); + + // Change the URL + var urlviewmode = ''; + if ((xxcurrentView >= 30) && (xxcurrentView <= 39) && (currentUser != null)) { + urlviewmode = '?viewmode=' + xxcurrentView + '&gotouser=' + currentUser._id.split('/')[2]; + try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { } + } } // Display the user's email change dialog box @@ -10338,8 +10371,14 @@ // Change the URL if (xxcurrentView > 0) { var urlviewmode = ''; - if ((xxcurrentView >= 10) && (xxcurrentView <= 19)) { + if ((xxcurrentView >= 10) && (xxcurrentView <= 19)) { // Device Link if (currentNode != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotonode=' + currentNode._id.split('/')[2]; } + } else if ((xxcurrentView >= 20) && (xxcurrentView <= 29)) { // Device Group Link + if (currentMesh != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotomesh=' + currentMesh._id.split('/')[2]; } + } else if ((xxcurrentView >= 30) && (xxcurrentView <= 39)) { // User Link + if (currentUser != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotouser=' + currentUser._id.split('/')[2]; } + } else if ((xxcurrentView >= 51) && (xxcurrentView <= 59)) { // User Group Link + if (currentUserGroup != null) { urlviewmode = '?viewmode=' + xxcurrentView + '&gotougrp=' + currentUserGroup._id.split('/')[2]; } } else if (xxcurrentView > 1) { urlviewmode = '?viewmode=' + xxcurrentView; } try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { } }