Skip to content

Commit

Permalink
refactor(webapp): refactor logic to show the health check
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Apr 25, 2023
1 parent 1297a7e commit 3d8319a
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions webapp/src/components/EndpointsTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Tooltip as MUITooltip } from '@mui/material'
import ListAltIcon from '@mui/icons-material/ListAlt'
import { Link as RouterLink } from 'react-router-dom'
import Link from '@mui/material/Link'
import QueryStatsIcon from '@mui/icons-material/QueryStats';
import QueryStatsIcon from '@mui/icons-material/QueryStats'

import HealthCheck from '../HealthCheck'
import HealthCheckInfo from 'components/HealthCheck/HealthCheckInfo'
Expand Down Expand Up @@ -42,24 +42,24 @@ const EndpointsTable = ({ producers }) => {

const syncToleranceInterval = eosConfig.syncToleranceInterval

const getStatus = (endpoint) => {
if (endpoint.response.status === undefined) return

const isSynchronized = endpoint => {
const diffBlockTimems =
new Date(endpoint.updated_at) - new Date(endpoint.head_block_time)

if (diffBlockTimems <= syncToleranceInterval) {
return 'greenLight'
} else {
switch (Math.floor(endpoint.response?.status / 100)) {
case 2:
return 'timerOff'
case 4:
case 5:
return 'yellowLight'
default:
return 'redLight'
}
return diffBlockTimems <= syncToleranceInterval
}

const getStatus = endpoint => {
if (endpoint.response.status === undefined) return

switch (Math.floor(endpoint.response?.status / 100)) {
case 2:
return isSynchronized(endpoint) ? 'greenLight' : 'timerOff'
case 4:
case 5:
return 'yellowLight'
default:
return 'redLight'
}
}

Expand Down Expand Up @@ -144,19 +144,19 @@ const EndpointsTable = ({ producers }) => {
<TableRow key={`${producer.name}-${index}`}>
<TableCell>
<div className={classes.healthContainer}>
{producer.name}
{!!producer.endpoints.api.length +
producer.endpoints.ssl.length && (
<Link
component={RouterLink}
state={{ producerId: producer.id }}
to="/endpoints-stats"
color="secondary"
>
<QueryStatsIcon />
</Link>
)}
</div>
{producer.name}
{!!producer.endpoints.api.length +
producer.endpoints.ssl.length && (
<Link
component={RouterLink}
state={{ producerId: producer.id }}
to="/endpoints-stats"
color="secondary"
>
<QueryStatsIcon />
</Link>
)}
</div>
</TableCell>
<CellList producer={producer} endpointType={'api'} />
<CellList producer={producer} endpointType={'ssl'} />
Expand Down

0 comments on commit 3d8319a

Please sign in to comment.