diff --git a/frontend/src/sections/devices/cwmp/connecteddevices.js b/frontend/src/sections/devices/cwmp/connecteddevices.js index b7ade81..beafcd0 100644 --- a/frontend/src/sections/devices/cwmp/connecteddevices.js +++ b/frontend/src/sections/devices/cwmp/connecteddevices.js @@ -1,9 +1,115 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; + +import { Card, CardActions, CardContent, CardHeader, CircularProgress, Divider, Grid, InputLabel, MenuItem, Select, SvgIcon, Tooltip, Typography } from "@mui/material"; +import CpuChipIcon from "@heroicons/react/24/solid/CpuChipIcon"; +import { Stack } from "@mui/system"; +import { useTheme } from "@emotion/react"; +import { useRouter } from "next/router"; +import { set } from "nprogress"; export const ConnectedDevices = () => { - return ( -
-

Connected Devices Page

-
+ + const theme = useTheme(); + const router = useRouter(); + + const [content, setContent] = useState(null); + const [interfaces, setInterfaces] = useState([]); + const [interfaceValue, setInterfaceValue] = useState(null); + + const fetchConnectedDevicesData = async () => { + + var myHeaders = new Headers(); + myHeaders.append("Content-Type", "application/json"); + myHeaders.append("Authorization", localStorage.getItem("token")); + + var requestOptions = { + method: 'GET', + headers: myHeaders, + redirect: 'follow' + }; + + fetch(`${process.env.NEXT_PUBLIC_REST_ENDPOINT}/device/${router.query.id[0]}/connecteddevices`, requestOptions) + .then(response => { + if (response.status === 401) { + router.push("/auth/login") + } + return response.json() + }) + .then(result => { + console.log("connecteddevices content", result) + let interfaces = Object.keys(result) + setInterfaces(interfaces) + setInterfaceValue(interfaces[0]) + setContent(result) + }) + .catch(error => console.log('error', error)); + }; + + useEffect(() => { + fetchConnectedDevicesData(); + },[]) + + return ( + + {content && interfaces.length > 0 ? + + + + Interface + + + { + content[interfaceValue].map((property) => ( + + + + + + + + + + + + {property.hostname} + + + + + + IP address: {property.ip_adress} + + + MAC: {property.mac} + + + + + RSSI: {property.rssi} dbm + + + Source: {property.adress_source} + + + + + + + )) + } + + : } + ) } \ No newline at end of file