Skip to content

Commit

Permalink
Scroll to correct robot when scheduling mission
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Nov 27, 2024
1 parent f42b338 commit 7778f3c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useMissionsContext } from 'components/Contexts/MissionRunsContext'
import { MissionHistoryButton } from './MissionHistoryButton'
import { Robot } from 'models/Robot'
import { RobotMissionQueueView } from './MissionQueueView'
import { FrontPageSectionId } from 'models/FrontPageSectionId'

const MissionControlStyle = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useLanguageContext } from 'components/Contexts/LanguageContext'
import { useMissionsContext } from 'components/Contexts/MissionRunsContext'
import { AlertType, useAlertContext } from 'components/Contexts/AlertContext'
import { FailedRequestAlertContent, FailedRequestAlertListContent } from 'components/Alerts/FailedRequestAlert'
import { FrontPageSectionId } from 'models/FrontPageSectionId'
import { AlertCategory } from 'components/Alerts/AlertsBanner'
import { Robot } from 'models/Robot'
import { tokens } from '@equinor/eds-tokens'
Expand Down Expand Up @@ -72,7 +71,7 @@ export const RobotMissionQueueView = ({ robot }: { robot: Robot }): JSX.Element
return (
<>
{(robotMissionQueue.length > 0 || loadingMissionSet.size > 0) && (
<StyledMissionView id={FrontPageSectionId.MissionQueue}>
<StyledMissionView>
{missionQueueDisplay}
{loadingMissionSet.size > 0 && loadingQueueDisplay}
</StyledMissionView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => {
})

if (missionsToSchedule.length > 0) {
let missionQueue = document.getElementById(FrontPageSectionId.MissionQueue)
let robotCard = document.getElementById(FrontPageSectionId.RobotCard + selectedRobot.id)
let topBarHeight = document.getElementById(FrontPageSectionId.TopBar)?.offsetHeight ?? 0

if (missionQueue) {
window.scroll({ top: missionQueue.offsetTop - topBarHeight, behavior: 'smooth' })
if (robotCard) {
window.scroll({ top: robotCard.offsetTop - topBarHeight, behavior: 'smooth' })
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/models/FrontPageSectionId.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum FrontPageSectionId {
TopBar = 'topBar',
MissionQueue = 'missionQueue',
RobotCard = 'robotCard',
InspectionTable = 'inspectionTable',
}

0 comments on commit 7778f3c

Please sign in to comment.