From 9d6ca04834340a74d272c4eed38004511ef93590 Mon Sep 17 00:00:00 2001 From: "Mariano Z." Date: Tue, 7 Oct 2025 13:25:55 -0300 Subject: [PATCH] dev: automated commit - 2025-10-07 13:25:55 --- templates/index.templ | 76 +++++++++++------- templates/index_templ.go | 165 +++++++++++++++++++++------------------ 2 files changed, 136 insertions(+), 105 deletions(-) diff --git a/templates/index.templ b/templates/index.templ index 11d47a3..a2663f6 100644 --- a/templates/index.templ +++ b/templates/index.templ @@ -27,7 +27,7 @@ type DNSRecord struct { Content string TTL int Proxied bool - IsStatic bool + IsStatic bool CreatedOn string } @@ -36,6 +36,38 @@ type UpdateFrequency struct { Value string } +// Helper type for grouped records +type IPGroup struct { + IP string + Records []DNSRecord +} + +// Helper function to group records by IP +func groupRecordsByIP(records []DNSRecord) []IPGroup { + groupMap := make(map[string][]DNSRecord) + for _, r := range records { + groupMap[r.Content] = append(groupMap[r.Content], r) + } + + // Stable order of groups + ips := make([]string, 0, len(groupMap)) + for ip := range groupMap { + ips = append(ips, ip) + } + sort.Strings(ips) + + // Convert to slice of IPGroup + result := make([]IPGroup, 0, len(ips)) + for _, ip := range ips { + result = append(result, IPGroup{ + IP: ip, + Records: groupMap[ip], + }) + } + + return result +} + templ Index(props IndexProps) { @Layout(props.Title) {
@@ -73,12 +105,7 @@ templ ConfigWarning() {

Configuration Required

Please configure your Cloudflare API credentials to manage your DNS records.

- + Configure Now
@@ -214,30 +241,20 @@ templ DNSRecordsTable(records []DNSRecord, currentIP string) { No DNS records found } else { - // Group records by Content (IP) - groups := make(map[string][]DNSRecord) - for _, r := range records { - groups[r.Content] = append(groups[r.Content], r) - } - - // Stable order of groups - ips := make([]string, 0, len(groups)) - for ip := range groups { - ips = append(ips, ip) - } - sort.Strings(ips) - - for _, ip := range ips { + for _, ipGroup := range groupRecordsByIP(records) { - { ip } - { fmt.Sprintf("%d record(s)", len(groups[ip])) } - if ip == currentIP { + { ipGroup.IP } + + { fmt.Sprintf("%d record(s)", + len(ipGroup.Records)) } + + if ipGroup.IP == currentIP { Current IP } - for _, record := range groups[ip] { + for _, record := range ipGroup.Records { @DNSRecordRow(record, currentIP) } } @@ -286,7 +303,8 @@ templ DNSRecordRow(record DNSRecord, currentIP string) { >
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -407,68 +416,68 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component { templ_7745c5c3_Var14 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(record.Type) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 252, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 269, Col: 19} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(record.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 253, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 270, Col: 19} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(record.Content) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 255, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 272, Col: 19} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if record.Type == "A" && !record.IsStatic { if record.Content == currentIP { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "Current IP") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "Current IP") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "Outdated IP") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "Outdated IP") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if record.TTL == 1 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "Auto") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "Auto") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -476,51 +485,52 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%ds", record.TTL)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 268, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 285, Col: 36} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if record.Proxied { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if record.Type == "A" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "\" x-target=\"dns-records-table\" @ajax:before=\"toggleLoading = true\" @ajax:after=\"toggleLoading = false\" @ajax:error=\"toggleLoading = false\" style=\"display: inline;\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var20 = []any{"btn btn-sm", templ.KV("btn-outline-secondary", !record.IsStatic), templ.KV("btn-secondary", record.IsStatic)} + var templ_7745c5c3_Var20 = []any{"btn btn-sm", templ.KV("btn-outline-secondary", + !record.IsStatic), templ.KV("btn-secondary", record.IsStatic)} templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var20...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "-") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "-") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "\" @ajax:after=\"deleteLoading = false\" @ajax:error=\"deleteLoading = false\" @ajax:success=\"$el.closest('tr').remove()\" style=\"display: inline;\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }