From 2d31751b09adc4aa21f05719f8a89d38ccd0e33a Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Fri, 14 Jul 2023 21:02:35 +0200 Subject: [PATCH] Better tables + SOA display is now okay-ish. --- src/App/Validation.purs | 20 ++++++++++----- src/App/ZoneInterface.purs | 52 +++++++++++++++++++++++++------------- src/Bulma.purs | 3 +++ src/CSSClasses.purs | 2 ++ 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/src/App/Validation.purs b/src/App/Validation.purs index ed3c313..1ca8779 100644 --- a/src/App/Validation.purs +++ b/src/App/Validation.purs @@ -228,6 +228,12 @@ validate_target_MX target where verify_length = lengthIsBetween Target target_min_len target_max_len +validate_target_SRV :: String -> V Errors String +validate_target_SRV target + = verify_length target !> verify_domain Target + where + verify_length = lengthIsBetween Target target_min_len target_max_len + -- Resource-related validations. validateA :: forall l. SimpleRR (|l) -> V Errors ResourceRecord @@ -289,13 +295,13 @@ validateMXRR_ form = case form.rrtype of validateSRV :: forall l. SRVRR (|l) -> V Errors ResourceRecord validateSRV form = ado - name <- validate_name form.name - ttl <- validate_ttl form.ttl - target <- validate_target_MX form.target - priority <- validate_priority form.priority - protocol <- validate_protocol form.protocol - weight <- validate_weight form.weight - port <- validate_port form.port + name <- validate_name form.name + ttl <- validate_ttl form.ttl + target <- validate_target_SRV form.target + priority <- validate_priority form.priority + protocol <- validate_protocol form.protocol + weight <- validate_weight form.weight + port <- validate_port form.port in toRR_srv form.rrid form.readonly "SRV" name ttl target priority port protocol weight validateSRVRR_ :: forall l. SRVRR (|l) -> V Errors ResourceRecord diff --git a/src/App/ZoneInterface.purs b/src/App/ZoneInterface.purs index 142336a..154f5b9 100644 --- a/src/App/ZoneInterface.purs +++ b/src/App/ZoneInterface.purs @@ -622,20 +622,38 @@ render_soa Nothing = HH.div_ [ HH.text "SOA not loaded, yet" ] render_soa (Just soa) = Bulma.columns [] [ left_block, right_block ] where left_block = Bulma.column class_title_size [ Bulma.zone_rr_title "Start Of Authority (SOA)" ] - right_block = Bulma.column_ [ Bulma.p "ALL AVAILABLE DATA" - , Bulma.p $ "rrtype: " <> soa.rrtype - , Bulma.p $ "rrid: " <> show soa.rrid - , Bulma.p $ "name: " <> soa.name - , Bulma.p $ "ttl: " <> soa.ttl - , Bulma.p $ "target: " <> soa.target - , Bulma.p $ "mname: " <> soa.mname - , Bulma.p $ "rname: " <> soa.rname - , Bulma.p $ "serial: " <> soa.serial - , Bulma.p $ "refresh: " <> soa.refresh - , Bulma.p $ "retry: " <> soa.retry - , Bulma.p $ "expire: " <> soa.expire - , Bulma.p $ "minttl: " <> soa.minttl + right_block = Bulma.column_ [ table_rr ] + table_rr = Bulma.table [] [ simple_SOA_table_header, table_content ] + simple_SOA_table_header + = HH.thead_ [ HH.tr_ [ HH.th_ [ HH.text "name"] + , HH.th_ [ HH.text "ttl"] + , HH.th_ [ HH.text "target"] + , HH.th_ [ HH.text "mname"] + , HH.th_ [ HH.text "rname"] + , HH.th_ [ HH.text "serial"] + , HH.th_ [ HH.text "refresh"] + , HH.th_ [ HH.text "retry"] + , HH.th_ [ HH.text "expire"] + , HH.th_ [ HH.text "minttl"] + ] + ] + table_content + = HH.tbody_ $ [ HH.tr_ $ [ + --, Bulma.p $ "rrtype: " <> soa.rrtype + --, Bulma.p $ "rrid: " <> show soa.rrid + HH.td_ [ HH.text soa.name ] + , HH.td_ [ HH.text soa.ttl ] + , HH.td_ [ HH.text soa.target ] + , HH.td_ [ HH.text soa.mname ] + , HH.td_ [ HH.text soa.rname ] + , HH.td_ [ HH.text soa.serial ] + , HH.td_ [ HH.text soa.refresh ] + , HH.td_ [ HH.text soa.retry ] + , HH.td_ [ HH.text soa.expire ] + , HH.td_ [ HH.text soa.minttl ] + ] + ] render_records :: forall (w :: Type). Hash.HashMap RRId Validation.Errors -> Array (SimpleRR ()) -> HH.HTML w Action render_records _ [] @@ -655,7 +673,7 @@ render_records errors records subtitle_txt = "and TXT records" -- subtitle_txt = "Each line is a resource record from your DNS zone." -- <> " You can edit them, then click on the \"fix\" button to synchronize with the server." - table_rr = HH.table [] [ Bulma.simple_table_header, table_content ] + table_rr = Bulma.table [] [ Bulma.simple_table_header, table_content ] table_content = HH.tbody_ $ A.concat $ map rows records rows rr @@ -671,7 +689,7 @@ render_records errors records error_row rr = case Hash.lookup rr.rrid errors of Nothing -> [] Just error_array -> [ HH.tr_ $ - [ Bulma.txt_name "-" + [ Bulma.txt_name "" , 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.Target @@ -701,7 +719,7 @@ render_mx_records errors records ] where title_txt = "MX records" - table_rr = HH.table [] [ Bulma.mx_table_header, table_content ] + table_rr = Bulma.table [] [ Bulma.mx_table_header, table_content ] table_content = HH.tbody_ $ A.concat $ map rows records rows rr = [ HH.tr_ $ @@ -737,7 +755,7 @@ render_srv_records errors records , Bulma.column_ [ Bulma.tile [ table_rr ] ] ] where title_txt = "SRV records" - table_rr = HH.table [] [ Bulma.srv_table_header, table_content ] + table_rr = Bulma.table [] [ Bulma.srv_table_header, table_content ] table_content = HH.tbody_ $ A.concat $ map rows records rows rr diff --git a/src/Bulma.purs b/src/Bulma.purs index 561f091..d1574e1 100644 --- a/src/Bulma.purs +++ b/src/Bulma.purs @@ -56,6 +56,9 @@ input_classes :: Boolean -> Array HH.ClassName input_classes true = C.input <> C.is_small <> C.is_info input_classes false = C.input <> C.is_small <> C.is_danger +table :: forall w i. HH.Node DHI.HTMLtable w i +table prop xs = HH.table ([ HP.classes $ C.table ] <> prop) xs + btn_classes :: Boolean -> Array HH.ClassName btn_classes true = C.button <> C.is_small <> C.is_info btn_classes false = C.button <> C.is_small <> C.is_danger diff --git a/src/CSSClasses.purs b/src/CSSClasses.purs index d1a0883..19f6433 100644 --- a/src/CSSClasses.purs +++ b/src/CSSClasses.purs @@ -112,6 +112,8 @@ select :: Array HH.ClassName select = [HH.ClassName "select"] subtitle :: Array HH.ClassName subtitle = [HH.ClassName "subtitle"] +table :: Array HH.ClassName +table = [HH.ClassName "table"] tile :: Array HH.ClassName tile = [HH.ClassName "tile"] title :: Array HH.ClassName