Moving tables.
This commit is contained in:
parent
49fced1992
commit
1b78d1cefd
3 changed files with 225 additions and 219 deletions
|
@ -358,7 +358,7 @@ render state
|
|||
, Style.h1 state._domain
|
||||
] []
|
||||
, Style.hr
|
||||
, render_resources $ sorted state._resources
|
||||
, render_resource_records (sorted state._resources) CreateUpdateRRModal DeleteRRModal
|
||||
, Style.hr
|
||||
, render_new_records state
|
||||
, render_zonefile state._zonefile
|
||||
|
@ -1054,194 +1054,7 @@ handleQuery = case _ of
|
|||
add_RR state new_rr = state { _resources = (state._resources <> [ new_rr ]) }
|
||||
|
||||
-- Rendering
|
||||
bg_color_ro = C.has_background_warning_light :: HH.ClassName
|
||||
|
||||
tag :: forall w i. String -> HH.HTML w i
|
||||
tag str = HH.span [HP.classes [C.tag, C.is_dark]] [HH.text str]
|
||||
|
||||
tag_ro :: forall w i. String -> HH.HTML w i
|
||||
tag_ro str = HH.span [HP.classes [C.tag, C.is_warning]] [HH.text str]
|
||||
|
||||
tags :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
|
||||
tags xs = HH.span [HP.classes [C.tags, C.no_margin_bottom, C.no_padding_bottom]] xs
|
||||
|
||||
-- | Render all Resource Records.
|
||||
render_resources :: forall w. Array ResourceRecord -> HH.HTML w Action
|
||||
render_resources [] = Style.box [Style.zone_rr_title "Resource records", Style.subtitle "No records for now"]
|
||||
render_resources records
|
||||
= HH.div_ $
|
||||
(rr_box [bg_color_ro] tag_soa Style.soa_table_header table_content all_soa_rr)
|
||||
<> (rr_box [] tag_basic Style.simple_table_header table_content_w_seps all_basic_rr)
|
||||
<> (rr_box [] tag_mx Style.mx_table_header table_content all_mx_rr)
|
||||
<> (rr_box [] tag_caa Style.caa_table_header table_content all_caa_rr)
|
||||
<> (rr_box [] tag_srv Style.srv_table_header table_content all_srv_rr)
|
||||
<> (rr_box [] tag_spf Style.spf_table_header table_content all_spf_rr)
|
||||
<> (rr_box [] tag_dkim Style.dkim_table_header table_content all_dkim_rr)
|
||||
<> (rr_box [] tag_dmarc Style.dmarc_table_header table_content all_dmarc_rr)
|
||||
<> (rr_box [bg_color_ro] tag_basic_ro Style.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_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_caa_rr = all_XX_rr "CAA"
|
||||
all_srv_rr = all_XX_rr "SRV"
|
||||
all_spf_rr = all_XX_rr "SPF"
|
||||
all_dkim_rr = all_XX_rr "DKIM"
|
||||
all_dmarc_rr = all_XX_rr "DMARC"
|
||||
|
||||
tag_soa = tags [tag_ro "SOA", tag_ro "read only"]
|
||||
tag_basic = tags [tag "Basic Resource Records (A, AAAA, PTR, NS, TXT)"]
|
||||
tag_mx = tags [tag "MX"]
|
||||
tag_caa = tags [tag "CAA"]
|
||||
tag_srv = tags [tag "SRV"]
|
||||
tag_spf = tags [tag "SPF"]
|
||||
tag_dkim = tags [tag "DKIM"]
|
||||
tag_dmarc = tags [tag "DMARC"]
|
||||
tag_basic_ro = tags [tag_ro "Basic Resource Records", tag_ro "read only"]
|
||||
|
||||
rr_box :: Array HH.ClassName -- css classes (such as colors)
|
||||
-> HH.HTML w Action -- box title (type of data)
|
||||
-> HH.HTML w Action -- table title
|
||||
-> (Array ResourceRecord -> HH.HTML w Action)
|
||||
-> Array ResourceRecord
|
||||
-> Array (HH.HTML w Action)
|
||||
rr_box colors title header dp rrs =
|
||||
if A.length rrs > 0
|
||||
then [ Style.box_with_tag colors title [Style.table_ [C.margin_left 3] [] [header, dp rrs]] ]
|
||||
else []
|
||||
--title_col_props = C.is 1
|
||||
|
||||
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')
|
||||
# A.intersperse [emptyline] -- -> [[hh], [line], [hh], [line], [h]]
|
||||
# A.concat -- -> [h h line h h line h]
|
||||
|
||||
emptyline = HH.tr_ [ Style.txt_name "", HH.td_ [], HH.td_ [], HH.td_ [], HH.td_ [], HH.td_ [] ]
|
||||
|
||||
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
|
||||
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 $ 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" ->
|
||||
[ HH.td_ [ Style.p rr.name ]
|
||||
, HH.td_ [ Style.p $ maybe "tcp" show rr.protocol ]
|
||||
, HH.td_ [ Style.p rr.target ]
|
||||
, HH.td_ [ Style.p $ maybe "" show rr.port ]
|
||||
, HH.td_ [ Style.p $ show rr.ttl ]
|
||||
, HH.td_ [ Style.p $ maybe "" show rr.priority ]
|
||||
, HH.td_ [ Style.p $ maybe "" show rr.weight ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Style.btn_readonly ]
|
||||
else HH.td_ [ Style.btn_modify (CreateUpdateRRModal rr.rrid), Style.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
"CAA" ->
|
||||
[ HH.td_ [ Style.p rr.name ]
|
||||
, HH.td_ [ Style.p $ show rr.ttl ]
|
||||
] <> case rr.caa of
|
||||
Just caa ->
|
||||
[ HH.td_ [ Style.p $ show caa.flag ]
|
||||
, HH.td_ [ Style.p $ show caa.tag ]
|
||||
, HH.td_ [ Style.p caa.value ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Style.btn_readonly ]
|
||||
else HH.td_ [ Style.btn_modify (CreateUpdateRRModal rr.rrid), Style.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
Nothing -> [Style.p "Problem: there is no CAA data." ]
|
||||
"SPF" ->
|
||||
[ HH.td_ [ Style.p rr.name ]
|
||||
, HH.td_ [ Style.p $ show rr.ttl ]
|
||||
-- , HH.td_ [ Style.p $ maybe "(default)" id rr.v ] -- For now, version isn't displayed.
|
||||
, HH.td_ [ Style.p $ maybe "" (A.fold <<< A.intersperse " " <<< map show_mechanism) rr.mechanisms ]
|
||||
, HH.td_ [ Style.p $ maybe "" (A.fold <<< A.intersperse " " <<< map show_modifier) rr.modifiers ]
|
||||
, HH.td_ [ Style.p $ maybe "" fancy_qualifier_display rr.q ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Style.btn_readonly ]
|
||||
else HH.td_ [ Style.btn_modify (CreateUpdateRRModal rr.rrid), Style.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
"DKIM" ->
|
||||
[ HH.td_ [ Style.p rr.name ]
|
||||
, HH.td_ [ Style.p $ show rr.ttl ]
|
||||
] <> case rr.dkim of
|
||||
Just dkim ->
|
||||
[
|
||||
-- , HH.td_ [ Style.p $ maybe "(default)" id rr.v ] -- For now, version isn't displayed. Assume DKIM1.
|
||||
HH.td_ [ Style.p $ maybe "" show dkim.h ]
|
||||
, HH.td_ [ Style.p $ maybe "" show dkim.k ]
|
||||
, HH.td_ [ Style.p $ CP.take 20 dkim.p ]
|
||||
, HH.td_ [ Style.p $ fromMaybe "" dkim.n ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Style.btn_readonly ]
|
||||
else HH.td_ [ Style.btn_modify (CreateUpdateRRModal rr.rrid), Style.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
Nothing -> [Style.p "Problem: there is no DKIM data." ]
|
||||
"DMARC" ->
|
||||
[ HH.td_ [ Style.p rr.name ]
|
||||
, HH.td_ [ Style.p $ show rr.ttl ]
|
||||
] <> case rr.dmarc of
|
||||
Just dmarc ->
|
||||
[
|
||||
-- , HH.td_ [ Style.p $ maybe "(default)" id rr.v ] -- For now, version isn't displayed. Assume DMARC1.
|
||||
HH.td_ [ Style.p $ show dmarc.p ]
|
||||
, HH.td_ [ Style.p $ maybe "" show dmarc.sp ]
|
||||
, HH.td_ [ Style.p $ maybe "" show dmarc.adkim ]
|
||||
, HH.td_ [ Style.p $ maybe "" show dmarc.aspf ]
|
||||
, HH.td_ [ Style.p $ maybe "" show dmarc.pct ]
|
||||
, HH.td_ [ Style.p $ maybe "" show dmarc.fo ]
|
||||
, HH.td_ [ Style.p $ maybe "" show dmarc.ri ]
|
||||
-- TODO? rua & ruf
|
||||
-- , HH.td_ [ ] -- For now, assume AFRF.
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Style.btn_readonly ]
|
||||
else HH.td_ [ Style.btn_modify (CreateUpdateRRModal rr.rrid), Style.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
Nothing -> [Style.p "Problem: there is no DMARC data." ]
|
||||
"MX" ->
|
||||
[ HH.td_ [ Style.p rr.name ]
|
||||
, HH.td_ [ Style.p $ show rr.ttl ]
|
||||
, HH.td_ [ Style.p $ maybe "" show rr.priority ]
|
||||
, HH.td_ [ Style.p rr.target ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Style.btn_readonly ]
|
||||
else HH.td_ [ Style.btn_modify (CreateUpdateRRModal rr.rrid), Style.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
]
|
||||
_ ->
|
||||
[ Style.txt_name rr.rrtype
|
||||
, HH.td_ [ Style.p rr.name ]
|
||||
, HH.td_ [ Style.p $ show rr.ttl ]
|
||||
, HH.td_ [ Style.p rr.target ]
|
||||
] <> if rr.readonly
|
||||
then [ HH.td_ [ Style.btn_readonly ] ]
|
||||
else [ HH.td_ [ Style.btn_modify (CreateUpdateRRModal rr.rrid), Style.btn_delete (DeleteRRModal rr.rrid) ]
|
||||
, HH.td_ [ maybe (show_token_or_btn rr) Style.p rr.token ]
|
||||
]
|
||||
|
||||
show_token_or_btn rr =
|
||||
case rr.rrtype of
|
||||
"A" -> Style.btn_ [C.is_small] "🏁 Ask for a token" (NewToken rr.rrid)
|
||||
"AAAA" -> Style.btn_ [C.is_small] "🏁 Ask for a token" (NewToken rr.rrid)
|
||||
_ -> HH.text ""
|
||||
|
||||
fancy_qualifier_display :: RR.Qualifier -> String
|
||||
fancy_qualifier_display qualifier = "(" <> show_qualifier_char qualifier <> ") " <> show_qualifier qualifier
|
||||
|
||||
display_mechanisms :: forall w. Array RR.Mechanism -> HH.HTML w Action
|
||||
display_mechanisms [] = Style.p "You don't have any mechanism."
|
||||
|
@ -1279,9 +1092,6 @@ display_dmarc_mail_addresses f ms =
|
|||
, HH.td_ [ Style.alert_btn "x" (f i) ]
|
||||
]
|
||||
|
||||
baseRecords :: Array String
|
||||
baseRecords = [ "A", "AAAA", "CNAME", "TXT", "NS" ]
|
||||
|
||||
-- Component definition and initial state
|
||||
|
||||
render_new_records :: forall (w :: Type). State -> HH.HTML w Action
|
||||
|
|
|
@ -3,7 +3,6 @@ module Style
|
|||
, module Style.Button
|
||||
, module Style.Input
|
||||
, module Style.Table
|
||||
, txt_name
|
||||
) where
|
||||
|
||||
import Style.Button
|
||||
|
@ -14,10 +13,3 @@ import Bulma
|
|||
|
||||
import Halogen.HTML as HH
|
||||
import Halogen.HTML.Properties as HP
|
||||
|
||||
txt_name :: forall w i. String -> HH.HTML w i
|
||||
txt_name t
|
||||
= HH.td [ rr_name_style ] [ rr_name_text ]
|
||||
where
|
||||
rr_name_style = HP.style "width: 80px;"
|
||||
rr_name_text = HH.text t
|
||||
|
|
|
@ -1,35 +1,47 @@
|
|||
module Style.Table
|
||||
( caa_table_header
|
||||
, dkim_table_header
|
||||
, dmarc_dmarcuri_table_header
|
||||
, dmarc_table_header
|
||||
( dmarc_dmarcuri_table_header
|
||||
, mechanism_table_header
|
||||
, modifier_table_header
|
||||
, mx_table_header
|
||||
, simple_table_header
|
||||
, simple_table_header_ro
|
||||
, soa_table_header
|
||||
, spf_table_header
|
||||
, srv_table_header
|
||||
|
||||
, owned_domains_table
|
||||
, shared_domains_table
|
||||
, render_resource_records
|
||||
) where
|
||||
|
||||
import Prelude (map, ($), (==), (>))
|
||||
import Prelude
|
||||
|
||||
import CSSClasses as C
|
||||
|
||||
import Data.Array.NonEmpty as NonEmpty
|
||||
import Data.Array as A
|
||||
import Data.Maybe (Maybe(..), fromMaybe)
|
||||
import Data.Maybe (Maybe(..), fromMaybe, maybe)
|
||||
|
||||
import Style.Button
|
||||
import Style.Button as Button
|
||||
import Bulma as Bulma
|
||||
import Halogen.HTML as HH
|
||||
import Halogen.HTML.Properties as HP
|
||||
import Data.String.CodePoints as CP
|
||||
|
||||
import App.Type.ResourceRecord (ResourceRecord, emptyRR
|
||||
, show_qualifier, show_qualifier_char
|
||||
, show_mechanism_type, show_mechanism, to_mechanism
|
||||
, show_modifier_type, show_modifier, to_modifier
|
||||
, qualifiers
|
||||
, mechanism_types, qualifier_types, modifier_types)
|
||||
import App.Type.ResourceRecord (Mechanism, Modifier, Qualifier(..), SRVProtocol(..)
|
||||
, srv_protocols, srv_protocols_txt) as RR
|
||||
|
||||
import App.Type.DomainInfo (DomainInfo)
|
||||
|
||||
id :: forall a. a -> a
|
||||
id x = x
|
||||
|
||||
txt_name :: forall w i. String -> HH.HTML w i
|
||||
txt_name t
|
||||
= HH.td [ rr_name_style ] [ rr_name_text ]
|
||||
where
|
||||
rr_name_style = HP.style "width: 80px;"
|
||||
rr_name_text = HH.text t
|
||||
|
||||
owned_domains_table :: forall w i. Array DomainInfo -> (String -> i) -> (String -> i) -> (String -> i) -> (String -> i) -> HH.HTML w i
|
||||
owned_domains_table domains_i_exclusively_own action_enter_domain action_transfer_domain action_share_domain action_delete_domain
|
||||
= if A.length domains_i_exclusively_own > 0
|
||||
|
@ -50,9 +62,9 @@ owned_domains_table domains_i_exclusively_own action_enter_domain action_transfe
|
|||
[ HH.td_ [ Bulma.btn domain.name (action_enter_domain domain.name) ]
|
||||
, case domain.transfer_key of
|
||||
Just key -> HH.td_ [ Bulma.p "Token key:", Bulma.p key ]
|
||||
Nothing -> HH.td_ [ btn_abbr "Generate a token to transfer the ownership of a domain." "Transfer" (action_transfer_domain domain.name) ]
|
||||
, HH.td_ [ btn_abbr "Generate a token to share the ownership of a domain." "Share" (action_share_domain domain.name) ]
|
||||
, HH.td_ [ alert_btn_abbr "Delete the domain. This will remove all zone data and the domain won't be served anymore." "Delete" (action_delete_domain domain.name) ]
|
||||
Nothing -> HH.td_ [ Button.btn_abbr "Generate a token to transfer the ownership of a domain." "Transfer" (action_transfer_domain domain.name) ]
|
||||
, HH.td_ [ Button.btn_abbr "Generate a token to share the ownership of a domain." "Share" (action_share_domain domain.name) ]
|
||||
, HH.td_ [ Button.alert_btn_abbr "Delete the domain. This will remove all zone data and the domain won't be served anymore." "Delete" (action_delete_domain domain.name) ]
|
||||
]
|
||||
|
||||
shared_domains_table :: forall w i. Array DomainInfo -> (String -> i) -> (String -> i) -> (String -> i) -> HH.HTML w i
|
||||
|
@ -75,11 +87,203 @@ shared_domains_table domains_i_share action_enter_domain action_unshare_domain a
|
|||
[ HH.td_ [ Bulma.btn domain.name (action_enter_domain domain.name) ]
|
||||
, HH.td_ [ HH.text $ fromMaybe "" domain.share_key ]
|
||||
, if A.length domain.owners == 1
|
||||
then HH.td_ [ alert_btn_abbr "Unshare the domain by removing the \"share\" token." "Unshare" (action_unshare_domain domain.name) ]
|
||||
else HH.td_ [ btn_ro [C.is_warning] "Cannot unshare it" ]
|
||||
, HH.td_ [ alert_btn_abbr "Delete the domain from your list of owned domains. In case you are the only owner, this will also remove all zone data and the domain won't be served anymore." "Delete" (action_delete_domain domain.name) ]
|
||||
then HH.td_ [ Button.alert_btn_abbr "Unshare the domain by removing the \"share\" token." "Unshare" (action_unshare_domain domain.name) ]
|
||||
else HH.td_ [ Button.btn_ro [C.is_warning] "Cannot unshare it" ]
|
||||
, HH.td_ [ Button.alert_btn_abbr "Delete the domain from your list of owned domains. In case you are the only owner, this will also remove all zone data and the domain won't be served anymore." "Delete" (action_delete_domain domain.name) ]
|
||||
]
|
||||
|
||||
tags :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
|
||||
tags xs = HH.span [HP.classes [C.tags, C.no_margin_bottom, C.no_padding_bottom]] xs
|
||||
|
||||
-- | Render all Resource Records.
|
||||
render_resource_records :: forall w i. Array ResourceRecord -> (Int -> i) -> (Int -> i) -> (Int -> i) -> HH.HTML w i
|
||||
render_resource_records [] _ _ _ = Bulma.box [Bulma.zone_rr_title "Resource records", Bulma.subtitle "No records for now"]
|
||||
render_resource_records records action_create_or_update_rr action_delete_rr action_new_token
|
||||
= HH.div_ $
|
||||
(rr_box [bg_color_ro] tag_soa soa_table_header table_content all_soa_rr)
|
||||
<> (rr_box [] tag_basic simple_table_header table_content_w_seps all_basic_rr)
|
||||
<> (rr_box [] tag_mx mx_table_header table_content all_mx_rr)
|
||||
<> (rr_box [] tag_caa caa_table_header table_content all_caa_rr)
|
||||
<> (rr_box [] tag_srv srv_table_header table_content all_srv_rr)
|
||||
<> (rr_box [] tag_spf spf_table_header table_content all_spf_rr)
|
||||
<> (rr_box [] tag_dkim dkim_table_header table_content all_dkim_rr)
|
||||
<> (rr_box [] tag_dmarc dmarc_table_header table_content all_dmarc_rr)
|
||||
<> (rr_box [bg_color_ro] tag_basic_ro simple_table_header_ro table_content_w_seps all_basic_ro_rr)
|
||||
where
|
||||
bg_color_ro = C.has_background_warning_light :: HH.ClassName
|
||||
|
||||
baseRecords :: Array String
|
||||
baseRecords = [ "A", "AAAA", "CNAME", "TXT", "NS" ]
|
||||
|
||||
tag :: forall w i. String -> HH.HTML w i
|
||||
tag str = HH.span [HP.classes [C.tag, C.is_dark]] [HH.text str]
|
||||
|
||||
tag_ro :: forall w i. String -> HH.HTML w i
|
||||
tag_ro str = HH.span [HP.classes [C.tag, C.is_warning]] [HH.text str]
|
||||
|
||||
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_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_caa_rr = all_XX_rr "CAA"
|
||||
all_srv_rr = all_XX_rr "SRV"
|
||||
all_spf_rr = all_XX_rr "SPF"
|
||||
all_dkim_rr = all_XX_rr "DKIM"
|
||||
all_dmarc_rr = all_XX_rr "DMARC"
|
||||
|
||||
tag_soa = tags [tag_ro "SOA", tag_ro "read only"]
|
||||
tag_basic = tags [tag "Basic Resource Records (A, AAAA, PTR, NS, TXT)"]
|
||||
tag_mx = tags [tag "MX"]
|
||||
tag_caa = tags [tag "CAA"]
|
||||
tag_srv = tags [tag "SRV"]
|
||||
tag_spf = tags [tag "SPF"]
|
||||
tag_dkim = tags [tag "DKIM"]
|
||||
tag_dmarc = tags [tag "DMARC"]
|
||||
tag_basic_ro = tags [tag_ro "Basic Resource Records", tag_ro "read only"]
|
||||
|
||||
rr_box :: Array HH.ClassName -- css classes (such as colors)
|
||||
-> HH.HTML w i -- box title (type of data)
|
||||
-> HH.HTML w i -- table title
|
||||
-> (Array ResourceRecord -> HH.HTML w i)
|
||||
-> Array ResourceRecord
|
||||
-> Array (HH.HTML w i)
|
||||
rr_box colors title header dp rrs =
|
||||
if A.length rrs > 0
|
||||
then [ Bulma.box_with_tag colors title [Bulma.table_ [C.margin_left 3] [] [header, dp rrs]] ]
|
||||
else []
|
||||
--title_col_props = C.is 1
|
||||
|
||||
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')
|
||||
# A.intersperse [emptyline] -- -> [[hh], [line], [hh], [line], [h]]
|
||||
# A.concat -- -> [h h line h h line h]
|
||||
|
||||
emptyline = HH.tr_ [ txt_name "", HH.td_ [], HH.td_ [], HH.td_ [], HH.td_ [], HH.td_ [] ]
|
||||
|
||||
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
|
||||
else HH.tr_ $ render_row rr
|
||||
|
||||
render_row :: ResourceRecord -> Array (HH.HTML w i)
|
||||
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 $ 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" ->
|
||||
[ HH.td_ [ Bulma.p rr.name ]
|
||||
, HH.td_ [ Bulma.p $ maybe "tcp" show rr.protocol ]
|
||||
, HH.td_ [ Bulma.p rr.target ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show rr.port ]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show rr.priority ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show rr.weight ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Button.btn_readonly ]
|
||||
else HH.td_ [ Button.btn_modify (action_create_or_update_rr rr.rrid), Button.btn_delete (action_delete_rr rr.rrid) ]
|
||||
]
|
||||
"CAA" ->
|
||||
[ HH.td_ [ Bulma.p rr.name ]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
] <> case rr.caa of
|
||||
Just caa ->
|
||||
[ HH.td_ [ Bulma.p $ show caa.flag ]
|
||||
, HH.td_ [ Bulma.p $ show caa.tag ]
|
||||
, HH.td_ [ Bulma.p caa.value ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Button.btn_readonly ]
|
||||
else HH.td_ [ Button.btn_modify (action_create_or_update_rr rr.rrid), Button.btn_delete (action_delete_rr rr.rrid) ]
|
||||
]
|
||||
Nothing -> [Bulma.p "Problem: there is no CAA data." ]
|
||||
"SPF" ->
|
||||
[ HH.td_ [ Bulma.p rr.name ]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
-- , HH.td_ [ Bulma.p $ maybe "(default)" id rr.v ] -- For now, version isn't displayed.
|
||||
, HH.td_ [ Bulma.p $ maybe "" (A.fold <<< A.intersperse " " <<< map show_mechanism) rr.mechanisms ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" (A.fold <<< A.intersperse " " <<< map show_modifier) rr.modifiers ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" fancy_qualifier_display rr.q ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Button.btn_readonly ]
|
||||
else HH.td_ [ Button.btn_modify (action_create_or_update_rr rr.rrid), Button.btn_delete (action_delete_rr rr.rrid) ]
|
||||
]
|
||||
"DKIM" ->
|
||||
[ HH.td_ [ Bulma.p rr.name ]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
] <> case rr.dkim of
|
||||
Just dkim ->
|
||||
[
|
||||
-- , HH.td_ [ Bulma.p $ maybe "(default)" id rr.v ] -- For now, version isn't displayed. Assume DKIM1.
|
||||
HH.td_ [ Bulma.p $ maybe "" show dkim.h ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show dkim.k ]
|
||||
, HH.td_ [ Bulma.p $ CP.take 20 dkim.p ]
|
||||
, HH.td_ [ Bulma.p $ fromMaybe "" dkim.n ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Button.btn_readonly ]
|
||||
else HH.td_ [ Button.btn_modify (action_create_or_update_rr rr.rrid), Button.btn_delete (action_delete_rr rr.rrid) ]
|
||||
]
|
||||
Nothing -> [Bulma.p "Problem: there is no DKIM data." ]
|
||||
"DMARC" ->
|
||||
[ HH.td_ [ Bulma.p rr.name ]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
] <> case rr.dmarc of
|
||||
Just dmarc ->
|
||||
[
|
||||
-- , HH.td_ [ Bulma.p $ maybe "(default)" id rr.v ] -- For now, version isn't displayed. Assume DMARC1.
|
||||
HH.td_ [ Bulma.p $ show dmarc.p ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show dmarc.sp ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show dmarc.adkim ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show dmarc.aspf ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show dmarc.pct ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show dmarc.fo ]
|
||||
, HH.td_ [ Bulma.p $ maybe "" show dmarc.ri ]
|
||||
-- TODO? rua & ruf
|
||||
-- , HH.td_ [ ] -- For now, assume AFRF.
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Button.btn_readonly ]
|
||||
else HH.td_ [ Button.btn_modify (action_create_or_update_rr rr.rrid), Button.btn_delete (action_delete_rr rr.rrid) ]
|
||||
]
|
||||
Nothing -> [Bulma.p "Problem: there is no DMARC data." ]
|
||||
"MX" ->
|
||||
[ 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 ]
|
||||
, if rr.readonly
|
||||
then HH.td_ [ Button.btn_readonly ]
|
||||
else HH.td_ [ Button.btn_modify (action_create_or_update_rr rr.rrid), Button.btn_delete (action_delete_rr rr.rrid) ]
|
||||
]
|
||||
_ ->
|
||||
[ txt_name rr.rrtype
|
||||
, HH.td_ [ Bulma.p rr.name ]
|
||||
, HH.td_ [ Bulma.p $ show rr.ttl ]
|
||||
, HH.td_ [ Bulma.p rr.target ]
|
||||
] <> if rr.readonly
|
||||
then [ HH.td_ [ Button.btn_readonly ] ]
|
||||
else [ HH.td_ [ Button.btn_modify (action_create_or_update_rr rr.rrid), Button.btn_delete (action_delete_rr rr.rrid) ]
|
||||
, HH.td_ [ maybe (show_token_or_btn rr) Bulma.p rr.token ]
|
||||
]
|
||||
|
||||
show_token_or_btn rr =
|
||||
case rr.rrtype of
|
||||
"A" -> Bulma.btn_ [C.is_small] "🏁 Ask for a token" (action_new_token rr.rrid)
|
||||
"AAAA" -> Bulma.btn_ [C.is_small] "🏁 Ask for a token" (action_new_token rr.rrid)
|
||||
_ -> HH.text ""
|
||||
|
||||
fancy_qualifier_display :: RR.Qualifier -> String
|
||||
fancy_qualifier_display qualifier = "(" <> show_qualifier_char qualifier <> ") " <> show_qualifier qualifier
|
||||
|
||||
mechanism_table_header :: forall w i. HH.HTML w i
|
||||
mechanism_table_header
|
||||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Policy" ]
|
||||
|
|
Loading…
Add table
Reference in a new issue