summaryrefslogtreecommitdiff
path: root/loadZoneWindow.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-01 15:31:33 -0600
committerJeff Carr <[email protected]>2024-01-01 15:31:33 -0600
commitf1a0d18ac19d0db4f7060ea5a5c662348118e399 (patch)
treef2e454da9c3ff512b6548ce741825261178a6a56 /loadZoneWindow.go
initial commit of cloudflare api
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'loadZoneWindow.go')
-rw-r--r--loadZoneWindow.go91
1 files changed, 91 insertions, 0 deletions
diff --git a/loadZoneWindow.go b/loadZoneWindow.go
new file mode 100644
index 0000000..56f65d8
--- /dev/null
+++ b/loadZoneWindow.go
@@ -0,0 +1,91 @@
+// This is a simple example
+package cloudflare
+
+import (
+ "log"
+ "strconv"
+
+ "go.wit.com/gui/gui"
+)
+
+func LoadZoneWindow(n *gui.Node, c *ConfigT) {
+ hostname := c.Domain
+ zoneID := c.ZoneID
+ log.Println("adding DNS record", hostname)
+
+ newt := n.NewTab(hostname)
+ vb := newt.NewBox("vBox", false)
+ newg := vb.NewGroup("more zoneID = " + zoneID)
+
+ // make a grid 6 things wide
+ grid := newg.NewGrid("gridnuts", 6, 1)
+
+// grid.NewButton("Type", func () {
+// log.Println("sort by Type")
+// })
+ 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")
+ if (record.Proxied) {
+ proxy.SetText("On")
+ } else {
+ proxy.SetText("Off")
+ }
+
+ var ttl string
+ if (record.TTL == 1) {
+ ttl = "Auto"
+ } else {
+ ttl = strconv.Itoa(record.TTL)
+ }
+ grid.NewLabel(ttl)
+
+ val := grid.NewLabel("Value")
+ val.SetText(record.Content)
+
+ load := grid.NewButton("Load", nil)
+ load.Custom = func () {
+ name := "save stuff to cloudflare for " + rr.ID
+ log.Println(name)
+
+ /*
+ rr.Domain = domainWidget.S
+ rr.ZoneID = zoneWidget.S
+ rr.Auth = authWidget.S
+ rr.Email = emailWidget.S
+ */
+
+ SetRow(&rr)
+ }
+ }
+
+ grid.Pad()
+}