Added Android Customization.

Ylian Saint-Hilaire committed Jun 23, 2021 at 16:59 UTC 778e8bd128ea0e8464df46dd563b947e38444c5b
4 files changed +35 -1
MeshCentralServer.njsproj
+1 -1
@@ -193,7 +193,7 @@
193 <Compile Include="public\scripts\amt-wsman-0.2.0.js" />
194 <Compile Include="public\scripts\amt-wsman-ws-0.2.0.js" />
195 <Compile Include="public\scripts\common-0.0.1.js" />
196 - <Compile Include="public\scripts\meshcentral.js" />
196 + <cls Include="public\scripts\meshcentral.js" />
197 <Compile Include="redirserver.js" />
198 <Compile Include="translate\translate.js" />
199 <Compile Include="ua-parser.js" />
meshagent.js
+22
@@ -1621,6 +1621,28 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1621 }
1622 break;
1623 }
1624 + case 'getServerImage': {
1625 + if (command.agent === 'assistant') {
1626 + // Return server title and image for MeshCentral Assistant
1627 + if ((domain.assistantcustomization != null) && (typeof domain.assistantcustomization == 'object')) {
1628 + var ok = false;
1629 + if (typeof domain.assistantcustomization.title == 'string') { ok = true; command.title = domain.assistantcustomization.title; }
1630 + if (typeof domain.assistantcustomization.image == 'string') { try { command.image = 'data:image/jpeg;base64,' + Buffer.from(parent.fs.readFileSync(parent.parent.getConfigFilePath(domain.assistantcustomization.image)), 'binary').toString('base64'); ok = true; } catch (ex) { console.log(ex); } }
1631 + if (ok) { obj.send(JSON.stringify(command)); }
1632 + }
1633 + }
1634 + if (command.agent === 'android') {
1635 + // Return server title and image for MeshCentral Assistant
1636 + if ((domain.androidcustomization != null) && (typeof domain.androidcustomization == 'object')) {
1637 + var ok = false;
1638 + if (typeof domain.androidcustomization.title == 'string') { ok = true; command.title = domain.androidcustomization.title; }
1639 + if (typeof domain.androidcustomization.subtitle == 'string') { ok = true; command.subtitle = domain.androidcustomization.subtitle; }
1640 + if (typeof domain.androidcustomization.image == 'string') { try { command.image = 'data:image/jpeg;base64,' + Buffer.from(parent.fs.readFileSync(parent.parent.getConfigFilePath(domain.androidcustomization.image)), 'binary').toString('base64'); ok = true; } catch (ex) { console.log(ex); } }
1641 + if (ok) { obj.send(JSON.stringify(command)); }
1642 + }
1643 + }
1644 + break;
1645 + }
1646 default: {
1647 parent.agentStats.unknownAgentActionCount++;
1648 parent.parent.debug('agent', 'Unknown agent action (' + obj.remoteaddrport + '): ' + JSON.stringify(command) + '.');
meshcentral-config-schema.json
+10
@@ -456,6 +456,16 @@
456 "fileName": { "type": "string", "default": "meshagent", "description": "The MeshCentral Assistant filename." }
457 }
458 },
459 + "androidCustomization": {
460 + "type": "object",
461 + "additionalProperties": false,
462 + "description": "Use this section to customize the MeshCentral Agent for Android.",
463 + "properties": {
464 + "title": { "type": "string", "default": "MeshCentral Agent", "description": "Displayed on top of the MeshCentral Agent for Android." },
465 + "subtitle": { "type": "string", "default": null, "description": "Subtitle displayed until the title on the toolbar." },
466 + "image": { "type": "string", "default": null, "description": "The filename of a image file in .png format located in meshcentral-data to display in MeshCentral Agent for Android, image should be square and from 64x64 to 128x128." },
467 + }
468 + },
469 "userAllowedIP": { "type": "string" },
470 "userBlockedIP": { "type": "string" },
471 "agentAllowedIP": { "type": "string" },
views/default.handlebars
+2
@@ -14751,6 +14751,8 @@
14751 function seriesColor2(n) { return 'rgba('+seriesColors[n][0]+','+seriesColors[n][1]+','+seriesColors[n][2]+')'; }
14752
14753 function updateServerTimelineStats() {
14754 + if (serverTimelineStats == null) return;
14755 +
14756 var data, chartType = Q('p40type').value, timeAfter = pastDate(Q('p40time').value), servers = [], selectedServer = null, serverEmptyExists = false, serverAutoSelect = true;
14757 if (Q('p40server').value != null) { selectedServer = decodeURIComponent(Q('p40server').value); if (selectedServer == "") { selectedServer = null; } serverAutoSelect = false; }
14758 serverTimelineConfig.options.scales.xAxes[0].time = { min: timeAfter };