Skip to content

Commit

Permalink
Improve robot cards
Browse files Browse the repository at this point in the history
  • Loading branch information
mrica-equinor committed Jul 24, 2024
1 parent 8338d41 commit 950f1de
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { PressureStatus } from 'models/Pressure'

const PressureAlignment = styled.div`
display: flex;
align-items: center;
gap: 7px;
align-items: end;
`

const StyledTypography = styled(Typography)<{ $fontSize?: 24 | 16 | 18 | 32 | 40 | 48 }>`
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Displays/RobotDisplays/RobotImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const StyledImage = styled.img<{ $height?: string }>`
object-fit: contain;
max-height: ${(props) => props.$height};
max-width: 100%;
display: flex;
justify-content: center;
padding: 12px 5px 12px 5px;
`

const StyledIcon = styled(Icon)`
Expand Down
62 changes: 0 additions & 62 deletions frontend/src/components/Displays/RobotDisplays/RobotStatusChip.tsx

This file was deleted.

72 changes: 72 additions & 0 deletions frontend/src/components/Displays/RobotDisplays/RobotStatusIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Icon, Typography } from '@equinor/eds-core-react'
import { RobotStatus } from 'models/Robot'
import { tokens } from '@equinor/eds-tokens'
import { useLanguageContext } from 'components/Contexts/LanguageContext'
import { useSafeZoneContext } from 'components/Contexts/SafeZoneContext'
import { Icons } from 'utils/icons'
import { styled } from 'styled-components'

interface StatusProps {
status?: RobotStatus
isarConnected: boolean
}

const StyledStatus = styled.div`
display: flex;
flex-direction: row;
align-items: end;
gap: 2px;
`

const StyledIcon = styled(Icon)`
width: 24px;
height: 24px;
`

export const RobotStatusChip = ({ status, isarConnected }: StatusProps) => {
const { TranslateText } = useLanguageContext()
const { safeZoneStatus } = useSafeZoneContext()

var iconColor = tokens.colors.text.static_icons__default.hex
var statusIcon = Icons.CloudOff
switch (status) {
case RobotStatus.Available: {
statusIcon = Icons.Successful
iconColor = tokens.colors.interactive.success__resting.hex
break
}
case RobotStatus.Busy: {
statusIcon = Icons.ClosedCircleOutlined
iconColor = tokens.colors.interactive.warning__resting.hex
break
}
case RobotStatus.Blocked: {
statusIcon = Icons.Blocked
iconColor = tokens.colors.interactive.danger__resting.hex
break
}
default: {
iconColor = tokens.colors.text.static_icons__default.hex
statusIcon = Icons.CloudOff
status = RobotStatus.Offline
break
}
}

if (!isarConnected) {
iconColor = tokens.colors.interactive.disabled__text.hex
statusIcon = Icons.Info
status = RobotStatus.ConnectionIssues
} else if (safeZoneStatus) {
iconColor = tokens.colors.interactive.danger__resting.hex
statusIcon = Icons.Warning
status = RobotStatus.SafeZone
}

return (
<StyledStatus>
<StyledIcon name={statusIcon} style={{ color: iconColor }} />
<Typography variant="body_short">{TranslateText(status)}</Typography>
</StyledStatus>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { 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/RobotStatusChip'
import { RobotStatusChip } from 'components/Displays/RobotDisplays/RobotStatusIcon'
import { BatteryStatusDisplay } from 'components/Displays/RobotDisplays/BatteryStatusDisplay'
import styled from 'styled-components'
import { RobotImage } from 'components/Displays/RobotDisplays/RobotImage'
Expand All @@ -17,34 +17,41 @@ interface RobotProps {

const StyledCard = styled(Card)`
width: 220px;
padding: 8px;
padding: 12px;
`
const HoverableStyledCard = styled(Card)`
width: 220px;
:hover {
background-color: ${tokens.colors.interactive.primary__hover_alt.hex};
display: flex;
flex-direction: column;
width: 280px;
gap: 0px;
background-color: ${tokens.colors.ui.background__default.hex};
cursor: pointer;
:hover + #bottomcard {
background-color: ${tokens.colors.infographic.primary__mist_blue.hex};
}
`

const ButtonCard = styled.div`
background-color: ${tokens.colors.ui.background__light.hex};
padding: 10px;
border-radius: 0px 0px 6px 6px;
pointer-events: auto;
`
const HorizontalContent = styled.div`
display: flex;
flex-direction: row;
align-content: end;
align-items: end;
justify-content: space-between;
padding-top: 2px;
`

const VerticalContent = styled.div<{ $alignItems?: string }>`
const VerticalContent = styled.div`
display: flex;
flex-direction: column;
align-items: ${(props) => props.$alignItems};
justify-content: flex-end;
justify-content: left;
gap: 4px;
`

const StyledPadding = styled.div`
padding: 8px;
`

const LongTypography = styled(Typography)`
overflow: hidden;
text-overflow: ellipsis;
Expand All @@ -59,41 +66,59 @@ const LongTypography = styled(Typography)`

export const RobotStatusCard = ({ robot }: RobotProps) => {
let navigate = useNavigate()
const { TranslateText } = useLanguageContext()
const goToRobot = () => {
const path = `${config.FRONTEND_BASE_ROUTE}/robot/${robot.id}`
navigate(path)
}

const getRobotModel = (type: RobotType) => {
if (type === RobotType.TaurobInspector || type === RobotType.TaurobOperator) return 'Taurob'
return type
}

return (
<HoverableStyledCard style={{ boxShadow: tokens.elevation.raised }} onClick={goToRobot}>
<StyledPadding>
<RobotImage robotType={robot.model.type} height="200px" />
<LongTypography variant="h5">{robot.name}</LongTypography>
<RobotImage robotType={robot.model.type} height="180px" />
<ButtonCard id="bottomcard">
<LongTypography variant="h5">
{robot.name}
{' ('}
{getRobotModel(robot.model.type)}
{')'}
</LongTypography>
<HorizontalContent>
<VerticalContent $alignItems="start">
<Typography variant="caption">{robot.model.type}</Typography>
<VerticalContent>
<Typography variant="meta">{TranslateText('Status')}</Typography>
<RobotStatusChip status={robot.status} isarConnected={robot.isarConnected} />
</VerticalContent>
<VerticalContent $alignItems="end">
{robot.status !== RobotStatus.Offline ? (
<>
{robot.pressureLevel !== undefined && robot.pressureLevel !== null && (

{robot.status !== RobotStatus.Offline ? (
<>
<VerticalContent>
<Typography variant="meta">{TranslateText('Battery')}</Typography>
<BatteryStatusDisplay
batteryLevel={robot.batteryLevel}
batteryWarningLimit={robot.model.batteryWarningThreshold}
/>
</VerticalContent>

{robot.pressureLevel !== undefined && robot.pressureLevel !== null && (
<VerticalContent>
<Typography variant="meta">{TranslateText('Pressure')}</Typography>
<PressureStatusDisplay
pressure={robot.pressureLevel}
upperPressureWarningThreshold={robot.model.upperPressureWarningThreshold}
lowerPressureWarningThreshold={robot.model.lowerPressureWarningThreshold}
/>
)}
<BatteryStatusDisplay
batteryLevel={robot.batteryLevel}
batteryWarningLimit={robot.model.batteryWarningThreshold}
/>
</>
) : (
<></>
)}
</VerticalContent>
</VerticalContent>
)}
</>
) : (
<></>
)}
</HorizontalContent>
</StyledPadding>
</ButtonCard>
</HoverableStyledCard>
)
}
Expand All @@ -106,9 +131,6 @@ export const RobotStatusCardPlaceholder = () => {
<Typography variant="h5" color="disabled">
{TranslateText('No robot connected')}
</Typography>
<Typography variant="body_short" color="disabled">
----
</Typography>
<HorizontalContent>
<RobotStatusChip isarConnected={true} />
</HorizontalContent>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Pages/RobotPage/RobotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MoveRobotArm } from './RobotArmMovement'
import { PressureTable } from './PressureTable'
import { PressureStatusDisplay } from 'components/Displays/RobotDisplays/PressureStatusDisplay'
import { BatteryStatusDisplay } from 'components/Displays/RobotDisplays/BatteryStatusDisplay'
import { RobotStatusChip } from 'components/Displays/RobotDisplays/RobotStatusChip'
import { RobotStatusChip } from 'components/Displays/RobotDisplays/RobotStatusIcon'
import { RobotStatus } from 'models/Robot'
import { useLanguageContext } from 'components/Contexts/LanguageContext'
import { RobotType } from 'models/RobotModel'
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,6 @@
"Failed to send robots to a safe zone": "Failed to send robots to a safe zone",
"Failed to release robots from safe zone": "Failed to release robots from safe zone",
"Failed to send robot {0} home": "Failed to send robot {0} to starting position",
"Failed to update inspection": "Failed to update inspection"
"Failed to update inspection": "Failed to update inspection",
"Battery": "Battery"
}
3 changes: 2 additions & 1 deletion frontend/src/language/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,6 @@
"Failed to send robots to a safe zone": "Kunne ikke sende roboter til trygg sone",
"Failed to release robots from safe zone": "Kunne ikke slippe roboter ut av trygg sone",
"Failed to send robot {0} home": "Kunne ikke sende robot {0} til startposisjon",
"Failed to update inspection": "Kunne ikke oppdatere inspeksjon"
"Failed to update inspection": "Kunne ikke oppdatere inspeksjon",
"Battery": "Batteri"
}
Binary file modified frontend/src/mediaAssets/anymal_x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/src/mediaAssets/robot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/src/mediaAssets/taurob_inspector_no_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions frontend/src/utils/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import {
play,
edit,
info_circle,
blocked,
close_circle_outlined,
} from '@equinor/eds-icons'

Icon.add({
Expand Down Expand Up @@ -83,6 +85,8 @@ Icon.add({
play,
edit,
info_circle,
blocked,
close_circle_outlined,
})

export enum Icons {
Expand Down Expand Up @@ -126,4 +130,6 @@ export enum Icons {
PlayTriangle = 'play',
Edit = 'edit',
Info = 'info_circle',
Blocked = 'blocked',
ClosedCircleOutlined = 'close_circle_outlined',
}

0 comments on commit 950f1de

Please sign in to comment.