more code cleanup and simplification

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-02 13:36:44 -07:00
parent 8057295409
commit 9cf4b3bfa6
3 changed files with 21 additions and 54 deletions

View File

@ -6,9 +6,8 @@ import "git.wit.com/wit/gui"
func makeCloudInfoBox(gw *gui.GuiWindow) {
log.Println("makeCloudInfoBox() START gw =", gw)
// box := gui.AddMainTab(gw)
gw = gui.InitGuiWindow(gui.Data.Config, "Box23", gw)
gw = gui.InitGuiWindow(gui.Data.Config, "makeCloudInfoBox() Box23", gw)
box := gui.AddGenericBox(gw, "makeCloudInfoBox")
log.Println("makeCloudInfoBox() START GW IS NOW: gw =", gw)
@ -16,8 +15,6 @@ func makeCloudInfoBox(gw *gui.GuiWindow) {
gui.NewLabel(box, "Hostname:")
// box = gui.HardHorizontalBox(gw)
tmp := gui.Data.Hostname + " (" + gui.Data.IPv6 + ")"
gui.MakeEntryHbox(box, "hostname:", tmp, true, "Hostname")
@ -33,20 +30,13 @@ func makeCloudInfoBox(gw *gui.GuiWindow) {
gui.NewLabel(box, config.Accounts[key].Email)
name := "Login " + config.Accounts[key].Nick
login := gui.CreateButton(box, config.Accounts[key], nil, name, "LOGIN", login)
gui.AddButtonToBox(box, login)
gui.CreateButton(box, config.Accounts[key], nil, name, "LOGIN", login)
name = "Show " + config.Accounts[key].Nick
show := gui.CreateButton(box, config.Accounts[key], nil, name, "SHOW", nil)
gui.AddButtonToBox(box, show)
gui.CreateButton(box, config.Accounts[key], nil, name, "SHOW", nil)
}
add := gui.CreateButton(box, nil, nil, "Add Account", "ADD TAB", addSubdomainButton)
gui.AddButtonToBox(box, add)
quit := gui.CreateButton(box, nil, nil, "Quit", "QUIT", nil)
gui.AddButtonToBox(box, quit)
gui.ShowMainTabShowBox(gw, box)
gui.CreateButton(box, nil, nil, "Add Account", "ADD TAB", addSubdomainButton)
gui.CreateButton(box, nil, nil, "Quit", "QUIT", nil)
log.Println("makeCloudInfoBox() END")
}

View File

@ -31,9 +31,7 @@ func showSplashBox(gw *gui.GuiWindow) *gui.GuiBox {
gui.NewLabel(box, "build date: " + BUILDTIME)
}
okButton := gui.CreateButton(box, nil, nil, "OK", "AREA", splashClick)
gui.AddButtonToBox(box, okButton)
gui.CreateButton(box, nil, nil, "OK", "AREA", splashClick)
log.Println("ShowSplashBox() END box =", box)
return box
}
@ -70,7 +68,7 @@ func splashClick(b *gui.GuiButton) {
return
}
// if there is not an account, then go to 'make account'
gw = gui.InitGuiWindow(config, "Box22", gw)
gw = gui.InitGuiWindow(config, "splashClick() Box22", gw)
gw.UiTab.Delete(0)
log.Println("addSubdomainQuestionBox() START")
@ -78,22 +76,14 @@ func splashClick(b *gui.GuiButton) {
gui.NewLabel(box, "Enter your Subdomain or")
button := gui.CreateButton(box, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain)
gui.AddButtonToBox(box, button)
gui.CreateButton(box, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain)
gui.AddEntry(box, "SUBDOMAIN")
gui.HorizontalBreak(box)
button2 := gui.CreateButton(box, nil, nil, "Create Subdomain Account", "ADD", addSubdomainButton)
gui.AddButtonToBox(box, button2)
gui.CreateButton(box, nil, nil, "Create Subdomain Account", "ADD", addSubdomainButton)
log.Println("addSubdomainQuestionBox() END box =", box)
}
// curl -vv -X POST -H "X-Wit-Auth: $TOKEN" 'http://stackapi-api1.stackapi.customers.wit.com:4000/vms/toby?count=1&cpu=2&ram=512&disk=25'
func addSubdomainButton(b *gui.GuiButton) {
log.Println("addSubdomainButton() START")
subdomain := gui.GetText(b.Box, "SUBDOMAIN")
@ -125,7 +115,8 @@ func generateSubdomain(b *gui.GuiButton) {
}
// subdomain.SetText("cust00013.wit.dev")
txt := gui.SetText(b.Box, "SUBDOMAIN", "cust001.testing.com.customers.wprod.wit.com")
// curl -vv -X POST -H "X-Wit-Auth: $TOKEN" 'http://stackapi-api1.stackapi.customers.wit.com:4000/vms/toby?count=1&cpu=2&ram=512&disk=25'
txt := gui.SetText(b.Box, "SUBDOMAIN", "http://stackapi-api1.stackapi.customers.wit.com:4000/vms/jcarr")
log.Println("generateSubdomain subdomain = ", txt)
log.Println("generateSubdomain END")
}

View File

@ -75,11 +75,7 @@ func addVmsTab(gw *gui.GuiWindow, name string, count int, a *pb.Account) *gui.Ta
human += 1
mh := gui.AddTableTab(gw, name, count, parts, a)
box := mh.Box
okButton := gui.CreateButton(box, a, nil, "Add Virtual Machine", "JUNK", createAddVmBox)
gui.AddButtonToBox(box, okButton)
gui.CreateButton(mh.Box, a, nil, "Add Virtual Machine", "JUNK", createAddVmBox)
return mh
}
@ -102,11 +98,8 @@ func createAddVmBox(b *gui.GuiButton) {
gui.HorizontalBreak(box)
add := gui.CreateButton(box, b.Account, nil, "Add Virtual Machine", "CREATE", nil)
gui.AddButtonToBox(box, add)
cancel := gui.CreateButton(box, b.Account, nil, "Cancel", "CLOSE", nil)
gui.AddButtonToBox(box, cancel)
gui.CreateButton(box, b.Account, nil, "Add Virtual Machine", "CREATE", nil)
gui.CreateButton(box, b.Account, nil, "Cancel", "CLOSE", nil)
}
func createVmBox(gw *gui.GuiWindow, vm *pb.Event_VM) {
@ -126,20 +119,13 @@ func createVmBox(gw *gui.GuiWindow, vm *pb.Event_VM) {
gui.HorizontalBreak(box)
a := gui.CreateButton(box, nil, vm, "Power On", "POWERON", nil)
gui.AddButtonToBox(box, a)
a = gui.CreateButton(box, nil, vm, "Power Off", "POWEROFF", nil)
gui.AddButtonToBox(box, a)
a = gui.CreateButton(box, nil, vm, "Destroy", "DESTROY", nil)
gui.AddButtonToBox(box, a)
a = gui.CreateButton(box, nil, vm, "ping", "PING", runPingClick)
gui.AddButtonToBox(box, a)
a = gui.CreateButton(box, nil, vm, "Console", "XTERM", runTestExecClick)
gui.AddButtonToBox(box, a)
a = gui.CreateButton(box, nil, vm, "Save", "SAVE", nil)
gui.AddButtonToBox(box, a)
a = gui.CreateButton(box, nil, vm, "Done", "DONE", nil)
gui.AddButtonToBox(box, a)
gui.CreateButton(box, nil, vm, "Power On", "POWERON", nil)
gui.CreateButton(box, nil, vm, "Power Off", "POWEROFF", nil)
gui.CreateButton(box, nil, vm, "Destroy", "DESTROY", nil)
gui.CreateButton(box, nil, vm, "ping", "PING", runPingClick)
gui.CreateButton(box, nil, vm, "Console", "XTERM", runTestExecClick)
gui.CreateButton(box, nil, vm, "Save", "SAVE", nil)
gui.CreateButton(box, nil, vm, "Done", "DONE", nil)
}
func runTestHide(b *gui.GuiButton) {