Merge pull request #5397 from Ylianst/add-tags-csv

add tags to csv
This commit is contained in:
Ylian Saint-Hilaire 2023-10-06 12:16:33 -07:00 committed by GitHub
commit 484146fb09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -4928,7 +4928,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (type == 'csv') { if (type == 'csv') {
try { try {
// Create the CSV file // Create the CSV file
output = 'id,name,rname,host,icon,ip,osdesc,groupname,av,update,firewall,bitlocker,avdetails,cpu,osbuild,biosDate,biosVendor,biosVersion,boardName,boardVendor,boardVersion,productUuid,totalMemory,agentOpenSSL,agentCommitDate,agentCommitHash,agentCompileTime,netIfCount,macs,addresses,lastConnectTime,lastConnectAddr\r\n'; output = 'id,name,rname,host,icon,ip,osdesc,groupname,av,update,firewall,bitlocker,avdetails,tags,cpu,osbuild,biosDate,biosVendor,biosVersion,boardName,boardVendor,boardVersion,productUuid,totalMemory,agentOpenSSL,agentCommitDate,agentCommitHash,agentCompileTime,netIfCount,macs,addresses,lastConnectTime,lastConnectAddr\r\n';
for (var i = 0; i < results.length; i++) { for (var i = 0; i < results.length; i++) {
const nodeinfo = results[i]; const nodeinfo = results[i];
@ -4950,10 +4950,18 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var avdetails = '', firstav = true; var avdetails = '', firstav = true;
for (var a in n.av) { if (typeof n.av[a].product == 'string') { if (firstav) { firstav = false; } else { avdetails += '|'; } avdetails += (n.av[a].product + '/' + ((n.av[a].enabled) ? 'enabled' : 'disabled') + '/' + ((n.av[a].updated) ? 'updated' : 'notupdated')); } } for (var a in n.av) { if (typeof n.av[a].product == 'string') { if (firstav) { firstav = false; } else { avdetails += '|'; } avdetails += (n.av[a].product + '/' + ((n.av[a].enabled) ? 'enabled' : 'disabled') + '/' + ((n.av[a].updated) ? 'updated' : 'notupdated')); } }
output += ',' + csvClean(avdetails); output += ',' + csvClean(avdetails);
}
else { output += ','; }
} else { } else {
output += ',,,,,,,,,,,,'; output += ',';
}
if (typeof n.tags == 'object') {
var tagsdetails = '', firsttags = true;
for (var a in n.tags) { if (firsttags) { firsttags = false; } else { tagsdetails += '|'; } tagsdetails += n.tags[a]; }
output += ',' + csvClean(tagsdetails);
} else {
output += ',';
}
} else {
output += ',,,,,,,,,,,,,';
} }
// System infomation // System infomation

View File

@ -5767,7 +5767,7 @@
meshserver.send({ action: 'getDeviceDetails', nodeids: chkNodeIds, tz: tz, tf: new Date().getTimezoneOffset(), l: getLang(), type: 'csv' }); // With details meshserver.send({ action: 'getDeviceDetails', nodeids: chkNodeIds, tz: tz, tf: new Date().getTimezoneOffset(), l: getLang(), type: 'csv' }); // With details
} else { } else {
// Without details // Without details
var csv = "id,name,rname,host,icon,ip,osdesc,state,groupname,conn,pwr,av,update,firewall,bitlocker,avdetails" + '\r\n', r = []; var csv = "id,name,rname,host,icon,ip,osdesc,state,groupname,conn,pwr,av,update,firewall,bitlocker,avdetails,tags" + '\r\n', r = [];
for (var i in chkNodeIds) { for (var i in chkNodeIds) {
var n = getNodeFromId(chkNodeIds[i]); var n = getNodeFromId(chkNodeIds[i]);
csv += '"' + n._id.split(',').join('') + '","' + n.name.split(',').join('') + '","' + (n.rname?(n.rname.split(',').join('')):'') + '","' + (n.host?(n.host.split(',').join('')):'') + '","' + n.icon + '","' + (n.ip?n.ip:'') + '","' + (n.osdesc?(n.osdesc.split(',').join('')):'') + '","' + n.state + '","' + meshes[n.meshid].name.split(',').join('') + '","' + (n.conn?n.conn:'') + '","' + (n.pwr?n.pwr:'') + '"'; csv += '"' + n._id.split(',').join('') + '","' + n.name.split(',').join('') + '","' + (n.rname?(n.rname.split(',').join('')):'') + '","' + (n.host?(n.host.split(',').join('')):'') + '","' + n.icon + '","' + (n.ip?n.ip:'') + '","' + (n.osdesc?(n.osdesc.split(',').join('')):'') + '","' + n.state + '","' + meshes[n.meshid].name.split(',').join('') + '","' + (n.conn?n.conn:'') + '","' + (n.pwr?n.pwr:'') + '"';
@ -5786,6 +5786,13 @@
else { else {
csv += ','; csv += ',';
} }
if (typeof n.tags == 'object') {
var tagsdetails = '', firsttags = true;
for (var a in n.tags) { if (firsttags) { firsttags = false; } else { tagsdetails += '|'; } tagsdetails += n.tags[a]; }
csv += ',"' + csvClean(tagsdetails) + '"'; }
else {
csv += ',';
}
csv += '\r\n'; csv += '\r\n';
} }
saveAs(stringToUtf8Blob(csv), "devicelist.csv"); saveAs(stringToUtf8Blob(csv), "devicelist.csv");