Skip to content

Commit 18d7d09

Browse files
committed
Add button for navigation to data view
1 parent 99add70 commit 18d7d09

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

frontend/src/language/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,5 +385,6 @@
385385
"Fill [%]": "Fill [%]",
386386
"No data available in the selected time range": "No data available in the selected time range",
387387
"Data View for Constant Level Oilers": "Data View for Constant Level Oilers",
388-
"Analysis result not available": "Analysis result not available"
388+
"Analysis result not available": "Analysis result not available",
389+
"Go to data overview": "Go to data overview"
389390
}

frontend/src/language/no.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,5 +385,6 @@
385385
"Fill [%]": "Fyll [%]",
386386
"No data available in the selected time range": "Ingen data tilgjengelig i det valgte tidsrommet",
387387
"Data View for Constant Level Oilers": "Datavisning for Constant Level Oilers",
388-
"Analysis result not available": "Analyseresultat ikke tilgjengelig"
388+
"Analysis result not available": "Analyseresultat ikke tilgjengelig",
389+
"Go to data overview": "Gå til dataoversikt"
389390
}

frontend/src/pages/MissionPage/MissionHeader/MissionHeader.tsx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { phone_width } from 'utils/constants'
1616
import { useContext } from 'react'
1717
import { InstallationContext } from 'components/Contexts/InstallationContext'
1818
import { RobotStatus } from 'models/Robot'
19+
import { AnalysisType } from 'models/MissionDefinition'
1920

2021
const HeaderSection = styled(Card)`
2122
width: 100%;
@@ -175,6 +176,23 @@ export const MissionHeader = ({ mission }: { mission: Mission }) => {
175176
mission.robot.status !== RobotStatus.GoingToRecharging &&
176177
mission.robot.status !== RobotStatus.RechargingWithMission
177178

179+
const analysisType = mission.tasks
180+
.flatMap((task) => task.inspection?.analysisTypes ?? [])
181+
.find((type) => type === AnalysisType.Fencilla || type === AnalysisType.CLOE)
182+
183+
const getDataOverviewUrl = (type: AnalysisType): string | undefined => {
184+
switch (type) {
185+
case AnalysisType.Fencilla:
186+
return `/${installation.installationCode}/data-view?missionName="Perimeter"&statuses=%5B"Successful"%2C"PartiallySuccessful"%5D`
187+
case AnalysisType.CLOE:
188+
return `/${installation.installationCode}/cloe-view`
189+
default:
190+
return undefined
191+
}
192+
}
193+
194+
const dataOverviewUrl = analysisType ? getDataOverviewUrl(analysisType) : undefined
195+
178196
return (
179197
<>
180198
<HeaderSection>
@@ -204,6 +222,11 @@ export const MissionHeader = ({ mission }: { mission: Mission }) => {
204222
>
205223
{TranslateText('View mission definition')}
206224
</Button>
225+
{dataOverviewUrl && (
226+
<Button variant="outlined" onClick={() => navigate(dataOverviewUrl)}>
227+
{TranslateText('Go to data overview')}
228+
</Button>
229+
)}
207230
</TitleSection>
208231
<Typography
209232
variant="body_long"
@@ -235,7 +258,8 @@ export const MissionHeader = ({ mission }: { mission: Mission }) => {
235258
export const SimpleMissionHeader = ({ mission }: { mission: Mission }) => {
236259
const { TranslateText } = useLanguageContext()
237260
const isMissionCompleted = mission.endTime ? true : false
238-
261+
const { installation } = useContext(InstallationContext)
262+
const navigate = useNavigate()
239263
const translatedStartDate = TranslateText('Start date')
240264
const translatedStartTime = TranslateText('Start time')
241265
const translatedUsedTime = TranslateText('Time used')
@@ -264,6 +288,18 @@ export const SimpleMissionHeader = ({ mission }: { mission: Mission }) => {
264288
{mission.description && `${translatedDescription}: ${mission.description}`}
265289
</Typography>
266290
<StatusReason statusReason={mission.statusReason} status={mission.status}></StatusReason>
291+
<TitleSection>
292+
<Button
293+
variant="outlined"
294+
onClick={() =>
295+
navigate(
296+
`/${installation.installationCode}/data-view?missionName="Perimeter"&statuses=%5B"Successful"%2C"PartiallySuccessful"%5D`
297+
)
298+
}
299+
>
300+
{TranslateText('Go to data overview')}
301+
</Button>
302+
</TitleSection>
267303
</StaticHeaderSection>
268304
<StyledMissionHeader>
269305
<InfoSection>

0 commit comments

Comments
 (0)