Minor code changes.
This commit is contained in:
parent
c35544f55e
commit
2f2d02249b
@ -34,7 +34,6 @@ error_to_paragraph v = Bulma.error_message (Bulma.p $ show_error_title v)
|
|||||||
<> ", current value: " <> show n <> "."
|
<> ", current value: " <> show n <> "."
|
||||||
ValidationDNS.VEWeight min max n -> Bulma.p $ "Weight should have a value between " <> show min <> " and " <> show max
|
ValidationDNS.VEWeight min max n -> Bulma.p $ "Weight should have a value between " <> show min <> " and " <> show max
|
||||||
<> ", current value: " <> show n <> "."
|
<> ", current value: " <> show n <> "."
|
||||||
ValidationDNS.VESPF err -> maybe default_error show_error_domain err.error
|
|
||||||
)
|
)
|
||||||
where default_error = Bulma.p ""
|
where default_error = Bulma.p ""
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ show_error_title v = case v of
|
|||||||
ValidationDNS.VEProtocol err -> "The Protocol input is wrong (position: " <> show err.position <> ")"
|
ValidationDNS.VEProtocol err -> "The Protocol input is wrong (position: " <> show err.position <> ")"
|
||||||
ValidationDNS.VEPort min max n -> "Invalid Port (min: " <> show min <> ", max: " <> show max <> ", n: " <> show n <> ")"
|
ValidationDNS.VEPort min max n -> "Invalid Port (min: " <> show min <> ", max: " <> show max <> ", n: " <> show n <> ")"
|
||||||
ValidationDNS.VEWeight min max n -> "Invalid Weight (min: " <> show min <> ", max: " <> show max <> ", n: " <> show n <> ")"
|
ValidationDNS.VEWeight min max n -> "Invalid Weight (min: " <> show min <> ", max: " <> show max <> ", n: " <> show n <> ")"
|
||||||
ValidationDNS.VESPF err -> "The SPF target input is wrong (position: " <> show err.position <> ")"
|
|
||||||
|
|
||||||
show_error_domain :: forall w i. DomainParser.DomainError -> HH.HTML w i
|
show_error_domain :: forall w i. DomainParser.DomainError -> HH.HTML w i
|
||||||
show_error_domain e = case e of
|
show_error_domain e = case e of
|
||||||
|
@ -44,7 +44,6 @@ data Error
|
|||||||
| VEMX (G.Error DomainParser.DomainError)
|
| VEMX (G.Error DomainParser.DomainError)
|
||||||
| VEPriority Int Int Int
|
| VEPriority Int Int Int
|
||||||
| VESRV (G.Error DomainParser.DomainError)
|
| VESRV (G.Error DomainParser.DomainError)
|
||||||
| VESPF (G.Error DomainParser.DomainError)
|
|
||||||
| VEProtocol (G.Error ProtocolError)
|
| VEProtocol (G.Error ProtocolError)
|
||||||
| VEPort Int Int Int
|
| VEPort Int Int Int
|
||||||
| VEWeight Int Int Int
|
| VEWeight Int Int Int
|
||||||
@ -183,9 +182,8 @@ validationSPF :: ResourceRecord -> V (Array Error) ResourceRecord
|
|||||||
validationSPF form = ado
|
validationSPF form = ado
|
||||||
name <- parse DomainParser.sub_eof form.name VEName
|
name <- parse DomainParser.sub_eof form.name VEName
|
||||||
ttl <- is_between min_ttl max_ttl form.ttl VETTL
|
ttl <- is_between min_ttl max_ttl form.ttl VETTL
|
||||||
target <- parse DomainParser.sub_eof form.target VESPF
|
|
||||||
in emptyRR { rrid = form.rrid, readonly = form.readonly, rrtype = "SPF"
|
in emptyRR { rrid = form.rrid, readonly = form.readonly, rrtype = "SPF"
|
||||||
, name = name, ttl = ttl, target = target
|
, name = name, ttl = ttl, target = ""
|
||||||
, v = form.v, mechanisms = maybe (Just []) Just form.mechanisms
|
, v = form.v, mechanisms = maybe (Just []) Just form.mechanisms
|
||||||
, modifiers = form.modifiers, q = form.q }
|
, modifiers = form.modifiers, q = form.q }
|
||||||
|
|
||||||
|
@ -395,10 +395,6 @@ render state
|
|||||||
(updateForm Field_TTL)
|
(updateForm Field_TTL)
|
||||||
(show state._currentRR.ttl)
|
(show state._currentRR.ttl)
|
||||||
should_be_disabled
|
should_be_disabled
|
||||||
, Bulma.box_input "targetSPF" "Target" "www"
|
|
||||||
(updateForm Field_Target)
|
|
||||||
state._currentRR.target
|
|
||||||
should_be_disabled
|
|
||||||
, case state._currentRR.v of
|
, case state._currentRR.v of
|
||||||
Nothing -> Bulma.p "default value for the version (spf1)"
|
Nothing -> Bulma.p "default value for the version (spf1)"
|
||||||
Just v -> Bulma.box_input "vSPF" "Version" "spf1" (updateForm Field_SPF_v) v should_be_disabled
|
Just v -> Bulma.box_input "vSPF" "Version" "spf1" (updateForm Field_SPF_v) v should_be_disabled
|
||||||
@ -676,17 +672,13 @@ handleQuery = case _ of
|
|||||||
add_RR state new_rr = state { _resources = (state._resources <> [ new_rr ]) }
|
add_RR state new_rr = state { _resources = (state._resources <> [ new_rr ]) }
|
||||||
|
|
||||||
-- Rendering
|
-- Rendering
|
||||||
render_soa :: forall (w :: Type). Maybe ResourceRecord -> HH.HTML w Action
|
render_soa :: forall w. Maybe ResourceRecord -> Array (HH.HTML w Action)
|
||||||
render_soa Nothing = Bulma.box [ HH.text "SOA not loaded, yet" ]
|
render_soa Nothing = [ HH.text "SOA not loaded, yet" ]
|
||||||
render_soa (Just soa) = Bulma.box [ Bulma.zone_rr_title "Start Of Authority (SOA)"
|
render_soa (Just soa) = [ Bulma.zone_rr_title "Start Of Authority (SOA)", table_rr ]
|
||||||
, table_rr
|
where
|
||||||
]
|
table_rr = Bulma.table [] [ Bulma.soa_table_header, table_content ]
|
||||||
where table_rr = Bulma.table [] [ Bulma.soa_table_header, table_content ]
|
|
||||||
table_content
|
table_content
|
||||||
= HH.tbody_ $ [ HH.tr_ $ [
|
= HH.tbody_ $ [ HH.tr_ $ [ HH.td_ [ HH.text soa.name ]
|
||||||
--, Bulma.p $ "rrtype: " <> soa.rrtype
|
|
||||||
--, Bulma.p $ "rrid: " <> show soa.rrid
|
|
||||||
HH.td_ [ HH.text soa.name ]
|
|
||||||
, HH.td_ [ HH.text $ show soa.ttl ]
|
, HH.td_ [ HH.text $ show soa.ttl ]
|
||||||
, HH.td_ [ HH.text soa.target ]
|
, HH.td_ [ HH.text soa.target ]
|
||||||
, HH.td_ [ HH.text $ maybe "" id soa.mname ]
|
, HH.td_ [ HH.text $ maybe "" id soa.mname ]
|
||||||
@ -699,23 +691,19 @@ render_soa (Just soa) = Bulma.box [ Bulma.zone_rr_title "Start Of Authority (SOA
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
bg_color_ro = C.has_background_warning_light :: Array HH.ClassName
|
||||||
|
|
||||||
-- | Render all Resource Records.
|
-- | Render all Resource Records.
|
||||||
render_resources :: forall w
|
render_resources :: forall w. Array ResourceRecord -> HH.HTML w Action
|
||||||
-- . Hash.HashMap RRId (Array Validation.Error)
|
render_resources [] = Bulma.box [Bulma.zone_rr_title "Resource records", Bulma.subtitle "No records for now"]
|
||||||
. 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
|
render_resources records
|
||||||
= HH.div_ $ [ render_soa $ A.head $ A.filter (\rr -> rr.rrtype == "SOA") records ]
|
= HH.div_ $
|
||||||
<> (if A.length all_basic_rr > 0 then [Bulma.box [basic_records_section]] else [])
|
[ Bulma.box $ render_soa $ A.head $ A.filter (\rr -> rr.rrtype == "SOA") records ]
|
||||||
<> (if A.length all_mx_rr > 0 then [Bulma.box [mx_records_section ]] else [])
|
<> (rr_box [] Bulma.simple_table_header table_content_with_separations all_basic_rr)
|
||||||
<> (if A.length all_srv_rr > 0 then [Bulma.box [srv_records_section ]] else [])
|
<> (rr_box [] Bulma.mx_table_header table_content all_mx_rr)
|
||||||
<> (if A.length all_spf_rr > 0 then [Bulma.box [spf_records_section ]] else [])
|
<> (rr_box [] Bulma.srv_table_header table_content all_srv_rr)
|
||||||
<> (if A.length all_basic_ro_rr > 0
|
<> (rr_box [] Bulma.spf_table_header table_content all_spf_rr)
|
||||||
then [Bulma.box_ C.has_background_warning_light [basic_readonly_records_section]] else [])
|
<> (rr_box bg_color_ro Bulma.simple_table_header_ro table_content_with_separations all_basic_ro_rr)
|
||||||
where
|
where
|
||||||
all_basic_rr = A.filter (\rr -> A.elem rr.rrtype baseRecords && not rr.readonly) 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_basic_ro_rr = A.filter (\rr -> A.elem rr.rrtype baseRecords && rr.readonly) records
|
||||||
@ -723,35 +711,15 @@ render_resources records
|
|||||||
all_srv_rr = A.filter (\rr -> rr.rrtype == "SRV") records
|
all_srv_rr = A.filter (\rr -> rr.rrtype == "SRV") records
|
||||||
all_spf_rr = A.filter (\rr -> rr.rrtype == "SPF") records
|
all_spf_rr = A.filter (\rr -> rr.rrtype == "SPF") records
|
||||||
|
|
||||||
basic_records_section
|
rr_box :: Array HH.ClassName
|
||||||
= if A.length all_basic_rr > 0
|
-> HH.HTML w Action
|
||||||
then Bulma.table [] [ Bulma.simple_table_header, render_basic_records all_basic_rr]
|
-> (Array ResourceRecord -> HH.HTML w Action)
|
||||||
else Bulma.p "no basic records"
|
-> Array ResourceRecord
|
||||||
|
-> Array (HH.HTML w Action)
|
||||||
basic_readonly_records_section
|
rr_box colors header dp rrs =
|
||||||
= if A.length all_basic_ro_rr > 0
|
if A.length rrs > 0
|
||||||
then Bulma.table [] [ Bulma.simple_table_header_ro, render_basic_records all_basic_ro_rr]
|
then [Bulma.box_ colors [Bulma.table [] [header, dp rrs]]]
|
||||||
else Bulma.p "no read only records?"
|
else []
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
spf_records_section
|
|
||||||
= if A.length all_spf_rr > 0
|
|
||||||
then Bulma.table [] [ Bulma.spf_table_header, render_spf_records ]
|
|
||||||
else Bulma.p "no spf records"
|
|
||||||
|
|
||||||
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
|
|
||||||
render_spf_records = table_content all_spf_rr
|
|
||||||
|
|
||||||
table_content_with_separations records_ = HH.tbody_ $
|
table_content_with_separations records_ = HH.tbody_ $
|
||||||
A.groupAllBy (comparing (_.rrtype)) records_ -- [x x y y z] -> [NE[xx], NE[yy], NE[z]]
|
A.groupAllBy (comparing (_.rrtype)) records_ -- [x x y y z] -> [NE[xx], NE[yy], NE[z]]
|
||||||
@ -790,8 +758,7 @@ render_resources records
|
|||||||
[ Bulma.txt_name rr.rrtype
|
[ 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 $ show rr.ttl ]
|
||||||
, HH.td_ [ Bulma.p rr.target ]
|
, HH.td_ [ Bulma.p $ maybe "(default)" id rr.v ]
|
||||||
, HH.td_ [ Bulma.p $ maybe "spf1 (default)" id rr.v ]
|
|
||||||
, 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_mechanism) rr.mechanisms ]
|
||||||
, HH.td_ [ Bulma.p $ maybe "" (A.fold <<< A.intersperse " " <<< map show_modifier) rr.modifiers ]
|
, HH.td_ [ Bulma.p $ maybe "" (A.fold <<< A.intersperse " " <<< map show_modifier) rr.modifiers ]
|
||||||
, HH.td_ [ Bulma.p $ maybe "" show_qualifier_char rr.q ]
|
, HH.td_ [ Bulma.p $ maybe "" show_qualifier_char rr.q ]
|
||||||
|
@ -128,7 +128,6 @@ spf_table_header
|
|||||||
= HH.thead_ [ HH.tr_ [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
|
= HH.thead_ [ HH.tr_ [ HH.th [ HP.style "width: 50px;" ] [ HH.text "Type" ]
|
||||||
, HH.th_ [ HH.text "Name" ]
|
, HH.th_ [ HH.text "Name" ]
|
||||||
, HH.th_ [ HH.text "TTL" ]
|
, HH.th_ [ HH.text "TTL" ]
|
||||||
, HH.th_ [ HH.text "Target" ]
|
|
||||||
, HH.th_ [ HH.text "Version" ]
|
, HH.th_ [ HH.text "Version" ]
|
||||||
, HH.th_ [ HH.text "Mechanisms" ]
|
, HH.th_ [ HH.text "Mechanisms" ]
|
||||||
, HH.th_ [ HH.text "Modifiers" ]
|
, HH.th_ [ HH.text "Modifiers" ]
|
||||||
@ -463,3 +462,6 @@ selection action values selected = HH.div [HP.classes $ C.select <> C.is_normal]
|
|||||||
[ HH.select [ HE.onSelectedIndexChange action ]
|
[ HH.select [ HE.onSelectedIndexChange action ]
|
||||||
$ map (\n -> HH.option [HP.value n, HP.selected (n == selected)] [HH.text n]) values
|
$ map (\n -> HH.option [HP.value n, HP.selected (n == selected)] [HH.text n]) values
|
||||||
]
|
]
|
||||||
|
|
||||||
|
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]
|
||||||
|
Loading…
Reference in New Issue
Block a user