From f243e442b90d3c787b9350b15b8e1f6b598f837b Mon Sep 17 00:00:00 2001 From: Julian Jones Date: Sat, 29 Mar 2025 14:45:17 +0000 Subject: [PATCH 01/19] added modal --- .vscode/settings.json | 3 +- gcs/src/components/customMantineTheme.jsx | 1 + .../components/dashboard/floatingToolbar.jsx | 15 +++ .../preFlightChecklist/checkListArea.jsx | 96 +++++++++++++++++++ .../preFlightChecklist/preFlightChecklist.jsx | 68 +++++++++++++ gcs/src/components/navbar.jsx | 1 - 6 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 gcs/src/components/dashboard/preFlightChecklist/checkListArea.jsx create mode 100644 gcs/src/components/dashboard/preFlightChecklist/preFlightChecklist.jsx diff --git a/.vscode/settings.json b/.vscode/settings.json index 7229cda57..519424e1f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,6 +13,7 @@ "RSSI", "serialutil", "SITL", - "statustext" + "statustext", + "SUAS" ] } diff --git a/gcs/src/components/customMantineTheme.jsx b/gcs/src/components/customMantineTheme.jsx index d44efe320..b4133cbd2 100644 --- a/gcs/src/components/customMantineTheme.jsx +++ b/gcs/src/components/customMantineTheme.jsx @@ -27,4 +27,5 @@ export const CustomMantineTheme = createTheme({ tailwindColors.falcongrey[950], ], }, + cursorType: 'pointer' }) diff --git a/gcs/src/components/dashboard/floatingToolbar.jsx b/gcs/src/components/dashboard/floatingToolbar.jsx index c0ae587e9..904c7c72d 100644 --- a/gcs/src/components/dashboard/floatingToolbar.jsx +++ b/gcs/src/components/dashboard/floatingToolbar.jsx @@ -8,6 +8,7 @@ import { useLocalStorage } from "@mantine/hooks" import { IconAnchor, IconAnchorOff, + IconChecklist, IconCrosshair, IconMapPins, IconSun, @@ -17,6 +18,8 @@ import { // Helper Functions import { filterMissionItems } from "../../helpers/filterMissions" import GetOutsideVisibilityColor from "../../helpers/outsideVisibility" +import { useState } from "react" +import PreFlightChecklist from "./preFlightChecklist/preFlightChecklist" export default function FloatingToolbar({ missionItems, @@ -31,6 +34,7 @@ export default function FloatingToolbar({ key: "outsideVisibility", defaultValue: false, }) + const [preflightModal, setPreflightModal] = useState(false); function updateFollowDroneAction() { setFollowDrone( @@ -125,6 +129,17 @@ export default function FloatingToolbar({ {outsideVisibility ? : } + + {/* Preflight checklist */} + + + setPreflightModal(true)} /> + + + ) } diff --git a/gcs/src/components/dashboard/preFlightChecklist/checkListArea.jsx b/gcs/src/components/dashboard/preFlightChecklist/checkListArea.jsx new file mode 100644 index 000000000..2286311b2 --- /dev/null +++ b/gcs/src/components/dashboard/preFlightChecklist/checkListArea.jsx @@ -0,0 +1,96 @@ +/* + The Checklist area, this can be edited. +*/ + +import { Button, Checkbox, Textarea} from "@mantine/core" +import { useEffect, useState } from "react" + +// Styling imports +import resolveConfig from "tailwindcss/resolveConfig" +import tailwindConfig from "../../../../tailwind.config.js" +const tailwindColors = resolveConfig(tailwindConfig).theme.colors + +export default function CheckListArea({items}) { + const [editMode, setEditMode] = useState(false) + const [checkBoxList, setCheckboxList] = useState(items) + const [checkBoxListString, setCheckboxListString] = useState(generateCheckboxListString()) + const [mappedItems, setMappedItems] = useState(generateMappedItems()) + + function generateCheckboxListString(set = false) { + // Go from list to string, returns + var final = "" + checkBoxList.map((element) => { + final += element.name + ", " + }) + + final = final.substring(0, final.length - 2) + if (set) { + setCheckboxListString(final) + } + + return final + } + + function generateCheckboxList() { + // Go from string to list, does not return + var final = [] + checkBoxListString.split(/,\s|,/).map((element) => { + final.push({ + "checked": false, + "name": element.trimStart() + }) + }) + setCheckboxList(final) + console.log(final) + } + + function generateMappedItems() { + return ( + checkBoxList.map((element) => { + return + }) + ) + } + + useEffect(() => { + setMappedItems(generateMappedItems()) + }, [checkBoxList]) + + return ( + <> + {/* Checkbox area */} + + + {/* Edit mode */} +
+