Show errors for both Simple, MX and SRV RR.

beta
Philippe Pittoli 2023-07-14 19:49:39 +02:00
parent b0b0429ace
commit 9b674a9d1e
1 changed files with 60 additions and 30 deletions

View File

@ -679,10 +679,10 @@ render_records errors records
, HH.td_ [] , HH.td_ []
] ]
] ]
where
from_error_array_to_td :: Validation.Errors -> Validation.Attribute -> _ from_error_array_to_td :: Validation.Errors -> Validation.Attribute -> _
from_error_array_to_td [] _ = [] from_error_array_to_td [] _ = []
from_error_array_to_td errors attribute = case A.uncons errors of from_error_array_to_td errors attribute = case A.uncons errors of
Just { head: (Tuple attr err), tail: xs } -> if attr == attribute Just { head: (Tuple attr err), tail: xs } -> if attr == attribute
then [Bulma.p err] then [Bulma.p err]
else from_error_array_to_td xs attribute else from_error_array_to_td xs attribute
@ -702,9 +702,9 @@ render_mx_records errors records
where where
title_txt = "MX records" title_txt = "MX records"
table_rr = HH.table [] [ Bulma.mx_table_header, table_content ] table_rr = HH.table [] [ Bulma.mx_table_header, table_content ]
table_content = HH.tbody_ $ map row records table_content = HH.tbody_ $ A.concat $ map rows records
row rr = HH.tr_ $ rows rr = [ HH.tr_ $
[ HH.td_ [ Bulma.input_domain ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_MXRR <<< Update_MX_Domain) rr.name rr.valid ] [ HH.td_ [ Bulma.input_domain ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_MXRR <<< Update_MX_Domain) rr.name rr.valid ]
, HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_MXRR <<< Update_MX_TTL) rr.ttl rr.valid ] , HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_MXRR <<< Update_MX_TTL) rr.ttl rr.valid ]
, HH.td_ [ Bulma.input_priority ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_MXRR <<< Update_MX_Priority) rr.priority rr.valid ] , HH.td_ [ Bulma.input_priority ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_MXRR <<< Update_MX_Priority) rr.priority rr.valid ]
@ -712,6 +712,19 @@ render_mx_records errors records
, HH.td_ [ Bulma.btn_change (SaveMXRR rr.rrid) (TellSomethingWentWrong rr.rrid "cannot update") rr.modified rr.valid ] , HH.td_ [ Bulma.btn_change (SaveMXRR rr.rrid) (TellSomethingWentWrong rr.rrid "cannot update") rr.modified rr.valid ]
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.rrid) ] , HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.rrid) ]
] ]
] <> error_row rr
error_row rr = case Hash.lookup rr.rrid errors of
Nothing -> []
Just error_array ->
[ HH.tr_ $
[ HH.td_ $ from_error_array_to_td error_array Validation.Name
, HH.td_ $ from_error_array_to_td error_array Validation.TTL
, HH.td_ $ from_error_array_to_td error_array Validation.Priority
, HH.td_ $ from_error_array_to_td error_array Validation.Target
, HH.td_ []
, HH.td_ []
]
]
render_srv_records :: forall (w :: Type) (l :: Row Type) render_srv_records :: forall (w :: Type) (l :: Row Type)
. Hash.HashMap RRId Validation.Errors -> Array (SRVRR l) -> HH.HTML w Action . Hash.HashMap RRId Validation.Errors -> Array (SRVRR l) -> HH.HTML w Action
@ -725,9 +738,10 @@ render_srv_records errors records
where where
title_txt = "SRV records" title_txt = "SRV records"
table_rr = HH.table [] [ Bulma.srv_table_header, table_content ] table_rr = HH.table [] [ Bulma.srv_table_header, table_content ]
table_content = HH.tbody_ $ map row records table_content = HH.tbody_ $ A.concat $ map rows records
row rr = HH.tr_ $ rows rr
= [ HH.tr_ $
[ HH.td_ [ Bulma.input_domain ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRVRR <<< Update_SRV_Domain ) rr.name rr.valid ] [ HH.td_ [ Bulma.input_domain ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRVRR <<< Update_SRV_Domain ) rr.name rr.valid ]
, HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRVRR <<< Update_SRV_TTL ) rr.ttl rr.valid ] , HH.td_ [ Bulma.input_ttl ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRVRR <<< Update_SRV_TTL ) rr.ttl rr.valid ]
, HH.td_ [ Bulma.input_priority ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRVRR <<< Update_SRV_Priority) rr.priority rr.valid ] , HH.td_ [ Bulma.input_priority ((UpdateLocalForm rr.rrid) <<< Update_Local_Form_SRVRR <<< Update_SRV_Priority) rr.priority rr.valid ]
@ -738,6 +752,22 @@ render_srv_records errors records
, HH.td_ [ Bulma.btn_change (SaveSRVRR rr.rrid) (TellSomethingWentWrong rr.rrid "cannot update") rr.modified rr.valid ] , HH.td_ [ Bulma.btn_change (SaveSRVRR rr.rrid) (TellSomethingWentWrong rr.rrid "cannot update") rr.modified rr.valid ]
, HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.rrid) ] , HH.td_ [ Bulma.btn_delete (\_ -> DeleteRRModal rr.rrid) ]
] ]
] <> error_row rr
error_row rr = case Hash.lookup rr.rrid errors of
Nothing -> []
Just error_array ->
[ HH.tr_ $
[ HH.td_ $ from_error_array_to_td error_array Validation.Name
, HH.td_ $ from_error_array_to_td error_array Validation.TTL
, HH.td_ $ from_error_array_to_td error_array Validation.Priority
, HH.td_ $ from_error_array_to_td error_array Validation.Protocol
, HH.td_ $ from_error_array_to_td error_array Validation.Weight
, HH.td_ $ from_error_array_to_td error_array Validation.Port
, HH.td_ $ from_error_array_to_td error_array Validation.Target
, HH.td_ []
, HH.td_ []
]
]
baseRecords :: Array String baseRecords :: Array String
baseRecords = [ "NS", "A", "AAAA", "CNAME", "TXT" ] baseRecords = [ "NS", "A", "AAAA", "CNAME", "TXT" ]