Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a9f97f
commit 2fae53b
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import axios from 'axios' | ||
import { withStyles } from '@material-ui/core/styles' | ||
import { red, green } from '@material-ui/core/colors' | ||
import Radio from '@material-ui/core/Radio' | ||
|
||
const radioStyle = (customColor) => ({ | ||
root: { | ||
color: customColor, | ||
'&$checked': { | ||
color: customColor, | ||
}, | ||
}, | ||
checked: {}, | ||
}) | ||
|
||
const CustomRadio = (customColor) => ( | ||
withStyles(radioStyle(customColor))(props => <Radio checked={true} color="default" {...props} />) | ||
) | ||
|
||
const GreenRadio = CustomRadio(green[600]) | ||
const RedRadio = CustomRadio(red[600]) | ||
|
||
function StatusIcon(props) { | ||
return props.value === 200 ? <GreenRadio /> : <RedRadio /> | ||
} | ||
|
||
function HealthCheck() { | ||
const [data, setData] = useState({ status: {} }) | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
const result = await axios( | ||
'http://127.0.0.1:8080/v1/health', | ||
) | ||
|
||
setData(result) | ||
} | ||
|
||
fetchData() | ||
}, []) | ||
|
||
return ( | ||
<div> | ||
API Health Status: <StatusIcon value={data.status}/> | ||
</div> | ||
) | ||
} | ||
|
||
export default HealthCheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import React from 'react'; | ||
import HealthCheck from '../components/health-check' | ||
|
||
export default function Home() { | ||
return ( | ||
<div> | ||
Home | ||
<HealthCheck /> | ||
</div> | ||
); | ||
} |