-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from pdxlocations/paxcounter
Add Paxcounter Config
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
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 type { PaxcounterValidation } from "@app/validation/moduleConfig/paxcounter.js"; | ||
import { DynamicForm } from "@components/Form/DynamicForm.js"; | ||
import { useDevice } from "@core/stores/deviceStore.js"; | ||
import { Protobuf } from "@meshtastic/js"; | ||
|
||
export const Paxcounter = (): JSX.Element => { | ||
const { moduleConfig, setWorkingModuleConfig } = useDevice(); | ||
|
||
const onSubmit = (data: PaxcounterValidation) => { | ||
setWorkingModuleConfig( | ||
new Protobuf.ModuleConfig.ModuleConfig({ | ||
payloadVariant: { | ||
case: "paxcounter", | ||
value: data, | ||
}, | ||
}), | ||
); | ||
}; | ||
|
||
return ( | ||
<DynamicForm<PaxcounterValidation> | ||
onSubmit={onSubmit} | ||
defaultValues={moduleConfig.paxcounter} | ||
fieldGroups={[ | ||
{ | ||
label: "Paxcounter Settings", | ||
description: "Settings for the Paxcounter module", | ||
fields: [ | ||
{ | ||
type: "toggle", | ||
name: "enabled", | ||
label: "Module Enabled", | ||
description: "Enable Paxcounter", | ||
}, | ||
{ | ||
type: "number", | ||
name: "paxcounterUpdateInterval", | ||
label: "Update Interval (seconds)", | ||
description: "How long to wait between sending paxcounter packets", | ||
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,14 @@ | ||
import type { Message } from "@bufbuild/protobuf"; | ||
import type { Protobuf } from "@meshtastic/js"; | ||
import { IsBoolean, IsInt } from "class-validator"; | ||
|
||
export class PaxcounterValidation | ||
implements | ||
Omit<Protobuf.ModuleConfig.ModuleConfig_PaxcounterConfig, keyof Message> | ||
{ | ||
@IsBoolean() | ||
enabled: boolean; | ||
|
||
@IsInt() | ||
paxcounterUpdateInterval: number; | ||
} |