commit 5aacba7ff2ca5936bbe48449cd5728ad582bc3cf Author: Jeff Carr Date: Mon Jan 1 15:26:36 2024 -0600 initial commit Signed-off-by: Jeff Carr diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01d3a55 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +control-panel-dns +/files/* +/*.deb +*.swp +/plugins/* + +control-panel-digitalocean diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..637bde3 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +# export GO111MODULE="off" +run: build + reset + ./control-panel-digitalocean --gui-debug + +build-release: + go get -v -u -x . + go build -v -o control-panel-digitalocean + ./control-panel-digitalocean + +build: + go get -v -x . + go build -v -o control-panel-digitalocean + +update: + go get -v -u -x . + +log: + reset + tail -f /tmp/witgui.* /tmp/guilogfile + +gocui: build + ./control-panel-digitalocean -gui gocui + +quiet: + ./control-panel-digitalocean >/tmp/witgui.log.stderr 2>&1 diff --git a/argv.go b/argv.go new file mode 100644 index 0000000..017a072 --- /dev/null +++ b/argv.go @@ -0,0 +1,18 @@ +package main + +/* + this enables command line options from other packages like 'gui' and 'log' +*/ + +import ( + arg "github.com/alexflint/go-arg" + "go.wit.com/log" + + "go.wit.com/gui/gui" +) + + +func init() { + arg.MustParse() + log.Info("INIT() gui args.ArgDebug =", gui.ArgDebug()) +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..be46fdb --- /dev/null +++ b/main.go @@ -0,0 +1,79 @@ +package main + +import ( + "time" + + "go.wit.com/log" + "go.wit.com/gui/gui" + "go.wit.com/gui/digitalocean" +) + +var title string = "Cloud App" +var myGui *gui.Node +var myDo *digitalocean.DigitalOcean + +func main() { + // initialize a new GO GUI instance + myGui = gui.New().Default() + + // draw the main window + cloudApp(myGui) + + log.Sleep(1) + myDo = digitalocean.New(myGui) + myDo.Update() + myDo.Show() + + doUpdate() + // This is just a optional goroutine to watch that things are alive + gui.Watchdog() + gui.StandardExit() +} + +func cloudApp(n *gui.Node) *gui.Node { + win := n.NewWindow(title) + + // make a group label and a grid + group := win.NewGroup("data").Pad() + grid := group.NewGrid("grid", 2, 1).Pad() + + grid.NewButton("New()", func () { + myDo = digitalocean.New(myGui) + }) + grid.NewLabel("initializes the DO golang gui package") + + grid.NewButton("Show", func () { + myDo.Show() + }) + grid.NewLabel("will show the DO window") + + grid.NewButton("Hide", func () { + myDo.Hide() + }) + grid.NewLabel("will hide the DO window") + + grid.NewButton("Update", func () { + myDo.Update() + }) + grid.NewLabel("polls DO via the API to find the state of all your droplets") + + grid.NewButton("Create", func () { + // myDo.Create("jcarr.wit.com") + digitalocean.InitCreateWindow() + }) + grid.NewLabel("makes a new droplet") + + return win +} + +func doUpdate() { + ticker := time.NewTicker(10 * time.Second) + defer ticker.Stop() + + for { + select { + case <-ticker.C: + myDo.Update() + } + } +}