Skip to content

Commit

Permalink
feat(Add backend version via `/status route):
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwahle committed Aug 9, 2022
1 parent 675291e commit 163b764
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
38 changes: 13 additions & 25 deletions src/routes/home.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import React from 'react';
import React, { useState, useEffect } from 'react';
import '../App.css';
import { Button, Container, Stack, Typography, useTheme } from '@mui/material';
import { ROUTE_LOGIN, ROUTE_PAPERS, ROUTE_REGISTER } from '../consts';
import { Link } from 'react-router-dom';
import GitInfo from 'react-git-info/macro';
import { GitHub } from '@mui/icons-material';
import { useNetworkGet } from '../network';
import { Status } from '../types';

export default function Home() {
const theme = useTheme();
const gitInfo = GitInfo();
const [backendVersion, setBackendVersion] = useState('0.0.1');

const { refetch } = useNetworkGet('status', '', (status: Status) =>
setBackendVersion(status.version)
);

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

return (
<div style={{ backgroundColor: '#eeeeee' }}>
Expand All @@ -19,7 +28,7 @@ export default function Home() {
Welcome to the CS-Insights Demo
</Typography>
<Typography className="statsHighlight" style={{ margin: '0px' }}>
v{process.env.REACT_APP_VERSION}
frontend: v{process.env.REACT_APP_VERSION} - backend: v{backendVersion}
</Typography>
<Button
variant="contained"
Expand Down Expand Up @@ -60,27 +69,6 @@ export default function Home() {
</a>
!
</Stack>
<footer
style={{
color: 'gray',
position: 'fixed',
bottom: 3,
}}
>
<Typography color={'gray'}>
{'Running commit '}
<a
href={'https://github.com/gipplab/NLP-Land-frontend/commit/' + gitInfo.commit.hash}
target="_blank"
rel="noopener noreferrer"
className="statsHighlight"
>
{gitInfo.commit.shortHash}
</a>
{` from `}
{new Date(gitInfo.commit.date).toUTCString()}
</Typography>
</footer>
</Stack>
</Container>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@ export type QueryParameters = {
citationsMax: string;
} & StringArrayParameters &
NonFilterParameters;

export type Status = {
status: string;
version: string;
}

0 comments on commit 163b764

Please sign in to comment.