Made changes needed to support Android agent.

Ylian Saint-Hilaire committed Jan 18, 2021 at 01:09 UTC e1804bce972846064e7a8fced83824a65b5968b7
3 files changed +39 -35
translate/translate.json
+5 -3
@@ -5058,7 +5058,7 @@
5058 "ru": "Android",
5059 "tr": "Android",
5060 "zh-chs": "Android",
5061 - "zh-cht": "Android"
5061 + "zh-cht": "Android",
5062 "xloc": [
5063 "default-mobile.handlebars->11->20",
5064 "default.handlebars->31->22",
@@ -11727,9 +11727,11 @@
11727 "default.handlebars->31->611"
11728 ]
11729 },
11730 + {
11731 + "en": "Desktop, Alleen kijken"
11732 + },
11733 {
11734 "en": "Desktop, View only",
11732 - "en": "Desktop, Alleen kijken",
11735 "xloc": [
11736 "default.handlebars->31->750"
11737 ]
@@ -46195,4 +46197,4 @@
46197 ]
46198 }
46199 ]
46198 -}
46200 +}
\ No newline at end of file
views/default-mobile.handlebars
+9 -8
@@ -3848,7 +3848,7 @@
3848 function p13gotFiles(data) {
3849 if ((data.length > 0) && (data.charCodeAt(0) != 123)) { p13gotDownloadBinaryData(data); return; } // This is ok because 4 first bytes is a control value.
3850 //console.log('p13gotFiles', data);
3851 - data = JSON.parse(decode_utf8(data));
3851 + try { data = JSON.parse(decode_utf8(data)); } catch (ex) { data = JSON.parse(data); }
3852 if (data.action == 'download') { p13gotDownloadCommand(data); return; }
3853
3854 // Process file upload commands
@@ -3960,6 +3960,7 @@
3960 }
3961
3962 function p13setActions() {
3963 + var advancedFeatures = (currentNode.agent.id != 14); // Reduct file feature on some devices.
3964 if (p13filetree == null) {
3965 QE('p13DeleteFileButton', false);
3966 QE('p13NewFolderButton', false);
@@ -3974,16 +3975,16 @@
3975 } else {
3976 var cc = p13getFileSelCount(), tc = p13getFileCount(), sfc = p13getFileSelCount(false); // In order: number of entires selected, number of total entries, number of selected entires that are files (not folders)
3977 var winAgent = ((currentNode.agent.id > 0) && (currentNode.agent.id < 5));
3977 - QE('p13DeleteFileButton', (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3978 - QE('p13NewFolderButton', ((p13filetreelocation.length > 0) || (winAgent == false)));
3979 - QE('p13UploadButton', ((p13filetreelocation.length > 0) || (winAgent == false)));
3980 - QE('p13RenameFileButton', (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3978 + QE('p13DeleteFileButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3979 + QE('p13NewFolderButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
3980 + QE('p13UploadButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
3981 + QE('p13RenameFileButton', advancedFeatures && (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3982 QE('p13SelectAllButton', tc > 0);
3983 Q('p13SelectAllButton').value = (cc > 0 ? "None" : "All");
3984 QE('p13RefreshButton', true);
3984 - QE('p13CutButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3985 - QE('p13CopyButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3986 - QE('p13PasteButton', ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0)));
3985 + QE('p13CutButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3986 + QE('p13CopyButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
3987 + QE('p13PasteButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0)));
3988 }
3989 }
3990
views/default.handlebars
+25 -24
@@ -4357,9 +4357,7 @@
4357 if (xxdialogMode) return false;
4358 var mesh = meshes[meshid], x = '', installType = 0, moreoptions = '';
4359
4360 - var opts = '<select id=aginsSelect onchange=addAgentToMeshClick() style=width:236px><option value=0>' + "Windows" + '</option><option value=1>' + "Linux / BSD" + '</option><option value=5>' + "Linux / BSD / macOS Binary Installer" + '</option><option value=2>' + "Apple macOS" + '</option>';
4361 - if (debugmode > 0) { opts += '<option value=6>' + "Mobile device" + '</option>'; }
4362 - opts += '<option value=3>' + "Windows (UnInstall)" + '</option><option value=4>' + "Linux / BSD (UnInstall)" + '</option></select>';
4360 + var opts = '<select id=aginsSelect onchange=addAgentToMeshClick() style=width:236px><option value=0>' + "Windows" + '</option><option value=1>' + "Linux / BSD" + '</option><option value=5>' + "Linux / BSD / macOS Binary Installer" + '</option><option value=2>' + "Apple macOS" + '</option><option value=6>' + "Mobile device" + '</option><option value=3>' + "Windows (UnInstall)" + '</option><option value=4>' + "Linux / BSD (UnInstall)" + '</option></select>';
4361 x += addHtmlValue("Operating System", opts);
4362
4363 var servername = serverinfo.name;
@@ -4424,13 +4422,11 @@
4422 setDialogMode(2, "Add Mesh Agent", 2, null, x, 'fileDownload');
4423
4424 // Create the QR code
4427 - if (debugmode > 0) {
4428 - var servername = serverinfo.name;
4429 - if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
4430 - var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1);
4431 - var portStr = (serverinfo.port == 443) ? '' : (':' + serverinfo.port);
4432 - new QRCode(Q('agins_qrimage'), { text: 'mc://' + servername + portStr + domainUrlNoSlash + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2], width: 180, height: 180, colorDark: '#000000', colorLight: '#EEE', correctLevel: QRCode.CorrectLevel.M });
4433 - }
4425 + var servername = serverinfo.name;
4426 + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
4427 + var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1);
4428 + var portStr = (serverinfo.port == 443) ? '' : (':' + serverinfo.port);
4429 + new QRCode(Q('agins_qrimage'), { text: 'mc://' + servername + portStr + domainUrlNoSlash + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2], width: 180, height: 180, colorDark: '#000000', colorLight: '#EEE', correctLevel: QRCode.CorrectLevel.M });
4430
4431 if (serverinfo.https == true)
4432 {
@@ -8308,7 +8304,7 @@
8304 function p13gotFiles(data) {
8305 if ((data.length > 0) && (data.charCodeAt(0) != 123)) { p13gotDownloadBinaryData(data); return; } // This is ok because 4 first bytes is a control value.
8306 //console.log('p13gotFiles', data);
8311 - data = JSON.parse(decode_utf8(data));
8307 + try { data = JSON.parse(decode_utf8(data)); } catch (ex) { data = JSON.parse(data); }
8308 if (data.action == 'download') { p13gotDownloadCommand(data); return; }
8309
8310 // Find file result
@@ -8397,7 +8393,11 @@
8393
8394 // Figure out the date
8395 var fdatestr = '';
8400 - if (f.d != null) { var fdate = new Date(f.d), fdatestr = printDateTime(fdate) + '&nbsp;'; }
8396 + if (f.d != null) {
8397 + var fdate = new Date(f.d);
8398 + if (typeof f.d == 'number') { fdate = new Date(f.d * 1000); }
8399 + var fdatestr = printDateTime(fdate) + '&nbsp;';
8400 + }
8401
8402 // Figure out the size
8403 var fsize = '';
@@ -8492,6 +8492,7 @@
8492 }
8493
8494 function p13setActions() {
8495 + var advancedFeatures = (currentNode.agent.id != 14); // Reduct file feature on some devices.
8496 if (p13filetree == null) {
8497 QE('p13DeleteFileButton', false);
8498 QE('p13NewFolderButton', false);
@@ -8509,19 +8510,19 @@
8510 } else {
8511 var cc = p13getFileSelCount(), tc = p13getFileCount(), sfc = p13getFileSelCount(false); // In order: number of entires selected, number of total entries, number of selected entires that are files (not folders)
8512 var winAgent = ((currentNode.agent.id > 0) && (currentNode.agent.id < 5));
8512 - QE('p13DeleteFileButton', (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8513 - QE('p13NewFolderButton', ((p13filetreelocation.length > 0) || (winAgent == false)));
8514 - QE('p13UploadButton', ((p13filetreelocation.length > 0) || (winAgent == false)));
8515 - QE('p13RenameFileButton', (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8516 - QE('p13ViewFileButton', (cc == 1) && (sfc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8513 + QE('p13DeleteFileButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8514 + QE('p13NewFolderButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
8515 + QE('p13UploadButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
8516 + QE('p13RenameFileButton', advancedFeatures && (cc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8517 + QE('p13ViewFileButton', advancedFeatures && (cc == 1) && (sfc == 1) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8518 QE('p13SelectAllButton', tc > 0);
8519 Q('p13SelectAllButton').value = (cc > 0 ? "Select None" : "Select All");
8520 QE('p13RefreshButton', true);
8520 - QE('p13FindButton', ((p13filetreelocation.length > 0) || (winAgent == false)));
8521 - QE('p13CutButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8522 - QE('p13CopyButton', (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8523 - QE('p13ZipButton', (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8524 - QE('p13PasteButton', ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0)));
8521 + QE('p13FindButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)));
8522 + QE('p13CutButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8523 + QE('p13CopyButton', advancedFeatures && (cc > 0) && (cc == sfc) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8524 + QE('p13ZipButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
8525 + QE('p13PasteButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0)));
8526 }
8527 }
8528
@@ -8605,7 +8606,7 @@
8606 haltEvent(e);
8607 QV('p13bigfail', false);
8608 QV('p13bigok', false);
8608 - if (e.dataTransfer == null || e.dataTransfer.files.length == 0 || p13filetree == null) return;
8609 + if ((e.dataTransfer == null) || (e.dataTransfer.files.length == 0) || (p13filetree == null) || (currentNode.agent.id == 14)) return;
8610
8611 // Check if these are files we can upload, remove all folders.
8612 var files = [];
@@ -8619,7 +8620,7 @@
8620 function p13fileDragOver(e) {
8621 haltEvent(e);
8622 if (p13dragtimer != null) { clearTimeout(p13dragtimer); p13dragtimer = null; }
8622 - var ac = (p13filetree != null); // Set to true if we can accept the file
8623 + var ac = (p13filetree != null) && (currentNode.agent.id != 14); // Set to true if we can accept the file
8624 QV('p13bigok', ac);
8625 QV('p13bigfail', !ac);
8626 }