Show network status (WiFi/Ethernet) in network info view

This commit is contained in:
Thomas Basler 2022-07-20 19:21:31 +02:00
parent 63ccf38250
commit 608912e9f3
4 changed files with 32 additions and 29 deletions

View File

@ -31,13 +31,14 @@ void WebApiNetworkClass::onNetworkStatus(AsyncWebServerRequest* request)
root[F("sta_status")] = ((WiFi.getMode() & WIFI_STA) != 0); root[F("sta_status")] = ((WiFi.getMode() & WIFI_STA) != 0);
root[F("sta_ssid")] = WiFi.SSID(); root[F("sta_ssid")] = WiFi.SSID();
root[F("sta_ip")] = NetworkSettings.localIP().toString();
root[F("sta_netmask")] = NetworkSettings.subnetMask().toString();
root[F("sta_gateway")] = NetworkSettings.gatewayIP().toString();
root[F("sta_dns1")] = NetworkSettings.dnsIP(0).toString();
root[F("sta_dns2")] = NetworkSettings.dnsIP(1).toString();
root[F("sta_mac")] = NetworkSettings.macAddress();
root[F("sta_rssi")] = WiFi.RSSI(); root[F("sta_rssi")] = WiFi.RSSI();
root[F("network_ip")] = NetworkSettings.localIP().toString();
root[F("network_netmask")] = NetworkSettings.subnetMask().toString();
root[F("network_gateway")] = NetworkSettings.gatewayIP().toString();
root[F("network_dns1")] = NetworkSettings.dnsIP(0).toString();
root[F("network_dns2")] = NetworkSettings.dnsIP(1).toString();
root[F("network_mac")] = NetworkSettings.macAddress();
root[F("network_mode")] = NetworkSettings.NetworkMode() == network_mode::WiFi ? F("Station") : F("Ethernet");
root[F("ap_status")] = ((WiFi.getMode() & WIFI_AP) != 0); root[F("ap_status")] = ((WiFi.getMode() & WIFI_AP) != 0);
root[F("ap_ssid")] = NetworkSettings.getApName(); root[F("ap_ssid")] = NetworkSettings.getApName();
root[F("ap_ip")] = WiFi.softAPIP().toString(); root[F("ap_ip")] = WiFi.softAPIP().toString();

View File

@ -14,7 +14,7 @@
<div class="mt-5"></div> <div class="mt-5"></div>
<WifiApInfo v-bind="networkDataList" /> <WifiApInfo v-bind="networkDataList" />
<div class="mt-5"></div> <div class="mt-5"></div>
<InterfaceStationInfo v-bind="networkDataList" /> <InterfaceNetworkInfo v-bind="networkDataList" />
<div class="mt-5"></div> <div class="mt-5"></div>
<InterfaceApInfo v-bind="networkDataList" /> <InterfaceApInfo v-bind="networkDataList" />
<div class="mt-5"></div> <div class="mt-5"></div>
@ -26,14 +26,14 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import WifiStationInfo from "./partials/WifiStationInfo.vue"; import WifiStationInfo from "./partials/WifiStationInfo.vue";
import WifiApInfo from "./partials/WifiApInfo.vue"; import WifiApInfo from "./partials/WifiApInfo.vue";
import InterfaceStationInfo from "./partials/InterfaceStationInfo.vue"; import InterfaceNetworkInfo from "./partials/InterfaceNetworkInfo.vue";
import InterfaceApInfo from "./partials/InterfaceApInfo.vue"; import InterfaceApInfo from "./partials/InterfaceApInfo.vue";
export default defineComponent({ export default defineComponent({
components: { components: {
WifiStationInfo, WifiStationInfo,
WifiApInfo, WifiApInfo,
InterfaceStationInfo, InterfaceNetworkInfo,
InterfaceApInfo, InterfaceApInfo,
}, },
data() { data() {
@ -48,13 +48,14 @@ export default defineComponent({
ap_status: false, ap_status: false,
ap_ssid: "", ap_ssid: "",
ap_stationnum: 0, ap_stationnum: 0,
// InterfaceStationInfo // InterfaceNetworkInfo
sta_ip: "", network_ip: "",
sta_netmask: "", network_netmask: "",
sta_gateway: "", network_gateway: "",
sta_dns1: "", network_dns1: "",
sta_dns2: "", network_dns2: "",
sta_mac: "", network_mac: "",
network_mode: "",
// InterfaceApInfo // InterfaceApInfo
ap_ip: "", ap_ip: "",
ap_mac: "", ap_mac: "",

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="card"> <div class="card">
<div class="card-header text-white bg-primary"> <div class="card-header text-white bg-primary">
Network Interface (Station) Network Interface ({{ network_mode }})
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive">
@ -9,27 +9,27 @@
<tbody> <tbody>
<tr> <tr>
<th>IP Address</th> <th>IP Address</th>
<td>{{ sta_ip }}</td> <td>{{ network_ip }}</td>
</tr> </tr>
<tr> <tr>
<th>Netmask</th> <th>Netmask</th>
<td>{{ sta_netmask }}</td> <td>{{ network_netmask }}</td>
</tr> </tr>
<tr> <tr>
<th>Default Gateway</th> <th>Default Gateway</th>
<td>{{ sta_gateway }}</td> <td>{{ network_gateway }}</td>
</tr> </tr>
<tr> <tr>
<th>DNS 1</th> <th>DNS 1</th>
<td>{{ sta_dns1 }}</td> <td>{{ network_dns1 }}</td>
</tr> </tr>
<tr> <tr>
<th>DNS 2</th> <th>DNS 2</th>
<td>{{ sta_dns2 }}</td> <td>{{ network_dns2 }}</td>
</tr> </tr>
<tr> <tr>
<th>MAC Address</th> <th>MAC Address</th>
<td>{{ sta_mac }}</td> <td>{{ network_mac }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -43,12 +43,13 @@ import { defineComponent } from 'vue';
export default defineComponent({ export default defineComponent({
props: { props: {
sta_ip: String, network_ip: String,
sta_netmask: String, network_netmask: String,
sta_gateway: String, network_gateway: String,
sta_dns1: String, network_dns1: String,
sta_dns2: String, network_dns2: String,
sta_mac: String, network_mac: String,
network_mode: String,
}, },
}); });
</script> </script>

Binary file not shown.