Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve iphone view for RobotArmMovement #1338

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { Button, Icon } from '@equinor/eds-core-react'
import { Icon } from '@equinor/eds-core-react'
import { useLanguageContext } from 'components/Contexts/LanguageContext'
import { Icons } from 'utils/icons'
import { useRef } from 'react'
import { useInstallationContext } from 'components/Contexts/InstallationContext'
import styled from 'styled-components'
import { tokens } from '@equinor/eds-tokens'
import { StyledButton } from 'components/Styles/StyledComponents'

const StyledButton = styled(Button)`
const StyledCreateMissionButton = styled(StyledButton)`
display: flex;
align-items: center;
gap: 8px;
border-radius: 4px;
height: auto;
min-height: ${tokens.shape.button.minHeight};
`

export const CreateEchoMissionButton = (): JSX.Element => {
Expand All @@ -22,7 +20,7 @@ export const CreateEchoMissionButton = (): JSX.Element => {
const echoURL = 'https://echo.equinor.com/missionplanner?instCode='

return (
<StyledButton
<StyledCreateMissionButton
variant="outlined"
onClick={() => {
window.open(echoURL + installationCode)
Expand All @@ -32,6 +30,6 @@ export const CreateEchoMissionButton = (): JSX.Element => {
>
<Icon name={Icons.ExternalLink} size={16}></Icon>
{TranslateText('Create new Echo mission')}
</StyledButton>
</StyledCreateMissionButton>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ interface TypeProps {
}

const StyledImage = styled.img<{ $height?: string }>`
height: ${(props) => props.$height};
object-fit: contain;
max-height: ${(props) => props.$height};
max-width: 100%;
`

const StyledIcon = styled(Icon)`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Icon, Tabs } from '@equinor/eds-core-react'
import { Icon, Tabs } from '@equinor/eds-core-react'
import { useLanguageContext } from 'components/Contexts/LanguageContext'
import { InspectionSection } from './InspectionSection'
import { useEffect, useRef, useState } from 'react'
Expand All @@ -15,7 +15,7 @@ import { AlertType, useAlertContext } from 'components/Contexts/AlertContext'
import { EchoMissionDefinition } from 'models/MissionDefinition'
import { FailedRequestAlertContent } from 'components/Alerts/FailedRequestAlert'
import { Icons } from 'utils/icons'
import { tokens } from '@equinor/eds-tokens'
import { StyledButton } from 'components/Styles/StyledComponents'

const StyledContent = styled.div`
display: flex;
Expand All @@ -35,11 +35,6 @@ const StyledView = styled.div`
align-items: flex-start;
`

const StyledButton = styled(Button)`
height: auto;
min-height: ${tokens.shape.button.minHeight};
`

export const InspectionOverviewSection = () => {
const { TranslateText } = useLanguageContext()
const { installationCode } = useInstallationContext()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Autocomplete, Button, Dialog, Typography, Popover, Icon } from '@equinor/eds-core-react'
import { Autocomplete, Dialog, Typography, Popover, Icon } from '@equinor/eds-core-react'
import styled from 'styled-components'
import { useLanguageContext } from 'components/Contexts/LanguageContext'
import { useRef, useState, useEffect } from 'react'
Expand All @@ -8,12 +8,11 @@ import { CondensedMissionDefinition } from 'models/MissionDefinition'
import { BackendAPICaller } from 'api/ApiCaller'
import { Icons } from 'utils/icons'
import { useRobotContext } from 'components/Contexts/RobotContext'
import { StyledAutoComplete, StyledDialog } from 'components/Styles/StyledComponents'
import { StyledAutoComplete, StyledButton, StyledDialog } from 'components/Styles/StyledComponents'
import { useMissionsContext } from 'components/Contexts/MissionRunsContext'
import { FailedRequestAlertContent } from 'components/Alerts/FailedRequestAlert'
import { AlertType, useAlertContext } from 'components/Contexts/AlertContext'
import { ScheduleMissionWithLocalizationVerificationDialog } from 'components/Displays/LocalizationVerification/ScheduleMissionWithLocalizationVerification'
import { tokens } from '@equinor/eds-tokens'

interface IProps {
missions: CondensedMissionDefinition[]
Expand Down Expand Up @@ -50,12 +49,6 @@ const StyledDangerContent = styled.div`
gap: 2px;
`

const StyledButton = styled(Button)`
display: inline-block;
height: auto;
min-height: ${tokens.shape.button.minHeight};
`

export const ScheduleMissionDialog = (props: IProps): JSX.Element => {
const { TranslateText } = useLanguageContext()
const { enabledRobots } = useRobotContext()
Expand Down
44 changes: 23 additions & 21 deletions frontend/src/components/Pages/RobotPage/RobotArmMovement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ import { Robot } from 'models/Robot'
import { useLanguageContext } from 'components/Contexts/LanguageContext'
import { tokens } from '@equinor/eds-tokens'
import styled from 'styled-components'
import { StyledButton, StyledDialog } from 'components/Styles/StyledComponents'

interface RobotProps {
robot: Robot
armPosition: string
isRobotAvailable: boolean
}
const feedbackTimer = 10000 // Clear feedback after 10 seconds

const StyledButton = styled.div`
const StyledCloseButton = styled.div`
display: flex;
justify-content: end;
margin-top: 8px;
`
const LimitWidthStyle = styled.div`
max-width: calc(80vw);
`

export const MoveRobotArm = ({ robot, armPosition, isRobotAvailable }: RobotProps) => {
const { TranslateText } = useLanguageContext()
Expand Down Expand Up @@ -49,12 +52,7 @@ export const MoveRobotArm = ({ robot, armPosition, isRobotAvailable }: RobotProp
const onClickMoveArm = () => {
BackendAPICaller.setArmPosition(robot.id, armPosition)
.then(() => {
setUsable(false)
setFeedback(() => TranslateText('Moving arm to ') + TranslateText(armPosition))
setTimeout(() => {
setFeedback('')
setUsable(true)
}, feedbackTimer)
})
.catch((error) => {
setFeedback(
Expand All @@ -64,29 +62,33 @@ export const MoveRobotArm = ({ robot, armPosition, isRobotAvailable }: RobotProp
TranslateText(' Error message: ') +
error.message
)
setTimeout(() => {
setFeedback('')
}, feedbackTimer)
})
}
return (
<>
<Popover anchorEl={anchorRef.current} onClose={closePopover} open={isPopoverOpen} placement="top">
<Popover.Content>
<Typography variant="body_short">
{TranslateText(
'This button is disabled because the robot is not available. Check that the robot is on, and are not doing any other activities.'
)}
</Typography>
<StyledButton>
<Button onClick={closePopover}>{TranslateText('Close')}</Button>
</StyledButton>
<LimitWidthStyle>
<Typography variant="body_short">
{TranslateText(
'This button is disabled because the robot is not available. Check that the robot is on, and are not doing any other activities.'
)}
</Typography>
<StyledCloseButton>
<Button onClick={closePopover}>{TranslateText('Close')}</Button>
</StyledCloseButton>
</LimitWidthStyle>
</Popover.Content>
</Popover>
<Button style={moveArmButtonStyle()} onClick={!usable ? openPopover : onClickMoveArm} ref={anchorRef}>
<StyledButton style={moveArmButtonStyle()} onClick={!usable ? openPopover : onClickMoveArm} ref={anchorRef}>
{TranslateText('Set robot arm to ') + '"' + TranslateText(armPosition) + '"'}
</Button>
{feedback && <p>{feedback}</p>}
</StyledButton>
<StyledDialog open={feedback !== ''}>
{feedback}
<StyledCloseButton>
<Button onClick={() => setFeedback('')}>{TranslateText('Close')}</Button>
</StyledCloseButton>
</StyledDialog>
</>
)
}
1 change: 1 addition & 0 deletions frontend/src/components/Pages/RobotPage/RobotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const RobotInfo = styled.div`
display: flex;
align-items: start;
gap: 1rem;
width: calc(80vw);
`
const VerticalContent = styled.div<{ $alignItems?: string }>`
display: flex;
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/Styles/StyledComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Dialog } from '@equinor/eds-core-react'
import { Button, Dialog } from '@equinor/eds-core-react'
import { tokens } from '@equinor/eds-tokens'
import styled from 'styled-components'

export const StyledDialog = styled(Dialog)`
Expand All @@ -16,3 +17,8 @@ export const StyledAutoComplete = styled.div`
gap: 25px;
box-shadow: none;
`

export const StyledButton = styled(Button)`
height: auto;
min-height: ${tokens.shape.button.minHeight};
`
Loading