From 3eb91493f9e70180d7c212360e61ebfca5ad8755 Mon Sep 17 00:00:00 2001 From: Aadarsh A Date: Tue, 16 Aug 2022 23:34:02 +0530 Subject: [PATCH] feat: All entries page + Navbar (#43) * Add home screen * Added navbar and an all entries page * Requested changes (part 1) * Change useFetch * Change vars * Add requested changes * Remove isSuccess check --- taxonomy-editor-frontend/src/App.js | 4 + .../src/components/ResponsiveAppBar.jsx | 176 ++++++++++++++++++ .../src/pages/allentries/index.jsx | 84 +++++++++ 3 files changed, 264 insertions(+) create mode 100644 taxonomy-editor-frontend/src/components/ResponsiveAppBar.jsx create mode 100644 taxonomy-editor-frontend/src/pages/allentries/index.jsx diff --git a/taxonomy-editor-frontend/src/App.js b/taxonomy-editor-frontend/src/App.js index f7f8c367..2eae8802 100644 --- a/taxonomy-editor-frontend/src/App.js +++ b/taxonomy-editor-frontend/src/App.js @@ -1,5 +1,7 @@ import { createTheme, CssBaseline, ThemeProvider } from "@mui/material"; import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; +import ResponsiveAppBar from "./components/ResponsiveAppBar"; +import Entry from "./pages/allentries"; import Home from './pages/home'; const theme = createTheme({ @@ -13,9 +15,11 @@ function App() { +
} /> + } />
diff --git a/taxonomy-editor-frontend/src/components/ResponsiveAppBar.jsx b/taxonomy-editor-frontend/src/components/ResponsiveAppBar.jsx new file mode 100644 index 00000000..cb479755 --- /dev/null +++ b/taxonomy-editor-frontend/src/components/ResponsiveAppBar.jsx @@ -0,0 +1,176 @@ +import * as React from "react"; +import AppBar from "@mui/material/AppBar"; +import Box from "@mui/material/Box"; +import Toolbar from "@mui/material/Toolbar"; +import IconButton from "@mui/material/IconButton"; +import Typography from "@mui/material/Typography"; +import Menu from "@mui/material/Menu"; +import MenuIcon from "@mui/icons-material/Menu"; +import Container from "@mui/material/Container"; +import Button from "@mui/material/Button"; +import MenuItem from "@mui/material/MenuItem"; +import ListSubheader from "@mui/material/ListSubheader"; +import MuiLink from "@mui/material/Link"; +import SettingsIcon from '@mui/icons-material/Settings'; +import logo from "../assets/logosmall.jpg"; +import { Link } from "react-router-dom"; +import { useTranslation } from "react-i18next"; + +const displayedPages = [ + { url: "entry", translationKey: "Nodes" } +]; + +const ResponsiveAppBar = () => { + const { t } = useTranslation(); + const [anchorElNav, setAnchorElNav] = React.useState(null); + + const handleOpenNavMenu = (event) => { + setAnchorElNav(event.currentTarget); + }; + + const handleCloseNavMenu = () => { + setAnchorElNav(null); + }; + + return ( + + + + {/* Mobile content */} + + + + + + {displayedPages.map((page) => + page.url ? ( + + + {t(page.translationKey)} + + + ) : ( + + {t(page.translationKey)} + + ) + )} + + + + Taxonomy Editor + + + {/* Desktop content */} + + + + OpenFoodFacts logo + + + Taxonomy Editor + + + {displayedPages.map((page) => + page.url ? ( + + ) : null + )} + + + + + + + ); +}; +export default ResponsiveAppBar; \ No newline at end of file diff --git a/taxonomy-editor-frontend/src/pages/allentries/index.jsx b/taxonomy-editor-frontend/src/pages/allentries/index.jsx new file mode 100644 index 00000000..56bbbbab --- /dev/null +++ b/taxonomy-editor-frontend/src/pages/allentries/index.jsx @@ -0,0 +1,84 @@ +import { Typography, Button, Box } from "@mui/material"; +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 TableRow from '@mui/material/TableRow'; +import Paper from '@mui/material/Paper'; +import EditIcon from '@mui/icons-material/Edit'; +import { Link } from "react-router-dom"; +import useFetch from "../../components/useFetch"; +import { API_URL } from "../../constants"; + +const Entry = () => { + const { data: nodes, isPending, isError, isSuccess, errorMessage } = useFetch(API_URL+'nodes'); + const title = "Test"; + if (isError) { + return ( +
+ {isError &&
{errorMessage}
} +
+ ) + } + if (isPending) { + return ( +
+ {isPending &&
Loading...
} +
+ ) + } + return ( +
+ + + List of nodes in {title} Taxonomy: + + + Number of nodes in taxonomy: {nodes.length} + + {/* Table for listing all nodes in taxonomy */} + + + + + + + + Nodes + + + + + Action + + + + + + {nodes.map((node) => ( + + + + {node[0].id} + + + + + + + ))} + +
+
+
+
+
+ ); +} + +export default Entry; \ No newline at end of file