Skip to content

Commit

Permalink
Fix refresh rate of inspections page
Browse files Browse the repository at this point in the history
  • Loading branch information
mrica-equinor authored and andchiind committed Sep 19, 2023
1 parent 2b0443e commit 1e2b49b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 38 deletions.
5 changes: 2 additions & 3 deletions frontend/src/components/Pages/FrontPage/FrontPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export const refreshInterval = 1000

export function FrontPage() {
const refreshInterval = 1000
const slowRefreshInterval = 5000


return (
<>
<Header page={'root'} />
Expand All @@ -49,7 +48,7 @@ export function FrontPage() {
</MissionsContent>
</HorizontalContent>
<RobotStatusSection refreshInterval={refreshInterval} />
<InspectionSection refreshInterval={slowRefreshInterval} />
<InspectionSection refreshInterval={refreshInterval} />
</StyledFrontPage>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => {

useEffect(() => {
const id = setInterval(() => {
BackendAPICaller.getEnabledRobots().then((robots) => {
setRobotOptions(robots)
})
BackendAPICaller.getEnabledRobots().then((robots) => robots.filter(robots => robots.currentInstallation.toLowerCase() === installationCode.toLowerCase()))
.then((robots) => {
setRobotOptions(robots)
})
}, props.refreshInterval)
return () => clearInterval(id)
}, [props.refreshInterval])
}, [props.refreshInterval])

let timer: ReturnType<typeof setTimeout>

Expand Down Expand Up @@ -88,42 +89,12 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => {
</Popover.Content>
</Popover>

<StyledMissionDialog>
<StyledDialog open={true}>
<StyledAutoComplete>
<StyledMissionSection>
<Button
onClick={() => {
props.closeDialog()
}}
variant="outlined"
color="primary"
>
{' '}
{TranslateText('Cancel')}{' '}
</Button>
</StyledMissionSection>
</StyledAutoComplete>
</StyledDialog>
</StyledMissionDialog>

<StyledMissionDialog>
<Dialog open={true}>
<StyledAutoComplete>
<Typography variant="h5">{TranslateText('This installation has no missions')}</Typography>
</StyledAutoComplete>
</Dialog>
</StyledMissionDialog>

<StyledMissionDialog>
<StyledDialog open={true}>
<StyledAutoComplete>
<Autocomplete
optionLabel={(r) => r.name + ' (' + r.model.type + ')'}
options={robotOptions.filter(
(r) =>
r.currentInstallation.toLocaleLowerCase() === installationCode.toLocaleLowerCase()
)}
options={robotOptions}
label={TranslateText('Select robot')}
onOptionsChange={(changes) => onSelectedRobot(changes.selectedItems[0])}
autoWidth={true}
Expand Down

0 comments on commit 1e2b49b

Please sign in to comment.