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 path from "path";
const router = Router();
router.use("/qualiteer", express.static("build/"));
router.use("/", express.static(path.resolve("./build")));
router.get("/*", (req, res) =>
res.sendFile(path.resolve("./build/index.html"))
);
export default router;

View file

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

View file

@ -61,9 +61,10 @@ export default function Navbar(props) {
}));
const navHeader = () => {
const pathStr =
location.pathname.charAt(1).toUpperCase() + location.pathname.slice(2);
if (location.pathname !== "/failing") return pathStr;
const name = location.pathname.split("/").pop();
const pathStr = name.charAt(0).toUpperCase() + name.slice(1);
if (location.pathname !== "/qualiteer/failing") return pathStr;
return (
<SideBadge
badgeContent={store.failing.length}
@ -107,8 +108,8 @@ export default function Navbar(props) {
<ListItemButton
key={text}
component={Link}
to={"/" + text}
selected={location.pathname === "/" + text}
to={"/qualiteer/" + text}
selected={location.pathname === "/qualiteer/" + text}
onClick={closeDrawer}
>
<ListItemIcon>{icons[index]}</ListItemIcon>
@ -126,7 +127,7 @@ export default function Navbar(props) {
<Avatar
style={{ cursor: "pointer" }}
alt="QA"
src="/assets/QA.png"
src="/qualiteer/assets/QA.png"
onClick={reloadPage}
/>
</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 Settings from "./settings/Settings.jsx";
import About from "./about/About.jsx";
import NotFound from "./NotFound.jsx";
export default function Views() {
return (
@ -20,13 +21,24 @@ export default function Views() {
<Box component="main" sx={{ flexGrow: 1, p: 3 }}>
<Toolbar />
<Routes>
<Route exact path="/" element={<Navigate to="/failing" replace />} />
<Route path="/failing" element={<Failing />} />
<Route path="/alerting" element={<Alerting />} />
<Route path="/jobs" element={<Jobs />} />
<Route path="/catalog" element={<Catalog />} />
<Route path="/settings" element={<Settings />} />
<Route path="/about" element={<About />} />
<Route
exact
path="/qualiteer/"
element={<Navigate to="/qualiteer/failing" replace />}
/>
<Route
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>
</Box>
</div>

View file

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