Skip to content
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
62 changes: 38 additions & 24 deletions backend/api/Database/Context/InitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,8 @@ private static List<TaskDefinition> GetMissionTaskDefinitions()
Description = "dummy task 1",
RobotPose = new Pose(),
AnalysisTypes = [AnalysisType.Fencilla],
TargetPosition = new Position
{
X = 0,
Y = 0,
Z = 0,
},
SensorType = SensorType.Image,
TargetPosition = new Position(),
};

var task2 = new TaskDefinition
Expand All @@ -216,13 +212,9 @@ private static List<TaskDefinition> GetMissionTaskDefinitions()
TagId = "dummy-tag-id-2",
Description = "dummy task 2",
RobotPose = new Pose(),
SensorType = SensorType.Image,
AnalysisTypes = [AnalysisType.CLOE],
TargetPosition = new Position
{
X = 0,
Y = 0,
Z = 0,
},
TargetPosition = new Position(),
};

var task3 = new TaskDefinition
Expand All @@ -232,12 +224,8 @@ private static List<TaskDefinition> GetMissionTaskDefinitions()
Description = "dummy task 3",
RobotPose = new Pose(),
AnalysisTypes = [AnalysisType.CO2],
TargetPosition = new Position
{
X = 0,
Y = 0,
Z = 0,
},
SensorType = SensorType.CO2Measurement,
TargetPosition = new Position(),
};

var task4 = new TaskDefinition
Expand All @@ -248,12 +236,7 @@ private static List<TaskDefinition> GetMissionTaskDefinitions()
RobotPose = new Pose(),
SensorType = SensorType.ThermalImage,
AnalysisTypes = [AnalysisType.ThermalReading],
TargetPosition = new Position
{
X = 0,
Y = 0,
Z = 0,
},
TargetPosition = new Position(),
};

return new List<TaskDefinition>([task1, task2, task3, task4]);
Expand Down Expand Up @@ -347,6 +330,36 @@ private static List<MissionDefinition> GetMissionDefinitions()
LastSuccessfulRun = null,
};

var onlyImagesWithoutAnalysisMissionDefinition = new MissionDefinition
{
Id = Guid.NewGuid().ToString(),
Name = "Only Images Without Analysis Mission",
InstallationCode = inspectionAreas[5].Installation.InstallationCode,
InspectionArea = inspectionAreas[5],
Tasks =
[
new TaskDefinition
{
TagId = "image-tag-1",
Description = "Tag to take image of",
RobotPose = new Pose(),
AnalysisTypes = [],
SensorType = SensorType.Image,
TargetPosition = new Position(),
},
new TaskDefinition
{
TagId = "image-tag-2",
Description = "Tag to take image of",
RobotPose = new Pose(),
AnalysisTypes = [],
SensorType = SensorType.Image,
TargetPosition = new Position(),
},
],
LastSuccessfulRun = null,
};

return new List<MissionDefinition>([
missionDefinition1,
missionDefinition2,
Expand All @@ -356,6 +369,7 @@ private static List<MissionDefinition> GetMissionDefinitions()
missionDefinition6,
thermalReadingMission,
cloeMission,
onlyImagesWithoutAnalysisMissionDefinition,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion backend/api/Database/Models/TaskDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public TaskDefinition(TaskQuery taskQuery, int index)

public IList<AnalysisType> AnalysisTypes { get; set; } = [];

public SensorType SensorType { get; set; }
public SensorType SensorType { get; set; } // Note that the enum will get SensorType.Image as default

public float? VideoDuration { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/models/InspectionRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface FlotillaAnalysisResultMessage {
export interface InspectionData {
inspectionId: string
analysisId: string
visualisedSAS?: string
visualizedSAS?: string
fileType: FileType
anonymizedSAS?: string
analysisType?: string
Expand Down Expand Up @@ -94,7 +94,7 @@ export const inspectionRecordToInspectionData = (record: InspectionRecord): Insp
return {
inspectionId: record.inspectionId,
analysisId: analysis.id,
visualisedSAS: analysis.visualizedSAS,
visualizedSAS: analysis.visualizedSAS,
anonymizedSAS: analysis.anonymizedSAS,
analysisType: record.inspectionType,
tag: record.tag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ const AnalysisImageWithPlaceholder = ({
const { useSaraData } = useInspectionsContext()
const { data, isPending, isError } = useSaraData(inspectionId)

if (!data?.visualisedSAS) {
if (!data?.visualizedSAS) {
return <TextAsImage isLargeImage={isLargeImage} text={'No analysis available'} />
} else if (isPending) {
return <PendingResultPlaceholder isLargeImage={isLargeImage} />
} else if (isError || !data) {
return <TextAsImage isLargeImage={isLargeImage} text={'No analysis could be found'} />
} else
return isLargeImage ? (
<StyledInspection $otherContentHeight={'174px'} src={data.visualisedSAS} />
<StyledInspection $otherContentHeight={'174px'} src={data.visualizedSAS} />
) : (
<StyledInspectionImage src={data.visualisedSAS} />
<StyledInspectionImage src={data.visualizedSAS} />
)
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/MissionPage/AnalysisResultView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const AnalysisResultDialogContent = ({ inspection }: { inspection: Inspec

return (
<div>
{inspection.visualisedSAS ? (
<AnalysisImage sasURI={inspection.visualisedSAS} isPending={false} />
{inspection.visualizedSAS ? (
<AnalysisImage sasURI={inspection.visualizedSAS} isPending={false} />
) : (
<>{/* No image to display*/}</>
)}
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/MissionPage/TaskOverview/TaskTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ const TaskTableRow = ({
<Table.Cell>
<TaskStatusDisplay status={task.status} errorMessage={task.errorDescription} />
</Table.Cell>
<Table.Cell>{inspectionData ? <TaskAnalysisDisplay inspectionData={inspectionData} /> : <></>}</Table.Cell>
<Table.Cell>
{inspectionData && (inspectionData.visualizedSAS || inspectionData.value) ? (
<TaskAnalysisDisplay inspectionData={inspectionData} />
) : (
<></>
)}
</Table.Cell>
</StyledTableRow>
)
}
Expand Down
107 changes: 28 additions & 79 deletions frontend/src/pages/MissionSchedulingComponents/InspectionAreaCards.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,66 @@
import { InspectionArea } from 'models/InspectionArea'
import { MissionDefinition } from 'models/MissionDefinition'
import { InspectionAreaInspectionTuple } from './InspectionSection'
import { useLanguageContext } from 'components/Contexts/LanguageContext'
import {
CardComponent,
Content,
InspectionAreaText,
Placeholder,
StyledCard,
StyledInspectionAreaCard,
StyledInspectionAreaCards,
TopInspectionAreaText,
} from './InspectionUtilities'
import { Button, Icon, Tooltip, Typography } from '@equinor/eds-core-react'
import { Icons } from 'utils/icons'
import { tokens } from '@equinor/eds-tokens'
import { useMissionsContext } from 'components/Contexts/MissionRunsContext'
import { useAssetContext } from 'components/Contexts/AssetContext'

interface InspectionAreaCardProps {
inspectionAreaData: InspectionAreaInspectionTuple
inspectionArea: InspectionArea
nMissions: number
onClickInspectionArea: (inspectionArea: InspectionArea) => void
selectedInspectionArea: InspectionArea | undefined
handleScheduleAll: (missionDefinitions: MissionDefinition[]) => void
isSelected: boolean
isMissionOngoing: boolean
onClickScheduleAll: (inspectionArea: InspectionArea) => void
}

const InspectionAreaCard = ({
inspectionAreaData,
export const InspectionAreaCard = ({
inspectionArea,
nMissions,
onClickInspectionArea,
selectedInspectionArea,
handleScheduleAll,
isSelected,
isMissionOngoing,
onClickScheduleAll,
}: InspectionAreaCardProps) => {
const { TranslateText } = useLanguageContext()
const { ongoingMissions } = useMissionsContext()
const { enabledRobots } = useAssetContext()

const isScheduleMissionsDisabled = enabledRobots.length === 0 || inspectionAreaData.missionDefinitions.length === 0
const isScheduleMissionsDisabled = enabledRobots.length === 0 || nMissions === 0

let queueMissionsTooltip = ''
if (inspectionAreaData.missionDefinitions.length === 0) queueMissionsTooltip = TranslateText('No available mission')
if (nMissions === 0) queueMissionsTooltip = TranslateText('No available mission')
else if (isScheduleMissionsDisabled) queueMissionsTooltip = TranslateText('No robot available')

return (
<StyledInspectionAreaCard key={inspectionAreaData.inspectionArea.inspectionAreaName}>
<StyledInspectionAreaCard key={inspectionArea.inspectionAreaName}>
<StyledCard
key={inspectionAreaData.inspectionArea.inspectionAreaName}
onClick={() => onClickInspectionArea(inspectionAreaData.inspectionArea)}
style={
selectedInspectionArea === inspectionAreaData.inspectionArea
? { border: `solid ${tokens.colors.interactive.focus.hex} 1px` }
: {}
}
key={inspectionArea.inspectionAreaName}
onClick={() => onClickInspectionArea(inspectionArea)}
style={isSelected ? { border: `solid ${tokens.colors.interactive.focus.hex} 1px` } : {}}
>
<InspectionAreaText>
<TopInspectionAreaText>
<Typography variant={'body_short_bold'}>
{inspectionAreaData.inspectionArea.inspectionAreaName.toString()}
{inspectionArea.inspectionAreaName.toString()}
</Typography>
{inspectionAreaData.missionDefinitions
.filter((m) => ongoingMissions.find((om) => om.missionId === m.id))
.map((mission) => (
<Content key={mission.id}>
<Icon name={Icons.Ongoing} size={16} />
{TranslateText('InProgress')}
</Content>
))}
{isMissionOngoing && (
<Content>
<Icon name={Icons.Ongoing} size={16} />
{TranslateText('InProgress')}
</Content>
)}
</TopInspectionAreaText>
<Typography color={tokens.colors.text.static_icons__secondary.hex}>
{inspectionAreaData.missionDefinitions.length}{' '}
{inspectionAreaData.missionDefinitions.length === 1
{nMissions}{' '}
{nMissions === 1
? TranslateText('Mission').toLowerCase()
: TranslateText('Missions').toLowerCase()}
</Typography>
Expand All @@ -78,13 +70,10 @@ const InspectionAreaCard = ({
<Button
disabled={isScheduleMissionsDisabled}
variant="ghost"
onClick={() => handleScheduleAll(inspectionAreaData.missionDefinitions)}
onClick={() => onClickScheduleAll(inspectionArea)}
color="secondary"
>
<Icon
name={Icons.Add}
color={inspectionAreaData.missionDefinitions.length > 0 ? '' : 'grey'}
/>
<Icon name={Icons.Add} color={nMissions > 0 ? '' : 'grey'} />
<Typography color={tokens.colors.text.static_icons__secondary.hex}>
{TranslateText('Queue the missions')}
</Typography>
Expand All @@ -95,43 +84,3 @@ const InspectionAreaCard = ({
</StyledInspectionAreaCard>
)
}

interface IInspectionAreaCardProps {
inspectionAreaMissions: InspectionAreaInspectionTuple[]
onClickInspectionArea: (inspectionArea: InspectionArea) => void
selectedInspectionArea: InspectionArea | undefined
handleScheduleAll: (missionDefinitions: MissionDefinition[]) => void
}

export const InspectionAreaCards = ({
inspectionAreaMissions,
onClickInspectionArea,
selectedInspectionArea,
handleScheduleAll,
}: IInspectionAreaCardProps) => {
const { TranslateText } = useLanguageContext()

return (
<>
{Object.keys(inspectionAreaMissions).length > 0 ? (
<StyledInspectionAreaCards>
{inspectionAreaMissions.map((inspectionAreaMission) => (
<InspectionAreaCard
key={'inspectionAreaCard' + inspectionAreaMission.inspectionArea.inspectionAreaName}
inspectionAreaData={inspectionAreaMission}
onClickInspectionArea={onClickInspectionArea}
selectedInspectionArea={selectedInspectionArea}
handleScheduleAll={handleScheduleAll}
/>
))}
</StyledInspectionAreaCards>
) : (
<Placeholder>
<Typography variant="h4" color="disabled">
{TranslateText('No inspections available')}
</Typography>
</Placeholder>
)}
</>
)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Card } from '@equinor/eds-core-react'
import styled from 'styled-components'
import { MissionDefinition } from 'models/MissionDefinition'
import { tokens } from '@equinor/eds-tokens'
import { cardShadow } from 'components/Styles/StyledComponents'

export const StyledCard = styled(Card)`
Expand Down Expand Up @@ -52,11 +51,6 @@ export const InspectionAreaOverview = styled.div`
flex-direction: column;
gap: 48px;
`
export const Placeholder = styled.div`
padding: 24px;
border: 1px solid ${tokens.colors.ui.background__medium.hex};
border-radius: 4px;
`
export const Content = styled.div`
display: flex;
align-items: centre;
Expand Down
Loading
Loading