auto formatting

This commit is contained in:
proddy
2021-05-07 10:15:29 +02:00
parent d15aa79d18
commit c6a40d2125
35 changed files with 633 additions and 570 deletions

View File

@@ -1,57 +1,57 @@
import { Theme } from "@material-ui/core";
import { NetworkStatus, NetworkConnectionStatus } from "./types";
import { Theme } from '@material-ui/core'
import { NetworkStatus, NetworkConnectionStatus } from './types'
export const isConnected = ({ status }: NetworkStatus) => {
return (
status === NetworkConnectionStatus.WIFI_STATUS_CONNECTED ||
status === NetworkConnectionStatus.ETHERNET_STATUS_CONNECTED
);
};
)
}
export const isWiFi = ({ status }: NetworkStatus) =>
status === NetworkConnectionStatus.WIFI_STATUS_CONNECTED;
status === NetworkConnectionStatus.WIFI_STATUS_CONNECTED
export const isEthernet = ({ status }: NetworkStatus) =>
status === NetworkConnectionStatus.ETHERNET_STATUS_CONNECTED;
status === NetworkConnectionStatus.ETHERNET_STATUS_CONNECTED
export const networkStatusHighlight = (
{ status }: NetworkStatus,
theme: Theme
theme: Theme,
) => {
switch (status) {
case NetworkConnectionStatus.WIFI_STATUS_IDLE:
case NetworkConnectionStatus.WIFI_STATUS_DISCONNECTED:
case NetworkConnectionStatus.WIFI_STATUS_NO_SHIELD:
return theme.palette.info.main;
return theme.palette.info.main
case NetworkConnectionStatus.WIFI_STATUS_CONNECTED:
case NetworkConnectionStatus.ETHERNET_STATUS_CONNECTED:
return theme.palette.success.main;
return theme.palette.success.main
case NetworkConnectionStatus.WIFI_STATUS_CONNECT_FAILED:
case NetworkConnectionStatus.WIFI_STATUS_CONNECTION_LOST:
return theme.palette.error.main;
return theme.palette.error.main
default:
return theme.palette.warning.main;
return theme.palette.warning.main
}
};
}
export const networkStatus = ({ status }: NetworkStatus) => {
switch (status) {
case NetworkConnectionStatus.WIFI_STATUS_NO_SHIELD:
return "Inactive";
return 'Inactive'
case NetworkConnectionStatus.WIFI_STATUS_IDLE:
return "Idle";
return 'Idle'
case NetworkConnectionStatus.WIFI_STATUS_NO_SSID_AVAIL:
return "No SSID Available";
return 'No SSID Available'
case NetworkConnectionStatus.WIFI_STATUS_CONNECTED:
return "Connected (WiFi)";
return 'Connected (WiFi)'
case NetworkConnectionStatus.ETHERNET_STATUS_CONNECTED:
return "Connected (Ethernet)";
return 'Connected (Ethernet)'
case NetworkConnectionStatus.WIFI_STATUS_CONNECT_FAILED:
return "Connection Failed";
return 'Connection Failed'
case NetworkConnectionStatus.WIFI_STATUS_CONNECTION_LOST:
return "Connection Lost";
return 'Connection Lost'
case NetworkConnectionStatus.WIFI_STATUS_DISCONNECTED:
return "Disconnected";
return 'Disconnected'
default:
return "Unknown";
return 'Unknown'
}
};
}

View File

@@ -1,22 +1,23 @@
import { WiFiNetwork, WiFiEncryptionType } from "./types";
import { WiFiNetwork, WiFiEncryptionType } from './types'
export const isNetworkOpen = ({ encryption_type }: WiFiNetwork) => encryption_type === WiFiEncryptionType.WIFI_AUTH_OPEN;
export const isNetworkOpen = ({ encryption_type }: WiFiNetwork) =>
encryption_type === WiFiEncryptionType.WIFI_AUTH_OPEN
export const networkSecurityMode = ({ encryption_type }: WiFiNetwork) => {
switch (encryption_type) {
case WiFiEncryptionType.WIFI_AUTH_WEP:
return "WEP";
return 'WEP'
case WiFiEncryptionType.WIFI_AUTH_WPA_PSK:
return "WPA";
return 'WPA'
case WiFiEncryptionType.WIFI_AUTH_WPA2_PSK:
return "WPA2";
return 'WPA2'
case WiFiEncryptionType.WIFI_AUTH_WPA_WPA2_PSK:
return "WPA/WPA2";
return 'WPA/WPA2'
case WiFiEncryptionType.WIFI_AUTH_WPA2_ENTERPRISE:
return "WPA2 Enterprise";
return 'WPA2 Enterprise'
case WiFiEncryptionType.WIFI_AUTH_OPEN:
return "None";
return 'None'
default:
return "Unknown";
return 'Unknown'
}
}

View File

@@ -6,7 +6,7 @@ export enum NetworkConnectionStatus {
WIFI_STATUS_CONNECTION_LOST = 5,
WIFI_STATUS_DISCONNECTED = 6,
ETHERNET_STATUS_CONNECTED = 10,
WIFI_STATUS_NO_SHIELD = 255
WIFI_STATUS_NO_SHIELD = 255,
}
export enum WiFiEncryptionType {
@@ -15,43 +15,43 @@ export enum WiFiEncryptionType {
WIFI_AUTH_WPA_PSK = 2,
WIFI_AUTH_WPA2_PSK = 3,
WIFI_AUTH_WPA_WPA2_PSK = 4,
WIFI_AUTH_WPA2_ENTERPRISE = 5
WIFI_AUTH_WPA2_ENTERPRISE = 5,
}
export interface NetworkStatus {
status: NetworkConnectionStatus;
local_ip: string;
mac_address: string;
rssi: number;
ssid: string;
bssid: string;
channel: number;
subnet_mask: string;
gateway_ip: string;
dns_ip_1: string;
dns_ip_2: string;
status: NetworkConnectionStatus
local_ip: string
mac_address: string
rssi: number
ssid: string
bssid: string
channel: number
subnet_mask: string
gateway_ip: string
dns_ip_1: string
dns_ip_2: string
}
export interface NetworkSettings {
ssid: string;
password: string;
hostname: string;
static_ip_config: boolean;
local_ip?: string;
gateway_ip?: string;
subnet_mask?: string;
dns_ip_1?: string;
dns_ip_2?: string;
ssid: string
password: string
hostname: string
static_ip_config: boolean
local_ip?: string
gateway_ip?: string
subnet_mask?: string
dns_ip_1?: string
dns_ip_2?: string
}
export interface WiFiNetworkList {
networks: WiFiNetwork[];
networks: WiFiNetwork[]
}
export interface WiFiNetwork {
rssi: number;
ssid: string;
bssid: string;
channel: number;
encryption_type: WiFiEncryptionType;
rssi: number
ssid: string
bssid: string
channel: number
encryption_type: WiFiEncryptionType
}