Display of zones: two columns solution. Not great, not terrible.
parent
2f2d02249b
commit
5ed64fc8c0
|
@ -672,25 +672,6 @@ handleQuery = case _ of
|
|||
add_RR state new_rr = state { _resources = (state._resources <> [ new_rr ]) }
|
||||
|
||||
-- Rendering
|
||||
render_soa :: forall w. Maybe ResourceRecord -> Array (HH.HTML w Action)
|
||||
render_soa Nothing = [ HH.text "SOA not loaded, yet" ]
|
||||
render_soa (Just soa) = [ Bulma.zone_rr_title "Start Of Authority (SOA)", table_rr ]
|
||||
where
|
||||
table_rr = Bulma.table [] [ Bulma.soa_table_header, table_content ]
|
||||
table_content
|
||||
= HH.tbody_ $ [ HH.tr_ $ [ HH.td_ [ HH.text soa.name ]
|
||||
, HH.td_ [ HH.text $ show soa.ttl ]
|
||||
, HH.td_ [ HH.text soa.target ]
|
||||
, HH.td_ [ HH.text $ maybe "" id soa.mname ]
|
||||
, HH.td_ [ HH.text $ maybe "" id soa.rname ]
|
||||
, HH.td_ [ HH.text $ maybe "" show soa.serial ]
|
||||
, HH.td_ [ HH.text $ maybe "" show soa.refresh ]
|
||||
, HH.td_ [ HH.text $ maybe "" show soa.retry ]
|
||||
, HH.td_ [ HH.text $ maybe "" show soa.expire ]
|
||||
, HH.td_ [ HH.text $ maybe "" show soa.minttl ]
|
||||
]
|
||||
]
|
||||
|
||||
bg_color_ro = C.has_background_warning_light :: Array HH.ClassName
|
||||
|
||||
-- | Render all Resource Records.
|
||||
|
@ -698,30 +679,38 @@ render_resources :: forall w. Array ResourceRecord -> HH.HTML w Action
|
|||
render_resources [] = Bulma.box [Bulma.zone_rr_title "Resource records", Bulma.subtitle "No records for now"]
|
||||
render_resources records
|
||||
= HH.div_ $
|
||||
[ Bulma.box $ render_soa $ A.head $ A.filter (\rr -> rr.rrtype == "SOA") records ]
|
||||
<> (rr_box [] Bulma.simple_table_header table_content_with_separations all_basic_rr)
|
||||
<> (rr_box [] Bulma.mx_table_header table_content all_mx_rr)
|
||||
<> (rr_box [] Bulma.srv_table_header table_content all_srv_rr)
|
||||
<> (rr_box [] Bulma.spf_table_header table_content all_spf_rr)
|
||||
<> (rr_box bg_color_ro Bulma.simple_table_header_ro table_content_with_separations all_basic_ro_rr)
|
||||
(rr_box "SOA" bg_color_ro Bulma.soa_table_header table_content all_soa_rr)
|
||||
<> (rr_box "Basic RRs" [] Bulma.simple_table_header table_content_w_seps all_basic_rr)
|
||||
<> (rr_box "MX" [] Bulma.mx_table_header table_content all_mx_rr)
|
||||
<> (rr_box "SRV" [] Bulma.srv_table_header table_content all_srv_rr)
|
||||
<> (rr_box "SPF" [] Bulma.spf_table_header table_content all_spf_rr)
|
||||
<> (rr_box "Basic RRs (read only)" bg_color_ro Bulma.simple_table_header_ro table_content_w_seps all_basic_ro_rr)
|
||||
where
|
||||
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
|
||||
all_spf_rr = A.filter (\rr -> rr.rrtype == "SPF") records
|
||||
all_XX_rr str = A.filter (\rr -> rr.rrtype == str) records
|
||||
all_soa_rr = all_XX_rr "SOA"
|
||||
all_mx_rr = all_XX_rr "MX"
|
||||
all_srv_rr = all_XX_rr "SRV"
|
||||
all_spf_rr = all_XX_rr "SPF"
|
||||
|
||||
rr_box :: Array HH.ClassName
|
||||
-> HH.HTML w Action
|
||||
rr_box :: String -- box title (type of data)
|
||||
-> Array HH.ClassName
|
||||
-> HH.HTML w Action -- table title
|
||||
-> (Array ResourceRecord -> HH.HTML w Action)
|
||||
-> Array ResourceRecord
|
||||
-> Array (HH.HTML w Action)
|
||||
rr_box colors header dp rrs =
|
||||
rr_box title colors header dp rrs =
|
||||
if A.length rrs > 0
|
||||
then [Bulma.box_ colors [Bulma.table [] [header, dp rrs]]]
|
||||
then [ Bulma.columns_
|
||||
[ Bulma.column title_col_props [Bulma.box [Bulma.div_content [HH.text title]]]
|
||||
, Bulma.column_ [ Bulma.box_ colors [Bulma.table [] [header, dp rrs]] ]
|
||||
]
|
||||
]
|
||||
else []
|
||||
title_col_props = C.is 1
|
||||
|
||||
table_content_with_separations records_ = HH.tbody_ $
|
||||
table_content_w_seps records_ = HH.tbody_ $
|
||||
A.groupAllBy (comparing (_.rrtype)) records_ -- [x x y y z] -> [NE[xx], NE[yy], NE[z]]
|
||||
# map NonEmpty.toArray -- -> [[xx], [yy], [z]]
|
||||
# map (map rows) -- -> [[hh], [hh], [h]] ('h' means 'html')
|
||||
|
@ -732,15 +721,26 @@ render_resources records
|
|||
|
||||
table_content records_ = HH.tbody_ $ map rows records_
|
||||
rows rr = if rr.readonly
|
||||
then HH.tr [ HP.classes C.has_background_warning_light ] $ render_row rr -- <> error_row rr
|
||||
else HH.tr_ $ render_row rr -- <> error_row rr
|
||||
then HH.tr [ HP.classes C.has_background_warning_light ] $ render_row rr
|
||||
else HH.tr_ $ render_row rr
|
||||
|
||||
render_row :: ResourceRecord -> Array (HH.HTML w Action)
|
||||
render_row rr =
|
||||
case rr.rrtype of
|
||||
"SOA" ->
|
||||
[ HH.td_ [ HH.text rr.name ]
|
||||
, HH.td_ [ HH.text $ show rr.ttl ]
|
||||
, HH.td_ [ HH.text rr.target ]
|
||||
, HH.td_ [ HH.text $ maybe "" id rr.mname ]
|
||||
, HH.td_ [ HH.text $ maybe "" id rr.rname ]
|
||||
, HH.td_ [ HH.text $ maybe "" show rr.serial ]
|
||||
, HH.td_ [ HH.text $ maybe "" show rr.refresh ]
|
||||
, HH.td_ [ HH.text $ maybe "" show rr.retry ]
|
||||
, HH.td_ [ HH.text $ maybe "" show rr.expire ]
|
||||
, HH.td_ [ HH.text $ maybe "" show rr.minttl ]
|
||||
]
|
||||
"SRV" ->
|
||||
[ Bulma.txt_name rr.rrtype
|
||||
, HH.td_ [ Bulma.p rr.name]
|
||||
[ HH.td_ [ Bulma.p rr.name]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show rr.priority ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" id rr.protocol ]
|
||||
|
@ -755,8 +755,7 @@ render_resources records
|
|||
else HH.td_ [ Bulma.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
"SPF" ->
|
||||
[ Bulma.txt_name rr.rrtype
|
||||
, HH.td_ [ Bulma.p rr.name]
|
||||
[ HH.td_ [ Bulma.p rr.name]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
, HH.td_ [ Bulma.p $ maybe "(default)" id rr.v ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" (A.fold <<< A.intersperse " " <<< map show_mechanism) rr.mechanisms ]
|
||||
|
@ -770,8 +769,7 @@ render_resources records
|
|||
else HH.td_ [ Bulma.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
"MX" ->
|
||||
[ Bulma.txt_name rr.rrtype
|
||||
, HH.td_ [ Bulma.p rr.name]
|
||||
[ HH.td_ [ Bulma.p rr.name]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show rr.priority ]
|
||||
, HH.td_ [ Bulma.p rr.target ]
|
||||
|
|
|
@ -98,8 +98,7 @@ simple_table_header_ro
|
|||
|
||||
mx_table_header :: forall w i. HH.HTML w i
|
||||
mx_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
|
||||
, HH.th_ [ HH.text "Name" ]
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ]
|
||||
, HH.th_ [ HH.text "TTL" ]
|
||||
, HH.th_ [ HH.text "Priority" ]
|
||||
, HH.th_ [ HH.text "Target" ]
|
||||
|
@ -110,8 +109,7 @@ mx_table_header
|
|||
|
||||
srv_table_header :: forall w i. HH.HTML w i
|
||||
srv_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
|
||||
, HH.th_ [ HH.text "Name" ]
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ]
|
||||
, HH.th_ [ HH.text "TTL" ]
|
||||
, HH.th_ [ HH.text "Priority" ]
|
||||
, HH.th_ [ HH.text "Protocol" ]
|
||||
|
@ -125,8 +123,7 @@ srv_table_header
|
|||
|
||||
spf_table_header :: forall w i. HH.HTML w i
|
||||
spf_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
|
||||
, HH.th_ [ HH.text "Name" ]
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ]
|
||||
, HH.th_ [ HH.text "TTL" ]
|
||||
, HH.th_ [ HH.text "Version" ]
|
||||
, HH.th_ [ HH.text "Mechanisms" ]
|
||||
|
@ -141,7 +138,8 @@ spf_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.thead_ [ HH.tr [ HP.classes C.has_background_warning_light ]
|
||||
[ HH.th_ [ HH.text "name"]
|
||||
, HH.th_ [ HH.text "ttl"]
|
||||
, HH.th_ [ HH.text "target"]
|
||||
, HH.th_ [ HH.text "mname"]
|
||||
|
@ -465,3 +463,9 @@ selection action values selected = HH.div [HP.classes $ C.select <> C.is_normal]
|
|||
|
||||
tag_light_info :: forall w i. String -> HH.HTML w i
|
||||
tag_light_info str = HH.span [HP.classes (C.is_info <> C.is_light)] [HH.text str]
|
||||
|
||||
div_large_content :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
|
||||
div_large_content content = HH.div [HP.classes (C.is_large <> C.content)] content
|
||||
|
||||
div_content :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
|
||||
div_content content = HH.div [HP.classes (C.content)] content
|
||||
|
|
|
@ -117,6 +117,10 @@ is_centered :: Array HH.ClassName
|
|||
is_centered = [HH.ClassName "is-centered"]
|
||||
is_danger :: Array HH.ClassName
|
||||
is_danger = [HH.ClassName "is-danger"]
|
||||
is_large :: Array HH.ClassName
|
||||
is_large = [HH.ClassName "is-large"]
|
||||
content :: Array HH.ClassName
|
||||
content = [HH.ClassName "content"]
|
||||
is :: Int -> Array HH.ClassName
|
||||
is size = [HH.ClassName $ "is-" <> show size]
|
||||
is_size :: Int -> Array HH.ClassName
|
||||
|
|
Loading…
Reference in New Issue