Zone Interface: group RO RRs and a better display of RRs in general.

This commit is contained in:
Philippe Pittoli 2024-02-21 00:52:43 +01:00
parent 419d68784a
commit d6f85b5a00
2 changed files with 38 additions and 10 deletions

View File

@ -19,8 +19,8 @@ module App.ZoneInterface where
import Prelude (Unit, unit, void
, bind, pure
, comparing, discard, map, show
, ($), (/=), (<<<), (<>), (==), (>), (#))
, not, comparing, discard, map, show
, (&&), ($), (/=), (<<<), (<>), (==), (>), (#))
import Data.Array as A
import Data.Int (fromString)
@ -691,21 +691,28 @@ render_resources []
, Bulma.subtitle "No records for now"
]
render_resources records
= Bulma.box [ render_soa $ A.head $ A.filter (\rr -> rr.rrtype == "SOA") records
, basic_records_section
, mx_records_section
, srv_records_section
]
= HH.div_ [ render_soa $ A.head $ A.filter (\rr -> rr.rrtype == "SOA") records
, Bulma.box [ basic_records_section ]
, Bulma.box [ mx_records_section ]
, Bulma.box [ srv_records_section ]
, Bulma.box_ C.has_background_warning_light [ basic_readonly_records_section ]
]
where
all_basic_rr = A.filter (\rr -> A.elem rr.rrtype baseRecords) records
all_basic_rr = A.filter (\rr -> A.elem rr.rrtype baseRecords && not rr.readonly) records
all_basic_ro_rr = A.filter (\rr -> A.elem rr.rrtype baseRecords && rr.readonly) 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 ]
then Bulma.table [] [ Bulma.simple_table_header, render_basic_records all_basic_rr]
else Bulma.p "no basic records"
basic_readonly_records_section
= if A.length all_basic_rr > 0
then Bulma.table [] [ Bulma.simple_table_header_ro, render_basic_records all_basic_ro_rr]
else Bulma.p "no read only records?"
mx_records_section
= if A.length all_mx_rr > 0
then Bulma.table [] [ Bulma.mx_table_header, render_mx_records ]
@ -716,7 +723,7 @@ render_resources records
then Bulma.table [] [ Bulma.srv_table_header, render_srv_records ]
else Bulma.p "no srv records"
render_basic_records = table_content_with_separations all_basic_rr
render_basic_records _rrs = table_content_with_separations _rrs
render_mx_records = table_content all_mx_rr
render_srv_records = table_content all_srv_rr

View File

@ -63,6 +63,20 @@ simple_table_header
, HH.th_ [ HH.text "Name" ]
, HH.th_ [ HH.text "TTL" ]
, HH.th_ [ HH.text "Target" ]
, HH.th_ [ HH.text "" ]
, HH.th_ [ HH.text "" ]
]
]
simple_table_header_ro :: forall w i. HH.HTML w i
simple_table_header_ro
= HH.thead_ [ HH.tr [ HP.classes C.has_background_warning_light ]
[ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
, HH.th_ [ HH.text "Name" ]
, HH.th_ [ HH.text "TTL" ]
, HH.th_ [ HH.text "Target" ]
, HH.th_ [ HH.text "" ]
, HH.th_ [ HH.text "" ]
]
]
@ -73,6 +87,8 @@ mx_table_header
, HH.th_ [ HH.text "TTL" ]
, HH.th_ [ HH.text "Priority" ]
, HH.th_ [ HH.text "Target" ]
, HH.th_ [ HH.text "" ]
, HH.th_ [ HH.text "" ]
]
]
@ -86,6 +102,8 @@ srv_table_header
, HH.th_ [ HH.text "Weight" ]
, HH.th_ [ HH.text "Port" ]
, HH.th_ [ HH.text "Target" ]
, HH.th_ [ HH.text "" ]
, HH.th_ [ HH.text "" ]
]
]
@ -279,6 +297,9 @@ p_ classes str = HH.p [HP.classes classes] [ HH.text str ]
box :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
box = HH.div [HP.classes C.box]
box_ :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i
box_ classes = HH.div [HP.classes $ C.box <> classes]
option :: forall w i. String -> HH.HTML w i
option value = HH.option_ [HH.text value]