4 changed files with 75 additions and 0 deletions
@ -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", |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
]} |
||||
|
/> |
||||
|
); |
||||
|
}; |
||||
@ -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; |
||||
|
} |
||||
Loading…
Reference in new issue