Skip to content

Commit

Permalink
Implement unconditional stop button for robots
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonsf committed Nov 19, 2024
1 parent 75d2ed7 commit 52cf4fc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, Typography } from '@equinor/eds-core-react'
import { Button, Card, Typography } from '@equinor/eds-core-react'
import { Robot, RobotStatus } from 'models/Robot'
import { tokens } from '@equinor/eds-tokens'
import { RobotStatusChip } from 'components/Displays/RobotDisplays/RobotStatusIcon'
Expand All @@ -11,10 +11,14 @@ import { PressureStatusDisplay } from 'components/Displays/RobotDisplays/Pressur
import { config } from 'config'
import { RobotType } from 'models/RobotModel'
import { Mission } from 'models/Mission'
import { StopMissionDialog } from '../MissionOverview/StopDialogs'
import { useState } from 'react'
import { TaskType } from 'models/Task'

interface RobotProps {
robot: Robot
mission: Mission | undefined
missionTaskType: TaskType | undefined
}

const StyledCard = styled(Card)`
Expand Down Expand Up @@ -78,13 +82,34 @@ const LongTypography = styled(Typography)`
}
`

export const RobotStatusCard = ({ robot, mission }: RobotProps) => {
const StyledButton = styled(Button)`
height: auto;
min-height: ${tokens.shape.button.minHeight};
justify-content: center;
align-items: center;
margin-top: 10px;
width: 100%;
#buttoncard:hover {
background-color: ${tokens.colors.infographic.primary__energy_red_100.hex};
}
:hover + #buttoncard {
background-color: ${tokens.colors.infographic.primary__energy_red_100.hex};
}
`

export const RobotStatusCard = ({ robot, mission, missionTaskType }: RobotProps) => {
let navigate = useNavigate()
const { TranslateText } = useLanguageContext()
const goToRobot = () => {
const path = `${config.FRONTEND_BASE_ROUTE}/robot/${robot.id}`
navigate(path)
}
const [isDialogOpen, setIsDialogOpen] = useState(false)
const toggleStopMissionDialog = () => {
setIsDialogOpen(!isDialogOpen)
}

const getRobotModel = (type: RobotType) => {
if (type === RobotType.TaurobInspector || type === RobotType.TaurobOperator) return 'Taurob'
Expand Down Expand Up @@ -143,6 +168,22 @@ export const RobotStatusCard = ({ robot, mission }: RobotProps) => {
<></>
)}
</HorizontalContent>
<StyledButton
variant="contained"
onClick={(event) => {
event.stopPropagation()
toggleStopMissionDialog()
}}
>
{TranslateText('Stop')} {robot.name}
<StopMissionDialog
missionName={mission?.name}
robotId={robot.id}
missionTaskType={undefined}
isStopMissionDialogOpen={isDialogOpen}
toggleDialog={toggleStopMissionDialog}
/>
</StyledButton>
</ButtonCard>
</HoverableStyledCard>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const RobotStatusSection = () => {
key={robot.id}
robot={robot}
mission={ongoingMissions.find((mission) => mission.robot.id === robot.id)}
missionTaskType={undefined}
/>
))

Expand Down

0 comments on commit 52cf4fc

Please sign in to comment.