diff --git a/gcs/src/components/params/paramsToolbar.jsx b/gcs/src/components/params/paramsToolbar.jsx index 84a455e84..d5bcddaf6 100644 --- a/gcs/src/components/params/paramsToolbar.jsx +++ b/gcs/src/components/params/paramsToolbar.jsx @@ -7,15 +7,7 @@ rebooting the autopilot // 3rd party imports import { Button, TextInput, Tooltip } from "@mantine/core" -import { - IconDownload, - IconEye, - IconPencil, - IconPower, - IconRefresh, - IconTool, - IconUpload, -} from "@tabler/icons-react" +import { IconEye, IconTool } from "@tabler/icons-react" // Styling imports import resolveConfig from "tailwindcss/resolveConfig" @@ -25,68 +17,21 @@ const tailwindColors = resolveConfig(tailwindConfig).theme.colors // Redux import { useDispatch, useSelector } from "react-redux" import { - emitExportParamsToFile, - emitRebootAutopilot, - emitRefreshParams, - emitSetMultipleParams, - resetParamState, selectModifiedParams, selectParamSearchValue, selectShowModifiedParams, - setAutoPilotRebootModalOpen, - setFetchingVars, - setModifiedParams, - setParams, setParamSearchValue, - setShownParams, toggleShowModifiedParams, } from "../../redux/slices/paramsSlice.js" -export default function ParamsToolbar({ loadParamsFromFile }) { +export default function ParamsToolbar() { const dispatch = useDispatch() + const searchValue = useSelector(selectParamSearchValue) const modifiedParams = useSelector(selectModifiedParams) const showModifiedParams = useSelector(selectShowModifiedParams) - const searchValue = useSelector(selectParamSearchValue) - - function refreshCallback() { - dispatch(setParams([])) - dispatch(setModifiedParams([])) - dispatch(setShownParams([])) - dispatch(emitRefreshParams()) - dispatch(setFetchingVars(true)) - } - - function rebootCallback() { - dispatch(emitRebootAutopilot()) - dispatch(setAutoPilotRebootModalOpen(true)) - dispatch(resetParamState()) - } - - async function saveParamsToFile() { - const options = { - title: "Save parameters to a file", - filters: [ - { name: "Param File", extensions: ["param"] }, - { name: "All Files", extensions: ["*"] }, - ], - } - - const result = await window.ipcRenderer.invoke( - "app:get-save-file-path", - options, - ) - - if (!result.canceled) { - dispatch( - emitExportParamsToFile({ - filePath: result.filePath, - }), - ) - } - } return ( -
+
dispatch(toggleShowModifiedParams())} color={tailwindColors.orange[600]} + disabled={modifiedParams.length === 0} > {showModifiedParams ? : } - - - - - - - - - - -
) } diff --git a/gcs/src/components/params/rowItem.jsx b/gcs/src/components/params/rowItem.jsx index 256fe3ac1..aa15263a4 100644 --- a/gcs/src/components/params/rowItem.jsx +++ b/gcs/src/components/params/rowItem.jsx @@ -59,15 +59,17 @@ const RowItem = memo(({ index, style }) => { }, [aircraftType, param]) return ( -
-
+
+

{param.param_id}

{paramDef?.Values && paramDef?.Range && ( {Object.keys(paramDef?.Values).map((key) => { diff --git a/gcs/src/components/params/valueInput.jsx b/gcs/src/components/params/valueInput.jsx index 1b8bfa7fc..5ebba3e20 100644 --- a/gcs/src/components/params/valueInput.jsx +++ b/gcs/src/components/params/valueInput.jsx @@ -76,12 +76,14 @@ export default function ValueInput({ index, paramDef, className }) { } else { // Otherwise add it to modified params dispatch( - appendModifiedParams({ - param_id: param.param_id, - param_value: value, - param_type: param.param_type, - initial_value: param.param_value, - }), + appendModifiedParams([ + { + param_id: param.param_id, + param_value: value, + param_type: param.param_type, + initial_value: param.param_value, + }, + ]), ) } } diff --git a/gcs/src/params.jsx b/gcs/src/params.jsx index 99544d848..dc90c4b88 100644 --- a/gcs/src/params.jsx +++ b/gcs/src/params.jsx @@ -8,11 +8,17 @@ import { useEffect } from "react" // 3rd Party Imports -import { Button, Progress } from "@mantine/core" +import { Button, Divider, Progress } from "@mantine/core" import { useDebouncedValue } from "@mantine/hooks" +import { ResizableBox } from "react-resizable" import AutoSizer from "react-virtualized-auto-sizer" import { FixedSizeList } from "react-window" +// Styling imports +import resolveConfig from "tailwindcss/resolveConfig" +import tailwindConfig from "../tailwind.config.js" +const tailwindColors = resolveConfig(tailwindConfig).theme.colors + // Custom components, helpers, and data import Layout from "./components/layout.jsx" import NoDroneConnected from "./components/noDroneConnected.jsx" @@ -27,7 +33,10 @@ import { EXCLUDE_PARAMS_LOAD } from "./helpers/mavlinkConstants.js" import { showErrorNotification } from "./helpers/notification.js" import { selectConnectedToDrone } from "./redux/slices/droneConnectionSlice.js" import { + emitExportParamsToFile, + emitRebootAutopilot, emitRefreshParams, + emitSetMultipleParams, resetParamState, selectFetchingVars, selectFetchingVarsProgress, @@ -37,11 +46,14 @@ import { selectParamSearchValue, selectShowModifiedParams, selectShownParams, + setAutoPilotRebootModalOpen, setFetchingVars, setHasFetchedOnce, setLoadedFileName, setLoadedParams, setLoadParamsFileModalOpen, + setModifiedParams, + setParams, setShownParams, } from "./redux/slices/paramsSlice.js" @@ -105,6 +117,43 @@ export default function Params() { dispatch(setHasFetchedOnce(true)) } + function refreshCallback() { + dispatch(setParams([])) + dispatch(setModifiedParams([])) + dispatch(setShownParams([])) + dispatch(emitRefreshParams()) + dispatch(setFetchingVars(true)) + } + + function rebootCallback() { + dispatch(emitRebootAutopilot()) + dispatch(setAutoPilotRebootModalOpen(true)) + dispatch(resetParamState()) + } + + async function saveParamsToFile() { + const options = { + title: "Save parameters to a file", + filters: [ + { name: "Param File", extensions: ["param"] }, + { name: "All Files", extensions: ["*"] }, + ], + } + + const result = await window.ipcRenderer.invoke( + "app:get-save-file-path", + options, + ) + + if (!result.canceled) { + dispatch( + emitExportParamsToFile({ + filePath: result.filePath, + }), + ) + } + } + async function loadParamsFromFile() { const result = await window.ipcRenderer.invoke( "params:load-params-from-file", @@ -163,51 +212,106 @@ export default function Params() { {connected ? ( - <> - {fetchingVars && ( -
- {fetchingVarsProgress.param_id && ( -

- Fetched {fetchingVarsProgress.param_id} -

- )} - -
- )} - - {Object.keys(params).length > 0 && !fetchingVars && ( -
- - -
- - {({ height, width }) => ( - +
+ {!fetchingVars && ( +
+ } + className="relative bg-falcongrey-800 overflow-y-auto" + > +
+
+ + +
+ +
+ + +
+ +
+ +
+
+ + )} + + {/* Main content area */} +
+ {fetchingVars && ( +
+ {fetchingVarsProgress.param_id && ( +

+ Fetched {fetchingVarsProgress.param_id} +

)} - -
-
- )} - {Object.keys(params).length === 0 && !fetchingVars && ( -
-

- No parameters found, try fetching them again. -

- + +
+ )} + + {Object.keys(params).length > 0 && !fetchingVars && ( +
+ + +
+ + {({ height, width }) => ( + + {Row} + + )} + +
+
+ )} + {Object.keys(params).length === 0 && !fetchingVars && ( +
+

+ No parameters found, try fetching them again. +

+ +
+ )}
- )} - +
+
) : ( )}