Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9f747fa
bruhe i hate ai
NexInfinite Sep 7, 2025
f7f8326
moved as much to redux as possible - now need to work on socket
NexInfinite Sep 7, 2025
b8cb644
fixed wrong export
NexInfinite Sep 7, 2025
ba72c55
moved sockets and emitters over
NexInfinite Sep 7, 2025
fa87279
moved more components to redux (i love redux this is fun)
NexInfinite Sep 7, 2025
b78696d
formatted and cleaned up
NexInfinite Sep 7, 2025
bad37d5
Merge branch 'release-alpha-0.1.10' into alpha-0.1.10/656-convert-par…
NexInfinite Sep 7, 2025
80de511
no idea how this was missed
NexInfinite Sep 8, 2025
f2877c1
Merge branch 'alpha-0.1.10/656-convert-params-to-redux' of https://gi…
NexInfinite Sep 8, 2025
98e2cce
Fixed dropdowns for everything but floats
NexInfinite Sep 11, 2025
42dab7d
Merge branch 'release-alpha-0.1.10' into alpha-0.1.10/656-convert-par…
NexInfinite Sep 11, 2025
0dea55d
Fixed the things :D (no idea why it was erroring in the first place)
NexInfinite Sep 11, 2025
9b112a6
formatted
NexInfinite Sep 11, 2025
ff339d7
ai stuff
NexInfinite Sep 11, 2025
c7a23e9
fixed sync bug
NexInfinite Sep 14, 2025
e21f2e6
i hate js so much why does this language exist
NexInfinite Sep 14, 2025
5ade0ac
formatted
NexInfinite Sep 14, 2025
76a84ca
cleaned up
NexInfinite Sep 14, 2025
36a586f
cleaned up
NexInfinite Sep 14, 2025
f56768d
fixed params when modified back to initial state
NexInfinite Sep 14, 2025
e3fa86c
Merge branch 'release-alpha-0.1.10' into alpha-0.1.10/656-convert-par…
NexInfinite Sep 14, 2025
ab93049
Fix some bugs with params
1Blademaster Sep 14, 2025
20a6b9a
Address copilot review comments
1Blademaster Sep 14, 2025
e636a77
Fix param refresh bug
1Blademaster Sep 14, 2025
cbafc2f
Fix mypy issue, address copilot review comments, fix params tests
1Blademaster Sep 14, 2025
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
2 changes: 1 addition & 1 deletion gcs/src/components/config/flightModes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default function FlightModes() {
{flightModes.map((flightModeNumber, idx) => (
<Select
key={idx}
label={`Flight mode ${idx}`}
label={`Flight mode ${idx + 1}`}
description={`PWM: ${FLIGHT_MODE_PWM_VALUES[idx][0]}${FLIGHT_MODE_PWM_VALUES[idx][1] === undefined ? "+" : `-${FLIGHT_MODE_PWM_VALUES[idx][1]}`}`}
value={flightModeNumber.toString()}
onChange={(value) => changeFlightMode(idx, value)}
Expand Down
20 changes: 15 additions & 5 deletions gcs/src/components/dashboard/statusBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { IconClock, IconNetwork, IconNetworkOff } from "@tabler/icons-react"

// Redux
import { useSelector } from "react-redux"
import { selectBatteryData, selectTelemetry } from "../../redux/slices/droneInfoSlice"
import {
selectBatteryData,
selectTelemetry,
} from "../../redux/slices/droneInfoSlice"

// Helper imports
import { socket } from "../../helpers/socket"
Expand Down Expand Up @@ -101,8 +104,11 @@ export default function StatusBar(props) {
const batteryAlertPercentages = getSetting("Dashboard.batteryAlert") ?? []
batteryAlertPercentages.sort((a1, a2) => a1 - a2)

batteryData.forEach(battery => {
for (const [i, batteryAlertPercentage] of batteryAlertPercentages.entries()) {
batteryData.forEach((battery) => {
for (const [
i,
batteryAlertPercentage,
] of batteryAlertPercentages.entries()) {
if (battery.battery_remaining < batteryAlertPercentage) {
dispatchAlert({
category: AlertCategory.Battery,
Expand All @@ -112,9 +118,13 @@ export default function StatusBar(props) {
: i == batteryAlertPercentages.length - 1
? AlertSeverity.Yellow
: AlertSeverity.Orange,
jsx: <>Caution! You've dropped below {batteryAlertPercentage}% battery</>
jsx: (
<>
Caution! You've dropped below {batteryAlertPercentage}% battery
</>
),
})
return;
return
}
}
})
Expand Down
20 changes: 16 additions & 4 deletions gcs/src/components/params/autopilotRebootModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
import { Button, Loader, Modal } from "@mantine/core"

// Styling imports
import tailwindConfig from "../../../tailwind.config.js"
import resolveConfig from "tailwindcss/resolveConfig"
import tailwindConfig from "../../../tailwind.config.js"
const tailwindColors = resolveConfig(tailwindConfig).theme.colors

export default function AutopilotRebootModal({ rebootData, opened, onClose }) {
// Redux
import { useDispatch, useSelector } from "react-redux"
import {
selectAutoPilotRebootModalOpen,
selectRebootData,
setAutoPilotRebootModalOpen,
} from "../../redux/slices/paramsSlice.js"

export default function AutopilotRebootModal() {
const dispatch = useDispatch()
const rebootData = useSelector(selectRebootData)
const opened = useSelector(selectAutoPilotRebootModalOpen)

return (
<Modal
opened={opened}
onClose={onClose}
onClose={() => dispatch(setAutoPilotRebootModalOpen(false))}
Comment thread
1Blademaster marked this conversation as resolved.
title="Rebooting autopilot"
closeOnClickOutside={false}
closeOnEscape={false}
Expand All @@ -36,7 +48,7 @@ export default function AutopilotRebootModal({ rebootData, opened, onClose }) {
{rebootData.message} You will need to reconnect.
</p>
<Button
onClick={close}
onClick={() => dispatch(setAutoPilotRebootModalOpen(false))}
color={tailwindColors.red[600]}
className="mt-4"
>
Expand Down
64 changes: 43 additions & 21 deletions gcs/src/components/params/paramsToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,48 @@ import {
IconTool,
} from "@tabler/icons-react"

// Custom helper, component and data imports
import { socket } from "../../helpers/socket.js"

// Styling imports
import tailwindConfig from "../../../tailwind.config.js"
import resolveConfig from "tailwindcss/resolveConfig"
import tailwindConfig from "../../../tailwind.config.js"
const tailwindColors = resolveConfig(tailwindConfig).theme.colors

export default function ParamsToolbar({
searchValue,
modifiedParams,
showModifiedParams,
refreshCallback,
rebootCallback,
modifiedCallback,
searchCallback,
}) {
/**
* Sets all the modified parameters to their new values on the drone
*/
function saveModifiedParams() {
socket.emit("set_multiple_params", modifiedParams)
// Redux
import { useDispatch, useSelector } from "react-redux"
import {
emitRebootAutopilot,
emitRefreshParams,
emitSetMultipleParams,
resetParamState,
selectModifiedParams,
selectParamSearchValue,
selectShowModifiedParams,
setAutoPilotRebootModalOpen,
setFetchingVars,
setModifiedParams,
setParams,
setParamSearchValue,
setShownParams,
toggleShowModifiedParams,
} from "../../redux/slices/paramsSlice.js"

export default function ParamsToolbar() {
const dispatch = useDispatch()
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())
}

return (
Expand All @@ -47,7 +67,7 @@ export default function ParamsToolbar({
>
<Button
size="sm"
onClick={modifiedCallback}
onClick={() => dispatch(toggleShowModifiedParams())}
color={tailwindColors.orange[600]}
>
{" "}
Expand All @@ -63,14 +83,16 @@ export default function ParamsToolbar({
className="w-1/3"
placeholder="Search by parameter name"
value={searchValue}
onChange={(event) => searchCallback(event.currentTarget.value)}
onChange={(event) =>
dispatch(setParamSearchValue(event.currentTarget.value))
}
/>

<Button
size="sm"
rightSection={<IconPencil size={14} />}
disabled={!modifiedParams.length}
onClick={saveModifiedParams}
onClick={() => dispatch(emitSetMultipleParams(modifiedParams))}
color={tailwindColors.green[600]}
>
{" "}
Expand Down
6 changes: 2 additions & 4 deletions gcs/src/components/params/row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
// Custom components, helpers and data
import RowItem from "./rowItem"

export const Row = ({ data, index, style }) => {
const param = data.params[index]

return <RowItem param={param} style={style} onChange={data.onChange} />
export const Row = ({ index, style }) => {
return <RowItem index={index} style={style} />
}
94 changes: 78 additions & 16 deletions gcs/src/components/params/rowItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,49 @@
import { memo, useEffect, useState } from "react"

// 3rd party imports
import { ScrollArea, Tooltip } from "@mantine/core"
import { useLocalStorage } from "@mantine/hooks"
import { ActionIcon, ScrollArea, Tooltip } from "@mantine/core"

// Custom components, helpers and data
import apmParamDefsCopter from "../../../data/gen_apm_params_def_copter.json"
import apmParamDefsPlane from "../../../data/gen_apm_params_def_plane.json"
import ValueInput from "./valueInput"

const RowItem = memo(({ param, style, onChange }) => {
const [aircraftType] = useLocalStorage({
key: "aircraftType",
})
// Redux
import { IconArrowBack, IconInfoCircle } from "@tabler/icons-react"
import { useDispatch, useSelector } from "react-redux"
import { selectAircraftType } from "../../redux/slices/droneInfoSlice"
import {
deleteModifiedParam,
selectModifiedParams,
selectShownParams,
selectSingleParam,
} from "../../redux/slices/paramsSlice"

const RowItem = memo(({ index, style }) => {
const dispatch = useDispatch()
const aircraftType = useSelector(selectAircraftType)
const shownParams = useSelector(selectShownParams)
const modifiedParams = useSelector(selectModifiedParams)
const [paramDef, setParamDef] = useState({})
const param = shownParams[index]
const paramPreviousValue = useSelector((state) =>
selectSingleParam(state, param.param_id),
)
const hasBeenModified = modifiedParams.find(
(item) => item.param_id === param.param_id,
)

function removeModified(param) {
let initial_value = modifiedParams.find(
(item) => item.param_id === param.param_id,
).initial_value
dispatch(
deleteModifiedParam({
param_id: param.param_id,
initial_value: initial_value,
}),
)
}

useEffect(() => {
if (aircraftType === 1) {
Expand All @@ -30,16 +60,48 @@ const RowItem = memo(({ param, style, onChange }) => {

return (
<div style={style} className="flex flex-row items-center space-x-4">
<Tooltip label={paramDef?.DisplayName}>
<p className="w-56">{param.param_id}</p>
</Tooltip>

<ValueInput
param={param}
paramDef={paramDef}
onChange={onChange}
className="w-3/12"
/>
<div className="flex flex-row w-2/12 gap-x-2">
<Tooltip label={paramDef?.DisplayName ?? null} position="top-start">
<p>{param.param_id}</p>
</Tooltip>

{paramDef?.Values && paramDef?.Range && (
<Tooltip
className="self-center"
label={
<div className="text-wrap max-w-80">
{Object.keys(paramDef?.Values).map((key) => {
return (
<p key={key}>
{key}: {paramDef?.Values[key]}
</p>
)
})}
</div>
}
>
<IconInfoCircle size={20} />
</Tooltip>
)}
</div>

<div className="flex items-end w-4/12 justify-between gap-x-4">
<ValueInput index={index} paramDef={paramDef} className="grow" />
{hasBeenModified && (
<Tooltip
label={`Reset to previous value of ${paramPreviousValue.param_value}`}
>
<ActionIcon
size="lg"
color="red"
variant="light"
onClick={() => removeModified(param)}
>
<IconArrowBack />
</ActionIcon>
</Tooltip>
)}
</div>

<div className="w-1/2">
<ScrollArea.Autosize className="max-h-24">
Expand Down
Loading
Loading