-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Showing
5 changed files
with
131 additions
and
94 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
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,69 @@ | ||
import {Capability, useAutoEmptyDockManualTriggerMutation, useRobotStatusQuery} from "../api"; | ||
import {useCapabilitiesSupported} from "../CapabilitiesProvider"; | ||
import {Box, Button, Grid, Icon, Paper, styled, Typography} from "@mui/material"; | ||
import { | ||
RestoreFromTrash as EmptyIcon | ||
} from "@mui/icons-material"; | ||
import React from "react"; | ||
|
||
const Dock = (): JSX.Element => { | ||
const { data: status } = useRobotStatusQuery(); | ||
|
||
const StyledIcon = styled(Icon)(({ theme }) => { | ||
return { | ||
marginRight: theme.spacing(1), | ||
marginLeft: -theme.spacing(1), | ||
}; | ||
}); | ||
|
||
const [triggerEmptySupported] = useCapabilitiesSupported(Capability.AutoEmptyDockManualTrigger); | ||
const { | ||
mutate: triggerDockEmpty, | ||
isLoading: emptyIsExecuting, | ||
} = useAutoEmptyDockManualTriggerMutation(); | ||
|
||
if (status === undefined) { | ||
return ( | ||
<Paper> | ||
<Box p={1}> | ||
<Typography color="error">Error loading dock controls</Typography> | ||
</Box> | ||
</Paper> | ||
); | ||
} | ||
|
||
const { value: state } = status; | ||
|
||
return ( | ||
<Paper> | ||
<Box px={2} py={1}> | ||
<Grid container direction="row" alignItems="center" spacing={1}> | ||
<Grid item> | ||
<Typography variant="subtitle1">Dock</Typography> | ||
</Grid> | ||
{ | ||
triggerEmptySupported && | ||
<Grid item xs> | ||
<Box display="flex" justifyContent="flex-end"> | ||
<Button | ||
disabled={emptyIsExecuting || state !== "docked"} | ||
variant="outlined" | ||
size="medium" | ||
color="inherit" | ||
onClick={() => { | ||
triggerDockEmpty(); | ||
}} | ||
> | ||
<StyledIcon as={EmptyIcon} /> Empty | ||
</Button> | ||
</Box> | ||
</Grid> | ||
} | ||
|
||
</Grid> | ||
</Box> | ||
</Paper> | ||
); | ||
}; | ||
|
||
export default Dock; |
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