Loading...
",amtversion=0,amtversionmin=0,amtFirstPull=0,amtwirelessif=-1,desktop,desktopsettings={encoding:1,showfocus:!1,showmouse:!0,showcad:!0,limitFrameRate:!1,noMouseRotate:!1},currentMeshNode=null,webcompilerfeatures="AgentPresence Alarms AuditLog Certificates ComputerSelectorToolbar Desktop DesktopInband DesktopInbandFiles Desktop-Multi DesktopRotation Desktop-Settings DesktopType EventLog EventSubscriptions FileSaver HardwareInfo IDER IDERDebug IDERStats Inflate Look-MeshCentral Mode-MeshCentral2 NetworkSettings PowerControl PowerControl-Advanced RemoteAccess Scripting Scripting-Editor Storage SystemDefense Terminal Terminal-Enumation-All Terminal-FxEnumation-All TerminalSize VersionWarning Wireless WsmanBrowser".split(" "),
StatusStrs=["Disconnected","Connecting...","Setup...","Connected"],scriptstate,t,t2,rsepass=null;
function startup(){var b=document.getElementsByTagName("input");for(t=0;t
+
@@ -1230,6 +1231,8 @@
var attemptWebRTC = ((features & 128) != 0);
var passRequirements = '{{{passRequirements}}}';
if (passRequirements != '') { passRequirements = JSON.parse(decodeURIComponent(passRequirements)); }
+ var customui = '{{{customui}}}';
+ if (customui != '') { customui = JSON.parse(decodeURIComponent(customui)); } else { customui = null; }
var deskAspectRatio = 0;
try { deskAspectRatio = parseInt(getstore('deskAspectRatio', '0')); } catch (ex) { }
var uiMode = parseInt(getstore('uiMode', 1));
@@ -1401,6 +1404,68 @@
if ((['en','ko','ja','zh-chs'].indexOf('{{{lang}}}') == -1) && ('{{{lang}}}'.toLowerCase() != '')) { QC('body').add('nonenglish'); }
var elements = document.getElementsByClassName('topbar_td');
for (var i in elements) { if (elements[i].innerHTML) { elements[i].innerHTML = elements[i].innerHTML.split(' ').join(' '); } }
+
+ // Custom UI
+ if (customui != null) {
+ if (customui.devicesbarbuttons) {
+ var x = '';
+ for (var i in customui.devicesbarbuttons) {
+ var disabled = ((customui.devicesbarbuttons[i].selection == 'one') || (customui.devicesbarbuttons[i].selection == 'many'))?'disabled':'';
+ x += '';
+ }
+ QH('devCustomUIBar', x);
+ }
+ }
+ }
+
+ // Generic handling of custom actions
+ function customUIAction(e, section) {
+ var id = e.srcElement.id;
+ if (id.startsWith('cui:') == false) return;
+ var info = customui[section][id.substring(4)];
+ if (info == null) return;
+ if (section == 'devicesbarbuttons') {
+ var elements = document.getElementsByClassName('DeviceCheckbox'), selectedDevices = [];
+ for (var i = 0; i < elements.length; i++) { if (elements[i].checked === true) { selectedDevices.push(elements[i].defaultValue.substring(6)); } }
+ if (typeof info.action == 'string') {
+ if (info.action == 'event') { meshserver.send({ action: 'uicustomevent', section: section, element: id.substring(4), selectedDevices: selectedDevices }); }
+ if (info.action.startsWith('dialog:')) { showCustomUiDialog(info.action.substring(7), { section: section, element: id.substring(4), selectedDevices: selectedDevices }); }
+ }
+ }
+ }
+
+ // Display a generic custom UI dialog
+ function showCustomUiDialog(name, tag) {
+ if ((customui == null) || (customui.dialogs == null) || (typeof customui.dialogs[name] != 'object')) return;
+ var x = '', dialog = customui.dialogs[name], buttons = 3;
+ if (typeof dialog.text == 'string') { x += ' ' + dialog.text + ' '; }
+ if (typeof dialog.buttons == 'number') { buttons = dialog.buttons; }
+ if (typeof dialog.elements == 'object') {
+ for (var i in dialog.elements) {
+ var elem = dialog.elements[i];
+ if (elem.type == 'text') { x += addHtmlValue(elem.name, ''); }
+ if (elem.type == 'droplist') {
+ var y = '';
+ for (var j in elem.options) { y += ''; }
+ x += addHtmlValue(elem.name, '' + y + '');
+ }
+ }
+ }
+ setDialogMode(2, dialog.title, buttons, showCustomUiDialogEx, x, { action: 'uicustomevent', section: 'dialogs', element: name, src: tag, values: {} });
+ }
+
+ // Handle a generic custom UI dialog event
+ function showCustomUiDialogEx(b, t) {
+ if (b != 1) return;
+ var dialog = customui.dialogs[t.element];
+ if (typeof dialog.elements == 'object') {
+ for (var i in dialog.elements) {
+ var elem = dialog.elements[i];
+ if (elem.type == 'text') { t.values[i] = Q('cui:' + i).value; }
+ if (elem.type == 'droplist') { t.values[i] = Q('cui:' + i).value; }
+ }
+ }
+ meshserver.send(t);
}
function adjustPanels() {
@@ -4033,6 +4098,16 @@
QV('cxmgroupsplit', false);
QV('cxmdesktop', false);
}
+
+ // Custom UI
+ if (customui != null) {
+ if (customui.devicesbarbuttons) {
+ for (var i in customui.devicesbarbuttons) {
+ if (customui.devicesbarbuttons[i].selection == 'one') { QE('cui:' + i, checkcount == 1); }
+ if (customui.devicesbarbuttons[i].selection == 'many') { QE('cui:' + i, checkcount >= 1); }
+ }
+ }
+ }
}
function groupActionFunction() {
@@ -7316,7 +7391,7 @@
h = '';
} else {
var link = shortname;
- if (f.s > 0) { link = '' + shortname + ''; }
+ if (f.s > 0) { link = '' + shortname + ''; }
h = '';
}
diff --git a/webserver.js b/webserver.js
index c4e66ed5..1cecc3e5 100644
--- a/webserver.js
+++ b/webserver.js
@@ -2180,7 +2180,12 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
for (var i in domain.forceduserwebstate) { webstate2[i] = domain.forceduserwebstate[i]; }
webstate = JSON.stringify(webstate2);
}
- render(req, res, getRenderPage('default', req, domain), getRenderArgs({ authCookie: authCookie, authRelayCookie: authRelayCookie, viewmode: viewmode, currentNode: currentNode, logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)).replace(/'/g, '%27'), domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, sessiontime: args.sessiontime, mpspass: args.mpspass, passRequirements: passRequirements, webcerthash: Buffer.from(obj.webCertificateFullHashs[domain.id], 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$'), footer: (domain.footer == null) ? '' : domain.footer, webstate: encodeURIComponent(webstate), pluginHandler: (parent.pluginHandler == null) ? 'null' : parent.pluginHandler.prepExports() }, req, domain));
+
+ // Custom user interface
+ var customui = '';
+ if (domain.customui != null) { customui = encodeURIComponent(JSON.stringify(domain.customui)); }
+
+ render(req, res, getRenderPage('default', req, domain), getRenderArgs({ authCookie: authCookie, authRelayCookie: authRelayCookie, viewmode: viewmode, currentNode: currentNode, logoutControls: encodeURIComponent(JSON.stringify(logoutcontrols)).replace(/'/g, '%27'), domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, sessiontime: args.sessiontime, mpspass: args.mpspass, passRequirements: passRequirements, customui: customui, webcerthash: Buffer.from(obj.webCertificateFullHashs[domain.id], 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$'), footer: (domain.footer == null) ? '' : domain.footer, webstate: encodeURIComponent(webstate), pluginHandler: (parent.pluginHandler == null) ? 'null' : parent.pluginHandler.prepExports() }, req, domain));
});
} else {
// Send back the login application
@@ -2269,8 +2274,12 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
if (typeof domain.authstrategies.saml == 'object') { authStrategies.push('saml'); }
}
+ // Custom user interface
+ var customui = '';
+ if (domain.customui != null) { customui = encodeURIComponent(JSON.stringify(domain.customui)); }
+
// Render the login page
- render(req, res, getRenderPage('login', req, domain), getRenderArgs({ loginmode: loginmode, rootCertLink: getRootCertLink(), newAccount: newAccountsAllowed, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.getWebServerName(domain), serverPublicPort: httpsPort, emailcheck: emailcheck, features: features, sessiontime: args.sessiontime, passRequirements: passRequirements, footer: (domain.footer == null) ? '' : domain.footer, hkey: encodeURIComponent(hardwareKeyChallenge), messageid: msgid, passhint: passhint, welcometext: domain.welcometext ? encodeURIComponent(domain.welcometext).split('\'').join('\\\'') : null, hwstate: hwstate, otpemail: otpemail, otpsms: otpsms, twoFactorCookieDays: twoFactorCookieDays, authStrategies: authStrategies.join(',') }, req, domain));
+ render(req, res, getRenderPage('login', req, domain), getRenderArgs({ loginmode: loginmode, rootCertLink: getRootCertLink(), newAccount: newAccountsAllowed, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.getWebServerName(domain), serverPublicPort: httpsPort, emailcheck: emailcheck, features: features, sessiontime: args.sessiontime, passRequirements: passRequirements, customui: customui, footer: (domain.footer == null) ? '' : domain.footer, hkey: encodeURIComponent(hardwareKeyChallenge), messageid: msgid, passhint: passhint, welcometext: domain.welcometext ? encodeURIComponent(domain.welcometext).split('\'').join('\\\'') : null, hwstate: hwstate, otpemail: otpemail, otpsms: otpsms, twoFactorCookieDays: twoFactorCookieDays, authStrategies: authStrategies.join(',') }, req, domain));
}
// Handle a post request on the root
|