diff --git a/frontend/src/components/Pages/FrontPage/AutoScheduleSection/AutoScheduleSection.tsx b/frontend/src/components/Pages/FrontPage/AutoScheduleSection/AutoScheduleSection.tsx new file mode 100644 index 000000000..39c2a3909 --- /dev/null +++ b/frontend/src/components/Pages/FrontPage/AutoScheduleSection/AutoScheduleSection.tsx @@ -0,0 +1,119 @@ +import { Table, Typography } from '@equinor/eds-core-react' +import { useLanguageContext } from 'components/Contexts/LanguageContext' +import { useMissionDefinitionsContext } from 'components/Contexts/MissionDefinitionsContext' +import { StyledTableBody, StyledTableCell } from 'components/Styles/StyledComponents' +import { DaysOfWeek } from 'models/AutoScheduleFrequency' +import { config } from 'config' +import { useNavigate } from 'react-router-dom' +import styled from 'styled-components' + +const StyledSection = styled.div` + display: flex; + flex-direction: column; + max-width: 960px; + gap: 1rem; +` +const StyledTableRow = styled.div` + display: flex; + flex-direction: row; + gap: 1rem; +` +const StyledHeader = styled.div` + gap: 0px; +` +const StyledDayOverview = styled.div` + display: grid; + gap: 0px; +` + +const AutoScheduleList = () => { + const { TranslateText } = useLanguageContext() + const { missionDefinitions } = useMissionDefinitionsContext() + const navigate = useNavigate() + + const autoScheduleMissionDefinitions = missionDefinitions.filter((m) => m.autoScheduleFrequency) + + const allDays = [ + DaysOfWeek.Monday, + DaysOfWeek.Tuesday, + DaysOfWeek.Wednesday, + DaysOfWeek.Thursday, + DaysOfWeek.Friday, + DaysOfWeek.Saturday, + DaysOfWeek.Sunday, + ] + + const DayOverview = () => + allDays.map((day) => { + const missionDefinitions = autoScheduleMissionDefinitions.filter((m) => + m.autoScheduleFrequency!.daysOfWeek.includes(day) + ) + const timeMissionPairs = missionDefinitions + .map((mission) => + mission.autoScheduleFrequency!.timesOfDay.map((time) => { + return { time, mission } + }) + ) + .flat() + .sort((a, b) => (a.time > b.time ? 1 : -1)) + + return ( + + + + {TranslateText(day)} + + + + {timeMissionPairs.length > 0 ? ( + timeMissionPairs.map(({ time, mission }) => ( + + navigate(`${config.FRONTEND_BASE_ROUTE}/mission-definition/${mission.id}`) + } + > + + + {`${time.substring(0, 5)}`} + {mission.name} + + + + )) + ) : ( + + + {TranslateText('No missions')} + + + )} + +
+ ) + }) + + return ( + <> + {autoScheduleMissionDefinitions.length > 0 && ( + + + + {TranslateText('Auto Scheduling')} + + + {TranslateText('These missions will be automatically scheduled at the specified time')} + + + + + + + )} + + ) +} + +export const AutoScheduleSection = () => { + return AutoScheduleList() +} diff --git a/frontend/src/components/Pages/FrontPage/FrontPage.tsx b/frontend/src/components/Pages/FrontPage/FrontPage.tsx index 3c5d2fc93..c5ef0a8c3 100644 --- a/frontend/src/components/Pages/FrontPage/FrontPage.tsx +++ b/frontend/src/components/Pages/FrontPage/FrontPage.tsx @@ -5,6 +5,7 @@ import { StopRobotDialog } from './MissionOverview/StopDialogs' import { tokens } from '@equinor/eds-tokens' import { MissionControlSection } from './MissionOverview/MissionControlSection' import { redirectIfNoInstallationSelected } from 'utils/RedirectIfNoInstallationSelected' +import { AutoScheduleSection } from './AutoScheduleSection/AutoScheduleSection' const StyledFrontPage = styled.div` display: flex; @@ -24,6 +25,7 @@ export const FrontPage = () => { + diff --git a/frontend/src/language/en.json b/frontend/src/language/en.json index 516a14291..d5845e932 100644 --- a/frontend/src/language/en.json +++ b/frontend/src/language/en.json @@ -299,5 +299,8 @@ "No days have been selected. Please select days": "No days have been selected. Please select days", "No times have been selected. Please add time": "No times have been selected. Please add time", "Mission source id": "Mission source id", - "Skip": "Skip" + "Skip": "Skip", + "No missions": "No missions", + "Auto Scheduling": "Auto Scheduling", + "These missions will be automatically scheduled at the specified time": "These missions will be automatically scheduled at the specified time" } diff --git a/frontend/src/language/no.json b/frontend/src/language/no.json index 1f7743a51..347dce4ae 100644 --- a/frontend/src/language/no.json +++ b/frontend/src/language/no.json @@ -299,5 +299,8 @@ "No days have been selected. Please select days": "Ingen dager er valgt. Vennligst velg dager", "No times have been selected. Please add time": "Ingen tidspunkt er valgt. Vennligst legg til tidspunkt", "Mission source id": "Mission source id", - "Skip": "Neste" + "Skip": "Neste", + "No missions": "Ingen oppdrag", + "Auto Scheduling": "Automatisk kjøring", + "These missions will be automatically scheduled at the specified time": "Disse oppdragene vil automatisk bli kjørt på de spesifiserte tidspunktene" }