diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index 5899833..5ee7d20 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -1211,37 +1211,134 @@ fetch("/cgi-bin/get_uptime") .then((response) => response.text()) .then((data) => { - // Split the data by space - const uptimeArray = data.split(" "); - console.log(uptimeArray); - // If uptimeArray[3] is not empty, and the value doesnt have : in it - if ( - uptimeArray[3] !== "" && - uptimeArray[3].match(/:/) == null && uptimeArray[4].match(/days/) == null - ) { - this.uptime = - uptimeArray[3] + - " days, " + - uptimeArray[5].split(":")[0] + - " hours, and " + - uptimeArray[5].split(":")[1].replace(",", "") + - " minutes"; - } else if (uptimeArray[3].match(/:/) != null) { - this.uptime = - uptimeArray[3].split(":")[0] + - " hours and " + - uptimeArray[3].split(":")[1].replace(",", "") + - " minutes"; - } else if (uptimeArray[5].match(/:/) == null && uptimeArray[4].match(/days/) != null) { - this.uptime = uptimeArray[3].replace(",", "") + " days and " + uptimeArray[5] + " minutes"; - } - - else { - this.uptime = - uptimeArray[4].split(":")[0] + - " hours and " + - uptimeArray[4].split(":")[1].replace(",", "") + - " minutes"; + // Example result + // 01:17:02 up 3 days, 2:41, load average: 0.65, 0.66, 0.60 + + // Look for xx days in the result + const days = data.match(/(\d+) day/); + // Do the same for hours + const hours = data.match(/(\d+) hour/); + // Do the same for minutes + const minutes = data.match(/(\d+) minute/); + // 2:41 + const hoursAndMinutes = data.match(/(\d+):(\d+),/); + + if (hoursAndMinutes != null) { + if (days != null) { + if (days[1] === "1") { + if (hoursAndMinutes[1] === "1") { + this.uptime = + days[1] + + " day, " + + hoursAndMinutes[1] + + " hour " + + hoursAndMinutes[2] + + " minutes"; + } else if (hoursAndMinutes[2] === 1) { + this.uptime = + days[1] + + " day, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minute"; + } else { + this.uptime = + days[1] + + " day, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minutes"; + } + } else { + if (hoursAndMinutes[1] === "1") { + this.uptime = + days[1] + + " days, " + + hoursAndMinutes[1] + + " hour " + + hoursAndMinutes[2] + + " minutes"; + } else if (hoursAndMinutes[2] === 1) { + this.uptime = + days[1] + + " days, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minute"; + } else { + this.uptime = + days[1] + + " days, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minutes"; + } + } + } else { + if (hoursAndMinutes[1] === "1") { + this.uptime = + hoursAndMinutes[1] + + " hour " + + hoursAndMinutes[2] + + " minutes"; + } else if (hoursAndMinutes[2] === 1) { + this.uptime = + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minute"; + } else { + this.uptime = + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minutes"; + } + } + } else if (days != null) { + if (hours != null) { + if (days[1] === "1") { + if (hours[1] === "1") { + this.uptime = days[1] + " day, " + hours[1] + " hour"; + } else { + this.uptime = days[1] + " day, " + hours[1] + " hours"; + } + } else { + if (hours[1] === "1") { + this.uptime = days[1] + " days, " + hours[1] + " hour"; + } else { + this.uptime = days[1] + " days, " + hours[1] + " hours"; + } + } + } else if (minutes != null) { + if (days[1] === "1") { + if (minutes[1] === "1") { + this.uptime = + days[1] + " day, " + minutes[1] + " minute"; + } else { + this.uptime = + days[1] + " day, " + minutes[1] + " minutes"; + } + } else { + if (minutes[1] === "1") { + this.uptime = + days[1] + " days, " + minutes[1] + " minute"; + } else { + this.uptime = + days[1] + " days, " + minutes[1] + " minutes"; + } + } + } else { + if (days[1] === "1") { + this.uptime = days[1] + " day"; + } else { + this.uptime = days[1] + " days"; + } + } } }); }, @@ -1334,4 +1431,4 @@ } - \ No newline at end of file + diff --git a/simpleadmin/www/scanner.html b/simpleadmin/www/scanner.html index c012627..cd57b70 100644 --- a/simpleadmin/www/scanner.html +++ b/simpleadmin/www/scanner.html @@ -127,7 +127,7 @@ class="btn btn-primary me-md-2" type="button" x-on:click="startCellScan()" - :disabled="isLoading" + :disabled='isLoading === true || cellScanMode === "Unspecified" || cellScanMode === "Select Scan Mode"' x-text="isCellScanning ? 'Scanning... Please wait.' : 'Start Cell Scan'" > @@ -135,7 +135,7 @@ class="btn btn-danger" type="button" x-on:click="clearTableRowsBodyCellScan()" - :disabled="isLoading" + :disabled="isLoading === true || resultDoneCell === false" > Clear @@ -192,7 +192,7 @@ class="btn btn-primary me-md-2" type="button" x-on:click="getNeighbourcellLTEandNR5G()" - :disabled="isLoading" + :disabled="isLoading === true || neighbourCellsScanMode === 'Unspecified' || neighbourCellsScanMode === 'Select Scan Mode'" > Start Neighbour Cell Scan @@ -200,7 +200,7 @@ class="btn btn-danger" type="button" x-on:click="clearTableRowsBodyNeighbourCells()" - :disabled="isLoading" + :disabled="isLoading === true || resultDoneNeighbourCell === false" > Clear @@ -1830,10 +1830,12 @@ nr5g_neighbourCellsParsed: [], lte_neighbourCellsParsed: [], neighbourCellsTableRows: [], - cellScanMode: "", - neighbourCellsScanMode: "", + cellScanMode: "Unspecified", + neighbourCellsScanMode: "Unspecified", isLoading: false, isCellScanning: false, + resultDoneCell: false, + resultDoneNeighbourCell: false, init() { this.generateNeighbourCellsTableRow(); @@ -1903,6 +1905,7 @@ this.generateTableRow(); this.isLoading = false; this.isCellScanning = false; + this.resultDoneCell = true; }); }, parseNr5gCells() { @@ -2090,6 +2093,7 @@ .then(() => { this.generateNeighbourCellsTableRow(); this.isLoading = false; + this.resultDoneNeighbourCell = true; }); }, @@ -2207,6 +2211,8 @@ this.nr5g_cells_parsed = []; this.tableRows = []; + this.resultDoneCell = false; + const tableBody = document.getElementById("cellScanTableBody"); tableBody.innerHTML = ""; this.tableRows.push(` @@ -2234,6 +2240,8 @@ this.nr5g_neighbourCellsParsed = []; this.neighbourCellsTableRows = []; + this.resultDoneNeighbourCell = false; + const tableBody = document.getElementById("neighbourCellTableBody"); tableBody.innerHTML = ""; this.neighbourCellsTableRows.push(` @@ -2253,4 +2261,4 @@ } - + \ No newline at end of file diff --git a/simpleadmin/www/settings.html b/simpleadmin/www/settings.html index 1795a1d..8b0b9ef 100644 --- a/simpleadmin/www/settings.html +++ b/simpleadmin/www/settings.html @@ -169,13 +169,24 @@ - ETH IP Passthrough + IP Passthrough + + + + + Data Call Method + + + + + + + Onboard DNS Proxy @@ -214,29 +254,6 @@ - - USB Mode - - - - - @@ -301,14 +318,14 @@
- - Go to Cell Scanner - + + Go to Cell Scanner +
@@ -384,9 +401,11 @@ ttlvalue: 0, ttlStatus: false, newTTL: null, - ethPassStatus: false, + ipPassMode: "Unspecified", + ipPassStatus: false, + usbNetMode: "Unspecified", + currentUsbNetMode: "Unknown", DNSProxyStatus: true, - USBModeStatus: true, closeModal() { this.confirmModal = false; @@ -421,6 +440,7 @@ this.atCommandResponse = data; this.isLoading = false; this.isClean = false; + this.fetchCurrentSettings(); }) .catch((error) => { console.error("Error: ", error); @@ -462,18 +482,27 @@ this.showRebootModal(); }, - ethPassthroughEnable() { - this.atcmd = 'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"'; - this.sendATCommand().then(() => { - this.fetchCurrentSettings(); - }); + ipPassThroughEnable() { + if (this.ipPassMode != "Unspecified") { + if (this.ipPassMode == "ETH") { + this.atcmd = + 'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"'; + this.sendATCommand(); + } else if (this.ipPassMode == "USB") { + this.atcmd = + 'AT+QMAP="MPDN_RULE",0,1,0,3,1,"FF:FF:FF:FF:FF:FF"'; + this.sendATCommand(); + } else { + console.error("Invalid IP Passthrough Mode"); + } + } else { + console.error("IP Passthrough Mode not specified"); + } }, - ethPassthroughDisable() { + ipPassThroughDisable() { this.atcmd = 'AT+QMAP="MPDN_RULE",0'; - this.sendATCommand().then(() => { - this.fetchCurrentSettings(); - }); + this.sendATCommand(); }, onBoardDNSProxyEnable() { @@ -490,23 +519,39 @@ }); }, - usbModeEnable() { - this.atcmd = "AT+QMAPWAC=1"; - this.sendATCommand().then(() => { - this.fetchCurrentSettings(); - }); - }, - - usbModeDisable() { - this.atcmd = "AT+QMAPWAC=0"; - this.sendATCommand().then(() => { - this.fetchCurrentSettings(); - }); + usbNetModeChanger() { + if (this.usbNetMode != "Unspecified") { + if (this.usbNetMode == "RMNET") { + this.atcmd = 'AT+QCFG="usbnet",0;'; + this.sendATCommand().then(() => { + this.rebootDevice(); + }); + } else if (this.usbNetMode == "ECM") { + this.atcmd = 'AT+QCFG="usbnet",1;'; + this.sendATCommand().then(() => { + this.rebootDevice(); + }); + } else if (this.usbNetMode == "MBIM") { + this.atcmd = 'AT+QCFG="usbnet",2;'; + this.sendATCommand().then(() => { + this.rebootDevice(); + }); + } else if (this.usbNetMode == "RNDIS") { + this.atcmd = 'AT+QCFG="usbnet",3;'; + this.sendATCommand().then(() => { + this.rebootDevice(); + }); + } else { + console.log("USB Net Mode Invalid"); + } + } else { + console.error("USB Net Mode not specified"); + } }, fetchCurrentSettings() { this.fetchATCommand = - 'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QMAPWAC?'; + 'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QCFG="usbnet"'; fetch( "/cgi-bin/get_atcommand?" + new URLSearchParams({ @@ -520,15 +565,16 @@ // Set the value of currentSettingsResponse this.currentSettingsResponse = data; const currentData = data.split("\n"); + console.log("Lines: ", currentData); const testEthpass = currentData[1].match( /\+QMAP: "MPDN_rule",0,0,0,0,0/ ); if (testEthpass) { - this.ethPassStatus = false; + this.ipPassStatus = false; } else { - this.ethPassStatus = true; + this.ipPassStatus = true; } const testDNSProxy = currentData[6].match( @@ -541,12 +587,20 @@ this.DNSProxyStatus = false; } - const testUSBMode = currentData[8].match(/\+QMAPWAC: 1/); + const testUSBNet = currentData[8].match( + /\+QCFG: "usbnet",(\d)/ + ); - if (testUSBMode) { - this.USBModeStatus = true; + if (testUSBNet[1] == "0") { + this.currentUsbNetMode = "RMNET"; + } else if (testUSBNet[1] == "1") { + this.currentUsbNetMode = "ECM"; + } else if (testUSBNet[1] == "2") { + this.currentUsbNetMode = "MBIM"; + } else if (testUSBNet[1] == "3") { + this.currentUsbNetMode = "RNDIS"; } else { - this.USBModeStatus = false; + this.currentUsbNetMode = "Unknown"; } // clear atcmd @@ -590,6 +644,7 @@ }); }, init() { + this.fetchCurrentSettings(); this.fetchTTL(); }, };