Skip to content
Snippets Groups Projects
Commit 5ddcee6f authored by Martin Wighus Holtmon's avatar Martin Wighus Holtmon
Browse files

implemented version number

parent 7b8647c7
No related branches found
No related tags found
1 merge request!1Add version number
...@@ -12,18 +12,19 @@ import fetchModel from '../../../lib/fetchModelData'; ...@@ -12,18 +12,19 @@ import fetchModel from '../../../lib/fetchModelData';
class TopBar extends React.Component { class TopBar extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {headerContext: '', name: 'Group 9'}; this.state = {headerContext: '', name: 'Group 9', version: ''};
} }
componentDidUpdate(prevProps) { componentDidMount() {
if (this.props.location.pathname !== prevProps.location.pathname) {
this.updateHeader(this.props.location.pathname); this.updateHeader(this.props.location.pathname);
} this.fetchInfo();
} }
componentDidMount() { componentDidUpdate(prevProps) {
if (this.props.location.pathname !== prevProps.location.pathname) {
this.updateHeader(this.props.location.pathname); this.updateHeader(this.props.location.pathname);
} }
}
updateHeader = (pathname) => { updateHeader = (pathname) => {
const path = pathname.split('/'); const path = pathname.split('/');
...@@ -44,6 +45,12 @@ class TopBar extends React.Component { ...@@ -44,6 +45,12 @@ class TopBar extends React.Component {
} }
}; };
fetchInfo() {
fetchModel('http://localhost:3001/test/info')
.then((value) => this.setState({version: `v.${value.data.__v}`}))
.catch((error) => console.log(error));
}
render() { render() {
return ( return (
<Box sx={{flexGrow: 1}}> <Box sx={{flexGrow: 1}}>
...@@ -55,6 +62,9 @@ class TopBar extends React.Component { ...@@ -55,6 +62,9 @@ class TopBar extends React.Component {
<Typography variant="h5" color="inherit" component="div" sx={{flexGrow: 1}} id="right"> <Typography variant="h5" color="inherit" component="div" sx={{flexGrow: 1}} id="right">
{this.state.headerContext} {this.state.headerContext}
</Typography> </Typography>
<Typography variant="h5" color="inherit" component="div" sx={{flexGrow: 1}} id="version">
{this.state.version}
</Typography>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
</Box> </Box>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment