Fixed web app device list issue, improved MeshCtrl.
Ylian Saint-Hilaire committed
Dec 20, 2019 at 17:29 UTC
3ad55e4634c16f9d3f5c45629a5de175bbd9004d
14 files changed
+63
-15
meshctrl.js
+38
-14
@@ -111,18 +111,7 @@ if (args['_'].length == 0) {
111
} else {
112
switch (args['_'][1].toLowerCase()) {
113
case 'config': {
114
- console.log("Perform operations on the config.json file. Example usage:\r\n");
115
- console.log(" MeshCtrl config --show");
116
- console.log("\r\nOptional arguments:\r\n");
117
- console.log(" --show - Display the config.json file.");
118
- console.log(" --adddomain [domain] - Add a domain.");
119
- console.log(" --removedomain [domain] - Remove a domain.");
120
- console.log(" --settodomain [domain] - Set values to the domain.");
121
- console.log(" --removefromdomain [domain] - Remove values from the domain.");
122
- console.log("\r\nWith adddomain, removedomain, settodomain and removefromdomain you can add the key and value pair. For example:\r\n");
123
- console.log(" --adddomain \"MyDomain\" --title \"My Server Name\" --newAccounts false");
124
- console.log(" --settodomain \"MyDomain\" --title \"My Server Name\"");
125
- console.log(" --removefromdomain \"MyDomain\" --title");
114
+ displayConfigHelp();
115
break;
116
}
117
case 'sendinviteemail': {
@@ -297,12 +286,29 @@ if (args['_'].length == 0) {
286
if (ok) { serverConnect(); }
287
}
288
289
+function displayConfigHelp() {
290
+ console.log("Perform operations on the config.json file. Example usage:\r\n");
291
+ console.log(" MeshCtrl config --show");
292
+ console.log("\r\nOptional arguments:\r\n");
293
+ console.log(" --show - Display the config.json file.");
294
+ console.log(" --listdomains - Display non-default domains.");
295
+ console.log(" --adddomain [domain] - Add a domain.");
296
+ console.log(" --removedomain [domain] - Remove a domain.");
297
+ console.log(" --settodomain [domain] - Set values to the domain.");
298
+ console.log(" --removefromdomain [domain] - Remove values from the domain.");
299
+ console.log("\r\nWith adddomain, removedomain, settodomain and removefromdomain you can add the key and value pair. For example:\r\n");
300
+ console.log(" --adddomain \"MyDomain\" --title \"My Server Name\" --newAccounts false");
301
+ console.log(" --settodomain \"MyDomain\" --title \"My Server Name\"");
302
+ console.log(" --removefromdomain \"MyDomain\" --title");
303
+}
304
+
305
function performConfigOperations(args) {
306
var domainValues = ['title', 'title2', 'titlepicture', 'trustedcert', 'welcomepicture', 'welcometext', 'userquota', 'meshquota', 'newaccounts', 'usernameisemail', 'newaccountemaildomains', 'newaccountspass', 'newaccountsrights', 'geolocation', 'lockagentdownload', 'userconsentflags', 'Usersessionidletimeout', 'auth', 'ldapoptions', 'ldapusername', 'ldapuserbinarykey', 'ldapoptions', 'footer', 'certurl', 'loginKey', 'userallowedip', 'agentallowedip', 'agentnoproxy', 'agentconfig', 'orphanagentuser', 'httpheaders', 'yubikey', 'passwordrequirements', 'limits', 'amtacmactivation', 'redirects', 'sessionrecording'];
307
var configChange = false;
308
var fs = require('fs');
309
var path = require('path');
310
var configFile = path.join(__dirname, 'config.json');
311
+ var didSomething = 0;
312
if (fs.existsSync(configFile) == false) { configFile = path.join('meshcentral-data', 'config.json'); }
313
if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, 'meshcentral-data', 'config.json'); }
314
if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, '..', 'meshcentral-data', 'config.json'); }
@@ -311,6 +317,7 @@ function performConfigOperations(args) {
317
try { config = fs.readFileSync(configFile); } catch (ex) { console.log("Error: Unable to read config.json"); return; }
318
try { config = JSON.parse(config); } catch (ex) { console.log("Error: Unable to parse config.json"); return; }
319
if (args.adddomain != null) {
320
+ didSomething++;
321
if (config.domains == null) { config.domains = {}; }
322
if (config.domains[args.adddomain] != null) { console.log("Error: Domain \"" + args.adddomain + "\" already exists"); }
323
else {
@@ -326,11 +333,13 @@ function performConfigOperations(args) {
333
}
334
}
335
if (args.removedomain != null) {
336
+ didSomething++;
337
if (config.domains == null) { config.domains = {}; }
338
if (config.domains[args.removedomain] == null) { console.log("Error: Domain \"" + args.removedomain + "\" does not exist"); }
339
else { delete config.domains[args.removedomain]; configChange = true; }
340
}
341
if (args.settodomain != null) {
342
+ didSomething++;
343
if (config.domains == null) { config.domains = {}; }
344
if (config.domains[args.settodomain] == null) { console.log("Error: Domain \"" + args.settodomain + "\" does not exist"); }
345
else {
@@ -346,15 +355,30 @@ function performConfigOperations(args) {
355
}
356
}
357
if (args.removefromdomain != null) {
358
+ didSomething++;
359
if (config.domains == null) { config.domains = {}; }
360
if (config.domains[args.removefromdomain] == null) { console.log("Error: Domain \"" + args.removefromdomain + "\" does not exist"); }
361
else { for (var i in args) { if (domainValues.indexOf(i.toLowerCase()) >= 0) { delete config.domains[args.removefromdomain][i]; configChange = true; } } }
362
}
353
- if (args.show == 1) { console.log(JSON.stringify(config, null, 2)); } else { console.log("Done."); }
363
if (configChange) {
364
try { fs.writeFileSync(configFile, JSON.stringify(config, null, 2)); } catch (ex) { console.log("Error: Unable to read config.json"); return; }
365
}
357
- //console.log(configFile);
366
+ if (args.show == 1) {
367
+ console.log(JSON.stringify(config, null, 2)); return;
368
+ } else if (args.listdomains == 1) {
369
+ if (config.domains == null) {
370
+ console.log('No domains found.'); return;
371
+ } else {
372
+ // Show the list of active domains, skip the default one.
373
+ for (var i in config.domains) { if ((i != '') && (i[0] != '_')) { console.log(i); } } return;
374
+ }
375
+ } else {
376
+ if (didSomething == 0) {
377
+ displayConfigHelp();
378
+ } else {
379
+ console.log("Done.", didSomething);
380
+ }
381
+ }
382
}
383
384
function onVerifyServer(clientName, certs) { return null; }
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.6-e",
3
+ "version": "0.4.6-f",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
views/default-min.handlebars
+2
@@ -1860,11 +1860,13 @@
1860
}
1861
1862
if (r != '') {
1863
+ r += '</table>';
1864
if (view == 2) {
1865
// This height of 1 div at the end to fix a problem in Linux firefox browsers
1866
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "User" + '<th style=color:gray;width:120px>' + "Address" + '<th style=color:gray;width:100px>' + "Connectivity" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
1867
}
1868
} else {
1869
+ r += '</table>';
1870
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
1871
}
1872
views/default.handlebars
+2
@@ -2913,11 +2913,13 @@
2913
}
2914
2915
if (r != '') {
2916
+ r += '</table>';
2917
if (view == 2) {
2918
// This height of 1 div at the end to fix a problem in Linux firefox browsers
2919
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "User" + '<th style=color:gray;width:120px>' + "Address" + '<th style=color:gray;width:100px>' + "Connectivity" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
2920
}
2921
} else {
2922
+ r += '</table>';
2923
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
2924
}
2925
views/translations/default-min_cs.handlebars
+2
@@ -1860,11 +1860,13 @@
1860
}
1861
1862
if (r != '') {
1863
+ r += '</table>';
1864
if (view == 2) {
1865
// This height of 1 div at the end to fix a problem in Linux firefox browsers
1866
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Uživatel" + '<th style=color:gray;width:120px>' + "Adresa" + '<th style=color:gray;width:100px>' + "Konektivita" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
1867
}
1868
} else {
1869
+ r += '</table>';
1870
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
1871
}
1872
views/translations/default-min_fr.handlebars
+2
@@ -1860,11 +1860,13 @@
1860
}
1861
1862
if (r != '') {
1863
+ r += '</table>';
1864
if (view == 2) {
1865
// This height of 1 div at the end to fix a problem in Linux firefox browsers
1866
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Utilisateur" + '<th style=color:gray;width:120px>' + "Address" + '<th style=color:gray;width:100px>' + "Connectivity" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
1867
}
1868
} else {
1869
+ r += '</table>';
1870
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
1871
}
1872
views/translations/default-min_ja.handlebars
+2
@@ -1860,11 +1860,13 @@
1860
}
1861
1862
if (r != '') {
1863
+ r += '</table>';
1864
if (view == 2) {
1865
// This height of 1 div at the end to fix a problem in Linux firefox browsers
1866
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "ユーザー" + '<th style=color:gray;width:120px>' + "住所" + '<th style=color:gray;width:100px>' + "接続性" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
1867
}
1868
} else {
1869
+ r += '</table>';
1870
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
1871
}
1872
views/translations/default-min_nl.handlebars
+2
@@ -1860,11 +1860,13 @@
1860
}
1861
1862
if (r != '') {
1863
+ r += '</table>';
1864
if (view == 2) {
1865
// This height of 1 div at the end to fix a problem in Linux firefox browsers
1866
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Gebruiker" + '<th style=color:gray;width:120px>' + "Adres" + '<th style=color:gray;width:100px>' + "connectiviteit" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
1867
}
1868
} else {
1869
+ r += '</table>';
1870
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
1871
}
1872
views/translations/default-min_pt.handlebars
+2
@@ -1860,11 +1860,13 @@
1860
}
1861
1862
if (r != '') {
1863
+ r += '</table>';
1864
if (view == 2) {
1865
// This height of 1 div at the end to fix a problem in Linux firefox browsers
1866
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Do utilizador" + '<th style=color:gray;width:120px>' + "Endereço" + '<th style=color:gray;width:100px>' + "Conectividade" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
1867
}
1868
} else {
1869
+ r += '</table>';
1870
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
1871
}
1872
views/translations/default_cs.handlebars
+2
@@ -2911,11 +2911,13 @@
2911
}
2912
2913
if (r != '') {
2914
+ r += '</table>';
2915
if (view == 2) {
2916
// This height of 1 div at the end to fix a problem in Linux firefox browsers
2917
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Uživatel" + '<th style=color:gray;width:120px>' + "Adresa" + '<th style=color:gray;width:100px>' + "Konektivita" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
2918
}
2919
} else {
2920
+ r += '</table>';
2921
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
2922
}
2923
views/translations/default_fr.handlebars
+2
@@ -2911,11 +2911,13 @@
2911
}
2912
2913
if (r != '') {
2914
+ r += '</table>';
2915
if (view == 2) {
2916
// This height of 1 div at the end to fix a problem in Linux firefox browsers
2917
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Utilisateur" + '<th style=color:gray;width:120px>' + "Address" + '<th style=color:gray;width:100px>' + "Connectivity" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
2918
}
2919
} else {
2920
+ r += '</table>';
2921
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
2922
}
2923
views/translations/default_ja.handlebars
+2
@@ -2911,11 +2911,13 @@
2911
}
2912
2913
if (r != '') {
2914
+ r += '</table>';
2915
if (view == 2) {
2916
// This height of 1 div at the end to fix a problem in Linux firefox browsers
2917
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "ユーザー" + '<th style=color:gray;width:120px>' + "住所" + '<th style=color:gray;width:100px>' + "接続性" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
2918
}
2919
} else {
2920
+ r += '</table>';
2921
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
2922
}
2923
views/translations/default_nl.handlebars
+2
@@ -2911,11 +2911,13 @@
2911
}
2912
2913
if (r != '') {
2914
+ r += '</table>';
2915
if (view == 2) {
2916
// This height of 1 div at the end to fix a problem in Linux firefox browsers
2917
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Gebruiker" + '<th style=color:gray;width:120px>' + "Adres" + '<th style=color:gray;width:100px>' + "connectiviteit" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
2918
}
2919
} else {
2920
+ r += '</table>';
2921
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
2922
}
2923
views/translations/default_pt.handlebars
+2
@@ -2911,11 +2911,13 @@
2911
}
2912
2913
if (r != '') {
2914
+ r += '</table>';
2915
if (view == 2) {
2916
// This height of 1 div at the end to fix a problem in Linux firefox browsers
2917
r = '<table style=width:100%;margin-top:4px cellpadding=0 cellspacing=0><th style=color:gray><th style=color:gray;width:120px>' + "Do utilizador" + '<th style=color:gray;width:120px>' + "Endereço" + '<th style=color:gray;width:100px>' + "Conectividade" + r + '</tr></table><div style=height:1px></div>'; //<th style=color:gray;width:100px>State';
2918
}
2919
} else {
2920
+ r += '</table>';
2921
if (sort == 3) { r = '<div style="margin:10px"><i>' + "No devices with tags found." + '</i></div>'; }
2922
}
2923