340 lines
15 KiB
Text
340 lines
15 KiB
Text
module Style.Table
|
||
( caa_table_header
|
||
, dkim_table_header
|
||
, dmarc_dmarcuri_table_header
|
||
, dmarc_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
|
||
) where
|
||
|
||
import Prelude (map, ($), (==), (>))
|
||
|
||
import CSSClasses as C
|
||
|
||
import Data.Array as A
|
||
import Data.Maybe (Maybe(..), fromMaybe)
|
||
|
||
import Style.Button
|
||
import Bulma as Bulma
|
||
import Halogen.HTML as HH
|
||
import Halogen.HTML.Properties as HP
|
||
|
||
import App.Type.DomainInfo (DomainInfo)
|
||
|
||
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
|
||
then Bulma.table [] [ owned_domains_table_header
|
||
, HH.tbody_ $ map owned_domain_row domains_i_exclusively_own
|
||
]
|
||
else Bulma.p "No domain yet."
|
||
where
|
||
owned_domains_table_header :: HH.HTML w i
|
||
owned_domains_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
owned_domain_row domain = HH.tr_
|
||
[ 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) ]
|
||
]
|
||
|
||
shared_domains_table :: forall w i. Array DomainInfo -> (String -> i) -> (String -> i) -> (String -> i) -> HH.HTML w i
|
||
shared_domains_table domains_i_share action_enter_domain action_unshare_domain action_delete_domain
|
||
= if A.length domains_i_share > 0
|
||
then Bulma.table [] [ shared_domains_table_header
|
||
, HH.tbody_ $ map shared_domain_row domains_i_share
|
||
]
|
||
else Bulma.p "No domain yet."
|
||
where
|
||
shared_domains_table_header :: HH.HTML w i
|
||
shared_domains_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Name" ]
|
||
, HH.th_ [ HH.text "Share key" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
shared_domain_row domain = HH.tr_
|
||
[ 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) ]
|
||
]
|
||
|
||
mechanism_table_header :: forall w i. HH.HTML w i
|
||
mechanism_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Policy" ]
|
||
, HH.th_ [ HH.text "Type" ]
|
||
, HH.th_ [ HH.text "Value" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
|
||
modifier_table_header :: forall w i. HH.HTML w i
|
||
modifier_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Type" ]
|
||
, HH.th_ [ HH.text "Value" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
|
||
dmarc_dmarcuri_table_header :: forall w i. HH.HTML w i
|
||
dmarc_dmarcuri_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Email address" ]
|
||
, HH.th_ [ HH.text "Report size limit" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
|
||
simple_table_header :: forall w i. HH.HTML w i
|
||
simple_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "Type" ]
|
||
, HH.th_ [ name_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
, HH.th_ [ target_header ]
|
||
, HH.th_ [ HH.text "" ]
|
||
, HH.th_ [ token_header ]
|
||
]
|
||
]
|
||
where
|
||
token_header :: HH.HTML w i
|
||
token_header = HH.abbr
|
||
[ HP.title "Tokens are used to update the entry, see the tab: \"Tokens? 🤨\"" ]
|
||
[ HH.text "Token" ]
|
||
|
||
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_ [ name_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
, HH.th_ [ target_header ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
|
||
mx_table_header :: forall w i. HH.HTML w i
|
||
mx_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
, HH.th_ [ priority_header ]
|
||
, HH.th_ [ target_header ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
|
||
caa_table_header :: forall w i. HH.HTML w i
|
||
caa_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
, HH.th_ [ HH.text "Flag" ]
|
||
, HH.th_ [ HH.text "Tag" ]
|
||
, HH.th_ [ HH.text "Value" ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
|
||
srv_table_header :: forall w i. HH.HTML w i
|
||
srv_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ]
|
||
, HH.th_ [ protocol_header ]
|
||
, HH.th_ [ target_header ]
|
||
, HH.th_ [ port_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
, HH.th_ [ priority_header ]
|
||
, HH.th_ [ weight_header ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
where
|
||
weight_header :: HH.HTML w i
|
||
weight_header = HH.abbr
|
||
[ HP.title "A relative weight used when multiple servers have the same priority, determining how often they should be used" ]
|
||
[ HH.text "Weight" ]
|
||
|
||
spf_table_header :: forall w i. HH.HTML w i
|
||
spf_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
-- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed.
|
||
, HH.th_ [ srv_mechanisms_header ]
|
||
, HH.th_ [ srv_modifiers_header ]
|
||
, HH.th_ [ srv_default_policy_header ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
where
|
||
srv_mechanisms_header :: HH.HTML w i
|
||
srv_mechanisms_header = HH.abbr
|
||
[ HP.title "Mechanisms specify which mail servers are allowed to send mail for the domain and how to evaluate the sending mail server’s IP address" ]
|
||
[ HH.text "Mechanisms" ]
|
||
srv_modifiers_header :: HH.HTML w i
|
||
srv_modifiers_header = HH.abbr
|
||
[ HP.title "Modifiers provide additional instructions, such as explanations for SPF failures or redirecting SPF checks to another domain" ]
|
||
[ HH.text "Modifiers" ]
|
||
srv_default_policy_header :: HH.HTML w i
|
||
srv_default_policy_header = HH.abbr
|
||
[ HP.title "" ]
|
||
[ HH.text "Default Policy" ]
|
||
|
||
dkim_table_header :: forall w i. HH.HTML w i
|
||
dkim_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
-- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. Assume DKIM1.
|
||
, HH.th_ [ HH.text "Hash algo" ]
|
||
, HH.th_ [ HH.text "Signature algo" ]
|
||
, HH.th_ [ HH.text "Public Key" ]
|
||
, HH.th_ [ dkim_notes_header ]
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
where
|
||
dkim_notes_header :: HH.HTML w i
|
||
dkim_notes_header = HH.abbr
|
||
[ HP.title "Arbitrary string related to this cryptographic material" ]
|
||
[ HH.text "Notes" ]
|
||
|
||
dmarc_table_header :: forall w i. HH.HTML w i
|
||
dmarc_table_header
|
||
= HH.thead_ [ HH.tr_ [ HH.th_ [ name_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
-- , HH.th_ [ HH.text "Version" ] -- For now, version isn't displayed. Assume DMARC1.
|
||
, HH.th_ [ dmarc_policy_header ] -- p
|
||
, HH.th_ [ dmarc_subdom_policy_header ] -- sp
|
||
, HH.th_ [ dmarc_dkim_policy_header ] -- adkim
|
||
, HH.th_ [ dmarc_spf_policy_header ] -- aspf
|
||
, HH.th_ [ dmarc_sample_rate_header ] -- pct
|
||
, HH.th_ [ dmarc_report_on_header ] -- fo
|
||
, HH.th_ [ dmarc_report_interval_header ] -- ri
|
||
-- TODO? rua & ruf
|
||
-- , HH.th_ [ HH.text "Accepted report formats" ] -- For now, assume AFRF.
|
||
, HH.th_ [ HH.text "" ]
|
||
]
|
||
]
|
||
where
|
||
dmarc_policy_header :: HH.HTML w i
|
||
dmarc_policy_header = HH.abbr
|
||
[ HP.title "How to handle email when SPF and DKIM aren't valid?" ]
|
||
[ HH.text "Policy" ]
|
||
dmarc_subdom_policy_header :: HH.HTML w i
|
||
dmarc_subdom_policy_header = HH.abbr
|
||
[ HP.title "How to handle email when SPF and DKIM aren't valid?" ]
|
||
[ HH.text "Subdomain Policy" ]
|
||
dmarc_dkim_policy_header :: HH.HTML w i
|
||
dmarc_dkim_policy_header = HH.abbr
|
||
[ HP.title "What should be considered acceptable to do with an email not conforming with DKIM" ]
|
||
[ HH.text "DKIM Policy" ]
|
||
dmarc_spf_policy_header :: HH.HTML w i
|
||
dmarc_spf_policy_header = HH.abbr
|
||
[ HP.title "What should be considered acceptable to do with an email not conforming with SPF" ]
|
||
[ HH.text "SPF Policy" ]
|
||
dmarc_sample_rate_header :: HH.HTML w i
|
||
dmarc_sample_rate_header = HH.abbr
|
||
[ HP.title "Percentage of messages subjected to the requested policy [0-100]" ]
|
||
[ HH.text "Sample Rate" ]
|
||
dmarc_report_on_header :: HH.HTML w i
|
||
dmarc_report_on_header = HH.abbr
|
||
[ HP.title "What error should be reported? DKIM, SPF, Both, Any or None?" ]
|
||
[ HH.text "Report on" ]
|
||
dmarc_report_interval_header :: HH.HTML w i
|
||
dmarc_report_interval_header = HH.abbr
|
||
[ HP.title "Minimal duration between two DMARC reports (in seconds)" ]
|
||
[ HH.text "Report interval" ]
|
||
|
||
soa_table_header :: forall w i. HH.HTML w i
|
||
soa_table_header
|
||
= HH.thead_ [ HH.tr [ HP.classes [C.has_background_warning_light] ]
|
||
[ HH.th_ [ name_soa_header ]
|
||
, HH.th_ [ ttl_header ]
|
||
, HH.th_ [ mname_soa_header ]
|
||
, HH.th_ [ rname_soa_header ]
|
||
, HH.th_ [ serial_soa_header ]
|
||
, HH.th_ [ refresh_soa_header ]
|
||
, HH.th_ [ retry_soa_header ]
|
||
, HH.th_ [ expire_soa_header ]
|
||
, HH.th_ [ minttl_soa_header ]
|
||
]
|
||
]
|
||
where
|
||
name_soa_header :: HH.HTML w i
|
||
name_soa_header = HH.abbr
|
||
[ HP.title "Your actual domain name (technical term: \"fully qualified domain name\")." ]
|
||
[ HH.text "Name" ]
|
||
mname_soa_header :: HH.HTML w i
|
||
mname_soa_header = HH.abbr
|
||
[ HP.title "Domain name of the primary authoritative DNS server for the zone (SOA \"MNAME\" field)." ]
|
||
[ HH.text "Primary NS" ]
|
||
rname_soa_header :: HH.HTML w i
|
||
rname_soa_header = HH.abbr
|
||
[ HP.title "The email address of the person responsible for managing the zone (the \"@\" is replaced by \".\" for some reason). This is the SOA \"RNAME\" field." ]
|
||
[ HH.text "Contact" ]
|
||
serial_soa_header :: HH.HTML w i
|
||
serial_soa_header = HH.abbr
|
||
[ HP.title "A number that is incremented every time the zone is updated. Secondary DNS servers use this number to check for updates." ]
|
||
[ HH.text "Serial" ]
|
||
refresh_soa_header :: HH.HTML w i
|
||
refresh_soa_header = HH.abbr
|
||
[ HP.title "The interval (in seconds) at which secondary DNS servers should check the primary server for changes to the zone." ]
|
||
[ HH.text "Refresh" ]
|
||
expire_soa_header :: HH.HTML w i
|
||
expire_soa_header = HH.abbr
|
||
[ HP.title "The time in seconds that secondary DNS servers will keep the zone data before discarding it if they cannot contact the primary server." ]
|
||
[ HH.text "Expire" ]
|
||
minttl_soa_header :: HH.HTML w i
|
||
minttl_soa_header = HH.abbr
|
||
[ HP.title "The minimum time (in seconds) that other DNS servers should cache negative responses (e.g., for non-existent domain names)." ]
|
||
[ HH.text "Minimum TTL" ]
|
||
retry_soa_header :: HH.HTML w i
|
||
retry_soa_header = HH.abbr
|
||
[ HP.title "The time in seconds that secondary servers should wait before retrying a failed attempt to contact the primary DNS server." ]
|
||
[ HH.text "Retry" ]
|
||
|
||
name_header :: forall w i. HH.HTML w i
|
||
name_header = HH.abbr
|
||
[ HP.title "Name of the DNS entry, the fully-qualified-domain-name is <name>.<domain>." ]
|
||
[ HH.text "Name" ]
|
||
|
||
ttl_header :: forall w i. HH.HTML w i
|
||
ttl_header = HH.abbr
|
||
[ HP.title "Time-to-Live, nb seconds before being considered invalid" ]
|
||
[ HH.text "TTL" ]
|
||
|
||
target_header :: forall w i. HH.HTML w i
|
||
target_header = HH.abbr
|
||
[ HP.title "In the DNS jargon, the target means the most important value associated with the entry, for an A entry it would be an IPv4 address, for example" ]
|
||
[ HH.text "Target" ]
|
||
|
||
priority_header :: forall w i. HH.HTML w i
|
||
priority_header = HH.abbr
|
||
[ HP.title "A numeric value that indicates the preference of the server (lower values indicate higher priority)" ]
|
||
[ HH.text "Priority" ]
|
||
|
||
protocol_header :: forall w i. HH.HTML w i
|
||
protocol_header = HH.abbr
|
||
[ HP.title "The related communication protocol, either TCP or UDP (want more? Just ask me)" ]
|
||
[ HH.text "Protocol" ]
|
||
|
||
port_header :: forall w i. HH.HTML w i
|
||
port_header = HH.abbr
|
||
[ HP.title "Related connection port" ]
|
||
[ HH.text "Port" ]
|