diff --git a/frontend/src/components/Pages/FrontPage/MissionOverview/MissionControlSection.tsx b/frontend/src/components/Pages/FrontPage/MissionOverview/MissionControlSection.tsx
index 384c8370..180de5fe 100644
--- a/frontend/src/components/Pages/FrontPage/MissionOverview/MissionControlSection.tsx
+++ b/frontend/src/components/Pages/FrontPage/MissionOverview/MissionControlSection.tsx
@@ -10,6 +10,7 @@ import { MissionHistoryButton } from './MissionHistoryButton'
import { Robot } from 'models/Robot'
import { RobotMissionQueueView } from './MissionQueueView'
import { FrontPageSectionId } from 'models/FrontPageSectionId'
+import { getNoMissionReason } from 'utils/IsRobotReadyToRunMissions'
const MissionControlStyle = styled.div`
display: flex;
@@ -89,7 +90,11 @@ const MissionControlCard = ({ robot }: { robot: Robot }) => {
>
- {ongoingMission ? : }
+ {ongoingMission ? (
+
+ ) : (
+
+ )}
diff --git a/frontend/src/components/Pages/FrontPage/MissionOverview/OngoingMissionCard.tsx b/frontend/src/components/Pages/FrontPage/MissionOverview/OngoingMissionCard.tsx
index 8ed8efd0..f1cc440f 100644
--- a/frontend/src/components/Pages/FrontPage/MissionOverview/OngoingMissionCard.tsx
+++ b/frontend/src/components/Pages/FrontPage/MissionOverview/OngoingMissionCard.tsx
@@ -140,16 +140,20 @@ export const OngoingMissionCard = ({ mission }: MissionProps): JSX.Element => {
)
}
-export const OngoingMissionPlaceholderCard = (): JSX.Element => {
+export const OngoingMissionPlaceholderCard = ({ noMissionReason }: { noMissionReason?: string }): JSX.Element => {
const { TranslateText } = useLanguageContext()
return (
<>
-
+
{TranslateText('No ongoing missions')}
+ {noMissionReason && {noMissionReason}}
{TranslateText('No ongoing missions')}
+ {noMissionReason && {noMissionReason}}
>
)
diff --git a/frontend/src/language/en.json b/frontend/src/language/en.json
index a34ed9be..2d4e9b97 100644
--- a/frontend/src/language/en.json
+++ b/frontend/src/language/en.json
@@ -279,5 +279,11 @@
"Tag": "Tag",
"Timestamp": "Timestamp",
"Last completed inspection": "Last completed inspection",
- "Inspection report": "Inspection report"
+ "Inspection report": "Inspection report",
+ "Battery is too low to start a mission. Queued missions will start when the battery is over {0}%.": "Battery is too low to start a mission. Queued missions will start when the battery is over {0}%.",
+ "Battery is too low to start a mission.": "Battery is too low to start a mission.",
+ "Pressure is too high to start a mission. Queued missions will start when the pressure is under {0}mBar.": "Pressure is too high to start a mission. Queued missions will start when the pressure is under {0}mBar.",
+ "Pressure is too high to start a mission.": "Pressure is too high to start a mission.",
+ "Pressure is too low to start a mission. Queued missions will start when the pressure is over {0}mBar.": "Pressure is too low to start a mission. Queued missions will start when the pressure is over {0}mBar.",
+ "Pressure is too low to start a mission.": "Pressure is too low to start a mission."
}
diff --git a/frontend/src/language/no.json b/frontend/src/language/no.json
index 354d5664..c37e90b3 100644
--- a/frontend/src/language/no.json
+++ b/frontend/src/language/no.json
@@ -279,5 +279,11 @@
"Tag": "Tag",
"Timestamp": "Tidspunkt",
"Last completed inspection": "Siste gjennomførte inspeksjon",
- "Inspection report": "Inspeksjonsrapport"
+ "Inspection report": "Inspeksjonsrapport",
+ "Battery is too low to start a mission. Queued missions will start when the battery is over {0}%.": "Batterinivået er for lavt til å starte oppdrag. Oppdrag i kø vil starte når batterinivået er over {0}%",
+ "Battery is too low to start a mission.": "Batterinivået er for lavt til å starte oppdrag.",
+ "Pressure is too high to start a mission. Queued missions will start when the pressure is under {0}mBar.": "Trykket er for høyt til å starte oppdrag. Oppdrag i kø vil starte når trykket er under {0}mBar.",
+ "Pressure is too high to start a mission.": "Trykket er for høyt til å starte oppdrag.",
+ "Pressure is too low to start a mission. Queued missions will start when the pressure is over {0}mBar.": "Trykket er for lavt til å starte oppdrag. Oppdrag i kø vil starte når trykket er over {0}mBar.",
+ "Pressure is too low to start a mission.": "Trykket er for lavt til å starte oppdrag."
}
diff --git a/frontend/src/models/RobotModel.ts b/frontend/src/models/RobotModel.ts
index 0e7c9bce..11d9c3a5 100644
--- a/frontend/src/models/RobotModel.ts
+++ b/frontend/src/models/RobotModel.ts
@@ -13,6 +13,7 @@ export interface RobotModel {
id: string
type: RobotType
batteryWarningThreshold?: number
+ batteryMissionStartThreshold?: number
upperPressureWarningThreshold?: number
lowerPressureWarningThreshold?: number
}
diff --git a/frontend/src/utils/IsRobotReadyToRunMissions.tsx b/frontend/src/utils/IsRobotReadyToRunMissions.tsx
new file mode 100644
index 00000000..943e3f92
--- /dev/null
+++ b/frontend/src/utils/IsRobotReadyToRunMissions.tsx
@@ -0,0 +1,59 @@
+import { useLanguageContext } from 'components/Contexts/LanguageContext'
+import { Robot, RobotFlotillaStatus } from 'models/Robot'
+
+export const isBatteryTooLow = (robot: Robot): boolean => {
+ if (robot.batteryLevel === undefined || robot.batteryLevel === null) return false
+
+ if (robot.model.batteryWarningThreshold && robot.batteryLevel < robot.model.batteryWarningThreshold) {
+ return true
+ } else if (
+ robot.model.batteryMissionStartThreshold &&
+ robot.batteryLevel < robot.model.batteryMissionStartThreshold &&
+ robot.flotillaStatus === RobotFlotillaStatus.Recharging
+ ) {
+ return true
+ }
+ return false
+}
+
+export const isRobotPressureTooHigh = (robot: Robot): boolean => {
+ if (robot.model.upperPressureWarningThreshold && robot.pressureLevel) {
+ return robot.pressureLevel > robot.model.upperPressureWarningThreshold
+ }
+ return false
+}
+
+export const isRobotPressureTooLow = (robot: Robot): boolean => {
+ if (robot.model.lowerPressureWarningThreshold && robot.pressureLevel) {
+ return robot.pressureLevel < robot.model.lowerPressureWarningThreshold
+ }
+ return false
+}
+
+export const getNoMissionReason = (robot: Robot): string | undefined => {
+ const { TranslateText } = useLanguageContext()
+
+ if (isBatteryTooLow(robot)) {
+ return robot.model.batteryMissionStartThreshold
+ ? TranslateText(
+ 'Battery is too low to start a mission. Queued missions will start when the battery is over {0}%.',
+ [robot.model.batteryMissionStartThreshold.toString()]
+ )
+ : TranslateText('Battery is too low to start a mission.')
+ } else if (isRobotPressureTooHigh(robot)) {
+ return robot.model.upperPressureWarningThreshold
+ ? TranslateText(
+ 'Pressure is too high to start a mission. Queued missions will start when the pressure is under {0}mBar.',
+ [(robot.model.upperPressureWarningThreshold * 1000).toString()]
+ )
+ : TranslateText('Pressure is too high to start a mission.')
+ } else if (isRobotPressureTooLow(robot)) {
+ return robot.model.lowerPressureWarningThreshold
+ ? TranslateText(
+ 'Pressure is too low to start a mission. Queued missions will start when the pressure is over {0}mBar.',
+ [(robot.model.lowerPressureWarningThreshold * 1000).toString()]
+ )
+ : TranslateText('Pressure is too low to start a mission.')
+ }
+ return undefined
+}