Added Android to agent install invitation page.

This commit is contained in:
Ylian Saint-Hilaire 2021-01-29 14:08:05 -08:00
parent 4b47565c06
commit 97fb257e9c
6 changed files with 1824 additions and 1703 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
<link type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
<link rel="apple-touch-icon" href="/favicon-303x303.png" />
<script type="text/javascript" src="scripts/common-0.0.1{{min}}.js"></script>
<script type="text/javascript" src="scripts/qrcode.min.js"></script>
<title>Agent Installation</title>
<style>
.tab {
@ -83,6 +84,7 @@
<button id="twintab32" class="tablinks" onclick="openTab(event, 'wintab32')">Windows 32bit</button>
<button id="tlinuxtab" class="tablinks" onclick="openTab(event, 'linuxtab')">Linux</button>
<button id="tmacostab" class="tablinks" onclick="openTab(event, 'macostab')">MacOS</button>
<button id="tandrotab" class="tablinks" onclick="openTab(event, 'androtab')">Android</button>
</div>
<div id="wintab64" class="tabcontent" style="background-color:white;color:black">
@ -119,6 +121,27 @@
<img src="images/macosagent.png" />
</div>
</div>
<div id="androtab" class="tabcontent" style="background-color:white;color:black">
<h3>Android</h3>
<div id=agins_qrcode style=min-height:220px;min-width:220px;float:right>
<a id=android_qrimage2 href="{{{magenturl}}}" rel="noreferrer noopener" target=_blank>
<div id=android_qrimage style=float:right;margin-left:10px;width:220px;height:220px;cursor:pointer;margin-left:25px></div>
</a>
</div>
<div style="min-height:220px">
<p>Download the agent software using the Google Play store or APK file, install it and use the QR code on the right or the pairing link below to setup your device on this server.</p>
<p>
<a rel="noreferrer noopener" target=_blank href="https://play.google.com/store/apps/details?id=com.meshcentral.agent2">Google Play Store</a>
</p>
<p>
<a rel="noreferrer noopener" target=_blank href="https://info.meshcentral.com/downloads/MeshCentral2/meshcentral-agent.apk">Android APK Download</a>
</p>
<p>
<a rel="noreferrer noopener" target=_blank href="{{{magenturl}}}">Server Pairing Link</a>
</p>
</div>
</div>
</div>
</div>
<div id="footer">
@ -144,6 +167,7 @@
var serverHttps = '{{{serverhttps}}}';
var serverNoProxy = '{{{servernoproxy}}}';
var installFlags = '{{{installflags}}}';
var magenturl = '{{{magenturl}}}';
var groupName = decodeURIComponent('{{{meshname}}}');
if (groupName != '') {
QH('groupname', format("Remote Agent Installation for {0}", escapeHtml(groupName)));
@ -154,6 +178,10 @@
userInterfaceSelectMenu();
setup();
// Create the QR code
new QRCode(Q('android_qrimage'), { text: magenturl, width: 220, height: 220, colorDark: '#000000', colorLight: '#FFF', correctLevel: QRCode.CorrectLevel.M });
Q('android_qrimage2').setAttribute('href', magenturl)
// Toggle user interface menu
function showUserInterfaceSelectMenu() {
Q('uiViewButton1').classList.remove('uiSelectorSel');
@ -290,6 +318,7 @@
else if (navigator.userAgent.indexOf('Windows') >= 0) { openTab(null, 'wintab32'); }
else if (navigator.userAgent.indexOf('Linux') >= 0) { openTab(null, 'linuxtab'); }
else if (navigator.userAgent.indexOf('Macintosh') >= 0) { openTab(null, 'macostab'); }
else if (navigator.userAgent.indexOf('Android') >= 0) { openTab(null, 'mobiltab'); }
else { openTab(null, 'wintab64'); }
}

View File

@ -4540,7 +4540,11 @@
x += '<br style=clear:both><br>';
var currentMeshLinks = currentMesh.links[userinfo._id];
if (currentMeshLinks && ((currentMeshLinks.rights & 2) != 0)) { x += '<div style=margin-bottom:6px><a onclick=p20showAddMeshUserDialog() style=cursor:pointer><img src=images/icon-addnew.png border=0 height=12 width=12> ' + "Add User" + '</a></div>'; }
if (currentMeshLinks && ((currentMeshLinks.rights & 2) != 0)) { x += '<div style=margin-bottom:6px;float:left;margin-right:10px><a onclick=p20showAddMeshUserDialog() style=cursor:pointer><img src=images/icon-addnew.png border=0 height=12 width=12> ' + "Add User" + '</a></div>'; }
if (navigator.userAgent.toLowerCase().indexOf('android') >= 0) {
x += '<div style=margin-bottom:6px;float:left;margin-right:10px><a onclick=p20installAndroidDialog() style=cursor:pointer><img src=images/icon-addnew.png border=0 height=12 width=12> ' + "Install on this device" + '</a></div>';
}
/*
if ((meshrights & 4) != 0) {
@ -4638,6 +4642,14 @@
QE('idx_dlgOkButton', Q('dp20meshname').value.length > 0);
}
function p20installAndroidDialog() {
if (xxdialogMode) return;
var x = '<div>' + "Install the MeshCentral Agent on your Android device. Once installed, click the pairing link to connect your device to this server." + '</div>';
x += '<br /><div><a href="https://play.google.com/store/apps/details?id=com.meshcentral.agent2"><b>' + "MeshCentral Agent for Android" + '</b></a><div>';
x += '<br /><div><a href="' + serverinfo.magenturl + ',' + serverinfo.agentCertHash + ',' + currentMesh._id.split('/')[2] + '"><b>' + "Device Pairing Link" + '</b></a><div>';
setDialogMode(2, "Android Installation", 1, null, x);
}
function p20showAddMeshUserDialog() {
if (xxdialogMode) return;
var x = addHtmlValue('User ID', '<input id=dp20username style=width:170px maxlength=256 onchange=p20validateAddMeshUserDialog() onkeyup=p20validateAddMeshUserDialog() />');

View File

@ -4405,7 +4405,7 @@
x += '</div>';
// QR code agent install
x += '<div id=agins_qrcode style=display:none;min-height:180px><div id=agins_qrimage style=float:right;margin-left:10px;width:180px;height:180px></div><div>' + format("To add a mobile device to group \"{0}\", download the MeshAgent application and scan this QR code.", EscapeHtml(mesh.name)) + "</div><div><a rel=\"noreferrer noopener\" target=_blank href=\"https://play.google.com/store/apps/details?id=com.meshcentral.agent2\"><img style=margin-top:20px;margin-left:5px;cursor:pointer width=40 height=40 src=\"images/android-40.png\" srcset=\"images/android-80.png 2x\" /></a></div></div>";
x += '<div id=agins_qrcode style=display:none;min-height:180px><a id=agins_qrimage_a rel=\"noreferrer noopener\" target=_blank><div id=agins_qrimage style=float:right;margin-left:10px;width:180px;height:180px;cursor:pointer></div></a><div>' + format("To add a mobile device to group \"{0}\", download the MeshAgent application and scan this QR code.", EscapeHtml(mesh.name)) + "</div><div><a rel=\"noreferrer noopener\" target=_blank href=\"https://play.google.com/store/apps/details?id=com.meshcentral.agent2\"><img style=margin-top:20px;margin-left:5px;cursor:pointer width=40 height=40 src=\"images/android-40.png\" srcset=\"images/android-80.png 2x\" /></a></div></div>";
// Windows agent uninstall
x += '<div id=agins_windows_un style=display:none>' + "To remove a mesh agent, download the file below, run it and click \"uninstall\"." + '<br /><br />';
@ -4428,6 +4428,7 @@
// Create the QR code
new QRCode(Q('agins_qrimage'), { text: serverinfo.magenturl + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2], width: 180, height: 180, colorDark: '#000000', colorLight: '#EEE', correctLevel: QRCode.CorrectLevel.M });
Q('agins_qrimage_a').setAttribute('href', serverinfo.magenturl + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2])
if ((features & 0x2000) == 0)
{
@ -5975,6 +5976,7 @@
x += '<input type=button value="' + "Log Event" + '" title="' + "Write an event for this device" + '" onclick=writeDeviceEvent("' + encodeURIComponentEx(node._id) + '") />';
if ((connectivity & 1) && (meshrights & 8) && (node.agent.id != 14)) { x += '<input type=button value="' + "Message" + '" title="' + "Display a text message on the remote device" + '" onclick=deviceMessageFunction() />'; }
//if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast title="' + "Display a text message of the remote device" + '" onclick=deviceToastFunction() />'; }
if ((connectivity & 1) && (meshrights & 8) && (node.agent.id == 14)) { x += '<input type=button value="' + "Chat" + '" title="' + "Open chat window to this computer" + '" onclick=deviceChat(event) />'; }
if ((serverinfo.guestdevicesharing !== false) && (node.agent != null) && (node.agent.caps & 3) && (connectivity & 1) && (meshrights & 0x80008) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 0x1000) == 0))) { x += '<input type=button value="' + "Share" + '" title="' + "Create a link to share this device with a guest" + '" onclick=showShareDevice() />'; }
// Custom UI

View File

@ -110,7 +110,7 @@
QH('xtitle', EscapeHtml(newTitle).split(' ').join('&nbsp'));
// Setup web notifications
if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
try { if (Notification) { QV('notifyButton', Notification.permission != 'granted'); } } catch (ex) { }
// Track window focus
window.addEventListener('focus', function (event) { windowFocus = true; }, false);

View File

@ -1786,8 +1786,18 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
var installflags = cookie.f;
if (typeof installflags != 'number') { installflags = 0; }
parent.debug('web', 'handleAgentInviteRequest using cookie.');
// Build the mobile agent URL, this is used to connect mobile devices
var agentServerName = obj.getWebServerName(domain);
if (typeof obj.args.agentaliasdns == 'string') { agentServerName = obj.args.agentaliasdns; }
var xdomain = (domain.dns == null) ? domain.id : '';
var agentHttpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
if (obj.args.agentport != null) { agentHttpsPort = obj.args.agentport; } // If an agent only port is enabled, use that.
if (obj.args.agentaliasport != null) { agentHttpsPort = obj.args.agentaliasport; } // If an agent alias port is specified, use that.
var magenturl = 'mc://' + agentServerName + ((agentHttpsPort != 443) ? (':' + agentHttpsPort) : '') + ((xdomain != '') ? ('/' + xdomain) : '') + ',' + obj.agentCertificateHashBase64 + ',' + mesh._id.split('/')[2];
var meshcookie = parent.encodeCookie({ m: mesh._id.split('/')[2] }, parent.invitationLinkEncryptionKey);
render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: meshcookie, serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: 1, servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).replace(/'/g, '%27'), installflags: installflags }, req, domain));
render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: meshcookie, serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: 1, servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).replace(/'/g, '%27'), installflags: installflags, magenturl: magenturl }, req, domain));
} else if (req.query.m != null) {
// The MeshId is specified in the query string, use that
var mesh = obj.meshes['mesh/' + domain.id + '/' + req.query.m.toLowerCase()];
@ -1796,8 +1806,18 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
if (req.query.f) { installflags = parseInt(req.query.f); }
if (typeof installflags != 'number') { installflags = 0; }
parent.debug('web', 'handleAgentInviteRequest using meshid.');
// Build the mobile agent URL, this is used to connect mobile devices
var agentServerName = obj.getWebServerName(domain);
if (typeof obj.args.agentaliasdns == 'string') { agentServerName = obj.args.agentaliasdns; }
var xdomain = (domain.dns == null) ? domain.id : '';
var agentHttpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
if (obj.args.agentport != null) { agentHttpsPort = obj.args.agentport; } // If an agent only port is enabled, use that.
if (obj.args.agentaliasport != null) { agentHttpsPort = obj.args.agentaliasport; } // If an agent alias port is specified, use that.
var magenturl = 'mc://' + agentServerName + ((agentHttpsPort != 443) ? (':' + agentHttpsPort) : '') + ((xdomain != '') ? ('/' + xdomain) : '') + ',' + obj.agentCertificateHashBase64 + ',' + mesh._id.split('/')[2];
var meshcookie = parent.encodeCookie({ m: mesh._id.split('/')[2] }, parent.invitationLinkEncryptionKey);
render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: meshcookie, serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: 1, servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).replace(/'/g, '%27'), installflags: installflags }, req, domain));
render(req, res, getRenderPage('agentinvite', req, domain), getRenderArgs({ meshid: meshcookie, serverport: ((args.aliasport != null) ? args.aliasport : args.port), serverhttps: 1, servernoproxy: ((domain.agentnoproxy === true) ? '1' : '0'), meshname: encodeURIComponent(mesh.name).replace(/'/g, '%27'), installflags: installflags, magenturl: magenturl }, req, domain));
}
}