2024-01-01 15:31:33 -06:00
|
|
|
// This is a simple example
|
|
|
|
package cloudflare
|
|
|
|
|
2024-01-18 01:33:28 -06:00
|
|
|
import (
|
2024-01-01 15:31:33 -06:00
|
|
|
"strconv"
|
|
|
|
|
2024-01-21 02:10:00 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-18 01:33:28 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
|
|
|
"go.wit.com/log"
|
2024-01-01 15:31:33 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func LoadZoneWindow(n *gui.Node, c *ConfigT) {
|
|
|
|
hostname := c.Domain
|
|
|
|
zoneID := c.ZoneID
|
2024-01-05 19:33:41 -06:00
|
|
|
log.Log(INFO, "adding DNS record", hostname)
|
2024-01-01 15:31:33 -06:00
|
|
|
|
2024-01-05 09:38:20 -06:00
|
|
|
newW := gadgets.NewBasicWindow(n, hostname)
|
|
|
|
newg := newW.Box().NewGroup("more zoneID = " + zoneID)
|
2024-01-01 15:31:33 -06:00
|
|
|
|
|
|
|
// make a grid 6 things wide
|
|
|
|
grid := newg.NewGrid("gridnuts", 6, 1)
|
|
|
|
|
2024-01-18 01:33:28 -06:00
|
|
|
// grid.NewButton("Type", func () {
|
|
|
|
// log.Log(INFO, "sort by Type")
|
|
|
|
// })
|
2024-01-01 15:31:33 -06:00
|
|
|
grid.NewLabel("RR type")
|
|
|
|
grid.NewLabel("hostname")
|
|
|
|
|
|
|
|
grid.NewLabel("Proxy")
|
|
|
|
grid.NewLabel("TTL")
|
|
|
|
grid.NewLabel("Value")
|
|
|
|
grid.NewLabel("Save")
|
|
|
|
|
|
|
|
records := GetZonefile(c)
|
|
|
|
for _, record := range records.Result {
|
|
|
|
var rr RRT // dns zonefile resource record
|
|
|
|
|
|
|
|
// copy all the JSON values into the row record.
|
|
|
|
rr.ID = record.ID
|
|
|
|
rr.Type = record.Type
|
|
|
|
rr.Name = record.Name
|
|
|
|
rr.Content = record.Content
|
|
|
|
rr.Proxied = record.Proxied
|
|
|
|
rr.Proxiable = record.Proxiable
|
|
|
|
rr.ZoneID = zoneID
|
|
|
|
// rr.Ttl = record.TTL
|
|
|
|
|
|
|
|
rr.Domain = hostname
|
|
|
|
rr.ZoneID = zoneID
|
|
|
|
rr.Auth = c.Auth
|
|
|
|
rr.Email = c.Email
|
|
|
|
|
|
|
|
grid.NewLabel(record.Type)
|
|
|
|
grid.NewLabel(record.Name)
|
|
|
|
|
|
|
|
proxy := grid.NewLabel("proxy")
|
2024-01-18 01:33:28 -06:00
|
|
|
if record.Proxied {
|
2024-01-01 15:31:33 -06:00
|
|
|
proxy.SetText("On")
|
|
|
|
} else {
|
|
|
|
proxy.SetText("Off")
|
|
|
|
}
|
|
|
|
|
2024-01-18 01:33:28 -06:00
|
|
|
var ttl string
|
|
|
|
if record.TTL == 1 {
|
2024-01-01 15:31:33 -06:00
|
|
|
ttl = "Auto"
|
|
|
|
} else {
|
|
|
|
ttl = strconv.Itoa(record.TTL)
|
|
|
|
}
|
|
|
|
grid.NewLabel(ttl)
|
|
|
|
|
|
|
|
val := grid.NewLabel("Value")
|
|
|
|
val.SetText(record.Content)
|
|
|
|
|
|
|
|
load := grid.NewButton("Load", nil)
|
2024-01-18 01:33:28 -06:00
|
|
|
load.Custom = func() {
|
2024-01-01 15:31:33 -06:00
|
|
|
name := "save stuff to cloudflare for " + rr.ID
|
2024-01-05 19:33:41 -06:00
|
|
|
log.Log(INFO, name)
|
2024-01-01 15:31:33 -06:00
|
|
|
|
|
|
|
/*
|
2024-01-18 01:33:28 -06:00
|
|
|
rr.Domain = domainWidget.S
|
|
|
|
rr.ZoneID = zoneWidget.S
|
|
|
|
rr.Auth = authWidget.S
|
|
|
|
rr.Email = emailWidget.S
|
2024-01-01 15:31:33 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
SetRow(&rr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
grid.Pad()
|
|
|
|
}
|