Finished Extend Wireless, Made minor tweaks

This commit is contained in:
Patrick Hatsune 2024-08-12 09:43:12 -07:00
parent ac24e02935
commit 4c31663182
Signed by: keyemail
GPG key ID: 6FD1A0FDB0D914C2
9 changed files with 288 additions and 72 deletions

View file

@ -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() {
/>
}
/>
<Route path="/devices" element={<Devices />} />
<Route path="/extend" element={<Extend />} />
<Route
path="/devices"
element={
<Devices
deviceNames={deviceNames}
deviceIPs={deviceIPs}
setDevice={setDeviceNames}
setDeviceIP={setDeviceIPs}
/>
}
/>
<Route
path="/extend"
element={
<Extend
selectedModeButton={selectedModeButton}
setSelecModeButton={setSelectedModeButton}
extendedMode={extenderMode}
setExtendedMode={setExtenderMode}
connected={connected}
setConnected={setConnected}
/>
}
/>
<Route path="/wireless" element={<WirelessSettings />} />
<Route path="/settings" element={<SystemSettings />} />
<Route

View file

@ -1,47 +1,56 @@
import { useState } from "react";
import Device from '../assets/device.png'
import '../styles/DeviceList.css'
import { Dispatch, SetStateAction } from "react";
import Device from "../assets/device.png";
import "../styles/DeviceList.css";
function DeviceList() {
let [deviceNames, setDeviceNames] = useState(["My PC", "My Smartphone", "My Smartfridge", "My Watch", "My Remote", "My TV"]);
let [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"]);
interface Props {
deviceNames: string[];
deviceIPs: string[];
setDevice: Dispatch<SetStateAction<string[]>>;
setDeviceIP: Dispatch<SetStateAction<string[]>>;
}
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);
setDeviceNames(newDeviceNames);
setDeviceIPs(newDeviceIPs);
}
setDevice(newDeviceNames);
setDeviceIP(newDeviceIPs);
};
return (
<div id="deviceList">
<h2>Device list</h2>
{deviceNames.length === 0 && <p>No devices are connected.</p>}
<ul id="devices">
{ deviceNames.map((device, index) =>
{deviceNames.map((device, index) => (
<li>
<img src={Device} />
<div>
<h3>{device}</h3>
<p>{deviceIPs[index]}</p>
</div>
<svg onClick={ () => removeDevice(index) } className="close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
<svg
onClick={() => removeDevice(index)}
className="close"
viewBox="0 0 384 512"
>
<path
fill="currentColor"
d="M376.6 84.5c11.3-13.6 9.5-33.8-4.1-45.1s-33.8-9.5-45.1 4.1L192 206 56.6 43.5C45.3 29.9 25.1 28.1 11.5 39.4S-3.9 70.9 7.4 84.5L150.3 256 7.4 427.5c-11.3 13.6-9.5 33.8 4.1 45.1s33.8 9.5 45.1-4.1L192 306 327.4 468.5c11.3 13.6 31.5 15.4 45.1 4.1s15.4-31.5 4.1-45.1L233.7 256 376.6 84.5z"
fill="none"
stroke="currentColor"
stroke-width="64"
stroke-linecap="round"
d="M32 64 352 448m0-384L32 448"
/>
</svg>
</li>
)
}
))}
</ul>
</div>
)
);
}
export default DeviceList;

View file

@ -1,5 +1,85 @@
function ExtendWirelessNetwork() {
return <p>Extend Wireless Network</p>
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<SetStateAction<number>>;
extendedMode: boolean;
setExtendedMode: Dispatch<SetStateAction<boolean>>;
connected: number;
setConnected: Dispatch<SetStateAction<number>>;
}
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 (
<div id="extendNetwork">
<h2>Extend Network</h2>
<div id="modeButton">
{buttons.map((button, index) => (
<button
className={selectedModeButton === index ? "modeButonActive" : ""}
onClick={() => {
setSelecModeButton(index);
setExtendedMode(buttons[index] === "Extend Mode");
}}
>
{button}
</button>
))}
</div>
{extendedMode ? (
<ul id="signalList">
{wifiNames.map((wifi, index) => (
<li>
<img src={wifiSignalImages[wifiSignals[index] - 1]} />
<div>
<h3>{wifi}</h3>
{index === connected ? <p>Connected</p> : <p>Unknown</p>}
</div>
<svg
className="link"
onClick={() => setConnected(index)}
viewBox="0 0 640 512"
>
<path
stroke="currentColor"
stroke-width="64"
stroke-linecap="round"
d="M230 437A114 112-4 0184 266L200 150A113 112-4 01365 301M410 75A114 112 176 01556 246L440 362A113 112 176 01275 211"
/>
</svg>
</li>
))}
</ul>
) : (
<p id="APMode">On AP Mode.</p>
)}
</div>
);
}
export default ExtendWirelessNetwork;

View file

@ -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<SetStateAction<boolean>>;
@ -13,10 +13,10 @@ 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();
@ -26,8 +26,8 @@ function Login({ setLogin, setUser }: Props) {
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]) {

View file

@ -1,5 +1,5 @@
function SystemSettings() {
return <p></p>
return <p>System Settings</p>;
}
export default SystemSettings;

View file

@ -1,5 +1,5 @@
function WirelessName() {
return <p>Wireless Name??????????</p>
return <p>Wireless Name</p>;
}
export default WirelessName;

View file

@ -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;
}
}

View file

@ -1,11 +1,3 @@
body {
height: 100vh;
}
#root {
height: 100%;
}
#login {
display: flex;
align-items: center;

View file

@ -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;