Browse Source

Added location management from web

pull/227/head
Hunter Thornsberry 2 years ago
parent
commit
4466a519c8
  1. 31
      src/components/PageComponents/Channel.tsx
  2. 18
      src/validation/channel.ts

31
src/components/PageComponents/Channel.tsx

@ -1,4 +1,4 @@
import type { ChannelValidation } from "@app/validation/channel.js";
import { ChannelValidation, Channel_SettingsValidation } from "@app/validation/channel.js";
import { DynamicForm } from "@components/Form/DynamicForm.js";
import { useToast } from "@core/hooks/useToast.js";
import { useDevice } from "@core/stores/deviceStore.js";
@ -20,7 +20,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
...data.settings,
psk: toByteArray(data.settings.psk ?? ""),
moduleSettings: {
positionPrecision: data.positionPrecision,
positionPrecision: data.settings.positionEnabled ? data.settings.preciseLocation ? 32 : data.settings.positionPrecision : 0,
}
},
});
@ -43,11 +43,11 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
settings: {
...channel?.settings,
psk: fromByteArray(channel?.settings?.psk ?? new Uint8Array(0)),
positionEnabled: channel?.settings?.moduleSettings?.positionPrecision != undefined && channel?.settings?.moduleSettings?.positionPrecision > 0,
preciseLocation: channel?.settings?.moduleSettings?.positionPrecision == 32,
positionPrecision: channel?.settings?.moduleSettings?.positionPrecision == undefined ? config.display?.units == 0 ? 23000 : 24140 : channel?.settings?.moduleSettings?.positionPrecision
},
},
positionEnabled: true,
preciseLocation: true,
positionPrecision: 1
}}
fieldGroups={[
{
@ -85,6 +85,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
name: "settings.uplinkEnabled",
label: "Uplink Enabled",
description: "Send messages from the local mesh to MQTT",
},
{
type: "toggle",
@ -94,35 +95,27 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
},
{
type: "toggle",
name: "positionEnabled",
name: "settings.positionEnabled",
label: "Allow Position Requests",
description: "Send position to channel",
},
{
type: "toggle",
name: "preciseLocation",
name: "settings.preciseLocation",
label: "Precise Location",
description: "Send precise location to channel",
disabledBy: [{
fieldName: "positionEnabled",
}]
},
{
type: "select",
name: "positionPrecision",
name: "settings.positionPrecision",
label: "Approximate Location",
description:
"Position shared on mesh is accurate within this distance",
"If not sharing precise location, position shared on mesh will be accurate within this distance",
properties: {
enumValue: config.display?.units == 0 ?
{ "Within 23 km":2300, "Within 12 km":12000, "Within 5.8 km":5800, "Within 2.9 km":2900, "Within 1.5 km":1500, "Within 700 m":700, "Within 350 m":350, "Within 200 m":200, "Within 90 m":90, "Within 50 m":50 } :
{ "Within 15 miles":1, "Within 7.3 miles":2, "Within 3.6 miles":3, "Within 1.8 miles":4, "Within 0.9 miles":5, "Within 0.5 miles":6, "Within 0.2 miles":7, "Within 600 feet":8, "Within 300 feet":9, "Within 150 feet":10 }
{ "Within 23 km":23000, "Within 12 km":12000, "Within 5.8 km":5800, "Within 2.9 km":2900, "Within 1.5 km":1500, "Within 700 m":700, "Within 350 m":350, "Within 200 m":200, "Within 90 m":90, "Within 50 m":50 } :
{ "Within 15 miles":24140, "Within 7.3 miles":11748, "Within 3.6 miles":5793, "Within 1.8 miles":2896, "Within 0.9 miles":1448, "Within 0.5 miles":804, "Within 0.2 miles":321, "Within 600 feet":182, "Within 300 feet":91, "Within 150 feet":45 }
},
disabledBy: [
{
fieldName: "positionEnabled",
},
],
},
],
},

18
src/validation/channel.ts

@ -19,15 +19,6 @@ export class ChannelValidation
@IsEnum(Protobuf.Channel.Channel_Role)
role: Protobuf.Channel.Channel_Role;
@IsBoolean()
positionEnabled: boolean;
@IsBoolean()
preciseLocation: boolean;
@IsInt()
positionPrecision: number;
}
export class Channel_SettingsValidation
@ -50,4 +41,13 @@ export class Channel_SettingsValidation
@IsBoolean()
downlinkEnabled: boolean;
@IsBoolean()
positionEnabled: boolean;
@IsBoolean()
preciseLocation: boolean;
@IsInt()
positionPrecision: number;
}

Loading…
Cancel
Save