diff --git a/pkgs/ui/.eslintrc.json b/pkgs/ui/.eslintrc.json index a0af9f6f..557e54a8 100644 --- a/pkgs/ui/.eslintrc.json +++ b/pkgs/ui/.eslintrc.json @@ -1,4 +1,5 @@ { "root": true, - "extends": ["next/core-web-vitals", "plugin:tailwindcss/recommended"] + "extends": ["next/core-web-vitals", "plugin:tailwindcss/recommended"], + "ignorePatterns": ["**/src/api/*"] } diff --git a/pkgs/ui/orval.config.ts b/pkgs/ui/orval.config.ts index 55246985..db48112c 100644 --- a/pkgs/ui/orval.config.ts +++ b/pkgs/ui/orval.config.ts @@ -2,8 +2,8 @@ const config = { petstore: { output: { mode: "tags-split", - target: "api", - schemas: "api/model", + target: "src/api", + schemas: "src/api/model", client: "swr", // mock: true, }, diff --git a/pkgs/ui/src/app/layout.tsx b/pkgs/ui/src/app/layout.tsx index 972e85e1..ec03ba89 100644 --- a/pkgs/ui/src/app/layout.tsx +++ b/pkgs/ui/src/app/layout.tsx @@ -20,6 +20,7 @@ import MenuIcon from "@mui/icons-material/Menu"; import Image from "next/image"; import { tw } from "@/utils/tailwind"; import axios from "axios"; +import { MachineContextProvider } from "@/components/hooks/useMachines"; const roboto = localFont({ src: [ @@ -81,45 +82,47 @@ export default function RootLayout({ -
- setShowSidebar(false)} - /> -
-
-
-
- -
-
- Clan Logo + +
+ setShowSidebar(false)} + /> +
+
+
+
+ +
+
+ Clan Logo +
-
-
-
-
{children}
+
+
+
{children}
+
-
+
diff --git a/pkgs/ui/src/app/nodes/add/page.tsx b/pkgs/ui/src/app/machines/add/page.tsx similarity index 100% rename from pkgs/ui/src/app/nodes/add/page.tsx rename to pkgs/ui/src/app/machines/add/page.tsx diff --git a/pkgs/ui/src/app/machines/edit/[name]/page.tsx b/pkgs/ui/src/app/machines/edit/[name]/page.tsx new file mode 100644 index 00000000..ca995d4d --- /dev/null +++ b/pkgs/ui/src/app/machines/edit/[name]/page.tsx @@ -0,0 +1,10 @@ +interface DeviceEditProps { + params: { name: string }; +} + +export default function EditDevice(props: DeviceEditProps) { + const { + params: { name }, + } = props; + return
{name}
; +} diff --git a/pkgs/ui/src/app/nodes/page.tsx b/pkgs/ui/src/app/machines/page.tsx similarity index 54% rename from pkgs/ui/src/app/nodes/page.tsx rename to pkgs/ui/src/app/machines/page.tsx index 6a250f29..964d6348 100644 --- a/pkgs/ui/src/app/nodes/page.tsx +++ b/pkgs/ui/src/app/machines/page.tsx @@ -1,12 +1,13 @@ "use client"; -import NodeTable from "./NodeTable"; - -import Box from "@mui/material/Box"; import { tableData } from "@/data/nodeDataStatic"; import { StrictMode } from "react"; +import { NodeTable } from "@/components/table"; +import { useMachines } from "@/components/hooks/useMachines"; export default function Page() { + const { data, isLoading } = useMachines(); + console.log({ data, isLoading }); return ( diff --git a/pkgs/ui/src/app/nodes/EnhancedTableToolbar.tsx b/pkgs/ui/src/app/nodes/EnhancedTableToolbar.tsx deleted file mode 100644 index 4f921e65..00000000 --- a/pkgs/ui/src/app/nodes/EnhancedTableToolbar.tsx +++ /dev/null @@ -1,194 +0,0 @@ -"use client"; - -import * as React from "react"; -import Box from "@mui/material/Box"; -import Toolbar from "@mui/material/Toolbar"; -import Typography from "@mui/material/Typography"; -import FormControlLabel from "@mui/material/FormControlLabel"; -import Switch from "@mui/material/Switch"; -import Stack from "@mui/material/Stack/Stack"; -import NodePieChart from "./NodePieChart"; - -import Grid2 from "@mui/material/Unstable_Grid2"; // Grid version 2 -import { Card, CardContent, FormGroup, useTheme } from "@mui/material"; -import hexRgb from "hex-rgb"; -import useMediaQuery from "@mui/material/useMediaQuery"; -import { NodeStatus, TableData } from "@/data/nodeData"; - -interface EnhancedTableToolbarProps { - tableData: TableData[]; -} - -function PieCardData(props: { pieData: PieData[]; debugSx: any }) { - const { pieData, debugSx } = props; - - const cardData = React.useMemo(() => { - return pieData - .filter((pieItem) => pieItem.value > 0) - .concat({ - name: "Total", - value: pieData.reduce((a, b) => a + b.value, 0), - color: "#000000", - }); - }, [pieData]); - - return ( - - {cardData.map((pieItem) => ( - - - - {pieItem.value} - - - {pieItem.name} - - - - ))} - - ); -} - -interface PieData { - name: string; - value: number; - color: string; -} - -export default function EnhancedTableToolbar( - props: React.PropsWithChildren, -) { - const { tableData } = props; - const theme = useTheme(); - const is_lg = useMediaQuery(theme.breakpoints.down("lg")); - const [debug, setDebug] = React.useState(false); - - const debugSx = debug - ? { - "--Grid-borderWidth": "1px", - borderTop: "var(--Grid-borderWidth) solid", - borderLeft: "var(--Grid-borderWidth) solid", - borderColor: "divider", - "& > div": { - borderRight: "var(--Grid-borderWidth) solid", - borderBottom: "var(--Grid-borderWidth) solid", - borderColor: "divider", - }, - } - : {}; - - const pieData: PieData[] = React.useMemo(() => { - const online = tableData.filter( - (row) => row.status === NodeStatus.Online, - ).length; - const offline = tableData.filter( - (row) => row.status === NodeStatus.Offline, - ).length; - const pending = tableData.filter( - (row) => row.status === NodeStatus.Pending, - ).length; - - return [ - { name: "Online", value: online, color: theme.palette.success.main }, - { name: "Offline", value: offline, color: theme.palette.error.main }, - { name: "Pending", value: pending, color: theme.palette.warning.main }, - ]; - }, [tableData, theme]); - - return ( - - - - NODES - - - {/* Debug Controls */} - - - { - setDebug(!debug); - }} - checked={debug} - /> - } - label="Debug" - /> - - - - {/* Pie Chart Grid */} - - - - - - - {/* Card Stack Grid */} - - - - - {/*Toolbar Grid */} - - - {props.children} - - - - ); -} diff --git a/pkgs/ui/src/app/templates/[id]/page.tsx b/pkgs/ui/src/app/templates/[id]/page.tsx index 555685aa..50ba463f 100644 --- a/pkgs/ui/src/app/templates/[id]/page.tsx +++ b/pkgs/ui/src/app/templates/[id]/page.tsx @@ -29,7 +29,7 @@ import { Typography, } from "@mui/material"; import { useState } from "react"; -import { useListMachines } from "../../../../api/default/default"; +import { useListMachines } from "@api/default/default"; export async function generateStaticParams() { return [{ id: "1" }, { id: "2" }]; @@ -46,7 +46,7 @@ function getTemplate(params: { id: string }) { interface TemplateDetailProps { params: { id: string }; } -export default function TemplateDetail({ params }: TemplateDetailProps) { +export function TemplateDetail({ params }: TemplateDetailProps) { const { data, isLoading } = useListMachines(); console.log({ data, isLoading }); const details = getTemplate(params); diff --git a/pkgs/ui/src/components/hooks/useMachines.tsx b/pkgs/ui/src/components/hooks/useMachines.tsx new file mode 100644 index 00000000..d1586186 --- /dev/null +++ b/pkgs/ui/src/components/hooks/useMachines.tsx @@ -0,0 +1,93 @@ +import { useListMachines } from "@/api/default/default"; +import { Machine, MachinesResponse } from "@/api/model"; +import { AxiosError, AxiosResponse } from "axios"; +import React, { + createContext, + Dispatch, + ReactNode, + SetStateAction, + useMemo, + useState, +} from "react"; +import { KeyedMutator } from "swr"; + +type Filter = { + name: keyof Machine; + value: Machine[keyof Machine]; +}; +type Filters = Filter[]; + +type MachineContextType = + | { + rawData: AxiosResponse | undefined; + data: Machine[]; + isLoading: boolean; + error: AxiosError | undefined; + isValidating: boolean; + + filters: Filters; + setFilters: Dispatch>; + mutate: KeyedMutator>; + swrKey: string | false | Record; + } + | { + isLoading: true; + data: readonly []; + }; + +const initialState = { + isLoading: true, + data: [], +} as const; + +export const MachineContext = createContext(initialState); + +interface MachineContextProviderProps { + children: ReactNode; +} + +export const MachineContextProvider = (props: MachineContextProviderProps) => { + const { children } = props; + const { + data: rawData, + isLoading, + error, + isValidating, + mutate, + swrKey, + } = useListMachines(); + const [filters, setFilters] = useState([]); + + const data = useMemo(() => { + if (!isLoading && !error && !isValidating && rawData) { + const { machines } = rawData.data; + return machines.filter((m) => + filters.every((f) => m[f.name] === f.value), + ); + } + return []; + }, [isLoading, error, isValidating, rawData, filters]); + + return ( + + {children} + + ); +}; + +export const useMachines = () => React.useContext(MachineContext); diff --git a/pkgs/ui/src/components/sidebar/index.tsx b/pkgs/ui/src/components/sidebar/index.tsx index 6e8f260d..34f66287 100644 --- a/pkgs/ui/src/components/sidebar/index.tsx +++ b/pkgs/ui/src/components/sidebar/index.tsx @@ -38,8 +38,8 @@ const menuEntries: MenuEntry[] = [ }, { icon: , - label: "Devices", - to: "/nodes", + label: "Machines", + to: "/machines", }, { icon: , diff --git a/pkgs/ui/src/components/table/enhancedTableToolbar.tsx b/pkgs/ui/src/components/table/enhancedTableToolbar.tsx new file mode 100644 index 00000000..44347fc9 --- /dev/null +++ b/pkgs/ui/src/components/table/enhancedTableToolbar.tsx @@ -0,0 +1,82 @@ +"use client"; + +import React, { useMemo } from "react"; +import Box from "@mui/material/Box"; +import Toolbar from "@mui/material/Toolbar"; +import Grid2 from "@mui/material/Unstable_Grid2"; +import useMediaQuery from "@mui/material/useMediaQuery"; +import { useTheme } from "@mui/material"; + +import { NodeStatus, TableData } from "@/data/nodeData"; +import { PieCards } from "./pieCards"; +import { PieData, NodePieChart } from "./nodePieChart"; + +interface EnhancedTableToolbarProps { + tableData: TableData[]; +} + +export function EnhancedTableToolbar( + props: React.PropsWithChildren, +) { + const { tableData } = props; + const theme = useTheme(); + const is_lg = useMediaQuery(theme.breakpoints.down("lg")); + + const pieData: PieData[] = useMemo(() => { + const online = tableData.filter( + (row) => row.status === NodeStatus.Online, + ).length; + const offline = tableData.filter( + (row) => row.status === NodeStatus.Offline, + ).length; + const pending = tableData.filter( + (row) => row.status === NodeStatus.Pending, + ).length; + + return [ + { name: "Online", value: online, color: theme.palette.success.main }, + { name: "Offline", value: offline, color: theme.palette.error.main }, + { name: "Pending", value: pending, color: theme.palette.warning.main }, + ]; + }, [tableData, theme]); + + return ( + + {/* Pie Chart Grid */} + + + + + + + {/* Card Stack Grid */} + + + + + {/*Toolbar Grid */} + + + {props.children} + + + + ); +} diff --git a/pkgs/ui/src/components/table/index.tsx b/pkgs/ui/src/components/table/index.tsx new file mode 100644 index 00000000..59710ae0 --- /dev/null +++ b/pkgs/ui/src/components/table/index.tsx @@ -0,0 +1 @@ +export { NodeTable } from "./nodeTable"; diff --git a/pkgs/ui/src/app/nodes/NodePieChart.tsx b/pkgs/ui/src/components/table/nodePieChart.tsx similarity index 86% rename from pkgs/ui/src/app/nodes/NodePieChart.tsx rename to pkgs/ui/src/components/table/nodePieChart.tsx index e076656c..9555f346 100644 --- a/pkgs/ui/src/app/nodes/NodePieChart.tsx +++ b/pkgs/ui/src/components/table/nodePieChart.tsx @@ -1,14 +1,7 @@ import React from "react"; -import { - PieChart, - Pie, - Sector, - Cell, - ResponsiveContainer, - Legend, -} from "recharts"; +import { PieChart, Pie, Cell, ResponsiveContainer, Legend } from "recharts"; import { useTheme } from "@mui/material/styles"; -import { Box, Color } from "@mui/material"; +import { Box } from "@mui/material"; export interface PieData { name: string; @@ -21,7 +14,7 @@ interface Props { showLabels?: boolean; } -export default function NodePieChart(props: Props) { +export function NodePieChart(props: Props) { const theme = useTheme(); const { data, showLabels } = props; diff --git a/pkgs/ui/src/app/nodes/NodeRow.tsx b/pkgs/ui/src/components/table/nodeRow.tsx similarity index 96% rename from pkgs/ui/src/app/nodes/NodeRow.tsx rename to pkgs/ui/src/components/table/nodeRow.tsx index 7830e9be..fdc08acf 100644 --- a/pkgs/ui/src/app/nodes/NodeRow.tsx +++ b/pkgs/ui/src/components/table/nodeRow.tsx @@ -13,9 +13,10 @@ import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp"; import Grid2 from "@mui/material/Unstable_Grid2"; // Grid version 2 import { Collapse } from "@mui/material"; + import { NodeStatus, NodeStatusKeys, TableData } from "@/data/nodeData"; -export default function NodeRow(props: { +export function NodeRow(props: { row: TableData; selected: string | undefined; setSelected: (a: string | undefined) => void; @@ -58,13 +59,13 @@ export default function NodeRow(props: { //const labelId = `enhanced-table-checkbox-${index}`; // Speed optimization. We compare string pointers here instead of the string content. - const isSelected = selected == row.id; + const isSelected = selected == row.name; - const handleClick = (event: React.MouseEvent, id: string) => { + const handleClick = (event: React.MouseEvent, name: string) => { if (isSelected) { setSelected(undefined); } else { - setSelected(id); + setSelected(name); } }; diff --git a/pkgs/ui/src/app/nodes/NodeTable.tsx b/pkgs/ui/src/components/table/nodeTable.tsx similarity index 74% rename from pkgs/ui/src/app/nodes/NodeTable.tsx rename to pkgs/ui/src/components/table/nodeTable.tsx index 26e97b8d..079b0f06 100644 --- a/pkgs/ui/src/app/nodes/NodeTable.tsx +++ b/pkgs/ui/src/components/table/nodeTable.tsx @@ -1,29 +1,27 @@ "use client"; -import * as React from "react"; +import { useState, ChangeEvent, SetStateAction, Dispatch } from "react"; import Box from "@mui/material/Box"; import TablePagination from "@mui/material/TablePagination"; import Paper from "@mui/material/Paper"; import IconButton from "@mui/material/IconButton"; import Tooltip from "@mui/material/Tooltip"; import SearchIcon from "@mui/icons-material/Search"; -import NodeTableContainer from "./NodeTableContainer"; - import { useTheme } from "@mui/material"; import useMediaQuery from "@mui/material/useMediaQuery"; -import { TableData } from "@/data/nodeData"; -import EnhancedTableToolbar from "./EnhancedTableToolbar"; -import { table } from "console"; -import StickySpeedDial from "./StickySpeedDial"; +import { TableData } from "@/data/nodeData"; +import { EnhancedTableToolbar } from "./enhancedTableToolbar"; +import { StickySpeedDial } from "./stickySpeedDial"; +import { NodeTableContainer } from "./nodeTableContainer"; export interface SearchBarProps { search: string; - setSearch: React.Dispatch>; + setSearch: Dispatch>; } function SearchBar(props: SearchBarProps) { const { search, setSearch } = props; - const handleSearch = (event: React.ChangeEvent) => { + const handleSearch = (event: ChangeEvent) => { setSearch(event.target.value); }; @@ -43,24 +41,22 @@ export interface NodeTableProps { tableData: TableData[]; } -export default function NodeTable(props: NodeTableProps) { +export function NodeTable(props: NodeTableProps) { let { tableData } = props; const theme = useTheme(); const is_xs = useMediaQuery(theme.breakpoints.only("xs")); - const [selected, setSelected] = React.useState(undefined); - const [page, setPage] = React.useState(0); - const [rowsPerPage, setRowsPerPage] = React.useState(5); - const [search, setSearch] = React.useState(""); + const [selected, setSelected] = useState(undefined); + const [page, setPage] = useState(0); + const [rowsPerPage, setRowsPerPage] = useState(5); + const [search, setSearch] = useState(""); const handleChangePage = (event: unknown, newPage: number) => { setPage(newPage); }; - const handleChangeRowsPerPage = ( - event: React.ChangeEvent, - ) => { + const handleChangeRowsPerPage = (event: ChangeEvent) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; diff --git a/pkgs/ui/src/app/nodes/NodeTableContainer.tsx b/pkgs/ui/src/components/table/nodeTableContainer.tsx similarity index 97% rename from pkgs/ui/src/app/nodes/NodeTableContainer.tsx rename to pkgs/ui/src/components/table/nodeTableContainer.tsx index 67af5718..0164aec6 100644 --- a/pkgs/ui/src/app/nodes/NodeTableContainer.tsx +++ b/pkgs/ui/src/components/table/nodeTableContainer.tsx @@ -10,7 +10,7 @@ import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; import TableSortLabel from "@mui/material/TableSortLabel"; import { visuallyHidden } from "@mui/utils"; -import NodeRow from "./NodeRow"; +import { NodeRow } from "./nodeRow"; import { TableData } from "@/data/nodeData"; @@ -141,7 +141,7 @@ interface NodeTableContainerProps { setSelected: React.Dispatch>; } -export default function NodeTableContainer(props: NodeTableContainerProps) { +export function NodeTableContainer(props: NodeTableContainerProps) { const { tableData, page, rowsPerPage, dense, selected, setSelected } = props; const [order, setOrder] = React.useState("asc"); const [orderBy, setOrderBy] = React.useState("status"); @@ -184,7 +184,7 @@ export default function NodeTableContainer(props: NodeTableContainerProps) { {visibleRows.map((row, index) => { return ( { + return pieData + .filter((pieItem) => pieItem.value > 0) + .concat({ + name: "Total", + value: pieData.reduce((a, b) => a + b.value, 0), + color: "#000000", + }); + }, [pieData]); + + return ( + + {cardData.map((pieItem) => ( + + + + {pieItem.value} + + + {pieItem.name} + + + + ))} + + ); +} diff --git a/pkgs/ui/src/app/nodes/StickySpeedDial.tsx b/pkgs/ui/src/components/table/stickySpeedDial.tsx similarity index 51% rename from pkgs/ui/src/app/nodes/StickySpeedDial.tsx rename to pkgs/ui/src/components/table/stickySpeedDial.tsx index d32a1fcf..44a6542b 100644 --- a/pkgs/ui/src/app/nodes/StickySpeedDial.tsx +++ b/pkgs/ui/src/components/table/stickySpeedDial.tsx @@ -1,57 +1,16 @@ "use client"; import * as React from "react"; -import { alpha } from "@mui/material/styles"; import Box from "@mui/material/Box"; -import Table from "@mui/material/Table"; -import TableBody from "@mui/material/TableBody"; -import TableCell from "@mui/material/TableCell"; -import TableContainer from "@mui/material/TableContainer"; -import TableHead from "@mui/material/TableHead"; -import TablePagination from "@mui/material/TablePagination"; -import TableRow from "@mui/material/TableRow"; -import TableSortLabel from "@mui/material/TableSortLabel"; -import Toolbar from "@mui/material/Toolbar"; -import Typography from "@mui/material/Typography"; -import Paper from "@mui/material/Paper"; -import IconButton from "@mui/material/IconButton"; -import Tooltip from "@mui/material/Tooltip"; -import FormControlLabel from "@mui/material/FormControlLabel"; -import Switch from "@mui/material/Switch"; import DeleteIcon from "@mui/icons-material/Delete"; -import FilterListIcon from "@mui/icons-material/FilterList"; import SpeedDial, { CloseReason, OpenReason } from "@mui/material/SpeedDial"; import SpeedDialIcon from "@mui/material/SpeedDialIcon"; import SpeedDialAction from "@mui/material/SpeedDialAction"; -import { visuallyHidden } from "@mui/utils"; -import CircleIcon from "@mui/icons-material/Circle"; -import Stack from "@mui/material/Stack/Stack"; import EditIcon from "@mui/icons-material/ModeEdit"; -import SearchIcon from "@mui/icons-material/Search"; -import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; -import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp"; -import NodePieChart, { PieData } from "./NodePieChart"; -import Fab from "@mui/material/Fab"; import AddIcon from "@mui/icons-material/Add"; import Link from "next/link"; -import Grid2 from "@mui/material/Unstable_Grid2"; // Grid version 2 -import { - Card, - CardContent, - Collapse, - Container, - FormGroup, - useTheme, -} from "@mui/material"; -import hexRgb from "hex-rgb"; -import useMediaQuery from "@mui/material/useMediaQuery"; -import { NodeStatus, NodeStatusKeys, TableData } from "@/data/nodeData"; -import { jsx } from "@emotion/react"; - -export default function StickySpeedDial(props: { - selected: string | undefined; -}) { +export function StickySpeedDial(props: { selected: string | undefined }) { const { selected } = props; const [open, setOpen] = React.useState(false); @@ -72,7 +31,7 @@ export default function StickySpeedDial(props: { function editDial() { if (isSomethingSelected) { return ( - + ); @@ -105,7 +64,7 @@ export default function StickySpeedDial(props: { + } diff --git a/pkgs/ui/src/data/nodeData.tsx b/pkgs/ui/src/data/nodeData.tsx index 5e536e3a..eb7e17e0 100644 --- a/pkgs/ui/src/data/nodeData.tsx +++ b/pkgs/ui/src/data/nodeData.tsx @@ -1,6 +1,5 @@ export interface TableData { name: string; - id: string; status: NodeStatusKeys; last_seen: number; } @@ -15,7 +14,6 @@ export type NodeStatusKeys = (typeof NodeStatus)[keyof typeof NodeStatus]; function createData( name: string, - id: string, status: NodeStatusKeys, last_seen: number, ): TableData { @@ -25,7 +23,6 @@ function createData( return { name, - id, status, last_seen: last_seen, }; @@ -95,72 +92,62 @@ function getRandomLastSeen(status: NodeStatusKeys): number { export const tableData = [ createData( "Matchbox", - "42:0:f21:6916:e333:c47e:4b5c:e74c", + NodeStatus.Pending, 0, ), createData( "Ahorn", - "42:0:3c46:b51c:b34d:b7e1:3b02:8d24", + NodeStatus.Online, 0, ), createData( "Yellow", - "42:0:3c46:98ac:9c80:4f25:50e3:1d8f", + NodeStatus.Offline, 16.0, ), - createData( - "Rauter", - "42:0:61ea:b777:61ea:803:f885:3523", - NodeStatus.Offline, - 6.0, - ), + createData("Rauter", NodeStatus.Offline, 6.0), createData( "Porree", - "42:0:e644:4499:d034:895e:34c8:6f9a", + NodeStatus.Offline, 13, ), createData( "Helsinki", - "42:0:3c46:fd4a:acf9:e971:6036:8047", + NodeStatus.Online, 0, ), createData( "Kelle", - "42:0:3c46:362d:a9aa:4996:c78e:839a", + NodeStatus.Online, 0, ), createData( "Shodan", - "42:0:3c46:6745:adf4:a844:26c4:bf91", + NodeStatus.Online, 0.0, ), createData( "Qubasa", - "42:0:3c46:123e:bbea:3529:db39:6764", + NodeStatus.Offline, 7.0, ), createData( "Green", - "42:0:a46e:5af:632c:d2fe:a71d:cde0", + NodeStatus.Offline, 2, ), - createData("Gum", "42:0:e644:238d:3e46:c884:6ec5:16c", NodeStatus.Offline, 0), - createData("Xu", "42:0:ca48:c2c2:19fb:a0e9:95b9:794f", NodeStatus.Online, 0), - createData( - "Zaatar", - "42:0:3c46:156e:10b6:3bd6:6e82:b2cd", - NodeStatus.Online, - 0, - ), + createData("Gum", NodeStatus.Offline, 0), + createData("Xu", NodeStatus.Online, 0), + createData("Zaatar", NodeStatus.Online, 0), ]; // A function to execute the createData function with dummy data in a loop 100 times and return an array @@ -174,7 +161,7 @@ export function executeCreateData(): TableData[] { let last_seen = getRandomLastSeen(status); // Call the createData function and push the result to the array - result.push(createData(name, id, status, last_seen)); + result.push(createData(name, status, last_seen)); } return result; } diff --git a/pkgs/ui/src/data/nodeDataStatic.tsx b/pkgs/ui/src/data/nodeDataStatic.tsx index cd97ea65..3acf7cf8 100644 --- a/pkgs/ui/src/data/nodeDataStatic.tsx +++ b/pkgs/ui/src/data/nodeDataStatic.tsx @@ -1,601 +1,589 @@ export const tableData = [ { name: "Bob", - id: "f435:9678:eff4:cedf:7725:421c:82c0:611c", status: "Pending", last_seen: 83, }, { - name: "Peggy", - id: "aa49:f231:04ac:f0d2:cf9a:4635:57e3:4b78", + name: "Peggy With %", status: "Offline", last_seen: 294, }, { name: "Wendy", - id: "a453:4ec6:c401:30dc:89a0:1567:90c9:4a72", status: "Pending", last_seen: 332, }, { name: "Sybil", - id: "3f14:92c3:1090:bef0:7dc6:9eaf:755c:6f7f", status: "Offline", last_seen: 48, }, { name: "Ivan", - id: "855e:d1ff:d20c:d1b8:86c4:9ffe:ca2a:fefa", status: "Offline", last_seen: 292, }, { name: "Ivan", - id: "7bfb:3980:dc1a:37e2:2464:6028:393b:315f", status: "Pending", last_seen: 240, }, { name: "Mallory", - id: "d457:0a59:ea77:963f:f20b:ca55:57f2:a54b", status: "Online", last_seen: 0, }, { name: "Mallory", - id: "bbef:a90a:f7ff:5f40:23fc:a1d8:6b2f:7b0a", status: "Offline", last_seen: 95, }, { name: "Zoe", - id: "1057:7b4d:0708:66a1:5d36:5d8c:6620:4f5f", status: "Online", last_seen: 0, }, { name: "Ivan", - id: "74d3:60dc:5e12:dc52:7c7f:6903:4ff1:ba20", status: "Pending", last_seen: 193, }, { name: "Ivan", - id: "6770:c213:bdd1:0226:26e0:a8d4:949a:f2cc", status: "Pending", last_seen: 181, }, { name: "Bob", - id: "5551:7363:ba70:6927:57f3:24ea:386d:e2d9", status: "Online", last_seen: 0, }, { name: "Victor", - id: "12eb:9b2b:0c94:0731:15e6:7cd1:8984:7669", + status: "Offline", last_seen: 130, }, { name: "Victor", - id: "785e:b8a0:289b:5108:a982:ecff:8f0b:9db2", + status: "Offline", last_seen: 336, }, { name: "Judy", - id: "ee4b:ce86:4885:2729:089e:7f93:d3dd:7a09", + status: "Pending", last_seen: 241, }, { name: "Frank", - id: "6c05:c65d:ef3b:be64:ae58:e1fd:7aaa:bd30", + status: "Online", last_seen: 0, }, { name: "Alice", - id: "0fe6:f3b1:58c2:ef75:12de:6514:d1a6:eda5", + status: "Pending", last_seen: 94, }, { name: "Charlie", - id: "095b:1b3f:cfeb:72f8:e84c:91f7:2c62:06e9", + status: "Pending", last_seen: 131, }, { name: "Walter", - id: "8d0a:56b0:1537:1b2e:9581:d640:cd29:21cf", + status: "Offline", last_seen: 273, }, { name: "Walter", - id: "d8ab:813a:cbc6:d379:d3be:cc4b:20b8:94ae", + status: "Offline", last_seen: 200, }, { name: "Trent", - id: "0199:cb5c:a8cd:af82:2d9a:e63a:a157:6ee6", + status: "Offline", last_seen: 352, }, { name: "Peggy", - id: "1b7b:8da6:623a:75ea:2385:8777:76b9:9ba8", + status: "Online", last_seen: 0, }, { name: "Zoe", - id: "6ed3:ee3b:f7df:044a:355a:7790:0bf3:a308", + status: "Online", last_seen: 0, }, { name: "Wendy", - id: "efed:821d:a944:0775:ead4:e520:6402:8dc4", + status: "Online", last_seen: 0, }, { name: "Heidi", - id: "b616:82c5:4a37:c020:9568:aaa4:6390:22d5", + status: "Online", last_seen: 0, }, { name: "Charlie", - id: "2c05:e6fc:a359:bf63:65e7:ee0e:49e3:6cc5", + status: "Online", last_seen: 0, }, { name: "Frank", - id: "e9cb:eddc:1a94:22e4:4e3d:e927:c599:db04", + status: "Online", last_seen: 0, }, { name: "Bob", - id: "be03:3537:719f:5152:f277:03ef:c6c9:c953", + status: "Offline", last_seen: 69, }, { name: "Oscar", - id: "cede:fa4a:518d:b885:d1fa:00f4:d97a:2258", + status: "Pending", last_seen: 280, }, { name: "Judy", - id: "9337:53e7:1aae:1b94:6035:e601:e562:350c", + status: "Online", last_seen: 0, }, { name: "Judy", - id: "d50b:0ddc:0c9d:cd34:40ee:34c9:75ff:d16c", + status: "Online", last_seen: 0, }, { name: "Charlie", - id: "368f:8855:59ed:b8c3:4fff:7630:9948:877f", + status: "Offline", last_seen: 63, }, { name: "Judy", - id: "0fcd:74ae:8dad:8d10:370b:46c5:a403:eab8", + status: "Pending", last_seen: 242, }, { name: "Wendy", - id: "285f:3015:2f09:2fde:25ee:87be:6d2c:f4f3", + status: "Pending", last_seen: 60, }, { name: "Ivan", - id: "942d:9c5c:1f4a:95ba:1046:c643:a874:83ce", + status: "Online", last_seen: 0, }, { name: "Frank", - id: "06f5:5b67:98e9:31b4:ddba:fb81:afb1:7677", + status: "Offline", last_seen: 154, }, { name: "Zoe", - id: "ec58:13b0:b7ef:6e19:6c78:2c35:4fa3:092a", + status: "Offline", last_seen: 264, }, { name: "Charlie", - id: "7151:20e3:3969:2933:c23b:6d9a:9723:d1bd", + status: "Online", last_seen: 0, }, { name: "David", - id: "0466:bd3f:0fff:2119:b9c0:ee60:2a90:6b54", + status: "Online", last_seen: 0, }, { name: "David", - id: "814d:b00c:4a98:7aa2:5354:7076:f48e:1609", + status: "Offline", last_seen: 249, }, { name: "David", - id: "8633:f51b:b643:829a:08b0:fc2a:7cad:abda", + status: "Offline", last_seen: 359, }, { name: "Eve", - id: "0fd5:7b72:4445:0e27:95c6:1b80:99dc:6590", + status: "Online", last_seen: 0, }, { name: "Wendy", - id: "dc9b:bac9:8ec8:9167:5da5:8530:fcb7:1458", + status: "Online", last_seen: 0, }, { name: "Bob", - id: "0412:6da1:82ef:6cb1:467e:34e9:34df:5742", + status: "Online", last_seen: 0, }, { name: "Ivan", - id: "d03b:aba5:ee40:1961:f824:0d9b:9669:2e3e", + status: "Online", last_seen: 0, }, { name: "Zoe", - id: "ad06:abfd:05c2:fc17:a8e0:857e:b04c:d3fe", + status: "Offline", last_seen: 25, }, { name: "Ivan", - id: "d2ca:12cb:d271:44a2:2813:e826:964b:b292", + status: "Pending", last_seen: 11, }, { name: "Charlie", - id: "aaa9:9754:34e2:7251:af6e:df7a:5422:96cd", + status: "Offline", last_seen: 131, }, { name: "Mallory", - id: "8511:8f44:45d7:cc8a:43ff:908c:a35f:19bc", + status: "Offline", last_seen: 141, }, { name: "Alice", - id: "8bc2:8f83:3081:d90c:087e:13bf:002b:934b", + status: "Online", last_seen: 0, }, { name: "Peggy", - id: "9b33:5e44:310f:f6ab:81ae:df8e:be7b:ddc4", + status: "Pending", last_seen: 354, }, { name: "Victor", - id: "9776:1f62:b8dc:1d14:bf9c:bf41:99b7:5c11", + status: "Online", last_seen: 0, }, { name: "David", - id: "874a:a4df:321a:5367:4b63:4a0c:48d6:0a0d", + status: "Offline", last_seen: 199, }, { name: "Charlie", - id: "05f0:7188:a2fb:cfe3:7d85:e3de:d6c2:07e9", + status: "Pending", last_seen: 46, }, { name: "Grace", - id: "dcbd:5ddf:496d:dd27:0e98:9905:7c24:664d", + status: "Pending", last_seen: 284, }, { name: "Ivan", - id: "3cb9:d178:2cb1:ae2c:dd3d:ce93:34e0:cc68", + status: "Online", last_seen: 0, }, { name: "Frank", - id: "c974:9ef6:df64:188c:4622:aa71:497b:1fd8", + status: "Pending", last_seen: 18, }, { name: "Frank", - id: "3ba0:9362:3b2f:ec10:03c2:7bd7:67ad:759c", + status: "Online", last_seen: 0, }, { name: "Walter", - id: "b57d:3d13:6654:d944:0e7c:61d6:9dc0:15d8", + status: "Online", last_seen: 0, }, { name: "Sybil", - id: "de00:f53f:0be4:8a57:047a:f99d:8ab2:fe7c", + status: "Pending", last_seen: 41, }, { name: "Trent", - id: "bb32:acd8:bbfb:ea3e:1b58:dc17:4cc4:64ce", + status: "Offline", last_seen: 326, }, { name: "Oscar", - id: "a3e9:1060:b0df:2adb:a340:3f34:5348:d882", + status: "Offline", last_seen: 57, }, { name: "Wendy", - id: "6b49:c86c:41c8:c021:2103:b707:26a9:6d6a", + status: "Online", last_seen: 0, }, { name: "Sybil", - id: "aaf2:68cb:da7e:0844:8a12:5fb9:cff5:9de8", + status: "Online", last_seen: 0, }, { name: "Victor", - id: "b87d:0cc5:e3be:a600:045e:4a26:f7e2:6b3d", + status: "Offline", last_seen: 342, }, { name: "Frank", - id: "13e6:1b80:ba7e:6275:21c8:dc96:6ab1:ac69", + status: "Pending", last_seen: 213, }, { name: "Sybil", - id: "14ad:2010:7648:fbc8:337c:6984:d7e2:5202", + status: "Online", last_seen: 0, }, { name: "Charlie", - id: "f79c:e3b8:1082:7a9d:7adf:f5b6:e333:affd", + status: "Online", last_seen: 0, }, { name: "Sybil", - id: "534c:0d80:97d5:7b54:a1c3:5457:c5e8:62ee", + status: "Pending", last_seen: 133, }, { name: "Victor", - id: "e829:f930:b7d7:6005:cc34:7bca:0163:7903", + status: "Online", last_seen: 0, }, { name: "Ivan", - id: "18c3:6ab2:93ea:0756:52e4:33a6:0c2b:bd79", + status: "Pending", last_seen: 109, }, { name: "Eve", - id: "49a3:28ad:6121:2e35:1b72:e5d7:5efc:0626", + status: "Online", last_seen: 0, }, { name: "Trent", - id: "d900:540b:b764:2468:ad9e:2716:ab4f:9955", + status: "Pending", last_seen: 117, }, { name: "Zoe", - id: "9d3d:de15:014a:ac0d:74b9:2ae8:08d4:8848", + status: "Pending", last_seen: 114, }, { name: "Peggy", - id: "2145:0e6a:f66a:8e93:71b7:385d:c25b:6a2b", + status: "Offline", last_seen: 71, }, { name: "Sybil", - id: "834c:adcc:a3d7:b5fc:d5cd:4209:e280:e625", + status: "Pending", last_seen: 200, }, { name: "Heidi", - id: "5ecc:904c:2d31:177b:346d:4c23:5169:a982", + status: "Online", last_seen: 0, }, { name: "Ivan", - id: "0446:9092:762c:48b6:310a:e6fb:be48:4631", + status: "Online", last_seen: 0, }, { name: "David", - id: "160c:97aa:f4ff:52d0:717e:2263:7262:90ed", + status: "Offline", last_seen: 275, }, { name: "Charlie", - id: "6832:d934:2a76:27c0:88ea:2b05:5bf8:4f86", + status: "Online", last_seen: 0, }, { name: "Eve", - id: "5363:e485:d9b9:89a8:3ee4:5d24:b2b5:2ab5", + status: "Offline", last_seen: 343, }, { name: "Peggy", - id: "5673:e221:3236:0a33:29a9:5c5f:ff03:c98d", + status: "Offline", last_seen: 130, }, { name: "Grace", - id: "8946:27f1:2abe:f009:b109:f0af:92d1:4c5b", + status: "Pending", last_seen: 72, }, { name: "Walter", - id: "7bc3:a683:660d:ffc3:a40f:b8ab:2246:ed38", + status: "Offline", last_seen: 264, }, { name: "Mallory", - id: "5b5d:129e:8c3e:4f34:94bf:ffe5:7a8a:b3ae", + status: "Online", last_seen: 0, }, { name: "Eve", - id: "d7db:981a:8885:838b:70b6:a691:1c26:4d59", + status: "Offline", last_seen: 172, }, { name: "Peggy", - id: "1255:426b:034c:0171:d67e:ef4c:d9a5:7da6", + status: "Pending", last_seen: 81, }, { name: "Frank", - id: "1c79:ef2f:c01a:d53b:016d:e2fc:3566:6b85", + status: "Online", last_seen: 0, }, { name: "Judy", - id: "b159:2924:969d:e1f6:e295:f19d:9bf2:8f58", + status: "Offline", last_seen: 221, }, { name: "Judy", - id: "bba4:85aa:bcc7:5ef6:920c:7d74:e921:7d47", + status: "Offline", last_seen: 168, }, { name: "Victor", - id: "dc3f:5b3a:3e71:552a:9cdb:10f2:699a:d8e9", + status: "Offline", last_seen: 217, }, { name: "Victor", - id: "e084:f4cf:be5b:83c1:f1f5:1159:d24d:dea2", + status: "Online", last_seen: 0, }, { name: "Trent", - id: "113c:335a:c844:7307:b192:1c44:fb34:4cc0", + status: "Offline", last_seen: 77, }, { name: "Sybil", - id: "05a0:cbe8:4b89:47e3:81e9:39b7:4966:bbed", + status: "Offline", last_seen: 145, }, { name: "Alice", - id: "0f33:461d:c779:067e:424e:b933:c855:c376", + status: "Online", last_seen: 0, }, { name: "Trent", - id: "a883:16c8:abb4:3ab3:7d6f:beb4:1398:bc9c", + status: "Pending", last_seen: 189, }, { name: "Wendy", - id: "2e7c:1162:1488:6a1e:34fe:0725:bd56:4461", + status: "Pending", last_seen: 338, }, { name: "Judy", - id: "c4e1:6d39:5079:097b:3228:1391:4f59:1be6", + status: "Offline", last_seen: 352, }, { name: "Victor", - id: "d32c:1045:4297:251a:6ec8:16c8:541d:7925", + status: "Offline", last_seen: 61, }, { name: "Zoe", - id: "b6cf:6f86:f510:9f39:93a9:aba9:4632:bb69", + status: "Online", last_seen: 0, }, diff --git a/pkgs/ui/tsconfig.json b/pkgs/ui/tsconfig.json index 16a5a112..2bc773b0 100644 --- a/pkgs/ui/tsconfig.json +++ b/pkgs/ui/tsconfig.json @@ -21,7 +21,7 @@ ], "paths": { "@/*": ["./src/*"], - "API": ["./api/*"] + "@API/*": ["./src/api/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],