feat(ui): add WiFi/network info to self-test
Add informational network status check at the beginning of self-test: - Shows connection mode (Hotspot, WiFi, or Ethernet) - Displays SSID/connection name - Shows IP address and hostname.local - Add wifi_status endpoint in launcher.php using nmcli Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -542,6 +542,53 @@ if ($type == "linux_memory") {
|
|||||||
echo $output;
|
echo $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type == "wifi_status") {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$result = array(
|
||||||
|
'connected' => false,
|
||||||
|
'mode' => 'unknown',
|
||||||
|
'ssid' => '',
|
||||||
|
'ip' => '',
|
||||||
|
'hostname' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get hostname
|
||||||
|
$result['hostname'] = trim(shell_exec('hostname'));
|
||||||
|
|
||||||
|
// Get wlan0 connection info
|
||||||
|
$connection = trim(shell_exec("nmcli -t -f GENERAL.CONNECTION device show wlan0 2>/dev/null | cut -d: -f2"));
|
||||||
|
|
||||||
|
if (!empty($connection) && $connection != '--') {
|
||||||
|
$result['connected'] = true;
|
||||||
|
$result['ssid'] = $connection;
|
||||||
|
|
||||||
|
// Check if it's a hotspot
|
||||||
|
if (strpos(strtolower($connection), 'hotspot') !== false || strpos($connection, 'nebuleair') !== false) {
|
||||||
|
$result['mode'] = 'hotspot';
|
||||||
|
} else {
|
||||||
|
$result['mode'] = 'wifi';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get IP address
|
||||||
|
$ip = trim(shell_exec("nmcli -t -f IP4.ADDRESS device show wlan0 2>/dev/null | head -1 | cut -d: -f2 | cut -d/ -f1"));
|
||||||
|
if (!empty($ip)) {
|
||||||
|
$result['ip'] = $ip;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Check if eth0 is connected
|
||||||
|
$eth_ip = trim(shell_exec("nmcli -t -f IP4.ADDRESS device show eth0 2>/dev/null | head -1 | cut -d: -f2 | cut -d/ -f1"));
|
||||||
|
if (!empty($eth_ip)) {
|
||||||
|
$result['connected'] = true;
|
||||||
|
$result['mode'] = 'ethernet';
|
||||||
|
$result['ssid'] = 'Ethernet';
|
||||||
|
$result['ip'] = $eth_ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($result);
|
||||||
|
}
|
||||||
|
|
||||||
if ($type == "sshTunnel") {
|
if ($type == "sshTunnel") {
|
||||||
$ssh_port=$_GET['ssh_port'];
|
$ssh_port=$_GET['ssh_port'];
|
||||||
$command = 'sudo ssh -i /var/www/.ssh/id_rsa -f -N -R "'.$ssh_port.':localhost:22" -p 50221 -o StrictHostKeyChecking=no "airlab_server1@aircarto.fr"';
|
$command = 'sudo ssh -i /var/www/.ssh/id_rsa -f -N -R "'.$ssh_port.':localhost:22" -p 50221 -o StrictHostKeyChecking=no "airlab_server1@aircarto.fr"';
|
||||||
|
|||||||
@@ -375,6 +375,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="list-group" id="selftest_results">
|
<div class="list-group" id="selftest_results">
|
||||||
|
<!-- Info: WiFi Status -->
|
||||||
|
<div class="list-group-item d-flex justify-content-between align-items-center" id="test_wifi">
|
||||||
|
<div>
|
||||||
|
<strong>WiFi / Network</strong>
|
||||||
|
<div class="small text-muted" id="test_wifi_detail">Waiting...</div>
|
||||||
|
</div>
|
||||||
|
<span id="test_wifi_status" class="badge bg-secondary">Pending</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Test 1: Modem Connection -->
|
<!-- Test 1: Modem Connection -->
|
||||||
<div class="list-group-item d-flex justify-content-between align-items-center" id="test_modem">
|
<div class="list-group-item d-flex justify-content-between align-items-center" id="test_modem">
|
||||||
<div>
|
<div>
|
||||||
@@ -1511,6 +1520,10 @@ function resetSelfTestUI() {
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
// Reset test items
|
// Reset test items
|
||||||
|
document.getElementById('test_wifi_status').className = 'badge bg-secondary';
|
||||||
|
document.getElementById('test_wifi_status').textContent = 'Pending';
|
||||||
|
document.getElementById('test_wifi_detail').textContent = 'Waiting...';
|
||||||
|
|
||||||
document.getElementById('test_modem_status').className = 'badge bg-secondary';
|
document.getElementById('test_modem_status').className = 'badge bg-secondary';
|
||||||
document.getElementById('test_modem_status').textContent = 'Pending';
|
document.getElementById('test_modem_status').textContent = 'Pending';
|
||||||
document.getElementById('test_modem_detail').textContent = 'Waiting...';
|
document.getElementById('test_modem_detail').textContent = 'Waiting...';
|
||||||
@@ -1605,6 +1618,62 @@ async function selfTestSequence() {
|
|||||||
let testsFailed = 0;
|
let testsFailed = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Step 0: Check WiFi / Network status (informational, no pass/fail)
|
||||||
|
document.getElementById('selftest_status').innerHTML = `
|
||||||
|
<div class="d-flex align-items-center text-primary">
|
||||||
|
<div class="spinner-border spinner-border-sm me-2" role="status"></div>
|
||||||
|
<span>Checking network status...</span>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
updateTestStatus('wifi', 'Checking...', 'Getting network info...', 'bg-info');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const wifiResponse = await new Promise((resolve, reject) => {
|
||||||
|
$.ajax({
|
||||||
|
url: 'launcher.php?type=wifi_status',
|
||||||
|
dataType: 'json',
|
||||||
|
method: 'GET',
|
||||||
|
success: function(data) {
|
||||||
|
addSelfTestLog(`WiFi status: ${JSON.stringify(data)}`);
|
||||||
|
resolve(data);
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
addSelfTestLog(`WiFi status error: ${error}`);
|
||||||
|
reject(new Error(error));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (wifiResponse.connected) {
|
||||||
|
let modeIcon = '';
|
||||||
|
let modeLabel = '';
|
||||||
|
let badgeClass = 'bg-info';
|
||||||
|
|
||||||
|
if (wifiResponse.mode === 'hotspot') {
|
||||||
|
modeIcon = '📡';
|
||||||
|
modeLabel = 'Hotspot';
|
||||||
|
badgeClass = 'bg-warning text-dark';
|
||||||
|
} else if (wifiResponse.mode === 'wifi') {
|
||||||
|
modeIcon = '📶';
|
||||||
|
modeLabel = 'WiFi';
|
||||||
|
badgeClass = 'bg-info';
|
||||||
|
} else if (wifiResponse.mode === 'ethernet') {
|
||||||
|
modeIcon = '🔌';
|
||||||
|
modeLabel = 'Ethernet';
|
||||||
|
badgeClass = 'bg-info';
|
||||||
|
}
|
||||||
|
|
||||||
|
const detailText = `${wifiResponse.ssid} | ${wifiResponse.ip} | ${wifiResponse.hostname}.local`;
|
||||||
|
updateTestStatus('wifi', modeLabel, detailText, badgeClass);
|
||||||
|
} else {
|
||||||
|
updateTestStatus('wifi', 'Disconnected', 'No network connection', 'bg-secondary');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
updateTestStatus('wifi', 'Error', error.message, 'bg-secondary');
|
||||||
|
}
|
||||||
|
|
||||||
|
await delay(500);
|
||||||
|
|
||||||
// Step 1: Enable config mode
|
// Step 1: Enable config mode
|
||||||
document.getElementById('selftest_status').innerHTML = `
|
document.getElementById('selftest_status').innerHTML = `
|
||||||
<div class="d-flex align-items-center text-primary">
|
<div class="d-flex align-items-center text-primary">
|
||||||
|
|||||||
Reference in New Issue
Block a user