Prepared for serving

This commit is contained in:
Dunemask 2022-07-12 23:28:47 +00:00
parent fd71714fc0
commit 6526b51429
6 changed files with 39 additions and 17 deletions

View file

@ -1,6 +1,8 @@
import express, { Router } from "express"; import express, { Router } from "express";
import path from "path";
const router = Router(); const router = Router();
router.use("/", express.static(path.resolve("./build")));
router.use("/qualiteer", express.static("build/")); router.get("/*", (req, res) =>
res.sendFile(path.resolve("./build/index.html"))
);
export default router; export default router;

View file

@ -19,7 +19,7 @@ export default function buildRoutes(pg, skio) {
// Middlewares // Middlewares
// Routes // Routes
router.use(react); // Static Build Route router.use("/qualiteer", react); // Static Build Route
router.use("/api/results", results); router.use("/api/results", results);
router.use("/api/alerting", alerting); router.use("/api/alerting", alerting);
router.use("/api/catalog", catalog); router.use("/api/catalog", catalog);

View file

@ -61,9 +61,10 @@ export default function Navbar(props) {
})); }));
const navHeader = () => { const navHeader = () => {
const pathStr = const name = location.pathname.split("/").pop();
location.pathname.charAt(1).toUpperCase() + location.pathname.slice(2);
if (location.pathname !== "/failing") return pathStr; const pathStr = name.charAt(0).toUpperCase() + name.slice(1);
if (location.pathname !== "/qualiteer/failing") return pathStr;
return ( return (
<SideBadge <SideBadge
badgeContent={store.failing.length} badgeContent={store.failing.length}
@ -107,8 +108,8 @@ export default function Navbar(props) {
<ListItemButton <ListItemButton
key={text} key={text}
component={Link} component={Link}
to={"/" + text} to={"/qualiteer/" + text}
selected={location.pathname === "/" + text} selected={location.pathname === "/qualiteer/" + text}
onClick={closeDrawer} onClick={closeDrawer}
> >
<ListItemIcon>{icons[index]}</ListItemIcon> <ListItemIcon>{icons[index]}</ListItemIcon>
@ -126,7 +127,7 @@ export default function Navbar(props) {
<Avatar <Avatar
style={{ cursor: "pointer" }} style={{ cursor: "pointer" }}
alt="QA" alt="QA"
src="/assets/QA.png" src="/qualiteer/assets/QA.png"
onClick={reloadPage} onClick={reloadPage}
/> />
</Toolbar> </Toolbar>

3
src/views/NotFound.jsx Normal file
View file

@ -0,0 +1,3 @@
export default function NotFound() {
return <h1>Error 404 not found!</h1>;
}

View file

@ -11,6 +11,7 @@ import Jobs from "./jobs/Jobs.jsx";
import Catalog from "./catalog/Catalog.jsx"; import Catalog from "./catalog/Catalog.jsx";
import Settings from "./settings/Settings.jsx"; import Settings from "./settings/Settings.jsx";
import About from "./about/About.jsx"; import About from "./about/About.jsx";
import NotFound from "./NotFound.jsx";
export default function Views() { export default function Views() {
return ( return (
@ -20,13 +21,24 @@ export default function Views() {
<Box component="main" sx={{ flexGrow: 1, p: 3 }}> <Box component="main" sx={{ flexGrow: 1, p: 3 }}>
<Toolbar /> <Toolbar />
<Routes> <Routes>
<Route exact path="/" element={<Navigate to="/failing" replace />} /> <Route
<Route path="/failing" element={<Failing />} /> exact
<Route path="/alerting" element={<Alerting />} /> path="/qualiteer/"
<Route path="/jobs" element={<Jobs />} /> element={<Navigate to="/qualiteer/failing" replace />}
<Route path="/catalog" element={<Catalog />} /> />
<Route path="/settings" element={<Settings />} /> <Route
<Route path="/about" element={<About />} /> exact
path="/"
element={<Navigate to="/qualiteer/failing" replace />}
/>
<Route path="/qualiteer/failing" element={<Failing />} />
<Route path="/qualiteer/alerting" element={<Alerting />} />
<Route path="/qualiteer/jobs" element={<Jobs />} />
<Route path="/qualiteer/catalog" element={<Catalog />} />
<Route path="/qualiteer/settings" element={<Settings />} />
<Route path="/qualiteer/about" element={<About />} />
<Route path="/qualiteer/404" element={<NotFound />} />
<Route path="*" element={<Navigate to="/qualiteer/404" replace />} />
</Routes> </Routes>
</Box> </Box>
</div> </div>

View file

@ -10,5 +10,9 @@ export default () => {
port: 443, port: 443,
}, },
}, },
build: {
outDir: "./build",
},
base: "/qualiteer/",
}); });
}; };