use gadgets.BasicWindow()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-05 09:38:20 -06:00
parent c68e530e76
commit 14419ebfd7
4 changed files with 16 additions and 26 deletions

View File

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
func LoadZoneWindow(n *gui.Node, c *ConfigT) { func LoadZoneWindow(n *gui.Node, c *ConfigT) {
@ -13,9 +14,8 @@ func LoadZoneWindow(n *gui.Node, c *ConfigT) {
zoneID := c.ZoneID zoneID := c.ZoneID
log.Println("adding DNS record", hostname) log.Println("adding DNS record", hostname)
newt := n.NewTab(hostname) newW := gadgets.NewBasicWindow(n, hostname)
vb := newt.NewBox("vBox", false) newg := newW.Box().NewGroup("more zoneID = " + zoneID)
newg := vb.NewGroup("more zoneID = " + zoneID)
// make a grid 6 things wide // make a grid 6 things wide
grid := newg.NewGrid("gridnuts", 6, 1) grid := newg.NewGrid("gridnuts", 6, 1)

View File

@ -10,20 +10,18 @@ import (
) )
// This creates a window // This creates a window
func MakeCloudflareWindow(n *gui.Node) *gui.Node { func MakeCloudflareWindow(n *gui.Node) *gadgets.BasicWindow {
CFdialog.rootGui = n CFdialog.rootGui = n
var t *gui.Node
log.Println("buttonWindow() START") log.Println("buttonWindow() START")
CFdialog.mainWindow = n.NewWindow("Cloudflare Config") CFdialog.mainWindow = gadgets.NewBasicWindow(n,"Cloudflare Config")
// this tab has the master cloudflare API credentials // this tab has the master cloudflare API credentials
makeConfigWindow(CFdialog.mainWindow) makeConfigWindow(CFdialog.mainWindow.Box())
t = CFdialog.mainWindow.NewTab("Zones") win := gadgets.NewBasicWindow(n,"Zones")
vb := t.NewBox("vBox", false) g1 := win.Box().NewGroup("zones")
g1 := vb.NewGroup("zones")
// make dropdown list of zones // make dropdown list of zones
CFdialog.zonedrop = g1.NewDropdown("zone") CFdialog.zonedrop = g1.NewDropdown("zone")
@ -54,13 +52,10 @@ func MakeCloudflareWindow(n *gui.Node) *gui.Node {
more := g1.NewGroup("data") more := g1.NewGroup("data")
showCloudflareCredentials(more) showCloudflareCredentials(more)
// makeDebugWindow(CFdialog.mainWindow)
return CFdialog.mainWindow return CFdialog.mainWindow
} }
func makeConfigWindow(n *gui.Node) { func makeConfigWindow(vb *gui.Node) {
t := n.NewTab("Get Zones")
vb := t.NewBox("vBox", false)
g1 := vb.NewGroup("Cloudflare API Config") g1 := vb.NewGroup("Cloudflare API Config")
g1.NewLabel("If you have an API key with access to list all of /n your zone files, enter it here. \n \n Alternatively, you can set the enviroment variables: \n env $CF_API_KEY \n env $CF_API_EMAIL\n") g1.NewLabel("If you have an API key with access to list all of /n your zone files, enter it here. \n \n Alternatively, you can set the enviroment variables: \n env $CF_API_KEY \n env $CF_API_EMAIL\n")
@ -106,8 +101,6 @@ func makeConfigWindow(n *gui.Node) {
CreateRR(CFdialog.rootGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06") CreateRR(CFdialog.rootGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
}) })
t.Pad()
t.Margin()
vb.Pad() vb.Pad()
vb.Margin() vb.Margin()
g1.Pad() g1.Pad()
@ -142,6 +135,6 @@ func showCloudflareCredentials(box *gui.Node) {
domain.ZoneID = CFdialog.zoneWidget.S domain.ZoneID = CFdialog.zoneWidget.S
domain.Auth = CFdialog.authWidget.S domain.Auth = CFdialog.authWidget.S
domain.Email = CFdialog.emailWidget.S domain.Email = CFdialog.emailWidget.S
LoadZoneWindow(CFdialog.mainWindow, &domain) LoadZoneWindow(CFdialog.mainWindow.Box(), &domain)
}) })
} }

10
rr.go
View File

@ -11,6 +11,7 @@ import (
"os" "os"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
func init() { func init() {
@ -24,14 +25,9 @@ func CreateRR(myGui *gui.Node, zone string, zoneID string) {
CFdialog.cloudflareB.Disable() CFdialog.cloudflareB.Disable()
return return
} }
CFdialog.cloudflareW = myGui.NewWindow("cloudflare " + zone + " API") CFdialog.cloudflareW = gadgets.NewBasicWindow(myGui, "cloudflare " + zone + " API")
CFdialog.cloudflareW.Custom = func () {
log.Println("createRR() don't really exit here")
CFdialog.cloudflareW = nil
CFdialog.cloudflareB.Enable()
}
group := CFdialog.cloudflareW.NewGroup("Create a new DNS Resource Record (rr)") group := CFdialog.cloudflareW.Box().NewGroup("Create a new DNS Resource Record (rr)")
// make a grid 2 things wide // make a grid 2 things wide
grid := group.NewGrid("gridnuts", 2, 3) grid := group.NewGrid("gridnuts", 2, 3)

View File

@ -3,6 +3,7 @@ package cloudflare
import ( import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
var cloudflareURL string = "https://api.cloudflare.com/client/v4/zones/" var cloudflareURL string = "https://api.cloudflare.com/client/v4/zones/"
@ -27,7 +28,7 @@ var CFdialog dialogT
type dialogT struct { type dialogT struct {
rootGui *gui.Node // the root node rootGui *gui.Node // the root node
mainWindow *gui.Node // the window node mainWindow *gadgets.BasicWindow // the window node
zonedrop *gui.Node // the drop down menu of zones zonedrop *gui.Node // the drop down menu of zones
domainWidget *gui.Node domainWidget *gui.Node
@ -38,7 +39,7 @@ type dialogT struct {
loadButton *gui.Node loadButton *gui.Node
saveButton *gui.Node saveButton *gui.Node
cloudflareW *gui.Node // the window node cloudflareW *gadgets.BasicWindow // the window node
cloudflareB *gui.Node // the cloudflare button cloudflareB *gui.Node // the cloudflare button
TypeNode *gui.Node // CNAME, A, AAAA, ... TypeNode *gui.Node // CNAME, A, AAAA, ...