Better display of resource records.
This commit is contained in:
parent
4f785e6dcc
commit
5a987a524c
@ -589,8 +589,6 @@ handleAction = case _ of
|
||||
case Validation.validation state._currentRR of
|
||||
Left actual_errors -> do
|
||||
H.modify_ _ { _currentRR_errors = actual_errors }
|
||||
H.raise $ Log $ SimpleLog $ "[😈] Errors in RR id " <> show state._currentRR.rrid
|
||||
<> ". Please fix them before update."
|
||||
Right rr -> do
|
||||
H.modify_ _ { _currentRR_errors = [] }
|
||||
handleAction $ SaveRR rr
|
||||
@ -653,7 +651,6 @@ handleQuery = case _ of
|
||||
|
||||
new_state <- H.get
|
||||
H.put $ add_RR new_state new_rr
|
||||
H.raise $ Log $ SimpleLog $ "Replacing a resource record! Should be visible everywhere!"
|
||||
|
||||
add_entries [] = H.raise $ Log $ SimpleLog "[🎉] Zone fully loaded!"
|
||||
add_entries arr = do
|
||||
@ -667,27 +664,13 @@ handleQuery = case _ of
|
||||
add_RR :: State -> ResourceRecord -> State
|
||||
add_RR state new_rr = state { _resources = (state._resources <> [ new_rr ]) }
|
||||
|
||||
|
||||
-- Rendering
|
||||
render_soa :: forall (w :: Type). Maybe ResourceRecord -> HH.HTML w Action
|
||||
render_soa Nothing = Bulma.box [ HH.text "SOA not loaded, yet" ]
|
||||
render_soa (Just soa) = Bulma.box [ Bulma.zone_rr_title "Start Of Authority (SOA)"
|
||||
, table_rr
|
||||
]
|
||||
where table_rr = Bulma.table [] [ simple_SOA_table_header, table_content ]
|
||||
simple_SOA_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "name"]
|
||||
, HH.th_ [ HH.text "ttl"]
|
||||
, HH.th_ [ HH.text "target"]
|
||||
, HH.th_ [ HH.text "mname"]
|
||||
, HH.th_ [ HH.text "rname"]
|
||||
, HH.th_ [ HH.text "serial"]
|
||||
, HH.th_ [ HH.text "refresh"]
|
||||
, HH.th_ [ HH.text "retry"]
|
||||
, HH.th_ [ HH.text "expire"]
|
||||
, HH.th_ [ HH.text "minttl"]
|
||||
]
|
||||
]
|
||||
where table_rr = Bulma.table [] [ Bulma.soa_table_header, table_content ]
|
||||
table_content
|
||||
= HH.tbody_ $ [ HH.tr_ $ [
|
||||
--, Bulma.p $ "rrtype: " <> soa.rrtype
|
||||
@ -711,17 +694,40 @@ render_resources :: forall w
|
||||
. Array (ResourceRecord)
|
||||
-> HH.HTML w Action
|
||||
render_resources []
|
||||
= Bulma.box [ Bulma.zone_rr_title "All records (TEST)"
|
||||
= Bulma.box [ Bulma.zone_rr_title "Resource records"
|
||||
, Bulma.subtitle "No records for now"
|
||||
]
|
||||
render_resources records
|
||||
= Bulma.box [ Bulma.zone_rr_title "All records (TEST)"
|
||||
, render_soa $ A.head $ A.filter (\rr -> rr.rrtype == "SOA") records
|
||||
, table_rr
|
||||
= Bulma.box [ render_soa $ A.head $ A.filter (\rr -> rr.rrtype == "SOA") records
|
||||
, basic_records_section
|
||||
, mx_records_section
|
||||
, srv_records_section
|
||||
]
|
||||
where
|
||||
table_rr = Bulma.table [] [ table_content ]
|
||||
table_content = HH.tbody_ $ A.concat $ map rows $ A.filter (\rr -> rr.rrtype /= "SOA") records
|
||||
all_basic_rr = A.filter (\rr -> A.elem rr.rrtype baseRecords) records
|
||||
all_mx_rr = A.filter (\rr -> rr.rrtype == "MX") records
|
||||
all_srv_rr = A.filter (\rr -> rr.rrtype == "SRV") records
|
||||
|
||||
basic_records_section
|
||||
= if A.length all_basic_rr > 0
|
||||
then Bulma.table [] [ Bulma.simple_table_header, render_basic_records ]
|
||||
else Bulma.p "no basic records"
|
||||
|
||||
mx_records_section
|
||||
= if A.length all_mx_rr > 0
|
||||
then Bulma.table [] [ Bulma.mx_table_header, render_mx_records ]
|
||||
else Bulma.p "no mx records"
|
||||
|
||||
srv_records_section
|
||||
= if A.length all_srv_rr > 0
|
||||
then Bulma.table [] [ Bulma.srv_table_header, render_srv_records ]
|
||||
else Bulma.p "no srv records"
|
||||
|
||||
render_basic_records = table_content all_basic_rr
|
||||
render_mx_records = table_content all_mx_rr
|
||||
render_srv_records = table_content all_srv_rr
|
||||
|
||||
table_content records_ = HH.tbody_ $ A.concat $ map rows records_
|
||||
rows rr = [ HH.tr_ $ render_row rr ] -- <> error_row rr
|
||||
|
||||
render_row :: ResourceRecord -> Array (HH.HTML w Action)
|
||||
|
@ -72,7 +72,8 @@ simple_table_header
|
||||
|
||||
mx_table_header :: forall w i. HH.HTML w i
|
||||
mx_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ]
|
||||
= HH.thead_ [ HH.tr_ [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
|
||||
, HH.th_ [ HH.text "Name" ]
|
||||
, HH.th_ [ HH.text "TTL" ]
|
||||
, HH.th_ [ HH.text "Priority" ]
|
||||
, HH.th_ [ HH.text "Target" ]
|
||||
@ -81,7 +82,8 @@ mx_table_header
|
||||
|
||||
srv_table_header :: forall w i. HH.HTML w i
|
||||
srv_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ]
|
||||
= HH.thead_ [ HH.tr_ [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
|
||||
, HH.th_ [ HH.text "Name" ]
|
||||
, HH.th_ [ HH.text "TTL" ]
|
||||
, HH.th_ [ HH.text "Priority" ]
|
||||
, HH.th_ [ HH.text "Protocol" ]
|
||||
@ -91,6 +93,21 @@ srv_table_header
|
||||
]
|
||||
]
|
||||
|
||||
soa_table_header :: forall w i. HH.HTML w i
|
||||
soa_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "name"]
|
||||
, HH.th_ [ HH.text "ttl"]
|
||||
, HH.th_ [ HH.text "target"]
|
||||
, HH.th_ [ HH.text "mname"]
|
||||
, HH.th_ [ HH.text "rname"]
|
||||
, HH.th_ [ HH.text "serial"]
|
||||
, HH.th_ [ HH.text "refresh"]
|
||||
, HH.th_ [ HH.text "retry"]
|
||||
, HH.th_ [ HH.text "expire"]
|
||||
, HH.th_ [ HH.text "minttl"]
|
||||
]
|
||||
]
|
||||
|
||||
txt_name :: forall w i. String -> HH.HTML w i
|
||||
txt_name t
|
||||
= HH.td [ rr_name_style ] [ rr_name_text ]
|
||||
|
Loading…
Reference in New Issue
Block a user