diff --git a/db/util.go b/db/util.go
index 965cf03..cfcfdbe 100644
--- a/db/util.go
+++ b/db/util.go
@@ -10,6 +10,32 @@ func InitSchema(db *sql.DB) error {
// Create a new Queries instance
q := New(db)
- // Execute the initialization query
- return q.InitSchema(context.Background())
+ // Execute the config table creation
+ if err := q.InitSchema(context.Background()); err != nil {
+ return err
+ }
+
+ // Create static_records table separately
+ _, err := db.ExecContext(context.Background(), `
+ CREATE TABLE IF NOT EXISTS static_records (
+ record_id TEXT PRIMARY KEY,
+ record_name TEXT NOT NULL,
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
+ );
+ `)
+ if err != nil {
+ return err
+ }
+
+ // Insert default config if none exists
+ _, err = db.ExecContext(context.Background(), `
+ INSERT OR IGNORE INTO config (api_token, zone_id, domain, update_period)
+ SELECT '', '', 'mz.uy', '0 */6 * * *'
+ WHERE NOT EXISTS (SELECT 1 FROM config);
+ `)
+ if err != nil {
+ return err
+ }
+
+ return nil
}
diff --git a/templates/index.templ b/templates/index.templ
index 5381d4a..6a83ebf 100644
--- a/templates/index.templ
+++ b/templates/index.templ
@@ -26,7 +26,7 @@ type DNSRecord struct {
Content string
TTL int
Proxied bool
- IsStatic bool // Nueva propiedad para indicar si es estático
+ IsStatic bool
CreatedOn string
}
@@ -72,13 +72,14 @@ templ ConfigWarning() {
Configuration Required
Please configure your Cloudflare API credentials to manage your DNS records.
-
+
}
@@ -364,4 +365,4 @@ func getStaticToggleTitle(isStatic bool) string {
return "Make dynamic (will auto-update)"
}
return "Make static (won't auto-update)"
-}
+ }
diff --git a/templates/index_templ.go b/templates/index_templ.go
index 5b0cd6d..7104580 100644
--- a/templates/index_templ.go
+++ b/templates/index_templ.go
@@ -34,7 +34,7 @@ type DNSRecord struct {
Content string
TTL int
Proxied bool
- IsStatic bool // Nueva propiedad para indicar si es estático
+ IsStatic bool
CreatedOn string
}
@@ -160,7 +160,7 @@ func ConfigWarning() templ.Component {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "Configuration Required
Please configure your Cloudflare API credentials to manage your DNS records.
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "Configuration Required
Please configure your Cloudflare API credentials to manage your DNS records.
Configure Now ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -196,7 +196,7 @@ func ConfigStatus(config ConfigData) templ.Component {
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(config.Domain)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 118, Col: 51}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 119, Col: 51}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
@@ -209,7 +209,7 @@ func ConfigStatus(config ConfigData) templ.Component {
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(config.ZoneID)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 121, Col: 52}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 122, Col: 52}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
@@ -222,7 +222,7 @@ func ConfigStatus(config ConfigData) templ.Component {
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(formatUpdateSchedule(config.UpdatePeriod))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 125, Col: 54}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 126, Col: 54}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
@@ -347,7 +347,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(record.Type)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 226, Col: 19}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 227, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
@@ -360,7 +360,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(record.Name)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 227, Col: 19}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 228, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil {
@@ -373,7 +373,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(record.Content)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 229, Col: 19}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 230, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
@@ -409,7 +409,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, 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: 242, Col: 36}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 243, Col: 36}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
if templ_7745c5c3_Err != nil {
@@ -438,7 +438,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var17 templ.SafeURL
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL(fmt.Sprintf("/records/%s/toggle-static", record.ID)))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 254, Col: 76}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 255, Col: 76}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
@@ -473,7 +473,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var20 string
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(getStaticToggleTitle(record.IsStatic))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 265, Col: 51}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 266, Col: 51}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
if templ_7745c5c3_Err != nil {
@@ -511,7 +511,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var21 templ.SafeURL
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL(fmt.Sprintf("/edit-record/%s", record.ID)))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 285, Col: 63}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 286, Col: 63}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil {
@@ -524,7 +524,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var22 templ.SafeURL
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL(fmt.Sprintf("/records/%s", record.ID)))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 303, Col: 61}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 304, Col: 61}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
if templ_7745c5c3_Err != nil {
@@ -537,7 +537,7 @@ func DNSRecordRow(record DNSRecord, currentIP string) templ.Component {
var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(`confirm('Are you sure you want to delete the record for "%s"?') || $event.preventDefault(); deleteLoading = true`, record.Name))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 305, Col: 159}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/index.templ`, Line: 306, Col: 159}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil {