1+ import Button from '@components/Buttons/Button'
12import DefaultButton from '@components/Buttons/DefaultButton'
23import SwitchButton from '@components/Buttons/Toggle'
34import Card from '@components/Cards/Card'
@@ -18,6 +19,7 @@ import {
1819import { NOTIFICATION_TYPE } from '@interfaces/notifications/enums'
1920import { getApi } from '@src/esp'
2021import { logger } from '@src/logger'
22+ import { TRACKERS } from '@src/static'
2123import { formatMac , shortMdnsAddress } from '@src/utils'
2224import { addNotification } from '@store/actions/notifications/addNotification'
2325import { setAction , setStep } from '@store/animation/animation'
@@ -39,15 +41,15 @@ import {
3941 selectedNetwork ,
4042 ssid ,
4143} from '@store/network/selectors'
42- import { activeStepAction } from '@store/ui/selectors'
44+ import { activeStepAction , setupCustomMdns , setupMacAddress } from '@store/ui/selectors'
45+ import { setSetupCustomMdns , setSetupMacAddress } from '@store/ui/ui'
4346import { writeText } from '@tauri-apps/api/clipboard'
4447import { BiRegularError , BiRegularLoaderAlt } from 'solid-icons/bi'
4548import { IoCheckmarkSharp } from 'solid-icons/io'
4649import { RiSystemLockPasswordLine } from 'solid-icons/ri'
47- import { batch , createMemo , createSignal , Match , onCleanup , Show , Switch } from 'solid-js'
50+ import { batch , createMemo , createSignal , For , Match , onCleanup , Show , Switch } from 'solid-js'
4851
4952const WirelessWizard = ( ) => {
50- const [ setupMacAddress , setSetupMacAddress ] = createSignal ( false )
5153 const [ ipAddress , setIpAddress ] = createSignal < string | undefined > ( '' )
5254 const sortedNetworks = createMemo ( ( ) => {
5355 return [ ...availableNetworks ( ) ] . sort ( ( a , b ) => {
@@ -120,6 +122,8 @@ const WirelessWizard = () => {
120122 setMac ( formatMac ( network . mac_address ) )
121123 setResetNetworkState ( )
122124 setSetupMacAddress ( false )
125+ setSetupCustomMdns ( false )
126+ setMdns ( '' )
123127 setStep ( WIRELESS_WIZARD_STEPS . WIRELESS_SETUP_CREDENTIALS )
124128 } )
125129 } }
@@ -129,7 +133,9 @@ const WirelessWizard = () => {
129133 setStep ( WIRELESS_WIZARD_STEPS . WIRELESS_MANUAL_SETUP )
130134 setSelectedNetwork ( undefined )
131135 setSetupMacAddress ( false )
136+ setSetupCustomMdns ( false )
132137 setResetNetworkState ( )
138+ setMdns ( '' )
133139 setSsid ( '' )
134140 setMac ( '' )
135141 } )
@@ -197,7 +203,7 @@ const WirelessWizard = () => {
197203 < SwitchButton
198204 active = { setupMacAddress ( ) }
199205 onClick = { ( ) => {
200- setSetupMacAddress ( ( prev ) => ! prev )
206+ setSetupMacAddress ( ! setupMacAddress ( ) )
201207 } }
202208 />
203209 </ div >
@@ -251,7 +257,7 @@ const WirelessWizard = () => {
251257 < SwitchButton
252258 active = { setupMacAddress ( ) }
253259 onClick = { ( ) => {
254- setSetupMacAddress ( ( prev ) => ! prev )
260+ setSetupMacAddress ( ! setupMacAddress ( ) )
255261 } }
256262 />
257263 </ div >
@@ -345,25 +351,65 @@ const WirelessWizard = () => {
345351 The tracker will be accessible under
346352 </ Typography >
347353 < Typography color = "blue" text = "caption" >
348- http://{ ! mdns ( ) . length ? 'openiristracker' : shortMdnsAddress ( mdns ( ) ) }
354+ http://
355+ { ! mdns ( ) . length ? '- - - -' : shortMdnsAddress ( mdns ( ) ) }
349356 .local
350357 </ Typography >
351358 </ div >
352- < div class = "flex flex-col gap-10 w-full" >
353- < Typography color = "white" text = "caption" class = "text-left" >
354- Setup tracker name
355- </ Typography >
356- < NetworkInput
357- id = "mdns"
358- type = "text"
359- onChange = { ( mdns ) => {
360- setMdns ( mdns )
361- } }
362- value = { mdns ( ) }
363- placeholder = {
364- ! mdns ( ) . length ? 'openiristracker' : shortMdnsAddress ( mdns ( ) )
365- }
366- />
359+ < div class = "w-full flex flex-col gap-24 items-end justify-end" >
360+ < div class = "flex flex-col gap-12 w-full" >
361+ < Typography color = "white" text = "caption" class = "text-left" >
362+ Setup tracker name
363+ </ Typography >
364+ < Show
365+ when = { setupCustomMdns ( ) }
366+ fallback = {
367+ < div class = "flex w-full flex-row gap-12" >
368+ < For each = { TRACKERS } >
369+ { ( tracker ) => (
370+ < Button
371+ size = "h-[39px]"
372+ label = { tracker . label }
373+ isActive = { ! ! mdns ( ) . match ( tracker . value ) }
374+ onClick = { ( ) => {
375+ setMdns (
376+ mdns ( ) . match ( tracker . value )
377+ ? ''
378+ : tracker . value ,
379+ )
380+ } }
381+ />
382+ ) }
383+ </ For >
384+ </ div >
385+ } >
386+ < NetworkInput
387+ id = "mdns"
388+ type = "text"
389+ onChange = { ( mdns ) => {
390+ setMdns ( mdns )
391+ } }
392+ value = { mdns ( ) }
393+ placeholder = {
394+ ! mdns ( ) . length
395+ ? 'openiristracker'
396+ : shortMdnsAddress ( mdns ( ) )
397+ }
398+ />
399+ </ Show >
400+ </ div >
401+ < div class = "flex w-full flex-row justify-between" >
402+ < Typography color = "white" text = "caption" class = "text-left" >
403+ Setup Custom Mdns
404+ </ Typography >
405+ < SwitchButton
406+ active = { setupCustomMdns ( ) }
407+ onClick = { ( ) => {
408+ setMdns ( '' )
409+ setSetupCustomMdns ( ! setupCustomMdns ( ) )
410+ } }
411+ />
412+ </ div >
367413 </ div >
368414 </ Card >
369415 </ Match >
0 commit comments