mirror of
https://github.com/meshtastic/web.git
synced 2026-03-12 19:06:17 -04:00
add paxcounter config
This commit is contained in:
51
src/components/PageComponents/ModuleConfig/Paxcounter.tsx
Normal file
51
src/components/PageComponents/ModuleConfig/Paxcounter.tsx
Normal file
@@ -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",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -243,6 +243,11 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
config.payloadVariant.value;
|
||||
break;
|
||||
}
|
||||
case "paxcounter": {
|
||||
device.moduleConfig.paxcounter =
|
||||
config.payloadVariant.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -9,6 +9,7 @@ import { RangeTest } from "@components/PageComponents/ModuleConfig/RangeTest.js"
|
||||
import { Serial } from "@components/PageComponents/ModuleConfig/Serial.js";
|
||||
import { StoreForward } from "@components/PageComponents/ModuleConfig/StoreForward.js";
|
||||
import { Telemetry } from "@components/PageComponents/ModuleConfig/Telemetry.js";
|
||||
import { Paxcounter } from "@components/PageComponents/ModuleConfig/Paxcounter.js";
|
||||
import {
|
||||
Tabs,
|
||||
TabsContent,
|
||||
@@ -62,6 +63,10 @@ export const ModuleConfig = (): JSX.Element => {
|
||||
label: "Detection Sensor",
|
||||
element: DetectionSensor,
|
||||
},
|
||||
{
|
||||
label: "Paxcounter",
|
||||
element: Paxcounter,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
14
src/validation/moduleConfig/paxcounter.ts
Normal file
14
src/validation/moduleConfig/paxcounter.ts
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user