hide powerstate with hidepowerstate

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

Simon Smith committed Oct 6, 2023 at 12:01 UTC 8b8ec48430d8fc59509396b1efb90885440e72dc
5 files changed +17 -2
docs/docs/meshcentral/config.md
+5
@@ -1642,6 +1642,11 @@ See description for information about each item.
1642 "type": "object",
1643 "description": "LDAP options passed to ldapauth-fork"
1644 },
1645 + "hidePowerState": {
1646 + "type": "boolean",
1647 + "default": false,
1648 + "description": "When enabled, this will hide the power state table in the web ui"
1649 + },
1650 "agentInviteCodes": {
1651 "type": "boolean",
1652 "default": false,
meshcentral-config-schema.json
+5
@@ -1640,6 +1640,11 @@
1640 "type": "object",
1641 "description": "LDAP options passed to ldapauth-fork"
1642 },
1643 + "hidePowerState": {
1644 + "type": "boolean",
1645 + "default": false,
1646 + "description": "When enabled, this will hide the power state table in the web ui"
1647 + },
1648 "agentInviteCodes": {
1649 "type": "boolean",
1650 "default": false,
sample-config-advanced.json
+1
@@ -189,6 +189,7 @@
189 "_agentKey": [ "abc", "123" ],
190 "_ipkvm": false,
191 "minify": true,
192 + "_hidePowerState": true,
193 "_newAccounts": true,
194 "_newAccountsUserGroups": [ "ugrp//xxxxxxxxxxxxxxxxx" ],
195 "_userNameIsEmail": true,
views/default.handlebars
+4 -1
@@ -8315,7 +8315,10 @@
8315 // Add the language and timezone of the browser to the server so the server can localize the time correctly.
8316 var tz = '';
8317 try { tz = '&tz=' + encodeURIComponentEx(Intl.DateTimeFormat().resolvedOptions().timeZone); } catch (ex) {}
8318 - QH('p10html2', '<table cellpadding=2 cellspacing=0><thead><tr style=><th scope=col style=text-align:center;width:150px>' + "Day" + '</th><th scope=col style=text-align:center><a onclick=downloadFile("devicepowerevents.ashx?id=' + currentNode._id + '&tf=' + new Date().getTimezoneOffset() + '&l=' + encodeURIComponentEx(getLang()) + tz + (urlargs.key?('&key=' + urlargs.key):'') + '",null,true)><img title="' + "Download power events" + '" src="images/link4.png" /></a>' + "7 Day Power State" + '</th></tr></thead><tbody>' + x + '</tbody></table>');
8318 + const hidePowerState = {{{hidePowerState}}};
8319 + if(!hidePowerState){
8320 + QH('p10html2', '<table cellpadding=2 cellspacing=0><thead><tr style=><th scope=col style=text-align:center;width:150px>' + "Day" + '</th><th scope=col style=text-align:center><a onclick=downloadFile("devicepowerevents.ashx?id=' + currentNode._id + '&tf=' + new Date().getTimezoneOffset() + '&l=' + encodeURIComponentEx(getLang()) + tz + (urlargs.key?('&key=' + urlargs.key):'') + '",null,true)><img title="' + "Download power events" + '" src="images/link4.png" /></a>' + "7 Day Power State" + '</th></tr></thead><tbody>' + x + '</tbody></table>');
8321 + }
8322 }
8323
8324 // Return a color for the given power state
webserver.js
+2 -1
@@ -3104,7 +3104,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
3104 amtscanoptions: amtscanoptions,
3105 pluginHandler: (parent.pluginHandler == null) ? 'null' : parent.pluginHandler.prepExports(),
3106 webRelayPort: ((args.relaydns != null) ? ((typeof args.aliasport == 'number') ? args.aliasport : args.port) : ((parent.webrelayserver != null) ? ((typeof args.relayaliasport == 'number') ? args.relayaliasport : parent.webrelayserver.port) : 0)),
3107 - webRelayDns: ((args.relaydns != null) ? args.relaydns[0] : '')
3107 + webRelayDns: ((args.relaydns != null) ? args.relaydns[0] : ''),
3108 + hidePowerState: (domain.hidepowerstate ? 'true' : 'false')
3109 }, dbGetFunc.req, domain), user);
3110 }
3111 xdbGetFunc.req = req;