Skip to content

Commit 3fcb17f

Browse files
committed
Lots of changes
1 parent d04aa82 commit 3fcb17f

File tree

8 files changed

+421
-96
lines changed

8 files changed

+421
-96
lines changed

frontend/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RouterProvider, createBrowserRouter } from "react-router-dom";
2-
import Sidebar from "./Sidebar";
2+
import Sidebar from "./AppFrame";
33
import Home from "./routes/Home";
44

55
export default function App() {

frontend/src/AppFrame.tsx

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import {
2+
Box,
3+
Drawer,
4+
List,
5+
ListItemButton,
6+
ListItemText,
7+
Paper,
8+
Typography,
9+
} from "@mui/material";
10+
import React from "react";
11+
import {
12+
Outlet,
13+
Link as RouterLink,
14+
LinkProps as RouterLinkProps,
15+
useLocation,
16+
} from "react-router-dom";
17+
18+
interface ListItemLinkProps {
19+
children: string;
20+
to: string;
21+
}
22+
23+
const Link = React.forwardRef<HTMLAnchorElement, RouterLinkProps>(function Link(
24+
itemProps,
25+
ref
26+
) {
27+
return <RouterLink ref={ref} {...itemProps} role={undefined} />;
28+
});
29+
30+
export function ListItemLink(props: ListItemLinkProps) {
31+
const { children, to } = props;
32+
const currentPath = useLocation().pathname;
33+
34+
const child = (
35+
<ListItemButton component={Link} to={to}>
36+
<ListItemText primary={children} />
37+
</ListItemButton>
38+
);
39+
40+
return (
41+
<li>
42+
{currentPath === to ? (
43+
<Paper square sx={{ backgroundColor: "#DDDDDD" }} elevation={1}>
44+
{child}
45+
</Paper>
46+
) : (
47+
child
48+
)}
49+
</li>
50+
);
51+
}
52+
53+
function Sidebar() {
54+
return (
55+
<Box component="aside" sx={{ width: { sm: "10%" }, flexShrink: { sm: 0 } }}>
56+
<Drawer
57+
variant="permanent"
58+
anchor="left"
59+
sx={{ "& .MuiDrawer-paper": { boxSizing: "border-box", width: "10%" } }}
60+
>
61+
<Paper elevation={0} square>
62+
<List>
63+
<ListItemLink to="/">Home</ListItemLink>
64+
</List>
65+
</Paper>
66+
</Drawer>
67+
</Box>
68+
);
69+
}
70+
71+
export const SetTitleContext = React.createContext<
72+
(newTitle: string) => unknown
73+
>(() => {});
74+
75+
export default function AppFrameOutlet() {
76+
const [title, setTitle] = React.useState("");
77+
78+
return (
79+
<div>
80+
<Box sx={{ display: "flex" }}>
81+
<Sidebar />
82+
<Box component="main" sx={{ flexGrow: 1, p: 3, width: { sm: "90%" } }}>
83+
<Box sx={{ width: { sm: "100%" }, px: 3, pb: 1.5, textAlign: "center", borderBottom: "1px solid black" }}>
84+
<Box>
85+
<Typography variant="h1" sx={{fontSize: "200%"}}>
86+
{title} {title ?? "-"} Wayback Archiver Server Data Viewer
87+
</Typography>
88+
</Box>
89+
</Box>
90+
<SetTitleContext.Provider value={setTitle}>
91+
<Outlet />
92+
</SetTitleContext.Provider>
93+
</Box>
94+
</Box>
95+
</div>
96+
);
97+
}

frontend/src/Sidebar.tsx

Lines changed: 0 additions & 73 deletions
This file was deleted.

frontend/src/api/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ const client = createClient<paths>({ baseUrl: basePath });
88
export const { GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE } = client;
99

1010
export type JobMaybe = paths["/current_job"]["get"]["responses"]["200"]["content"]["application/json"]["job"];
11-
export type Job = NonNullable<JobMaybe>;
11+
export type Job = NonNullable<JobMaybe>;
12+
export type Stats = paths["/stats"]["get"]["responses"]["200"]["content"]["application/json"];

frontend/src/misc/BatchChip.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import ListAltIcon from '@mui/icons-material/ListAlt';
2+
import { Chip } from '@mui/material';
3+
import { Link } from 'react-router-dom';
4+
5+
export default function BatchChip({batchId}: { batchId: number} ) {
6+
return (
7+
<Chip color='secondary' clickable={true} icon={<ListAltIcon />} label={'Batch ' + batchId} component={Link} to={`/batch/${batchId}`} />
8+
)
9+
}

0 commit comments

Comments
 (0)