diff --git a/.env.example b/.env.example index 3fd316e5..6b29b9a8 100644 --- a/.env.example +++ b/.env.example @@ -18,6 +18,9 @@ OSEM_API_URL="https://api.opensensemap.org/" DIRECTUS_URL="https://coelho.opensensemap.org" SENSORWIKI_API_URL="https://api.sensors.wiki/" +MQTT_SERVICE_URL="http://localhost:3001" +MQTT_SERVICE_KEY="dev-service-key-change-in-production" + MYBADGES_API_URL = "https://api.v2.mybadges.org/" MYBADGES_URL = "https://mybadges.org/" MYBADGES_SERVERADMIN_USERNAME = "" diff --git a/app/components/device/new/advanced-info.tsx b/app/components/device/new/advanced-info.tsx index 240c8f20..6284f79e 100644 --- a/app/components/device/new/advanced-info.tsx +++ b/app/components/device/new/advanced-info.tsx @@ -1,246 +1,130 @@ -import { useFormContext } from 'react-hook-form' -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from '~/components/ui/card' -import { Input } from '~/components/ui/input' -import { Label } from '~/components/ui/label' -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '~/components/ui/select' -import { Switch } from '~/components/ui/switch' -import { Textarea } from '~/components/ui/textarea' +import Form from "@rjsf/core"; +import validator from "@rjsf/validator-ajv8"; +import { useEffect, useState } from "react"; +import { useFormContext } from "react-hook-form"; +import { CheckboxWidget } from "~/components/rjsf/checkboxWidget"; +import { FieldTemplate } from "~/components/rjsf/fieldTemplate"; +import { BaseInputTemplate } from "~/components/rjsf/inputTemplate"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "~/components/ui/card"; +import { Label } from "~/components/ui/label"; +import { Switch } from "~/components/ui/switch"; +import { type IntegrationMetadata } from "~/routes/api.integrations"; export function AdvancedStep() { - const { register, setValue, watch, resetField } = useFormContext() - - // Watch field states - const isMqttEnabled = watch('mqttEnabled') || false - const isTtnEnabled = watch('ttnEnabled') || false - - // Clear corresponding fields when disabling - const handleMqttToggle = (checked: boolean) => { - setValue('mqttEnabled', checked) - if (!checked) { - resetField('url') - resetField('topic') - resetField('messageFormat') - resetField('decodeOptions') - resetField('connectionOptions') - } - } - - const handleTtnToggle = (checked: boolean) => { - setValue('ttnEnabled', checked) - if (!checked) { - resetField('dev_id') - resetField('app_id') - resetField('profile') - resetField('decodeOptions') - resetField('port') - } - } - - const handleInputChange = ( - event: React.ChangeEvent, - ) => { - const { name, value } = event.target - setValue(name, value) - } - - const handleSelectChange = (field: string, value: string) => { - setValue(field, value) - } - - return ( - <> - {/* MQTT Configuration */} - - - MQTT Configuration - - Configure your MQTT settings for data streaming - - - -
- - -
- - {isMqttEnabled && ( -
-
- - -
- -
- - -
- -
- - -
- -
- -