Added AMT device group downloads device list option.
Ylian Saint-Hilaire committed
Jul 1, 2021 at 14:04 UTC
adf2a382ae628e42cd0e037db86cc3b0488436f0
1 file changed
+23
-1
views/default.handlebars
+23
-1
@@ -11117,7 +11117,8 @@
11117
// Display list of devices in this device group
11118
count = 0;
11119
nodes.sort(deviceSort);
11120
- var y = '<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:left;width:430px>' + "Devices" + '</th><th scope=col style=text-align:left></th></tr>';
11120
+ var dllist = (currentMesh.mtype == 1)?'<a onclick=meshDownloadDeviceList()><img title="' + "Download device list" + '" src="images/link4.png" /></a>':'';
11121
+ var y = '<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:left;width:430px>' + "Devices" + '</th><th scope=col style=text-align:right>' + dllist + '</th></tr>';
11122
for (var i in nodes) {
11123
var node = nodes[i], gray = ((node.conn > 0)?'':' gray');
11124
if (currentMesh._id != node.meshid) continue;
@@ -11147,6 +11148,22 @@
11148
try { window.history.replaceState({}, document.title, window.location.pathname + urlviewmode); } catch (ex) { }
11149
}
11150
}
11151
+
11152
+ // Save the list of devices in a device group in the MeshCommander format
11153
+ function meshDownloadDeviceList() {
11154
+ if (xxdialogMode) return;
11155
+ var r = { webappversion: "0.9.0", computers: [ ] };
11156
+ for (var i in nodes) {
11157
+ var node = nodes[i];
11158
+ if ((currentMesh._id != node.meshid) || (node.intelamt == null)) continue;
11159
+ var c = { name: node.name, host: node.host, user: node.intelamt.user, pass: '', tls: (node.intelamt.tls == 1)?1:0, ver: node.intelamt.ver, pstate: node.intelamt.state }
11160
+ if (node.intelamt.state == 2) { c.pmode = 1; } // TODO
11161
+ if (node.intelamt.realm) { c.digestrealm = node.intelamt.realm; }
11162
+ if (node.intelamt.hash) { c.tlscerthash = node.intelamt.hash; }
11163
+ r.computers.push(c);
11164
+ }
11165
+ saveAs(stringToUtf8BlobNoHeader(JSON.stringify(r, null, 2)), currentMesh.name + ".json");
11166
+ }
11167
11168
function p20editMeshAmt() {
11169
if (xxdialogMode) return;
@@ -15645,6 +15662,11 @@
15662
return new Blob([bytes2], { type: 'application/octet-stream' }) // application/json;charset=utf-8
15663
}
15664
15665
+ // Convert a string into a UTF8 blob
15666
+ function stringToUtf8BlobNoHeader(str) {
15667
+ return new Blob([new TextEncoder().encode(str)], { type: 'application/octet-stream' }) // application/json;charset=utf-8
15668
+ }
15669
+
15670
function getLang() { if (navigator.languages != undefined) { return navigator.languages[0]; } return navigator.language; }
15671
function getNodeAmtVersion(node) { if ((node == null) || (node.intelamt == null) || (typeof node.intelamt.ver != 'string')) return 0; var verSplit = node.intelamt.ver.split('.'); if (verSplit.length < 2) return 0; return parseInt(verSplit[0]) + (parseInt(verSplit[1]) / 100); }
15672
function getstore(name, val) { try { if (typeof (localStorage) === 'undefined') return val; var v = localStorage.getItem(name); if ((v == null) || (v == null)) return val; return v; } catch (e) { return val; } }