diff --git a/src/Index.tsx b/src/Index.tsx index edb57ef..27c1d70 100644 --- a/src/Index.tsx +++ b/src/Index.tsx @@ -11,14 +11,39 @@ import Navbar from "./components/Navbar"; import "./styles/Main.css"; function Index() { - let [loginState, setLoginState] = useState(false); - let [loggedUser, setLoggedUser] = useState(""); + const [loginState, setLoginState] = useState(false); + const [loggedUser, setLoggedUser] = useState(""); - let [routerName, setRoutername] = useState("Example Router"); - let [twoGExtendedName, settwoGExtendedName] = useState("Example 2G Network"); - let [fiveGExtendedName, setFiveGExtendedName] = - useState("Example 5G Network"); - let [devicesOnline, setDevicesOnline] = useState(0); + const [deviceNames, setDeviceNames] = useState([ + "My PC", + "My Smartphone", + "My Smartfridge", + "My Watch", + "My Remote", + "My TV", + ]); + const [deviceIPs, setDeviceIPs] = useState([ + "10.0.0.2", + "10.0.0.3", + "10.0.0.4", + "10.0.0.5", + "10.0.0.6", + "10.0.0.7", + ]); + + const [routerName, setRouterName] = useState("Example Router"); + const [twoGExtendedName, setTwoGExtendedName] = useState( + "Example 2.4GHz Network", + ); + const [fiveGExtendedName, setFiveGExtendedName] = useState( + "Example 5GHz Network", + ); + const [devicesOnline, setDevicesOnline] = useState(0); + + const [extenderMode, setExtenderMode] = useState(false); + const [connected, setConnected] = useState(-1); + + const [selectedModeButton, setSelectedModeButton] = useState(0); const navigate = useNavigate(); @@ -26,10 +51,8 @@ function Index() { if (!loginState) { navigate("/login"); } - if (loggedUser === "") { - setLoggedUser("Not Logged In"); - } - }, [loginState, setLoggedUser]); + setDevicesOnline(deviceNames.length); + }, [loginState, navigate, setLoggedUser, deviceNames]); return ( <> @@ -46,8 +69,30 @@ function Index() { /> } /> - } /> - } /> + + } + /> + + } + /> } /> } /> >; + setDeviceIP: Dispatch>; +} +function DeviceList({ deviceNames, deviceIPs, setDevice, setDeviceIP }: Props) { const removeDevice = (index: number) => { - const newDeviceNames = [...deviceNames]; - const newDeviceIPs = [...deviceIPs]; + const newDeviceNames = deviceNames.slice(); + const newDeviceIPs = deviceIPs.slice(); newDeviceNames.splice(index, 1); - newDeviceIPs.splice(index,1); + newDeviceIPs.splice(index, 1); + + setDevice(newDeviceNames); + setDeviceIP(newDeviceIPs); + }; - setDeviceNames(newDeviceNames); - setDeviceIPs(newDeviceIPs); - } - return (

Device list

- { deviceNames.length === 0 &&

No devices are connected.

} + {deviceNames.length === 0 &&

No devices are connected.

}
    - { deviceNames.map((device, index) => -
  • - -
    -

    { device }

    -

    { deviceIPs[index] }

    -
    - removeDevice(index) } className="close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"> - - -
  • - ) - } + {deviceNames.map((device, index) => ( +
  • + +
    +

    {device}

    +

    {deviceIPs[index]}

    +
    + removeDevice(index)} + className="close" + viewBox="0 0 384 512" + > + + +
  • + ))}
- ) + ); } -export default DeviceList; \ No newline at end of file +export default DeviceList; diff --git a/src/pages/ExtendWirelessNetwork.tsx b/src/pages/ExtendWirelessNetwork.tsx index d068d35..501d895 100644 --- a/src/pages/ExtendWirelessNetwork.tsx +++ b/src/pages/ExtendWirelessNetwork.tsx @@ -1,5 +1,85 @@ -function ExtendWirelessNetwork() { - return

Extend Wireless Network

+import { Dispatch, SetStateAction } from "react"; +import VeryLowSignal from "../assets/very_low_signal.png"; +import LowSignal from "../assets/low_signal.png"; +import MediumSignal from "../assets/medium_signal.png"; +import HighSignal from "../assets/high_signal.png"; +import "../styles/ExtendWirelessNetwork.css"; + +interface Props { + selectedModeButton: number; + setSelecModeButton: Dispatch>; + extendedMode: boolean; + setExtendedMode: Dispatch>; + connected: number; + setConnected: Dispatch>; } -export default ExtendWirelessNetwork; \ No newline at end of file +function ExtendWirelessNetwork({ + selectedModeButton, + setSelecModeButton, + extendedMode, + setExtendedMode, + connected, + setConnected, +}: Props) { + const buttons = ["AP Mode", "Extend Mode"]; + const wifiNames = [ + "Wifi 1", + "Wifi 2", + "Wifi 3", + "Wifi 4", + "Wifi 5", + "Wifi 6", + ]; + const wifiSignals = [4, 3, 1, 2, 1, 2]; + const wifiSignalImages = [VeryLowSignal, LowSignal, MediumSignal, HighSignal]; + + return ( +
+

Extend Network

+
+ {buttons.map((button, index) => ( + + ))} +
+ + {extendedMode ? ( +
    + {wifiNames.map((wifi, index) => ( +
  • + +
    +

    {wifi}

    + {index === connected ?

    Connected

    :

    Unknown

    } +
    + setConnected(index)} + viewBox="0 0 640 512" + > + + +
  • + ))} +
+ ) : ( +

On AP Mode.

+ )} +
+ ); +} + +export default ExtendWirelessNetwork; diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index 2d02564..72b1f3b 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -2,8 +2,8 @@ import { Dispatch, SetStateAction, useState } from 'react'; import { useNavigate, Link } from 'react-router-dom'; import '../styles/Login.css' -let usernames = ['root']; -let passwords = ['123', 'hello']; +const usernames = ['root']; +const passwords = ['123']; interface Props { setLogin: Dispatch>; @@ -13,21 +13,21 @@ interface Props { function Login({ setLogin, setUser }: Props) { const navigate = useNavigate(); - let [usernameError, setUsernameError] = useState(false); - let [passwordError, setPasswordError] = useState(false); + const [usernameError, setUsernameError] = useState(false); + const [passwordError, setPasswordError] = useState(false); - setUser(''); + setUser('Not Logged In'); const handleLogin = (e: React.FormEvent) => { e.preventDefault(); const userElement = document.getElementById('username') as HTMLInputElement | null; const passwordElement = document.getElementById('password') as HTMLInputElement | null; - + if(!userElement || !passwordElement) return; - let user = userElement?.value; - let password = passwordElement?.value; + const user = userElement?.value; + const password = passwordElement?.value; for (let i = 0; i < usernames.length; i++) { if(user === usernames[i] && password === passwords[i]) { @@ -50,13 +50,13 @@ function Login({ setLogin, setUser }: Props) {

Username

- { passwordError && + { passwordError &&

Wrong username.

}

Password

- { usernameError && + { usernameError &&

Wrong password.

}

Forgot password? Reset it

@@ -67,4 +67,4 @@ function Login({ setLogin, setUser }: Props) { ) } -export default Login; \ No newline at end of file +export default Login; diff --git a/src/pages/SystemSettings.tsx b/src/pages/SystemSettings.tsx index ece2db8..2d8eb42 100644 --- a/src/pages/SystemSettings.tsx +++ b/src/pages/SystemSettings.tsx @@ -1,5 +1,5 @@ function SystemSettings() { - return

+ return

System Settings

; } -export default SystemSettings; \ No newline at end of file +export default SystemSettings; diff --git a/src/pages/WirelessSettings.tsx b/src/pages/WirelessSettings.tsx index ee834b4..2bec647 100644 --- a/src/pages/WirelessSettings.tsx +++ b/src/pages/WirelessSettings.tsx @@ -1,5 +1,5 @@ function WirelessName() { - return

Wireless Name??????????

+ return

Wireless Name

; } -export default WirelessName; \ No newline at end of file +export default WirelessName; diff --git a/src/styles/ExtendWirelessNetwork.css b/src/styles/ExtendWirelessNetwork.css index e69de29..3e896b2 100644 --- a/src/styles/ExtendWirelessNetwork.css +++ b/src/styles/ExtendWirelessNetwork.css @@ -0,0 +1,85 @@ +#extendNetwork { + background-color: var(--bg-color-alt); + margin-top: 20px; + border-radius: 20px; + padding: 20px; + height: calc(100% - 50px); + overflow: scroll; + + h2 { + font-size: 2.5rem; + text-align: center; + } + button { + background-color: #071436; + color: white; + border: none; + cursor: pointer; + height: 50px; + width: 80px; + border-radius: 10px; + transition: 0.3s background-color; + } + button:hover { + background-color: #0069ff; + } + #modeButton { + margin-top: 20px; + display: flex; + justify-content: center; + gap: 20px; + } + #APMode { + margin-top: 60px; + font-size: 2rem; + text-align: center; + } + .modeButonActive { + background-color: #0069ff; + } +} + +#signalList { + list-style: none; + display: flex; + flex-direction: column; + gap: 20px; + margin-top: 20px; + + li { + display: inherit; + background-color: #071436; + padding: 30px 20px; + border-radius: 20px; + justify-content: space-between; + align-items: center; + } + h3 { + font-size: 1.8rem; + width: fit-content; + } + p { + font-size: 1.3rem; + width: fit-content; + } + div { + display: inherit; + flex-direction: column; + text-align: center; + margin: 0 20px; + position: relative; + width: 100%; + } + img { + max-width: 100px; + } + .link { + max-width: 50px; + cursor: pointer; + color: #fff; + transition: 0.3s color; + } + .link:hover { + color: #0069ff; + } +} diff --git a/src/styles/Login.css b/src/styles/Login.css index 5966d73..9514bf9 100644 --- a/src/styles/Login.css +++ b/src/styles/Login.css @@ -1,11 +1,3 @@ -body { - height: 100vh; -} - -#root { - height: 100%; -} - #login { display: flex; align-items: center; diff --git a/src/styles/Main.css b/src/styles/Main.css index 2d7572d..ce7372e 100644 --- a/src/styles/Main.css +++ b/src/styles/Main.css @@ -25,6 +25,7 @@ body { color: #fff; padding: 20px; font-family: 'Poppins', sans-serif; + height: 100vh; } a { @@ -32,6 +33,10 @@ a { text-decoration: none; } +#root { + height: 100%; +} + #topNav { display: flex; justify-content: space-between;