diff --git a/src/App/RR.purs b/src/App/RR.purs index 897f58f..afe6738 100644 --- a/src/App/RR.purs +++ b/src/App/RR.purs @@ -39,6 +39,16 @@ type SRVRR l = RecordBase ( priority :: Priority , port :: Port | l) +type SOARR l + = RecordBase ( mname :: String + , rname :: String + , serial :: String -- Int + , refresh :: String -- Int + , retry :: String -- Int + , expire :: String -- Int + , minttl :: String -- Int + | l) + --data Status -- = Synchronized -- | UnSynchronized diff --git a/src/App/ZoneInterface.purs b/src/App/ZoneInterface.purs index cf31bd5..59a0838 100644 --- a/src/App/ZoneInterface.purs +++ b/src/App/ZoneInterface.purs @@ -128,6 +128,7 @@ data Action type State = { _current_domain :: RecordDomain + , _soa :: Maybe (SOARR ()) , _srr :: Array (SimpleRR ()) , _mxrr :: Array (MXRR ()) , _srvrr :: Array (SRVRR ()) @@ -163,6 +164,7 @@ initialState domain = , active_modal: Nothing , _current_domain: domain + , _soa: Nothing , _srr: [] , _mxrr: [] , _srvrr: [] @@ -176,9 +178,10 @@ render state = Bulma.section_small [ case state.wsUp, state.active_modal of false, _ -> Bulma.p "You are disconnected." - true, Just rr_id -> modal_rr_delete rr_id + true, Just rr_id -> modal_rr_delete rr_id true, Nothing -> HH.div_ [ Bulma.h1 state._current_domain , Bulma.hr + , render_soa state._soa , render_records sorted , render_mx_records state._mxrr , render_srv_records state._srvrr @@ -529,12 +532,33 @@ handleQuery = case _ of _, true -> Right $ add_new_entry state $ fromResourceRecordToLocalRepresentationSimpleRR new_rr "MX", _ -> Right $ add_new_mx state $ fromResourceRecordToLocalRepresentationMXRR new_rr "SRV", _ -> Right $ add_new_srv state $ fromResourceRecordToLocalRepresentationSRVRR new_rr + "SOA", _ -> Right $ new_soa state $ fromResourceRecordToLocalRepresentationSOARR new_rr _, _ -> Left $ "TODO: cannot add '" <> new_rr.rrtype <> "' resource records at the moment." -- Rendering class_title_size :: Array (HH.ClassName) class_title_size = [HH.ClassName "is-4"] +render_soa :: forall (w :: Type). Maybe (SOARR ()) -> HH.HTML w Action +render_soa Nothing = HH.div_ [ HH.text "SOA not loaded, yet" ] +render_soa (Just soa) = Bulma.columns [] [ left_block, right_block ] + where left_block = Bulma.column class_title_size + [ Bulma.zone_rr_title "Start Of Authority (SOA)" ] + right_block = Bulma.column_ [ Bulma.p "ALL AVAILABLE DATA" + , Bulma.p $ "rrtype: " <> soa.t + , Bulma.p $ "rrid: " <> show soa.id + , Bulma.p $ "name: " <> soa.domain + , Bulma.p $ "ttl: " <> soa.ttl + , Bulma.p $ "target: " <> soa.value + , Bulma.p $ "mname: " <> soa.mname + , Bulma.p $ "rname: " <> soa.rname + , Bulma.p $ "serial: " <> soa.serial + , Bulma.p $ "refresh: " <> soa.refresh + , Bulma.p $ "retry: " <> soa.retry + , Bulma.p $ "expire: " <> soa.expire + , Bulma.p $ "minttl: " <> soa.minttl + ] + render_records :: forall (w :: Type). Array (SimpleRR ()) -> HH.HTML w Action render_records [] = Bulma.columns [] [ left_block, right_block ] @@ -771,6 +795,11 @@ add_new_srv :: State -> Maybe (SRVRR ()) -> State add_new_srv state = case _ of Nothing -> state Just rr -> state { _srvrr = (state._srvrr <> [ rr ]), _current_entry_srv = defaultResourceSRV } + +new_soa :: State -> Maybe (SOARR ()) -> State +new_soa state = case _ of + Nothing -> state + Just rr -> state { _soa = Just rr } changeType :: forall (l :: Row Type). (SimpleRR l) -> Maybe String -> (SimpleRR l) changeType rr Nothing = rr @@ -860,6 +889,31 @@ fromResourceRecordToLocalRepresentationSRVRR new_rr = do } _, _, _ -> Nothing +fromResourceRecordToLocalRepresentationSOARR :: ResourceRecord -> Maybe (SOARR ()) +fromResourceRecordToLocalRepresentationSOARR new_rr = do + mname <- new_rr.mname -- :: Maybe String + rname <- new_rr.rname -- :: Maybe String + serial <- new_rr.serial -- :: Maybe Int + refresh <- new_rr.refresh -- :: Maybe Int + retry <- new_rr.retry -- :: Maybe Int + expire <- new_rr.expire -- :: Maybe Int + minttl <- new_rr.minttl -- :: Maybe Int + Just { t: new_rr.rrtype + , id: new_rr.rrid + , modified: false + , valid: true + , ttl: show new_rr.ttl + , domain: new_rr.name + , value: new_rr.target + , mname: mname -- :: RR (Maybe String) Local (String) + , rname: rname -- :: RR (Maybe String) Local (String) + , serial: show serial -- :: RR (Maybe Int) Local (String) + , refresh: show refresh -- :: RR (Maybe Int) Local (String) + , retry: show retry -- :: RR (Maybe Int) Local (String) + , expire: show expire -- :: RR (Maybe Int) Local (String) + , minttl: show minttl -- :: RR (Maybe Int) Local (String) + } + fromLocalSimpleRRRepresentationToResourceRecord :: SimpleRR () -> ResourceRecord fromLocalSimpleRRRepresentationToResourceRecord form = { rrtype: form.t