added various changes

This commit is contained in:
Russel Yasol
2024-05-14 12:36:11 +08:00
parent b260cf369e
commit 12cebf6900
3 changed files with 265 additions and 105 deletions

View File

@@ -1211,37 +1211,134 @@
fetch("/cgi-bin/get_uptime") fetch("/cgi-bin/get_uptime")
.then((response) => response.text()) .then((response) => response.text())
.then((data) => { .then((data) => {
// Split the data by space // Example result
const uptimeArray = data.split(" "); // 01:17:02 up 3 days, 2:41, load average: 0.65, 0.66, 0.60
console.log(uptimeArray);
// If uptimeArray[3] is not empty, and the value doesnt have : in it // Look for xx days in the result
if ( const days = data.match(/(\d+) day/);
uptimeArray[3] !== "" && // Do the same for hours
uptimeArray[3].match(/:/) == null && uptimeArray[4].match(/days/) == null const hours = data.match(/(\d+) hour/);
) { // Do the same for minutes
this.uptime = const minutes = data.match(/(\d+) minute/);
uptimeArray[3] + // 2:41
" days, " + const hoursAndMinutes = data.match(/(\d+):(\d+),/);
uptimeArray[5].split(":")[0] +
" hours, and " + if (hoursAndMinutes != null) {
uptimeArray[5].split(":")[1].replace(",", "") + if (days != null) {
" minutes"; if (days[1] === "1") {
} else if (uptimeArray[3].match(/:/) != null) { if (hoursAndMinutes[1] === "1") {
this.uptime = this.uptime =
uptimeArray[3].split(":")[0] + days[1] +
" hours and " + " day, " +
uptimeArray[3].split(":")[1].replace(",", "") + hoursAndMinutes[1] +
" minutes"; " hour " +
} else if (uptimeArray[5].match(/:/) == null && uptimeArray[4].match(/days/) != null) { hoursAndMinutes[2] +
this.uptime = uptimeArray[3].replace(",", "") + " days and " + uptimeArray[5] + " minutes"; " minutes";
} } else if (hoursAndMinutes[2] === 1) {
this.uptime =
else { days[1] +
this.uptime = " day, " +
uptimeArray[4].split(":")[0] + hoursAndMinutes[1] +
" hours and " + " hours " +
uptimeArray[4].split(":")[1].replace(",", "") + hoursAndMinutes[2] +
" minutes"; " 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 @@
} }
</script> </script>
</body> </body>
</html> </html>

View File

@@ -127,7 +127,7 @@
class="btn btn-primary me-md-2" class="btn btn-primary me-md-2"
type="button" type="button"
x-on:click="startCellScan()" x-on:click="startCellScan()"
:disabled="isLoading" :disabled='isLoading === true || cellScanMode === "Unspecified" || cellScanMode === "Select Scan Mode"'
x-text="isCellScanning ? 'Scanning... Please wait.' : 'Start Cell Scan'" x-text="isCellScanning ? 'Scanning... Please wait.' : 'Start Cell Scan'"
> >
</button> </button>
@@ -135,7 +135,7 @@
class="btn btn-danger" class="btn btn-danger"
type="button" type="button"
x-on:click="clearTableRowsBodyCellScan()" x-on:click="clearTableRowsBodyCellScan()"
:disabled="isLoading" :disabled="isLoading === true || resultDoneCell === false"
> >
Clear Clear
</button> </button>
@@ -192,7 +192,7 @@
class="btn btn-primary me-md-2" class="btn btn-primary me-md-2"
type="button" type="button"
x-on:click="getNeighbourcellLTEandNR5G()" x-on:click="getNeighbourcellLTEandNR5G()"
:disabled="isLoading" :disabled="isLoading === true || neighbourCellsScanMode === 'Unspecified' || neighbourCellsScanMode === 'Select Scan Mode'"
> >
Start Neighbour Cell Scan Start Neighbour Cell Scan
</button> </button>
@@ -200,7 +200,7 @@
class="btn btn-danger" class="btn btn-danger"
type="button" type="button"
x-on:click="clearTableRowsBodyNeighbourCells()" x-on:click="clearTableRowsBodyNeighbourCells()"
:disabled="isLoading" :disabled="isLoading === true || resultDoneNeighbourCell === false"
> >
Clear Clear
</button> </button>
@@ -1830,10 +1830,12 @@
nr5g_neighbourCellsParsed: [], nr5g_neighbourCellsParsed: [],
lte_neighbourCellsParsed: [], lte_neighbourCellsParsed: [],
neighbourCellsTableRows: [], neighbourCellsTableRows: [],
cellScanMode: "", cellScanMode: "Unspecified",
neighbourCellsScanMode: "", neighbourCellsScanMode: "Unspecified",
isLoading: false, isLoading: false,
isCellScanning: false, isCellScanning: false,
resultDoneCell: false,
resultDoneNeighbourCell: false,
init() { init() {
this.generateNeighbourCellsTableRow(); this.generateNeighbourCellsTableRow();
@@ -1903,6 +1905,7 @@
this.generateTableRow(); this.generateTableRow();
this.isLoading = false; this.isLoading = false;
this.isCellScanning = false; this.isCellScanning = false;
this.resultDoneCell = true;
}); });
}, },
parseNr5gCells() { parseNr5gCells() {
@@ -2090,6 +2093,7 @@
.then(() => { .then(() => {
this.generateNeighbourCellsTableRow(); this.generateNeighbourCellsTableRow();
this.isLoading = false; this.isLoading = false;
this.resultDoneNeighbourCell = true;
}); });
}, },
@@ -2207,6 +2211,8 @@
this.nr5g_cells_parsed = []; this.nr5g_cells_parsed = [];
this.tableRows = []; this.tableRows = [];
this.resultDoneCell = false;
const tableBody = document.getElementById("cellScanTableBody"); const tableBody = document.getElementById("cellScanTableBody");
tableBody.innerHTML = ""; tableBody.innerHTML = "";
this.tableRows.push(` this.tableRows.push(`
@@ -2234,6 +2240,8 @@
this.nr5g_neighbourCellsParsed = []; this.nr5g_neighbourCellsParsed = [];
this.neighbourCellsTableRows = []; this.neighbourCellsTableRows = [];
this.resultDoneNeighbourCell = false;
const tableBody = document.getElementById("neighbourCellTableBody"); const tableBody = document.getElementById("neighbourCellTableBody");
tableBody.innerHTML = ""; tableBody.innerHTML = "";
this.neighbourCellsTableRows.push(` this.neighbourCellsTableRows.push(`
@@ -2253,4 +2261,4 @@
} }
</script> </script>
</body> </body>
</html> </html>

View File

@@ -169,13 +169,24 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">ETH IP Passthrough</th> <th scope="row">IP Passthrough</th>
<td>
<select
class="form-select"
id="ipPassModeSelect"
x-model="ipPassMode"
>
<option selected>Passthrough Mode</option>
<option value="ETH">ETH</option>
<option value="USB">USB</option>
</select>
</td>
<td> <td>
<button <button
type="submit" type="submit"
class="btn btn-primary" class="btn btn-primary"
@click="ethPassthroughEnable()" @click="ipPassThroughEnable()"
x-show="ethPassStatus === false" x-show="ipPassStatus === false"
:disabled="isLoading" :disabled="isLoading"
> >
Enable Enable
@@ -183,14 +194,43 @@
<button <button
type="submit" type="submit"
class="btn btn-danger" class="btn btn-danger"
@click="ethPassthroughDisable()" @click="ipPassThroughDisable()"
x-show="ethPassStatus === true" x-show="ipPassStatus === true"
:disabled="isLoading" :disabled="isLoading"
> >
Disable Disable
</button> </button>
</td> </td>
</tr> </tr>
<tr>
<th scope="row">Data Call Method</th>
<td>
<select
class="form-select"
id="usbNetModeSelect"
x-model="usbNetMode"
>
<option
selected
x-text="currentUsbNetMode"
></option>
<option value="RMNET">RMNET</option>
<option value="ECM">ECM (Recommended)</option>
<option value="MBIM">MBIM</option>
<option value="RNDIS">RNDIS</option>
</select>
</td>
<td>
<button
type="submit"
class="btn btn-primary"
@click="usbNetModeChanger()"
:disabled="isLoading"
>
Change
</button>
</td>
</tr>
<tr> <tr>
<th scope="row">Onboard DNS Proxy</th> <th scope="row">Onboard DNS Proxy</th>
<td> <td>
@@ -214,29 +254,6 @@
</button> </button>
</td> </td>
</tr> </tr>
<tr>
<th scope="row">USB Mode</th>
<td>
<button
type="submit"
class="btn btn-primary"
@click="usbModeEnable()"
x-show="USBModeStatus === true"
:disabled="isLoading"
>
Enable
</button>
<button
type="submit"
class="btn btn-danger"
@click="usbModeDisable()"
x-show="USBModeStatus === false"
:disabled="isLoading"
>
Disable
</button>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -301,14 +318,14 @@
<label class="form-label">Cell Scanner</label> <label class="form-label">Cell Scanner</label>
<div class="d-grid gap-1 w-full"> <div class="d-grid gap-1 w-full">
<!-- --> <!-- -->
<a <a
class="btn btn-warning" class="btn btn-warning"
type="button" type="button"
href="/scanner.html" href="/scanner.html"
role="button" role="button"
> >
Go to Cell Scanner Go to Cell Scanner
</a> </a>
<!-- </a> --> <!-- </a> -->
</div> </div>
</div> </div>
@@ -384,9 +401,11 @@
ttlvalue: 0, ttlvalue: 0,
ttlStatus: false, ttlStatus: false,
newTTL: null, newTTL: null,
ethPassStatus: false, ipPassMode: "Unspecified",
ipPassStatus: false,
usbNetMode: "Unspecified",
currentUsbNetMode: "Unknown",
DNSProxyStatus: true, DNSProxyStatus: true,
USBModeStatus: true,
closeModal() { closeModal() {
this.confirmModal = false; this.confirmModal = false;
@@ -421,6 +440,7 @@
this.atCommandResponse = data; this.atCommandResponse = data;
this.isLoading = false; this.isLoading = false;
this.isClean = false; this.isClean = false;
this.fetchCurrentSettings();
}) })
.catch((error) => { .catch((error) => {
console.error("Error: ", error); console.error("Error: ", error);
@@ -462,18 +482,27 @@
this.showRebootModal(); this.showRebootModal();
}, },
ethPassthroughEnable() { ipPassThroughEnable() {
this.atcmd = 'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"'; if (this.ipPassMode != "Unspecified") {
this.sendATCommand().then(() => { if (this.ipPassMode == "ETH") {
this.fetchCurrentSettings(); 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.atcmd = 'AT+QMAP="MPDN_RULE",0';
this.sendATCommand().then(() => { this.sendATCommand();
this.fetchCurrentSettings();
});
}, },
onBoardDNSProxyEnable() { onBoardDNSProxyEnable() {
@@ -490,23 +519,39 @@
}); });
}, },
usbModeEnable() { usbNetModeChanger() {
this.atcmd = "AT+QMAPWAC=1"; if (this.usbNetMode != "Unspecified") {
this.sendATCommand().then(() => { if (this.usbNetMode == "RMNET") {
this.fetchCurrentSettings(); this.atcmd = 'AT+QCFG="usbnet",0;';
}); this.sendATCommand().then(() => {
}, this.rebootDevice();
});
usbModeDisable() { } else if (this.usbNetMode == "ECM") {
this.atcmd = "AT+QMAPWAC=0"; this.atcmd = 'AT+QCFG="usbnet",1;';
this.sendATCommand().then(() => { this.sendATCommand().then(() => {
this.fetchCurrentSettings(); 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() { fetchCurrentSettings() {
this.fetchATCommand = this.fetchATCommand =
'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QMAPWAC?'; 'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QCFG="usbnet"';
fetch( fetch(
"/cgi-bin/get_atcommand?" + "/cgi-bin/get_atcommand?" +
new URLSearchParams({ new URLSearchParams({
@@ -520,15 +565,16 @@
// Set the value of currentSettingsResponse // Set the value of currentSettingsResponse
this.currentSettingsResponse = data; this.currentSettingsResponse = data;
const currentData = data.split("\n"); const currentData = data.split("\n");
console.log("Lines: ", currentData);
const testEthpass = currentData[1].match( const testEthpass = currentData[1].match(
/\+QMAP: "MPDN_rule",0,0,0,0,0/ /\+QMAP: "MPDN_rule",0,0,0,0,0/
); );
if (testEthpass) { if (testEthpass) {
this.ethPassStatus = false; this.ipPassStatus = false;
} else { } else {
this.ethPassStatus = true; this.ipPassStatus = true;
} }
const testDNSProxy = currentData[6].match( const testDNSProxy = currentData[6].match(
@@ -541,12 +587,20 @@
this.DNSProxyStatus = false; this.DNSProxyStatus = false;
} }
const testUSBMode = currentData[8].match(/\+QMAPWAC: 1/); const testUSBNet = currentData[8].match(
/\+QCFG: "usbnet",(\d)/
);
if (testUSBMode) { if (testUSBNet[1] == "0") {
this.USBModeStatus = true; 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 { } else {
this.USBModeStatus = false; this.currentUsbNetMode = "Unknown";
} }
// clear atcmd // clear atcmd
@@ -590,6 +644,7 @@
}); });
}, },
init() { init() {
this.fetchCurrentSettings();
this.fetchTTL(); this.fetchTTL();
}, },
}; };