Skip to content

Commit d011208

Browse files
authoredNov 3, 2022
feat(front): display server's status and app version (#4)
fix #2
1 parent 597ece3 commit d011208

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed
 

‎Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ RUN [[ -d /app/public ]] || CI=false GENERATE_SOURCEMAP=false npm run build:dock
3030
# Final image
3131
FROM scratch
3232

33+
ARG APP_VERSION
34+
ENV APP_VERSION=${APP_VERSION}
35+
3336
# copy front files
3437
COPY --from=front-builder /app/public /app/public
3538

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Your web browser should open on `http://localhost:3000`. The app is configured t
141141
- [x] optimize build time
142142
- [x] allow user to set the public url for shortened content
143143
- [x] move from sqlite3 to modernc.org/sqlite to compile without CGO (and use scratch, lighter image)
144-
- [ ] display status with version
144+
- [x] display status with version
145145
- [ ] allow user to change language
146146
- [ ] add all options in front when create a new text
147147
- [ ] error handling (on add and delete)

‎front/src/App.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ function App() {
3131
<ThemeProvider theme={theme}>
3232
<AppContext.Provider value={appContextValue}>
3333
<div className={classes.root}>
34-
{!isLoading ? <><MainMenu />
35-
<Content>
36-
<Route path="/" element={<Links />} />
37-
<Route path="/texts" element={<Texts />} />
38-
<Route path="/files" element={<Files />} />
39-
</Content>
34+
{!isLoading ? <>
35+
<MainMenu />
36+
<Content>
37+
<Route path="/" element={<Links />} />
38+
<Route path="/texts" element={<Texts />} />
39+
<Route path="/files" element={<Files />} />
40+
</Content>
4041
</> : null}
4142
</div>
4243
</AppContext.Provider>

‎front/src/components/main_menu/index.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useContext } from "react";
12
import classes from "./styles.module.scss";
23
import Item from "./item";
34

@@ -6,10 +7,14 @@ import {Link as LinkIcon, TextSnippetOutlined as TextIcon, FilePresent as FileIc
67
import { AppBar, Drawer, Toolbar } from "@mui/material";
78
import { useTranslation } from "react-i18next";
89

10+
import AppContext from "../../app_context";
11+
import classNames from "classnames";
12+
913
const MainMenu:React.FC = () => {
1014
const {t} = useTranslation();
15+
const app = useContext(AppContext);
1116

12-
return <>
17+
return <>
1318
<AppBar position="fixed" className={classes.root_bottom} sx={{ display: { xs: 'block', md: 'none' }, top: 'auto', bottom: 0 }}>
1419
<Toolbar>
1520
<Item to="/" color="blue"><LinkIcon />{t("menu.links")}</Item>
@@ -22,6 +27,8 @@ const MainMenu:React.FC = () => {
2227
<Item to="/" color="blue"><LinkIcon />{t("menu.links")}</Item>
2328
<Item to="/texts" color="purple"><TextIcon />{t("menu.texts")}</Item>
2429
<Item to="/files" color="pink"><FileIcon />{t("menu.files")}</Item>
30+
<div className={classes.spacer} />
31+
<div className={classes.info}><span className={classNames(classes.status, {[classes.up]: app?.status === "up"})} /> {app?.version}</div>
2532
</Drawer>
2633
</>;
2734
};

‎front/src/components/main_menu/styles.module.scss

+21
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,25 @@
4141
.spacer {
4242
flex-grow: 1;
4343
}
44+
45+
.info {
46+
width: 100%;
47+
text-align: center;
48+
font-family: monospace;
49+
font-size: 12px;
50+
color: $gray-400;
51+
}
52+
53+
.status {
54+
display: inline-block;
55+
width: 8px;
56+
height: 8px;
57+
border-radius: 4px;
58+
background: $red-400;
59+
60+
61+
&.up {
62+
background: $green-400;
63+
}
64+
}
4465
}

0 commit comments

Comments
 (0)
Please sign in to comment.