Add monorepo support to project (#682)
* feat: add monorepo support * fix: correct relatedProjects structure in vercel.json * update github actions with monorepo support * removed legacy dep * moved jsr config into web package
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import {
|
||||
type AmbientLightingValidation,
|
||||
AmbientLightingValidationSchema,
|
||||
} from "@app/validation/moduleConfig/ambientLighting.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface AmbientLightingModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<AmbientLightingValidation>;
|
||||
}
|
||||
|
||||
export const AmbientLighting = (
|
||||
{ onFormInit }: AmbientLightingModuleConfigProps,
|
||||
) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: AmbientLightingValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.ambientLighting, data, true)) {
|
||||
removeWorkingModuleConfig("ambientLighting");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "ambientLighting",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<AmbientLightingValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={AmbientLightingValidationSchema}
|
||||
formId="ModuleConfig_AmbientLightingConfig"
|
||||
defaultValues={moduleConfig.ambientLighting}
|
||||
values={getEffectiveModuleConfig("ambientLighting")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("ambientLighting.title"),
|
||||
description: t("ambientLighting.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "ledState",
|
||||
label: t("ambientLighting.ledState.label"),
|
||||
description: t("ambientLighting.ledState.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "current",
|
||||
label: t("ambientLighting.current.label"),
|
||||
description: t("ambientLighting.current.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "red",
|
||||
label: t("ambientLighting.red.label"),
|
||||
description: t("ambientLighting.red.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "green",
|
||||
label: t("ambientLighting.green.label"),
|
||||
description: t("ambientLighting.green.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "blue",
|
||||
label: t("ambientLighting.blue.label"),
|
||||
description: t("ambientLighting.blue.description"),
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,108 @@
|
||||
import {
|
||||
type AudioValidation,
|
||||
AudioValidationSchema,
|
||||
} from "@app/validation/moduleConfig/audio.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface AudioModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<AudioValidation>;
|
||||
}
|
||||
|
||||
export const Audio = ({ onFormInit }: AudioModuleConfigProps) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: AudioValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.audio, data, true)) {
|
||||
removeWorkingModuleConfig("audio");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "audio",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<AudioValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={AudioValidationSchema}
|
||||
formId="ModuleConfig_AudioConfig"
|
||||
defaultValues={moduleConfig.audio}
|
||||
values={getEffectiveModuleConfig("audio")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("audio.title"),
|
||||
description: t("audio.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "codec2Enabled",
|
||||
label: t("audio.codec2Enabled.label"),
|
||||
description: t("audio.codec2Enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "pttPin",
|
||||
label: t("audio.pttPin.label"),
|
||||
description: t("audio.pttPin.description"),
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "bitrate",
|
||||
label: t("audio.bitrate.label"),
|
||||
description: t("audio.bitrate.description"),
|
||||
properties: {
|
||||
enumValue:
|
||||
Protobuf.ModuleConfig.ModuleConfig_AudioConfig_Audio_Baud,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "i2sWs",
|
||||
label: t("audio.i2sWs.label"),
|
||||
description: t("audio.i2sWs.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "i2sSd",
|
||||
label: t("audio.i2sSd.label"),
|
||||
description: t("audio.i2sSd.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "i2sDin",
|
||||
label: t("audio.i2sDin.label"),
|
||||
description: t("audio.i2sDin.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "i2sSck",
|
||||
label: t("audio.i2sSck.label"),
|
||||
description: t("audio.i2sSck.description"),
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,142 @@
|
||||
import {
|
||||
type CannedMessageValidation,
|
||||
CannedMessageValidationSchema,
|
||||
} from "@app/validation/moduleConfig/cannedMessage.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface CannedMessageModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<CannedMessageValidation>;
|
||||
}
|
||||
|
||||
export const CannedMessage = (
|
||||
{ onFormInit }: CannedMessageModuleConfigProps,
|
||||
) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: CannedMessageValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.cannedMessage, data, true)) {
|
||||
removeWorkingModuleConfig("cannedMessage");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "cannedMessage",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<CannedMessageValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={CannedMessageValidationSchema}
|
||||
formId="ModuleConfig_CannedMessageConfig"
|
||||
defaultValues={moduleConfig.cannedMessage}
|
||||
values={getEffectiveModuleConfig("cannedMessage")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("cannedMessage.title"),
|
||||
description: t("cannedMessage.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("cannedMessage.moduleEnabled.label"),
|
||||
description: t("cannedMessage.moduleEnabled.description"),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "rotary1Enabled",
|
||||
label: t("cannedMessage.rotary1Enabled.label"),
|
||||
description: t("cannedMessage.rotary1Enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "inputbrokerPinA",
|
||||
label: t("cannedMessage.inputbrokerPinA.label"),
|
||||
description: t("cannedMessage.inputbrokerPinA.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "inputbrokerPinB",
|
||||
label: t("cannedMessage.inputbrokerPinB.label"),
|
||||
description: t("cannedMessage.inputbrokerPinB.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "inputbrokerPinPress",
|
||||
label: t("cannedMessage.inputbrokerPinPress.label"),
|
||||
description: t("cannedMessage.inputbrokerPinPress.description"),
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "inputbrokerEventCw",
|
||||
label: t("cannedMessage.inputbrokerEventCw.label"),
|
||||
description: t("cannedMessage.inputbrokerEventCw.description"),
|
||||
properties: {
|
||||
enumValue: Protobuf.ModuleConfig
|
||||
.ModuleConfig_CannedMessageConfig_InputEventChar,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "inputbrokerEventCcw",
|
||||
label: t("cannedMessage.inputbrokerEventCcw.label"),
|
||||
description: t("cannedMessage.inputbrokerEventCcw.description"),
|
||||
properties: {
|
||||
enumValue: Protobuf.ModuleConfig
|
||||
.ModuleConfig_CannedMessageConfig_InputEventChar,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "inputbrokerEventPress",
|
||||
label: t("cannedMessage.inputbrokerEventPress.label"),
|
||||
description: t("cannedMessage.inputbrokerEventPress.description"),
|
||||
properties: {
|
||||
enumValue: Protobuf.ModuleConfig
|
||||
.ModuleConfig_CannedMessageConfig_InputEventChar,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "updown1Enabled",
|
||||
label: t("cannedMessage.updown1Enabled.label"),
|
||||
description: t("cannedMessage.updown1Enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
name: "allowInputSource",
|
||||
label: t("cannedMessage.allowInputSource.label"),
|
||||
description: t("cannedMessage.allowInputSource.description"),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "sendBell",
|
||||
label: t("cannedMessage.sendBell.label"),
|
||||
description: t("cannedMessage.sendBell.description"),
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,158 @@
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import {
|
||||
type DetectionSensorValidation,
|
||||
DetectionSensorValidationSchema,
|
||||
} from "@app/validation/moduleConfig/detectionSensor.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface DetectionSensorModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<DetectionSensorValidation>;
|
||||
}
|
||||
|
||||
export const DetectionSensor = (
|
||||
{ onFormInit }: DetectionSensorModuleConfigProps,
|
||||
) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: DetectionSensorValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.detectionSensor, data, true)) {
|
||||
removeWorkingModuleConfig("detectionSensor");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "detectionSensor",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<DetectionSensorValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={DetectionSensorValidationSchema}
|
||||
formId="ModuleConfig_DetectionSensorConfig"
|
||||
defaultValues={moduleConfig.detectionSensor}
|
||||
values={getEffectiveModuleConfig("detectionSensor")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("detectionSensor.title"),
|
||||
description: t("detectionSensor.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("detectionSensor.enabled.label"),
|
||||
description: t("detectionSensor.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "minimumBroadcastSecs",
|
||||
label: t("detectionSensor.minimumBroadcastSecs.label"),
|
||||
description: t(
|
||||
"detectionSensor.minimumBroadcastSecs.description",
|
||||
),
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "stateBroadcastSecs",
|
||||
label: t("detectionSensor.stateBroadcastSecs.label"),
|
||||
description: t("detectionSensor.stateBroadcastSecs.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "sendBell",
|
||||
label: t("detectionSensor.sendBell.label"),
|
||||
description: t("detectionSensor.sendBell.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
name: "name",
|
||||
label: t("detectionSensor.name.label"),
|
||||
description: t("detectionSensor.name.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "monitorPin",
|
||||
label: t("detectionSensor.monitorPin.label"),
|
||||
description: t("detectionSensor.monitorPin.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "detectionTriggerType",
|
||||
label: t("detectionSensor.detectionTriggerType.label"),
|
||||
description: t(
|
||||
"detectionSensor.detectionTriggerType.description",
|
||||
),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
enumValue: Protobuf.ModuleConfig
|
||||
.ModuleConfig_DetectionSensorConfig_TriggerType,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "usePullup",
|
||||
label: t("detectionSensor.usePullup.label"),
|
||||
description: t("detectionSensor.usePullup.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,234 @@
|
||||
import {
|
||||
type ExternalNotificationValidation,
|
||||
ExternalNotificationValidationSchema,
|
||||
} from "@app/validation/moduleConfig/externalNotification.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface ExternalNotificationModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<ExternalNotificationValidation>;
|
||||
}
|
||||
|
||||
export const ExternalNotification = (
|
||||
{ onFormInit }: ExternalNotificationModuleConfigProps,
|
||||
) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: ExternalNotificationValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.externalNotification, data, true)) {
|
||||
removeWorkingModuleConfig("externalNotification");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "externalNotification",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<ExternalNotificationValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={ExternalNotificationValidationSchema}
|
||||
formId="ModuleConfig_ExternalNotificationConfig"
|
||||
defaultValues={moduleConfig.externalNotification}
|
||||
values={getEffectiveModuleConfig("externalNotification")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("externalNotification.title"),
|
||||
description: t("externalNotification.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("externalNotification.enabled.label"),
|
||||
description: t("externalNotification.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "outputMs",
|
||||
label: t("externalNotification.outputMs.label"),
|
||||
description: t("externalNotification.outputMs.description"),
|
||||
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
suffix: t("unit.millisecond.suffix"),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "output",
|
||||
label: t("externalNotification.output.label"),
|
||||
description: t("externalNotification.output.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "outputVibra",
|
||||
label: t("externalNotification.outputVibra.label"),
|
||||
description: t("externalNotification.outputVibra.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "outputBuzzer",
|
||||
label: t("externalNotification.outputBuzzer.label"),
|
||||
description: t("externalNotification.outputBuzzer.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "active",
|
||||
label: t("externalNotification.active.label"),
|
||||
description: t("externalNotification.active.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "alertMessage",
|
||||
label: t("externalNotification.alertMessage.label"),
|
||||
description: t("externalNotification.alertMessage.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "alertMessageVibra",
|
||||
label: t("externalNotification.alertMessageVibra.label"),
|
||||
description: t(
|
||||
"externalNotification.alertMessageVibra.description",
|
||||
),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "alertMessageBuzzer",
|
||||
label: t("externalNotification.alertMessageBuzzer.label"),
|
||||
description: t(
|
||||
"externalNotification.alertMessageBuzzer.description",
|
||||
),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "alertBell",
|
||||
label: t("externalNotification.alertBell.label"),
|
||||
description: t("externalNotification.alertBell.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "alertBellVibra",
|
||||
label: t("externalNotification.alertBellVibra.label"),
|
||||
description: t("externalNotification.alertBellVibra.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "alertBellBuzzer",
|
||||
label: t("externalNotification.alertBellBuzzer.label"),
|
||||
description: t(
|
||||
"externalNotification.alertBellBuzzer.description",
|
||||
),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "usePwm",
|
||||
label: t("externalNotification.usePwm.label"),
|
||||
description: t("externalNotification.usePwm.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "nagTimeout",
|
||||
label: t("externalNotification.nagTimeout.label"),
|
||||
description: t("externalNotification.nagTimeout.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "useI2sAsBuzzer",
|
||||
label: t("externalNotification.useI2sAsBuzzer.label"),
|
||||
description: t("externalNotification.useI2sAsBuzzer.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,292 @@
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import {
|
||||
type MqttValidation,
|
||||
MqttValidationSchema,
|
||||
} from "@app/validation/moduleConfig/mqtt.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface MqttModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<MqttValidation>;
|
||||
}
|
||||
|
||||
export const MQTT = ({ onFormInit }: MqttModuleConfigProps) => {
|
||||
const {
|
||||
config,
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: MqttValidation) => {
|
||||
const payload = {
|
||||
...data,
|
||||
mapReportSettings: create(
|
||||
Protobuf.ModuleConfig.ModuleConfig_MapReportSettingsSchema,
|
||||
data.mapReportSettings,
|
||||
),
|
||||
};
|
||||
|
||||
if (deepCompareConfig(moduleConfig.mqtt, payload, true)) {
|
||||
removeWorkingModuleConfig("mqtt");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "mqtt",
|
||||
value: payload,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const populateDefaultValues = (
|
||||
cfg: Protobuf.ModuleConfig.ModuleConfig_MQTTConfig | undefined,
|
||||
) => {
|
||||
return cfg
|
||||
? {
|
||||
...cfg,
|
||||
mapReportSettings: cfg.mapReportSettings ??
|
||||
{ publishIntervalSecs: 0, positionPrecision: 10 },
|
||||
}
|
||||
: undefined;
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<MqttValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={MqttValidationSchema}
|
||||
formId="ModuleConfig_MqttConfig"
|
||||
defaultValues={populateDefaultValues(moduleConfig.mqtt)}
|
||||
values={populateDefaultValues(getEffectiveModuleConfig("mqtt"))}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("mqtt.title"),
|
||||
description: t("mqtt.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("mqtt.enabled.label"),
|
||||
description: t("mqtt.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
name: "address",
|
||||
label: t("mqtt.address.label"),
|
||||
description: t("mqtt.address.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
name: "username",
|
||||
label: t("mqtt.username.label"),
|
||||
description: t("mqtt.username.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "password",
|
||||
name: "password",
|
||||
label: t("mqtt.password.label"),
|
||||
description: t("mqtt.password.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "encryptionEnabled",
|
||||
label: t("mqtt.encryptionEnabled.label"),
|
||||
description: t("mqtt.encryptionEnabled.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "jsonEnabled",
|
||||
label: t("mqtt.jsonEnabled.label"),
|
||||
description: t("mqtt.jsonEnabled.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "tlsEnabled",
|
||||
label: t("mqtt.tlsEnabled.label"),
|
||||
description: t("mqtt.tlsEnabled.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
name: "root",
|
||||
label: t("mqtt.root.label"),
|
||||
description: t("mqtt.root.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "proxyToClientEnabled",
|
||||
label: t("mqtt.proxyToClientEnabled.label"),
|
||||
description: t("mqtt.proxyToClientEnabled.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "mapReportingEnabled",
|
||||
label: t("mqtt.mapReportingEnabled.label"),
|
||||
description: t("mqtt.mapReportingEnabled.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "mapReportSettings.publishIntervalSecs",
|
||||
label: t("mqtt.mapReportSettings.publishIntervalSecs.label"),
|
||||
description: t(
|
||||
"mqtt.mapReportSettings.publishIntervalSecs.description",
|
||||
),
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
{
|
||||
fieldName: "mapReportingEnabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "mapReportSettings.positionPrecision",
|
||||
label: t(
|
||||
"mqtt.mapReportSettings.positionPrecision.label",
|
||||
),
|
||||
description: t(
|
||||
"mqtt.mapReportSettings.positionPrecision.description",
|
||||
),
|
||||
properties: {
|
||||
enumValue: config.display?.units === 0
|
||||
? {
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_km23")
|
||||
]: 10,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_km12")
|
||||
]: 11,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_km5_8")
|
||||
]: 12,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_km2_9")
|
||||
]: 13,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_km1_5")
|
||||
]: 14,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_m700")
|
||||
]: 15,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_m350")
|
||||
]: 16,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_m200")
|
||||
]: 17,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_m90")
|
||||
]: 18,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.metric_m50")
|
||||
]: 19,
|
||||
}
|
||||
: {
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_mi15")
|
||||
]: 10,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_mi7_3")
|
||||
]: 11,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_mi3_6")
|
||||
]: 12,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_mi1_8")
|
||||
]: 13,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_mi0_9")
|
||||
]: 14,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_mi0_5")
|
||||
]: 15,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_mi0_2")
|
||||
]: 16,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_ft600")
|
||||
]: 17,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_ft300")
|
||||
]: 18,
|
||||
[
|
||||
t("mqtt.mapReportSettings.positionPrecision.options.imperial_ft150")
|
||||
]: 19,
|
||||
},
|
||||
},
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
{
|
||||
fieldName: "mapReportingEnabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import {
|
||||
type NeighborInfoValidation,
|
||||
NeighborInfoValidationSchema,
|
||||
} from "@app/validation/moduleConfig/neighborInfo.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface NeighborInfoModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<NeighborInfoValidation>;
|
||||
}
|
||||
|
||||
export const NeighborInfo = ({ onFormInit }: NeighborInfoModuleConfigProps) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: NeighborInfoValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.neighborInfo, data, true)) {
|
||||
removeWorkingModuleConfig("neighborInfo");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "neighborInfo",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<NeighborInfoValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={NeighborInfoValidationSchema}
|
||||
formId="ModuleConfig_NeighborInfoConfig"
|
||||
defaultValues={moduleConfig.neighborInfo}
|
||||
values={getEffectiveModuleConfig("neighborInfo")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("neighborInfo.title"),
|
||||
description: t("neighborInfo.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("neighborInfo.enabled.label"),
|
||||
description: t("neighborInfo.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "updateInterval",
|
||||
label: t("neighborInfo.updateInterval.label"),
|
||||
description: t("neighborInfo.updateInterval.description"),
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,104 @@
|
||||
import {
|
||||
type PaxcounterValidation,
|
||||
PaxcounterValidationSchema,
|
||||
} from "@app/validation/moduleConfig/paxcounter.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface PaxcounterModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<PaxcounterValidation>;
|
||||
}
|
||||
|
||||
export const Paxcounter = ({ onFormInit }: PaxcounterModuleConfigProps) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: PaxcounterValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.paxcounter, data, true)) {
|
||||
removeWorkingModuleConfig("paxcounter");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "paxcounter",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<PaxcounterValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={PaxcounterValidationSchema}
|
||||
formId="ModuleConfig_PaxcounterConfig"
|
||||
defaultValues={moduleConfig.paxcounter}
|
||||
values={getEffectiveModuleConfig("paxcounter")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("paxcounter.title"),
|
||||
description: t("paxcounter.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("paxcounter.enabled.label"),
|
||||
description: t("paxcounter.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "paxcounterUpdateInterval",
|
||||
label: t("paxcounter.paxcounterUpdateInterval.label"),
|
||||
description: t("paxcounter.paxcounterUpdateInterval.description"),
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "wifiThreshold",
|
||||
label: t("paxcounter.wifiThreshold.label"),
|
||||
description: t("paxcounter.wifiThreshold.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "bleThreshold",
|
||||
label: t("paxcounter.bleThreshold.label"),
|
||||
description: t("paxcounter.bleThreshold.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,93 @@
|
||||
import {
|
||||
type RangeTestValidation,
|
||||
RangeTestValidationSchema,
|
||||
} from "@app/validation/moduleConfig/rangeTest.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface RangeTestModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<RangeTestValidation>;
|
||||
}
|
||||
|
||||
export const RangeTest = ({ onFormInit }: RangeTestModuleConfigProps) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: RangeTestValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.rangeTest, data, true)) {
|
||||
removeWorkingModuleConfig("rangeTest");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "rangeTest",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<RangeTestValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={RangeTestValidationSchema}
|
||||
formId="ModuleConfig_RangeTestConfig"
|
||||
defaultValues={moduleConfig.rangeTest}
|
||||
values={getEffectiveModuleConfig("rangeTest")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("rangeTest.title"),
|
||||
description: t("rangeTest.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("rangeTest.enabled.label"),
|
||||
description: t("rangeTest.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "sender",
|
||||
label: t("rangeTest.sender.label"),
|
||||
description: t("rangeTest.sender.description"),
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "save",
|
||||
label: t("rangeTest.save.label"),
|
||||
description: t("rangeTest.save.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,154 @@
|
||||
import {
|
||||
type SerialValidation,
|
||||
SerialValidationSchema,
|
||||
} from "@app/validation/moduleConfig/serial.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface SerialModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<SerialValidation>;
|
||||
}
|
||||
|
||||
export const Serial = ({ onFormInit }: SerialModuleConfigProps) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: SerialValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.serial, data, true)) {
|
||||
removeWorkingModuleConfig("serial");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "serial",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<SerialValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={SerialValidationSchema}
|
||||
formId="ModuleConfig_SerialConfig"
|
||||
defaultValues={moduleConfig.serial}
|
||||
values={getEffectiveModuleConfig("serial")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("serial.title"),
|
||||
description: t("serial.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("serial.enabled.label"),
|
||||
description: t("serial.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "echo",
|
||||
label: t("serial.echo.label"),
|
||||
description: t("serial.echo.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "rxd",
|
||||
label: t("serial.rxd.label"),
|
||||
description: t("serial.rxd.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "txd",
|
||||
label: t("serial.txd.label"),
|
||||
description: t("serial.txd.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "baud",
|
||||
label: t("serial.baud.label"),
|
||||
description: t("serial.baud.description"),
|
||||
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
enumValue:
|
||||
Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Baud,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "timeout",
|
||||
label: t("serial.timeout.label"),
|
||||
description: t("serial.timeout.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "mode",
|
||||
label: t("serial.mode.label"),
|
||||
description: t("serial.mode.description"),
|
||||
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
enumValue:
|
||||
Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Mode,
|
||||
formatEnumName: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "overrideConsoleSerialPort",
|
||||
label: t("serial.overrideConsoleSerialPort.label"),
|
||||
description: t("serial.overrideConsoleSerialPort.description"),
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
import {
|
||||
type StoreForwardValidation,
|
||||
StoreForwardValidationSchema,
|
||||
} from "@app/validation/moduleConfig/storeForward.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface StoreForwardModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<StoreForwardValidation>;
|
||||
}
|
||||
|
||||
export const StoreForward = ({ onFormInit }: StoreForwardModuleConfigProps) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: StoreForwardValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.storeForward, data, true)) {
|
||||
removeWorkingModuleConfig("storeForward");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "storeForward",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<StoreForwardValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={StoreForwardValidationSchema}
|
||||
formId="ModuleConfig_StoreForwardConfig"
|
||||
defaultValues={moduleConfig.storeForward}
|
||||
values={getEffectiveModuleConfig("storeForward")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("storeForward.title"),
|
||||
description: t("storeForward.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "toggle",
|
||||
name: "enabled",
|
||||
label: t("storeForward.enabled.label"),
|
||||
description: t("storeForward.enabled.description"),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "heartbeat",
|
||||
label: t("storeForward.heartbeat.label"),
|
||||
description: t("storeForward.heartbeat.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "records",
|
||||
label: t("storeForward.records.label"),
|
||||
description: t("storeForward.records.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
suffix: t("unit.record.plural"),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "historyReturnMax",
|
||||
label: t("storeForward.historyReturnMax.label"),
|
||||
description: t("storeForward.historyReturnMax.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "historyReturnWindow",
|
||||
label: t("storeForward.historyReturnWindow.label"),
|
||||
description: t("storeForward.historyReturnWindow.description"),
|
||||
disabledBy: [
|
||||
{
|
||||
fieldName: "enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,132 @@
|
||||
import {
|
||||
type TelemetryValidation,
|
||||
TelemetryValidationSchema,
|
||||
} from "@app/validation/moduleConfig/telemetry.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
DynamicForm,
|
||||
type DynamicFormFormInit,
|
||||
} from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
import { Protobuf } from "@meshtastic/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { deepCompareConfig } from "@core/utils/deepCompareConfig.ts";
|
||||
|
||||
interface TelemetryModuleConfigProps {
|
||||
onFormInit: DynamicFormFormInit<TelemetryValidation>;
|
||||
}
|
||||
|
||||
export const Telemetry = ({ onFormInit }: TelemetryModuleConfigProps) => {
|
||||
const {
|
||||
moduleConfig,
|
||||
setWorkingModuleConfig,
|
||||
getEffectiveModuleConfig,
|
||||
removeWorkingModuleConfig,
|
||||
} = useDevice();
|
||||
const { t } = useTranslation("moduleConfig");
|
||||
|
||||
const onSubmit = (data: TelemetryValidation) => {
|
||||
if (deepCompareConfig(moduleConfig.telemetry, data, true)) {
|
||||
removeWorkingModuleConfig("telemetry");
|
||||
return;
|
||||
}
|
||||
|
||||
setWorkingModuleConfig(
|
||||
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
||||
payloadVariant: {
|
||||
case: "telemetry",
|
||||
value: data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<DynamicForm<TelemetryValidation>
|
||||
onSubmit={onSubmit}
|
||||
onFormInit={onFormInit}
|
||||
validationSchema={TelemetryValidationSchema}
|
||||
formId="ModuleConfig_TelemetryConfig"
|
||||
defaultValues={moduleConfig.telemetry}
|
||||
values={getEffectiveModuleConfig("telemetry")}
|
||||
fieldGroups={[
|
||||
{
|
||||
label: t("telemetry.title"),
|
||||
description: t("telemetry.description"),
|
||||
fields: [
|
||||
{
|
||||
type: "number",
|
||||
name: "deviceUpdateInterval",
|
||||
label: t("telemetry.deviceUpdateInterval.label"),
|
||||
description: t("telemetry.deviceUpdateInterval.description"),
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "environmentUpdateInterval",
|
||||
label: t("telemetry.environmentUpdateInterval.label"),
|
||||
description: t("telemetry.environmentUpdateInterval.description"),
|
||||
properties: {
|
||||
suffix: t("unit.second.plural"),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "environmentMeasurementEnabled",
|
||||
label: t("telemetry.environmentMeasurementEnabled.label"),
|
||||
description: t(
|
||||
"telemetry.environmentMeasurementEnabled.description",
|
||||
),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "environmentScreenEnabled",
|
||||
label: t("telemetry.environmentScreenEnabled.label"),
|
||||
description: t("telemetry.environmentScreenEnabled.description"),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "environmentDisplayFahrenheit",
|
||||
label: t("telemetry.environmentDisplayFahrenheit.label"),
|
||||
description: t(
|
||||
"telemetry.environmentDisplayFahrenheit.description",
|
||||
),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "airQualityEnabled",
|
||||
label: t("telemetry.airQualityEnabled.label"),
|
||||
description: t("telemetry.airQualityEnabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "airQualityInterval",
|
||||
label: t("telemetry.airQualityInterval.label"),
|
||||
description: t("telemetry.airQualityInterval.description"),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "powerMeasurementEnabled",
|
||||
label: t("telemetry.powerMeasurementEnabled.label"),
|
||||
description: t("telemetry.powerMeasurementEnabled.description"),
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "powerUpdateInterval",
|
||||
label: t("telemetry.powerUpdateInterval.label"),
|
||||
description: t("telemetry.powerUpdateInterval.description"),
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
name: "powerScreenEnabled",
|
||||
label: t("telemetry.powerScreenEnabled.label"),
|
||||
description: t("telemetry.powerScreenEnabled.description"),
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user