Can ask `dnsmanagerd` for the final zonefile, fancy display.
parent
1f2142e62b
commit
755a2a577d
|
@ -637,9 +637,10 @@ handleAction = case _ of
|
||||||
m@(DNSManager.MkRRAdded response) -> do
|
m@(DNSManager.MkRRAdded response) -> do
|
||||||
handleAction $ Log $ SuccessLog $ "Resource Record added: " <> response.rr.rrtype
|
handleAction $ Log $ SuccessLog $ "Resource Record added: " <> response.rr.rrtype
|
||||||
handleAction $ DispatchDNSMessage m
|
handleAction $ DispatchDNSMessage m
|
||||||
(DNSManager.MkGeneratedZoneFile response) -> do
|
m@(DNSManager.MkGeneratedZoneFile response) -> do
|
||||||
handleAction $ Log $ SuccessLog $ "Received the generated zonefile for " <> response.domain
|
handleAction $ Log $ SuccessLog $ "Received the generated zonefile for " <> response.domain
|
||||||
handleAction $ Log $ SuccessLog $ "TODO: show it, " <> response.zonefile
|
handleAction $ Log $ SuccessLog $ "TODO: show it, " <> response.zonefile
|
||||||
|
handleAction $ DispatchDNSMessage m
|
||||||
(DNSManager.MkInvalidDomainName _) -> do
|
(DNSManager.MkInvalidDomainName _) -> do
|
||||||
handleAction $ Log $ ErrorLog $ "The domain is not valid!"
|
handleAction $ Log $ ErrorLog $ "The domain is not valid!"
|
||||||
m@(DNSManager.MkDomainDeleted response) -> do
|
m@(DNSManager.MkDomainDeleted response) -> do
|
||||||
|
|
|
@ -134,6 +134,9 @@ data Action
|
||||||
-- | Automatically closes the modal.
|
-- | Automatically closes the modal.
|
||||||
| RemoveRR RRId
|
| RemoveRR RRId
|
||||||
|
|
||||||
|
-- | Ask `dnsmanagerd` for the generated zone file.
|
||||||
|
| AskZoneFile
|
||||||
|
|
||||||
data RRModal
|
data RRModal
|
||||||
= NoModal
|
= NoModal
|
||||||
| NewRRModal AcceptedRRTypes
|
| NewRRModal AcceptedRRTypes
|
||||||
|
@ -175,6 +178,8 @@ type State =
|
||||||
-- Unique RR form.
|
-- Unique RR form.
|
||||||
, _currentRR :: ResourceRecord
|
, _currentRR :: ResourceRecord
|
||||||
, _currentRR_errors :: Array Validation.Error
|
, _currentRR_errors :: Array Validation.Error
|
||||||
|
|
||||||
|
, _zonefile :: Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
component :: forall m. MonadAff m => H.Component Query Input Output m
|
component :: forall m. MonadAff m => H.Component Query Input Output m
|
||||||
|
@ -235,6 +240,7 @@ initialState domain =
|
||||||
, _currentRR: default_empty_rr
|
, _currentRR: default_empty_rr
|
||||||
-- List of errors within the form in new RR modal.
|
-- List of errors within the form in new RR modal.
|
||||||
, _currentRR_errors: []
|
, _currentRR_errors: []
|
||||||
|
, _zonefile: Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
type SortableRecord l = Record (rrtype :: String, rrid :: Int | l)
|
type SortableRecord l = Record (rrtype :: String, rrid :: Int | l)
|
||||||
|
@ -253,6 +259,7 @@ render state
|
||||||
, render_resources $ sorted state._resources
|
, render_resources $ sorted state._resources
|
||||||
, Bulma.hr
|
, Bulma.hr
|
||||||
, render_new_records state
|
, render_new_records state
|
||||||
|
, render_zonefile state._zonefile
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
@ -605,6 +612,14 @@ handleAction = case _ of
|
||||||
-- Modal doesn't need to be active anymore.
|
-- Modal doesn't need to be active anymore.
|
||||||
handleAction CancelModal
|
handleAction CancelModal
|
||||||
|
|
||||||
|
AskZoneFile -> do
|
||||||
|
state <- H.get
|
||||||
|
H.raise $ Log $ SystemLog $ "Asking for the '" <> state._domain <> "' zonefile"
|
||||||
|
message <- H.liftEffect
|
||||||
|
$ DNSManager.serialize
|
||||||
|
$ DNSManager.MkAskGeneratedZoneFile { domain: state._domain }
|
||||||
|
H.raise $ MessageToSend message
|
||||||
|
|
||||||
handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a)
|
handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a)
|
||||||
handleQuery = case _ of
|
handleQuery = case _ of
|
||||||
|
|
||||||
|
@ -622,6 +637,8 @@ handleQuery = case _ of
|
||||||
-- Remove the resource record.
|
-- Remove the resource record.
|
||||||
state <- H.get
|
state <- H.get
|
||||||
H.modify_ _ { _resources = A.filter (\rr -> rr.rrid /= response.rrid) state._resources }
|
H.modify_ _ { _resources = A.filter (\rr -> rr.rrid /= response.rrid) state._resources }
|
||||||
|
(DNSManager.MkGeneratedZoneFile response) -> do
|
||||||
|
H.modify_ _ { _zonefile = Just response.zonefile }
|
||||||
(DNSManager.MkZone response) -> do
|
(DNSManager.MkZone response) -> do
|
||||||
add_entries response.zone.resources
|
add_entries response.zone.resources
|
||||||
|
|
||||||
|
@ -793,7 +810,6 @@ render_new_records :: forall (w :: Type). State -> HH.HTML w Action
|
||||||
render_new_records _
|
render_new_records _
|
||||||
= Bulma.hdiv
|
= Bulma.hdiv
|
||||||
[ Bulma.h1 "Adding new records"
|
[ Bulma.h1 "Adding new records"
|
||||||
, Bulma.hr
|
|
||||||
-- use "level" to get horizontal buttons next to each other (probably vertical on mobile)
|
-- use "level" to get horizontal buttons next to each other (probably vertical on mobile)
|
||||||
, Bulma.level [
|
, Bulma.level [
|
||||||
Bulma.btn "A" (CreateNewRRModal A)
|
Bulma.btn "A" (CreateNewRRModal A)
|
||||||
|
@ -804,8 +820,23 @@ render_new_records _
|
||||||
, Bulma.btn "MX" (CreateNewRRModal MX)
|
, Bulma.btn "MX" (CreateNewRRModal MX)
|
||||||
, Bulma.btn "SRV" (CreateNewRRModal SRV)
|
, Bulma.btn "SRV" (CreateNewRRModal SRV)
|
||||||
] []
|
] []
|
||||||
|
, Bulma.hr
|
||||||
|
, Bulma.h1 "Special records about the mail system (soon)"
|
||||||
|
-- use "level" to get horizontal buttons next to each other (probably vertical on mobile)
|
||||||
|
, Bulma.level [
|
||||||
|
Bulma.btn_ro (C.is_small <> C.is_warning) "SPF"
|
||||||
|
, Bulma.btn_ro (C.is_small <> C.is_warning) "DKIM"
|
||||||
|
, Bulma.btn_ro (C.is_small <> C.is_warning) "DMARC"
|
||||||
|
] []
|
||||||
|
, Bulma.hr
|
||||||
|
, Bulma.level [
|
||||||
|
Bulma.btn "Get the final zone file." AskZoneFile
|
||||||
|
] [HH.text "For debug purposes. ⚠"]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
render_zonefile :: forall (w :: Type). Maybe String -> HH.HTML w Action
|
||||||
|
render_zonefile zonefile = Bulma.box [ maybe (HH.text "") (\x -> HH.pre_ [HH.text x]) zonefile ]
|
||||||
|
|
||||||
-- ACTIONS
|
-- ACTIONS
|
||||||
|
|
||||||
first :: forall a. (a -> Boolean) -> Array a -> Maybe a
|
first :: forall a. (a -> Boolean) -> Array a -> Maybe a
|
||||||
|
|
Loading…
Reference in New Issue