diff --git a/gui-accountPage.go b/gui-accountPage.go index 5890301..32b5e64 100644 --- a/gui-accountPage.go +++ b/gui-accountPage.go @@ -4,10 +4,12 @@ import "log" import "fmt" import "git.wit.com/wit/gui" +import pb "git.wit.com/wit/witProtobuf" func makeCloudInfoBox(gw *gui.GuiWindow) { log.Println("makeCloudInfoBox() START gw =", gw) + gw.UiTab.Delete(0) // does this make things more or less stable or neither? gw = gui.InitGuiWindow("makeCloudInfoBox() Box23", gw) // TODO: make this text i18n box := gui.HardBox(gw, gui.Yaxis, "Cloud Accounts") @@ -32,7 +34,7 @@ func makeCloudInfoBox(gw *gui.GuiWindow) { gui.NewLabel(vbox, config.Accounts[key].Domain) gui.NewLabel(vbox, config.Accounts[key].Email) - name := "Login " + config.Accounts[key].Nick + name := "Login " // + config.Accounts[key].Nick makeButton(vbox, config.Accounts[key], nil, name, "LOGIN", login) name = "Show " + config.Accounts[key].Nick @@ -45,3 +47,70 @@ func makeCloudInfoBox(gw *gui.GuiWindow) { makeButton(Xbox, nil, nil, "Debug", "DEBUG", debugClick) log.Println("makeCloudInfoBox() END") } + +func createAccount(gw *gui.GuiWindow) { + // if there is not an account, then go to 'make account' + gw = gui.InitGuiWindow("splashClick() Box22", gw) + + box := gui.HardBox(gw, gui.Yaxis, "Create New Account") + + // make a place for someone to enter their subdomain + hardXbox := gui.HardBox(gw, gui.Xaxis, "subdomain test") + makeButton(hardXbox, nil, nil, "Generate a Subdomain", "SUBDOMAIN", generateSubdomain) + gui.NewLabel(hardXbox, "") + + gui.AddEntry(box, "SUBDOMAIN") + // gui.HorizontalBreak(box) + + hardXbox1 := gui.HardBox(gw, gui.Xaxis, "subdomain test") + makeButton(hardXbox1, nil, nil, "Create Account", "ADD", addSubdomainClick) + gui.NewLabel(hardXbox, "") + + log.Println("splashClick() END box =", box) +} + +func addSubdomainClick(b *gui.GuiButton) { + log.Println("addSubdomainClick() START") + subdomain := gui.GetText(b.Box, "SUBDOMAIN") + if (subdomain == "") { + gui.ErrorWindow(b.Box.Window, "Blank Name", "You must have a valid subdomain") + return + } + log.Println("\tsubdomain =", subdomain) + + acc := new(pb.Account) + acc.Nick = subdomain + acc.Domain = subdomain + acc.Username = "jcarr@wit.com" + acc.Email = "jcarr@wit.com" + acc.Password = "badpass" + acc.URL = "http://stackapi-api1.stackapi.customers.dev.wit.com:4000/" + config.Accounts = append(config.Accounts, acc) + + makeCloudInfoBox(b.Box.Window) + State = "done" + log.Println("addSubdomainClick() END") +} + +func generateSubdomain(b *gui.GuiButton) { + log.Println("generateSubdomain START") + if values, ok := b.Values.(*myButtonInfo); ! ok { + log.Println("\tvalues.Accounts error") + } else { + log.Println("\tvalues.Accounts =", values.Accounts) + log.Println("\tvalues.Name =", values.Name) + } + // use this way? + // values, _ := b.Values.(*myButtonInfo) + + if (b == nil) { + log.Println("generateSubdomain ERROR b == nil") + return + } + // subdomain.SetText("cust00013.wit.dev") + +// 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") +} diff --git a/gui-splashPage.go b/gui-splashPage.go index 3cb2bda..21542bf 100644 --- a/gui-splashPage.go +++ b/gui-splashPage.go @@ -8,7 +8,7 @@ import "git.wit.com/wit/gui" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" -import pb "git.wit.com/wit/witProtobuf" +// import pb "git.wit.com/wit/witProtobuf" func showSplashBox(gw *gui.GuiWindow) *gui.GuiBox { log.Println("ShowSplashBox() START") @@ -72,10 +72,10 @@ func splashClick(b *gui.GuiButton) { makeCloudInfoBox(gw) return } - // if there is not an account, then go to 'make account' - gw = gui.InitGuiWindow("splashClick() Box22", gw) - // gw.UiTab.Hide() // Hide or Delete ? + gw.UiTab.Delete(0) // does this make things more or less stable or neither? + createAccount(gw) + /* box := gui.HardBox(gw, gui.Yaxis, "Create New Account") @@ -91,51 +91,6 @@ func splashClick(b *gui.GuiButton) { makeButton(hardXbox1, nil, nil, "Create Account", "ADD", addSubdomainClick) gui.NewLabel(hardXbox, "") - log.Println("splashClick() END box =", box) -} - -func addSubdomainClick(b *gui.GuiButton) { - log.Println("addSubdomainClick() START") - subdomain := gui.GetText(b.Box, "SUBDOMAIN") - if (subdomain == "") { - gui.ErrorWindow(b.Box.Window, "Blank Name", "You must have a valid subdomain") - return - } - log.Println("\tsubdomain =", subdomain) - - acc := new(pb.Account) - acc.Nick = subdomain - acc.Domain = subdomain - acc.Username = "jcarr@wit.com" - acc.Email = "jcarr@wit.com" - acc.Password = "badpass" - acc.URL = "http://stackapi-api1.stackapi.customers.dev.wit.com:4000/" - config.Accounts = append(config.Accounts, acc) - - makeCloudInfoBox(b.Box.Window) - State = "done" - log.Println("addSubdomainClick() END") -} - -func generateSubdomain(b *gui.GuiButton) { - log.Println("generateSubdomain START") - if values, ok := b.Values.(*myButtonInfo); ! ok { - log.Println("\tvalues.Accounts error") - } else { - log.Println("\tvalues.Accounts =", values.Accounts) - log.Println("\tvalues.Name =", values.Name) - } - // use this way? - // values, _ := b.Values.(*myButtonInfo) - - if (b == nil) { - log.Println("generateSubdomain ERROR b == nil") - return - } - // subdomain.SetText("cust00013.wit.dev") - -// 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") + */ + log.Println("splashClick() END") }