Merge pull request #53 from dr-dolomite/development-socat

Added Various Changes for Alpha 0.8
This commit is contained in:
Cameron Thompson
2024-05-19 00:06:01 -04:00
committed by GitHub
7 changed files with 371 additions and 52 deletions

View File

@@ -13,9 +13,9 @@ if [ "${QUERY_STRING}" ]; then
done
fi
x=$(urldecode "$atcmd")
MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}")
if [ -n "${MYATCMD}" ]; then
x=$(urldecode "$atcmd")
# Initialize wait time to 200 ms
wait_time=200
while true; do
@@ -32,4 +32,4 @@ fi
echo "Content-type: text/plain"
echo $x
echo ""
echo $runcmd
echo $runcmd

View File

@@ -139,7 +139,7 @@
</tr>
<tr>
<th scope="row">Simple Admin Version</th>
<td class="col-md-2">SimpleAdminRev-Alpha-0.7</td>
<td class="col-md-2">SimpleAdminRev-Alpha-0.8</td>
</tr>
</tbody>
</table>

View File

@@ -100,6 +100,28 @@
</div>
</div>
<div class="col align-self-center">
<div class="card">
<div
class="card-body d-flex flex-column align-items-center justify-content-center"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 384 512"
height="85"
width="85"
>
<path
fill="#6a46d8"
d="M64 0H242.7c17 0 33.3 6.7 45.3 18.7L365.3 96c12 12 18.7 28.3 18.7 45.3V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64C0 28.7 28.7 0 64 0zM96 192c-17.7 0-32 14.3-32 32v32h64V192H96zM64 352h80 96 80V288H240 144 64v64zM320 224c0-17.7-14.3-32-32-32H256v64h64V224zM160 192v64h64V192H160zM288 448c17.7 0 32-14.3 32-32V384H256v64h32zM160 384v64h64V384H160zM64 416c0 17.7 14.3 32 32 32h32V384H64v32z"
/>
</svg>
<h1 class="card-text mt-4" x-text="sim"></h1>
</div>
<div class="card-footer">SIM</div>
</div>
</div>
<div class="col align-self-center">
<div class="card">
<div
@@ -118,7 +140,7 @@
</svg>
<h1 class="card-text mt-4" x-text="signalPercentage + '%'"></h1>
</div>
<div class="card-footer">Signal %</div>
<div class="card-footer">Signal Percentage</div>
</div>
</div>
@@ -577,6 +599,7 @@
<script>
function getStaticNetworkInfo() {
return {
sim: "Inactive",
atcmd: null,
temperature: "0",
active_sim: "?",
@@ -672,6 +695,43 @@
this.ipv4 = lines[24].split(",")[4].replace(/"/g, "");
this.ipv6 = lines[25].split(",")[4].replace(/"/g, "");
// If no network IP detected, consider as disconnected. Return all values as unknown (except temperature, sim, network provider, mccmnc, and apn)
if (this.ipv4 == "0.0.0.0" && this.ipv6 == "0:0:0:0:0:0:0:0") {
this.temperature = this.temperature;
this.active_sim = this.active_sim;
this.network_provider = this.network_provider;
this.mccmnc = this.mccmnc;
this.apn = this.apn;
this.network_mode =
"Network Disconnected. Please check your SIM card and network settings.";
this.bands = "Unknown";
this.bandwidth = "Unknown";
this.earfcns = "Unknown";
this.pcc_pci = "Unknown";
this.scc_pci = "Unknown";
this.csq = "Unknown";
this.rssi = "Unknown";
this.cellID = "Unknown";
this.eNBID = "Unknown";
this.tac = "Unknown";
this.rsrqLTE = "Unknown";
this.rsrqNR = "Unknown";
this.rsrqLTEPercentage = "0%";
this.rsrqNRPercentage = "0%";
this.rsrpLTE = "Unknown";
this.rsrpNR = "Unknown";
this.rsrpLTEPercentage = "0%";
this.rsrpNRPercentage = "0%";
this.sinrLTE = "Unknown";
this.sinrNR = "Unknown";
this.sinrLTEPercentage = "0%";
this.sinrNRPercentage = "0%";
this.signalPercentage = "0";
this.internetConnection = "Disconnected";
this.lastUpdate = new Date().toLocaleString();
return;
}
// Parse the network mode
const networkMode1 = lines[27].split(",")[2];
@@ -1191,6 +1251,43 @@
}
},
fetchSIMInfo() {
this.atcmd = "AT+QSIMSTAT?";
fetch(
"/cgi-bin/get_atcommand?" +
new URLSearchParams({
atcmd: this.atcmd,
})
).then((response) => {
response
.text()
.then((data) => {
const rawdata = data;
const lines = rawdata.split("\n");
console.log("SIM: ", lines);
const sim_status = lines[1]
.split(":")[1]
.split(",")[1]
.trim();
if (sim_status === "1") {
this.sim = "Active";
} else {
this.sim = "Inactive";
}
console.log("SIM: ", this.sim);
})
.then(() => {
this.fetchNetworkInfo();
})
.then(() => {
this.fetchCSQ();
});
});
},
requestPing() {
return fetch("/cgi-bin/get_ping")
.then((response) => response.text())
@@ -1219,7 +1316,7 @@
// Do the same for hours
const hours = data.match(/(\d+) hour/);
// Do the same for minutes
const minutes = data.match(/(\d+) minute/);
const minutes = data.match(/(\d+) min/);
// 2:41
const hoursAndMinutes = data.match(/(\d+):(\d+),/);
@@ -1339,6 +1436,20 @@
this.uptime = days[1] + " days";
}
}
} else if (hours != null) {
if (hours[1] === "1") {
this.uptime = hours[1] + " hour";
} else {
this.uptime = hours[1] + " hours";
}
} else if (minutes != null) {
if (minutes[1] === "1") {
this.uptime = minutes[1] + " minute";
} else {
this.uptime = minutes[1] + " minutes";
}
} else {
this.uptime = "Unknown Time";
}
});
},
@@ -1372,11 +1483,13 @@
? parseInt(storedRefreshRate)
: 3; // Change 5 to your desired default value
this.fetchNetworkInfo();
// sleep for 2 seconds
setTimeout(() => {
this.fetchCSQ();
}, 2000);
// Ensure fetchSIMInfo returns a promise
this.fetchSIMInfo();
// // sleep for 2 seconds
// setTimeout(() => {
// this.fetchCSQ();
// }, 2000);
this.requestPing()
.then((data) => {
@@ -1400,11 +1513,7 @@
// Set the refresh rate
this.intervalId = setInterval(() => {
this.fetchNetworkInfo();
// sleep for 2 seconds
setTimeout(() => {
this.fetchCSQ();
}, 2000);
this.fetchSIMInfo();
this.requestPing()
.then((data) => {

View File

@@ -1,29 +1,37 @@
// Function to toggle dark mode
const toggleDarkMode = () => {
const html = document.querySelector('html');
const currentTheme = html.getAttribute('data-bs-theme');
// Function to toggle dark mode
const toggleDarkMode = () => {
const html = document.querySelector('html');
const currentTheme = html.getAttribute('data-bs-theme');
if (currentTheme === 'dark') {
html.removeAttribute('data-bs-theme');
darkModeToggle.textContent = 'Dark Mode';
localStorage.setItem('theme', 'light'); // Store the theme in localStorage
} else {
html.setAttribute('data-bs-theme', 'dark');
darkModeToggle.textContent = 'Light Mode';
localStorage.setItem('theme', 'dark'); // Store the theme in localStorage
}
};
const darkModeToggle = document.getElementById('darkModeToggle');
// Check if theme preference is stored in localStorage
const storedTheme = localStorage.getItem('theme');
if (storedTheme) {
const html = document.querySelector('html');
html.setAttribute('data-bs-theme', storedTheme);
if (storedTheme === 'dark') {
darkModeToggle.textContent = 'Light Mode';
}
if (currentTheme === 'dark') {
html.removeAttribute('data-bs-theme');
darkModeToggle.textContent = 'Dark Mode';
localStorage.setItem('theme', 'light'); // Store the theme in localStorage
} else {
html.setAttribute('data-bs-theme', 'dark');
darkModeToggle.textContent = 'Light Mode';
localStorage.setItem('theme', 'dark'); // Store the theme in localStorage
}
};
darkModeToggle.addEventListener('click', toggleDarkMode);
const darkModeToggle = document.getElementById('darkModeToggle');
// Check if theme preference is stored in localStorage
const storedTheme = localStorage.getItem('theme');
const html = document.querySelector('html');
if (storedTheme) {
html.setAttribute('data-bs-theme', storedTheme);
if (storedTheme === 'dark') {
darkModeToggle.textContent = 'Light Mode';
} else {
darkModeToggle.textContent = 'Dark Mode';
}
} else {
// If no preference is stored, default to dark mode
html.setAttribute('data-bs-theme', 'dark');
darkModeToggle.textContent = 'Light Mode';
localStorage.setItem('theme', 'dark');
}
darkModeToggle.addEventListener('click', toggleDarkMode);

View File

@@ -814,7 +814,7 @@
310340: "Limitless Mobile, LLC",
310360: "Cellular Network Partnership",
310390: "TX-11 Acquisition, LLC",
310410: "Liberty",
310410: "AT&T Mobility",
310430: "GCI Communications Corp.",
310440: "Numerex",
310450: "Viaero Wireless",

View File

@@ -178,7 +178,7 @@
>
<option selected>Passthrough Mode</option>
<option value="ETH">ETH</option>
<option value="USB">USB</option>
<option value="USB">USB (ECM/RNDIS)</option>
</select>
</td>
<td>
@@ -203,7 +203,7 @@
</td>
</tr>
<tr>
<th scope="row">Data Call Method</th>
<th scope="row">USB Modem Protocol</th>
<td>
<select
class="form-select"
@@ -425,15 +425,15 @@
this.atcmd
);
}
this.isLoading = true;
fetch(
"/cgi-bin/get_atcommand?" +
new URLSearchParams({
atcmd: this.atcmd,
})
)
const encodedATCmd = encodeURIComponent(this.atcmd);
const url = `/cgi-bin/get_atcommand?atcmd=${encodedATCmd}`;
fetch(url)
.then((res) => {
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
return res.text();
})
.then((data) => {
@@ -445,6 +445,7 @@
.catch((error) => {
console.error("Error: ", error);
this.showError = true;
this.isLoading = false;
});
},
@@ -486,6 +487,7 @@
if (this.ipPassMode != "Unspecified") {
if (this.ipPassMode == "ETH") {
this.atcmd =
// at+qmap="mpdn_rule",0,1,1,1,1,"FF:FF:FF:FF:FF:FF"
'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"';
this.sendATCommand();
} else if (this.ipPassMode == "USB") {
@@ -501,7 +503,7 @@
},
ipPassThroughDisable() {
this.atcmd = 'AT+QMAP="MPDN_RULE",0';
this.atcmd = 'AT+QMAP="MPDN_RULE",0;+QMAPWAC=1';
this.sendATCommand();
},

View File

@@ -0,0 +1,200 @@
<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Simple Admin</title>
<!-- <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous"
/> -->
<!-- Import all the bootstrap css files from css folder -->
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<!-- Logo -->
<link rel="simpleadmin-logo" href="favicon.ico" />
<!-- Import BootStrap Javascript -->
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/alpinejs.min.js" defer></script>
</head>
<body>
<main>
<div class="container my-4" x-data="simpleWatchCat()">
<nav class="navbar navbar-expand-lg mt-2">
<div class="container-fluid">
<a class="navbar-brand" href="/"
><span class="mb-0 h4">Simple Admin</span></a
>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarText"
aria-controls="navbarText"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav me-auto mb-2 ml-4 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/network.html">Simple Network</a>
</li>
<li class="nav-item">
<a
class="nav-link active"
href="/settings.html"
aria-current="page"
>Simple Settings</a
>
</li>
<li class="nav-item">
<a class="nav-link" href="/sms.html">SMS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/console">Console</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/deviceinfo.html"
>Device Information</a
>
</li>
</ul>
<span class="navbar-text">
<button class="btn btn-link text-reset" id="darkModeToggle">
Dark Mode
</button>
</span>
</div>
</div>
</nav>
<div class="row mt-3 mb-4">
<div class="col">
<div class="card">
<div class="card-header">Simple Watchcat</div>
<div class="card-body">
<div class="card-text">
<div>
<label
class="form-check-label m-lg-3"
for="flexSwitchCheckDefault"
>Select Watchcat Status</label
>
<!-- If wacthCatStatus is Enabled then make it checked -->
<input
type="radio"
class="btn-check"
name="Enable"
id="Enable"
autocomplete="off"
x-bind:checked="wacthCatStatus === 'Enable'"
x-bind:disabled="wacthCatStatus === 'Enable'"
x-model="wacthCatStatus"
/>
<label class="btn btn-primary" for="option1">Enable</label>
<input
type="radio"
class="btn-check"
name="Disable"
id="Disable"
autocomplete="off"
x-bind:checked="wacthCatStatus === 'Disable'"
x-bind:disabled="wacthCatStatus === 'Disable'"
x-model="wacthCatStatus"
/>
<label class="btn btn-danger" for="option2">Disable</label>
</div>
<div class="input-group mb-3 mt-3">
<span
class="input-group-text"
id="inputGroup-sizing-default"
>IP or DNS to Ping</span
>
<input
type="text"
class="form-control"
aria-label="Ping Timeout"
aria-describedby="inputGroup-sizing-default"
x-bind:placeholder="ipDNS"
/>
</div>
<div class="input-group mb-3 mt-3">
<span
class="input-group-text"
id="inputGroup-sizing-default"
>Ping Timeout in Seconds</span
>
<input
type="text"
class="form-control"
aria-label="Ping Failure Count"
aria-describedby="inputGroup-sizing-default"
x-bind:placeholder="pingTimeout + ' seconds'"
/>
</div>
<div class="input-group mb-3 mt-3">
<span
class="input-group-text"
id="inputGroup-sizing-default"
>Ping Failure Amount</span
>
<input
type="text"
class="form-control"
aria-label="Sizing example input"
aria-describedby="inputGroup-sizing-default"
x-bind:placeholder="pingFailures"
/>
</div>
<div>
<select
class="form-select"
aria-label="Default select example"
>
<option selected>Select Action</option>
<option value="1">None</option>
<option value="2">Reboot</option>
<option value="3">Switch Sim</option>
</select>
<label class="mt-1">
Current Action: <span x-text="action"></span>
</label>
</div>
</div>
</div>
<div class="card-footer">
Setting a low ping timeout and ping failure count may cause
intermittent disconnections due to high sensitivity. <br />
Select appropriate values for both based on your needs.
</div>
</div>
</div>
</div>
</div>
</main>
<script src="js/dark-mode.js"></script>
<script>
function simpleWatchCat() {
return {
wacthCatStatus: "Enable",
ipDNS: "1.1.1.1",
pingTimeout: "30",
pingFailures: "5",
action: "Reboot",
};
}
</script>
</body>
</html>