fromLocalToRR + some code removal
This commit is contained in:
parent
15012f3824
commit
c2fb32b547
@ -123,27 +123,12 @@ mkSRV i c ok p prot w prt t d v
|
|||||||
, ttl: t, domain: d, value: v
|
, ttl: t, domain: d, value: v
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultResourceRecords :: Array (SimpleRR ())
|
|
||||||
defaultResourceRecords
|
|
||||||
= [ mkNS 0 false true "3600" "@" "ns0.truc.fr"
|
|
||||||
, mkA 1 false true "200" "www" "192.168.10.2"
|
|
||||||
, mkAAAA 2 false true "610" "www" "fe80::1"
|
|
||||||
, mkCNAME 3 false true "630" "nom" "autrenom"
|
|
||||||
, mkTXT 4 false true "600" "txtme" "Ceci est un texte."
|
|
||||||
]
|
|
||||||
|
|
||||||
defaultMXResourceRecords :: Array (MXRR ())
|
|
||||||
defaultMXResourceRecords
|
|
||||||
= [ mkMX 5 false true "600" "www" "192.168.10.2" "200"
|
|
||||||
, mkMX 6 false true "3600" "www" "192.168.10.2" "200"
|
|
||||||
]
|
|
||||||
|
|
||||||
defaultResourceA :: SimpleRR ()
|
defaultResourceA :: SimpleRR ()
|
||||||
defaultResourceA = mkA 0 false true "200" "www" "192.168.10.2"
|
defaultResourceA = mkA 0 false true "200" "www" "192.168.10.2"
|
||||||
|
|
||||||
defaultResourceMX :: MXRR ()
|
defaultResourceMX :: MXRR ()
|
||||||
defaultResourceMX = mkMX 0 false true "500" "www" "192.168.10.2" "200"
|
defaultResourceMX = mkMX 0 false true "500" "mail" "www" "200"
|
||||||
|
|
||||||
defaultResourceSRV :: SRVRR ()
|
defaultResourceSRV :: SRVRR ()
|
||||||
-- RRId Modified Valid Priority Protocol Weight Port TTL Domain Value
|
-- RRId Modified Valid Priority Protocol Weight Port TTL Domain Value
|
||||||
defaultResourceSRV = mkSRV 0 false true "10" "_tcp" "100" "80" "200" "www" "192.168.10.2"
|
defaultResourceSRV = mkSRV 0 false true "10" "_tcp" "100" "80" "200" "_sip._tcp.example.com." "sip.example.com."
|
||||||
|
@ -410,6 +410,10 @@ handleAction = case _ of
|
|||||||
-- TODO: network operations
|
-- TODO: network operations
|
||||||
SyncRR rr_id -> do
|
SyncRR rr_id -> do
|
||||||
H.raise $ Log $ SimpleLog ("TODO: SyncRR: " <> show rr_id)
|
H.raise $ Log $ SimpleLog ("TODO: SyncRR: " <> show rr_id)
|
||||||
|
-- message <- H.liftEffect
|
||||||
|
-- $ DNSManager.serialize
|
||||||
|
-- $ DNSManager.MkDeleteRR { domain: _current_domain, rrid: rr_id }
|
||||||
|
-- H.raise $ MessageToSend message
|
||||||
|
|
||||||
RemoveRR rr_id -> do
|
RemoveRR rr_id -> do
|
||||||
{ _current_domain } <- H.get
|
{ _current_domain } <- H.get
|
||||||
@ -653,72 +657,6 @@ render_srv_records records
|
|||||||
baseRecords :: Array String
|
baseRecords :: Array String
|
||||||
baseRecords = [ "NS", "A", "AAAA", "CNAME", "TXT" ]
|
baseRecords = [ "NS", "A", "AAAA", "CNAME", "TXT" ]
|
||||||
|
|
||||||
render_new_record :: forall (w :: Type). (SimpleRR ()) -> HH.HTML w Action
|
|
||||||
render_new_record rr
|
|
||||||
= Bulma.hdiv [ Bulma.zone_rr_title "New record (NS, A, AAAA, CNAME, TXT)", table ]
|
|
||||||
|
|
||||||
where
|
|
||||||
table = HH.table [] [ Bulma.simple_table_header, render_record_builder ]
|
|
||||||
|
|
||||||
-- render_record_builder :: forall w. HH.HTML w Action
|
|
||||||
render_record_builder
|
|
||||||
= HH.tr_
|
|
||||||
[ HH.td_ [ type_selection ]
|
|
||||||
, HH.td_ [ Bulma.input_domain (UpdateNewSRRForm <<< Update_SRR_Domain) rr.domain rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_ttl (UpdateNewSRRForm <<< Update_SRR_TTL) rr.ttl rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_value (UpdateNewSRRForm <<< Update_SRR_Value) rr.value rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.btn_add AddSRR (TellSomethingWentWrong rr.id "cannot add") rr.valid ]
|
|
||||||
]
|
|
||||||
|
|
||||||
-- type_selection :: forall w i. HH.HTML w i
|
|
||||||
type_selection = HH.select
|
|
||||||
[ HE.onSelectedIndexChange (UpdateNewSRRForm <<< Update_SRR_Type) ]
|
|
||||||
$ map type_option baseRecords
|
|
||||||
type_option n
|
|
||||||
= HH.option
|
|
||||||
[ HP.value n
|
|
||||||
, HP.selected (n == rr.t)
|
|
||||||
] [ HH.text n ]
|
|
||||||
|
|
||||||
|
|
||||||
render_mx_new_record :: forall (w :: Type). (MXRR ()) -> HH.HTML w Action
|
|
||||||
render_mx_new_record rr
|
|
||||||
= Bulma.hdiv [ Bulma.zone_rr_title "New MX record", table ]
|
|
||||||
|
|
||||||
where
|
|
||||||
table = HH.table [] [ Bulma.mx_table_header, render_record_builder ]
|
|
||||||
|
|
||||||
-- render_record_builder :: forall w. HH.HTML w Action
|
|
||||||
render_record_builder
|
|
||||||
= HH.tr_
|
|
||||||
[ HH.td_ [ Bulma.input_domain (UpdateNewMXForm <<< Update_MX_Domain) rr.domain rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_ttl (UpdateNewMXForm <<< Update_MX_TTL) rr.ttl rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_priority (UpdateNewMXForm <<< Update_MX_Priority) rr.priority rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_value (UpdateNewMXForm <<< Update_MX_Value) rr.value rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.btn_add AddMX (TellSomethingWentWrong rr.id "cannot add") rr.valid ]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
render_srv_new_record :: forall (w :: Type). (SRVRR ()) -> HH.HTML w Action
|
|
||||||
render_srv_new_record rr
|
|
||||||
= Bulma.hdiv [ Bulma.zone_rr_title "New SRV record", table ]
|
|
||||||
where
|
|
||||||
table = HH.table [] [ Bulma.srv_table_header, render_record_builder ]
|
|
||||||
|
|
||||||
-- render_record_builder :: forall w. HH.HTML w Action
|
|
||||||
render_record_builder
|
|
||||||
= HH.tr_
|
|
||||||
[ HH.td_ [ Bulma.input_domain (UpdateNewSRVForm <<< Update_SRV_Domain) rr.domain rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_ttl (UpdateNewSRVForm <<< Update_SRV_TTL) rr.ttl rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_priority (UpdateNewSRVForm <<< Update_SRV_Priority) rr.priority rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_protocol (UpdateNewSRVForm <<< Update_SRV_Protocol) rr.protocol rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_weight (UpdateNewSRVForm <<< Update_SRV_Weight) rr.weight rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_port (UpdateNewSRVForm <<< Update_SRV_Port) rr.port rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.input_value (UpdateNewSRVForm <<< Update_SRV_Value) rr.value rr.valid ]
|
|
||||||
, HH.td_ [ Bulma.btn_add AddSRV (TellSomethingWentWrong rr.id "cannot add") rr.valid ]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
-- Component definition and initial state
|
-- Component definition and initial state
|
||||||
|
|
||||||
render_new_records :: forall (w :: Type). State -> HH.HTML w Action
|
render_new_records :: forall (w :: Type). State -> HH.HTML w Action
|
||||||
@ -857,6 +795,15 @@ update f rr_id records = map doSmth records
|
|||||||
| rr_id == rr.id = f rr
|
| rr_id == rr.id = f rr
|
||||||
| otherwise = rr
|
| otherwise = rr
|
||||||
|
|
||||||
|
fromLocalToRR :: forall (l :: Row Type). SRVRR (|l) -> Either String ResourceRecord
|
||||||
|
fromLocalToRR new_rr = do
|
||||||
|
case new_rr.t, (A.elem new_rr.t baseRecords) of
|
||||||
|
_, true -> Right $ fromLocalSimpleRRRepresentationToResourceRecord new_rr
|
||||||
|
"MX", _ -> Right $ fromLocalMXRRRepresentationToResourceRecord new_rr
|
||||||
|
"SRV", _ -> Right $ fromLocalSRVRRepresentationToResourceRecord new_rr
|
||||||
|
-- "SOA" resource record shouldn't be useful in this context.
|
||||||
|
_, _ -> Left $ "TODO: cannot convert RR type '" <> new_rr.t <> "' to ResourceRecord representation."
|
||||||
|
|
||||||
fromResourceRecordToLocalRepresentationSimpleRR :: ResourceRecord -> Maybe (SimpleRR ())
|
fromResourceRecordToLocalRepresentationSimpleRR :: ResourceRecord -> Maybe (SimpleRR ())
|
||||||
fromResourceRecordToLocalRepresentationSimpleRR new_rr =
|
fromResourceRecordToLocalRepresentationSimpleRR new_rr =
|
||||||
Just { t: new_rr.rrtype
|
Just { t: new_rr.rrtype
|
||||||
@ -929,7 +876,7 @@ fromResourceRecordToLocalRepresentationSOARR new_rr = do
|
|||||||
, minttl: show minttl -- :: RR (Maybe Int) Local (String)
|
, minttl: show minttl -- :: RR (Maybe Int) Local (String)
|
||||||
}
|
}
|
||||||
|
|
||||||
fromLocalSimpleRRRepresentationToResourceRecord :: SimpleRR () -> ResourceRecord
|
fromLocalSimpleRRRepresentationToResourceRecord :: forall l. SimpleRR (|l) -> ResourceRecord
|
||||||
fromLocalSimpleRRRepresentationToResourceRecord form
|
fromLocalSimpleRRRepresentationToResourceRecord form
|
||||||
= { rrtype: form.t
|
= { rrtype: form.t
|
||||||
, rrid: form.id
|
, rrid: form.id
|
||||||
@ -950,7 +897,7 @@ fromLocalSimpleRRRepresentationToResourceRecord form
|
|||||||
, minttl: Nothing
|
, minttl: Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
fromLocalMXRRRepresentationToResourceRecord :: MXRR () -> ResourceRecord
|
fromLocalMXRRRepresentationToResourceRecord :: forall l. MXRR (|l) -> ResourceRecord
|
||||||
fromLocalMXRRRepresentationToResourceRecord form
|
fromLocalMXRRRepresentationToResourceRecord form
|
||||||
= { rrtype: form.t
|
= { rrtype: form.t
|
||||||
, rrid: form.id
|
, rrid: form.id
|
||||||
@ -971,7 +918,7 @@ fromLocalMXRRRepresentationToResourceRecord form
|
|||||||
, minttl: Nothing
|
, minttl: Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
fromLocalSRVRRepresentationToResourceRecord :: SRVRR () -> ResourceRecord
|
fromLocalSRVRRepresentationToResourceRecord :: forall l. SRVRR (|l) -> ResourceRecord
|
||||||
fromLocalSRVRRepresentationToResourceRecord form
|
fromLocalSRVRRepresentationToResourceRecord form
|
||||||
= { rrtype: form.t
|
= { rrtype: form.t
|
||||||
, rrid: form.id
|
, rrid: form.id
|
||||||
|
Loading…
Reference in New Issue
Block a user