import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import { makeStyles, withStyles } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; import Box from '@material-ui/core/Box'; import Drawer from '@material-ui/core/Drawer'; import IconButton from '@material-ui/core/IconButton'; import Link from '@material-ui/core/Link'; import MenuItem from '@material-ui/core/MenuItem'; import MenuIcon from '@material-ui/icons/Menu'; import Tab from '@material-ui/core/Tab'; import Tabs from '@material-ui/core/Tabs'; import Toolbar from '@material-ui/core/Toolbar'; import Typography from '@material-ui/core/Typography'; import CookieConsent from "react-cookie-consent"; import ReactiveSearchComponent from './reactive_search'; import UploadComponent from './upload'; import DatasetComponent from './datasets'; import WeedCOCOComponent from './weedcoco'; import AnnotationComponent from './annotate' import AboutComponent from './about'; import axios from 'axios'; import Cookies from 'js-cookie'; import PrivacyComponent from './privacy'; const useStyles = makeStyles((theme) => ({ root: { flexGrow: 1, backgroundColor: theme.palette.background.paper, }, container: { marginTop: '3rem', '@media (max-width: 1000px)': { marginTop: '4.5rem', }, }, logo: { position: 'absolute', right: '2em', top: '0.2em', fontSize: '1.8rem', fontWeight: 700, color: "white", }, footer: { backgroundColor: theme.palette.primary.main, textAlign: "center", padding: '.2em 1em', }, cookieConsent: { "& a": { color: "#ccf", }, }, })); const StyledTabs = withStyles({ indicator: { display: 'flex', justifyContent: 'center', backgroundColor: 'transparent', '& > span': { maxWidth: 0 }, }, })((props) => }} />); const StyledTab = withStyles((theme) => ({ root: { textTransform: 'none', color: 'white', fontWeight: theme.typography.fontWeightBold, fontSize: theme.typography.pxToRem(18), marginRight: theme.spacing(1), paddingLeft: '0px', paddingRight: '0px', '&$selected': { backgroundColor: 'orange', }, "&:hover": { opacity: 1 }, }, selected: {}, }))((props) => ); const sections = [ {value: "explore", href: "/explore", label: "Explore"}, {value: "datasets", href: "/datasets", label: "Datasets"}, {value: "upload", href: "/upload", label: "Upload"}, {value: "editor", href: "/editor", label: "AgContext Editor", mobileOnly: true}, {value: "metaeditor", href: "/meta-editor", label: "Metadata Editor", mobileOnly: true}, {value: "weedcoco", href: "/weedcoco", label: "WeedCOCO"}, {value: "annotate", href: "/annotate", label: "Annotate"}, {value: "about", href: "/about", label: "About"}, ] const MobileNavbar = (props) => { const {classes, selectedTab, handleChange} = props; const [drawerOpen, setDrawerOpen] = React.useState(false); const getCurrentLabel = () => { const idx = sections.findIndex((x) => x.value == selectedTab); return idx == -1 ? "" : sections[idx].label; } return ( {setDrawerOpen(true)}} > {setDrawerOpen(false)}}> { sections.map((section) => {section.label} ) } {getCurrentLabel()} ); } const Logo = (props) => { const {classes} = props; return ( Weed-AI ); } const DesktopNavbar = (props) => { const {handleChange, selectedTab, classes} = props; return ( { sections.filter(section => section.mobileOnly !== true).map(section => ) } ); } const manageCsrf = () => { const csrftoken = Cookies.get('csrftoken'); if (!csrftoken) { // Reloading the page to set up csrf token is a hack axios.get('/api/set_csrf/').then(() => window.location.reload()); } } export default function NavbarComponent(props) { const classes = useStyles(); const { match } = props; const { params } = match; const { page, dataset_id } = params; const [selectedTab, setSelectedTab] = React.useState(page); const [mobileView, setMobileView] = React.useState(false); useEffect(() => { manageCsrf(); const setResponsiveness = () => { return window.innerWidth < 1000 ? setMobileView(true) : setMobileView(false); }; setResponsiveness(); window.addEventListener("resize", () => setResponsiveness()); }, []); const handleChange = (event, newValue) => { window.location.assign(`/${newValue}`); }; const footer = (
Site Copyright © 2021 The University of Sydney. Contribute on GitHub (MIT Licensed). See our Privacy Policy. Images and annotations are owned and copyright held by their respective contributors, and are licensed under CC BY 4.0. See Dataset pages for attribution.
); return (
{ mobileView ? : }
{ selectedTab === "explore" && } { selectedTab === "datasets" && } { selectedTab === "upload" && } { selectedTab === "weedcoco" && } { selectedTab === "annotate" && } { selectedTab === "about" && } { selectedTab === "privacy" && }
{(selectedTab != "explore") ? footer : []} This website uses cookies to manage your login to the web site for uploading, and optionally for site analytics. See our Privacy Policy.
); }