Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/components/CursorWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { useEffect, useRef } from "react";
import { Table } from "@mantine/core";

type CursorWrapperProps = {
clickFunc: () => void;
bg: string;
children: React.ReactNode;
isCursor: boolean;
getNextPage: (cursorIdx: number) => void;
cursorIdx: number;
};

const CursorWrapper: React.FC<CursorWrapperProps> = ({
clickFunc,
bg,
children,
isCursor,
getNextPage,
cursorIdx,
}) => {
const ref = useRef<HTMLTableRowElement | null>(null);

useEffect(() => {
if (!isCursor) return;
const element = ref.current;

if (!element) return;

const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) {
getNextPage(cursorIdx);
}
},
{ threshold: 0.5 },
);

observer.observe(element);

return () => observer.disconnect();
}, []);

return (
<Table.Tr ref={ref} onClick={clickFunc} bg={bg}>
{children}
</Table.Tr>
);
};

export default CursorWrapper;
27 changes: 17 additions & 10 deletions src/components/DataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Table } from "@mantine/core";
import { useMantineTheme } from "@mantine/core";
import { Input, Textarea } from "@mantine/core";
import CursorWrapper from "./CursorWrapper";

// Data table of the files/root page
interface DataTableProps {
Expand All @@ -10,13 +11,15 @@ interface DataTableProps {
setSelectedData: React.Dispatch<
React.SetStateAction<MCAPFileInformation | undefined>
>;
getNextPage: (cursorIdx: number) => void;
}

export default function DataTable({
data,
selectedRow,
setSelectedRow,
setSelectedData,
getNextPage,
}: DataTableProps) {
const theme = useMantineTheme();

Expand Down Expand Up @@ -51,22 +54,27 @@ export default function DataTable({
</Table.Td>
</Table.Tr>
) : (
data.map((file) => (
<Table.Tr
data.map((file, idx) => (
<CursorWrapper
key={file.id}
onClick={() => setPreviewData(file)}
clickFunc={() => setPreviewData(file)}
bg={selectedRow === file.id ? theme.primaryColor : ""}
isCursor={idx === data.length - 1}
getNextPage={getNextPage}
cursorIdx={idx}
>
<Table.Td style={{ paddingLeft: "25px", size: "xs" }}>
{getFileNameWithoutExtension(file.mcap_files[0].file_name)}
{file.mcap_files
? getFileNameWithoutExtension(file.mcap_files[0].file_name)
: null}
</Table.Td>
<Table.Td>{file.date}</Table.Td>
<Table.Td style={{ size: "xs"}}>
<Input.Wrapper >
<Table.Td style={{ size: "xs" }}>
<Input.Wrapper>
<Textarea
variant="unstyled"
value={file.location}
style={{ whiteSpace: "normal", wordWrap: "break-word"}}
style={{ whiteSpace: "normal", wordWrap: "break-word" }}
readOnly
autosize
placeholder="No Location Available"
Expand All @@ -75,13 +83,12 @@ export default function DataTable({
/>
</Input.Wrapper>
</Table.Td>

<Table.Td style={{ paddingRight: "25px" }}>
<Input.Wrapper>
<Textarea
variant="unstyled"
value={file.notes}
style={{ whiteSpace: "normal", wordWrap: "break-word"}}
style={{ whiteSpace: "normal", wordWrap: "break-word" }}
readOnly
autosize
placeholder="No Note Available"
Expand All @@ -90,7 +97,7 @@ export default function DataTable({
/>
</Input.Wrapper>
</Table.Td>
</Table.Tr>
</CursorWrapper>
))
);
return (
Expand Down
22 changes: 13 additions & 9 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "@/css/Navbar.css";
import { NavLink } from "react-router-dom";
import FileUpload from "@/components/FileUpload";
import Feedback from "@/components/Feedback";
import PingStatus from "@/components/PingStatus";
import { Button } from "@mantine/core";
import { IconHelp } from "@tabler/icons-react";

Expand All @@ -29,23 +30,26 @@ export default function Navbar() {
alt="Logo"
className="navbar-icon"
/>
<Button
<Button
variant="filled"
component="a"
target="_blank"
href="https://wiki.hytechracing.org/books/software/page/query-frontend-demo-and-documentation">
<IconHelp size="25"/>
href="https://wiki.hytechracing.org/books/software/page/query-frontend-demo-and-documentation"
>
<IconHelp size="25" />
</Button>
{links}

{/* Once POST API is out -- Currently WIP */}
<FileUpload uploadUrl={`${import.meta.env.VITE_API_URL}/api/v2/mcaps/bulk_upload`}/>
<div style={{right: 0}}>
<Feedback/>
</div>
<FileUpload
uploadUrl={`${import.meta.env.VITE_API_URL}/api/v2/mcaps/bulk_upload`}
/>
<div style={{ right: 0 }}>
<Feedback />
</div>
{/* Optionally render active link or other content here */}
<h3 className="hytechName">{hytechName}</h3>

<PingStatus />
</nav>
);
}
}
37 changes: 37 additions & 0 deletions src/components/PingStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import "@/css/Navbar.css";
import { useEffect, useState } from "react";

const PingStatus: React.FC = () => {
const [vpnActive, setVpnActive] = useState(false);
const [isHovering, setIsHovering] = useState(false);

const handleGetStatus = async () => {
try {
const res = await fetch(`${import.meta.env.VITE_API_URL}/ping`, {});

setVpnActive(res.ok); // res is always truthy if fetch didn't throw
} catch {
setVpnActive(false);
}
};

useEffect(() => {
handleGetStatus();
}, []);

return (
<div
className={`vpnStatus ${vpnActive ? "vpnStatusGood" : "vpnStatusBad"}`}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
>
{isHovering ? (
<div className="vpnStatusHover">
VPN is {vpnActive ? "active" : "inactive"}
</div>
) : null}
</div>
);
};

export default PingStatus;
87 changes: 57 additions & 30 deletions src/css/Navbar.css
Original file line number Diff line number Diff line change
@@ -1,47 +1,74 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap");

nav {
padding: 15px 0;
background: #B3A36A;
display: flex;
height: 50px;
align-items: center;
padding: 15px 0;
background: #b3a36a;
display: flex;
height: 50px;
align-items: center;
}

.nav-link {
padding: 3px 15px;
text-decoration: none;
color: #FFFFFF;
background-color: transparent;
border-radius: 8px;
font-weight: bold;
cursor: pointer;
transition: all 0.2s ease-in-out;
display: inline-block;
margin-left: 20px;
font-family: 'Roboto', sans-serif;
padding: 3px 15px;
text-decoration: none;
color: #ffffff;
background-color: transparent;
border-radius: 8px;
font-weight: bold;
cursor: pointer;
transition: all 0.2s ease-in-out;
display: inline-block;
margin-left: 20px;
font-family: "Roboto", sans-serif;
}

#navbar a.active {
background-color: #978750;
font-weight: bold;
background-color: #978750;
font-weight: bold;
}

.nav-link:hover {
color: white;
background-color: #D1BF80;
color: white;
background-color: #d1bf80;
}

.navbar-icon {
height: 30px;
margin-right: 20px;
margin-left: 20px;
height: 30px;
margin-right: 20px;
margin-left: 20px;
}

.hytechName {
margin-left: auto;
margin-right: 10px;
border-radius: 5px;
color: white;
font-weight: 900;
}
margin-left: auto;
margin-right: 10px;
border-radius: 5px;
color: white;
font-weight: 900;
}

.vpnStatus {
border-radius: 100%;
width: 1rem;
height: 1rem;
margin: 1rem;
cursor: pointer;
}

.vpnStatusGood {
background-color: green;
}

.vpnStatusBad {
background-color: red;
}

.vpnStatusHover {
white-space: nowrap;
z-index: 10;
background-color: white;
width: fit-content;
border-radius: 5px;
transform: translate(-85%, 75%);
padding: 0.25rem;
border: 1px solid gray;
}
Loading