-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7256454
commit a8c45cc
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/components/PageComponents/ModuleConfig/NeighborInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useDevice } from "@app/core/stores/deviceStore.js"; | ||
import type { NeighborInfoValidation } from "@app/validation/moduleConfig/neighborInfo.js"; | ||
import { DynamicForm } from "@components/Form/DynamicForm.js"; | ||
import { Protobuf } from "@meshtastic/meshtasticjs"; | ||
|
||
export const NeighborInfo = (): JSX.Element => { | ||
const { moduleConfig, setWorkingModuleConfig } = useDevice(); | ||
|
||
const onSubmit = (data: NeighborInfoValidation) => { | ||
setWorkingModuleConfig( | ||
new Protobuf.ModuleConfig({ | ||
payloadVariant: { | ||
case: "neighborInfo", | ||
value: data, | ||
}, | ||
}), | ||
); | ||
}; | ||
|
||
return ( | ||
<DynamicForm<NeighborInfoValidation> | ||
onSubmit={onSubmit} | ||
defaultValues={moduleConfig.neighborInfo} | ||
fieldGroups={[ | ||
{ | ||
label: "Neighbor Info Settings", | ||
description: "Settings for the Neighbor Info module", | ||
fields: [ | ||
{ | ||
type: "toggle", | ||
name: "enabled", | ||
label: "Enabled", | ||
description: "Enable or disable Neighbor Info Module", | ||
}, | ||
{ | ||
type: "number", | ||
name: "updateInterval", | ||
label: "Update Interval", | ||
description: "Interval in seconds of how often we should try to send our Neighbor Info to the mesh", | ||
disabledBy: [ | ||
{ | ||
fieldName: "enabled", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { IsBoolean, IsInt, Length } from "class-validator"; | ||
|
||
import type { Protobuf } from "@meshtastic/meshtasticjs"; | ||
|
||
export class NeighborInfoValidation | ||
implements | ||
Omit< | ||
Protobuf.ModuleConfig_NeighborInfoConfig, | ||
keyof Protobuf.native.Message | ||
> | ||
{ | ||
@IsBoolean() | ||
enabled: boolean; | ||
|
||
@IsInt() | ||
updateInterval: number; | ||
} |