package main import "log" import "fmt" import "git.wit.org/wit/gui" import pb "git.wit.org/jcarr/witProtobuf" func makeCloudInfoBox(gw *gui.GuiWindow) { log.Println("makeCloudInfoBox() START gw =", gw) // TODO: make this text i18n box := gui.InitWindow(gw, "Cloud Accounts", gui.Yaxis) if (box == nil) { log.Println("gui.InitWindow() FAILED") return } gw = box.Window log.Println("makeCloudInfoBox() START GW IS NOW: gw =", gw) log.Println("makeCloudInfoBox() box =", box) yBox := gui.HardBox(gw, gui.Yaxis, "hostname test") gui.NewLabel(yBox, "Hostname:") tmp := config.Hostname + " (" + config.IPv6 + ")" gui.MakeEntryHbox(yBox, "hostname:", tmp, true, "Hostname") for key, a := range config.Accounts { vbox := gui.NewBox(box, gui.Xaxis, fmt.Sprintf("ACCOUNT %d", key)) log.Println("account = ", key, a) log.Println("Accounts[key] = ", config.Accounts[key]) if config.Accounts[key] == nil { continue; } log.Println("account.Nick = ", config.Accounts[key].Nick) log.Println("account.Username = ", config.Accounts[key].Username) log.Println("account.Token = ", config.Accounts[key].Token) // name := "Login" // + config.Accounts[key].Nick // makeButton(vbox, config.Accounts[key], nil, name, "LOGIN", login) // name = "Show " + config.Accounts[key].Nick // name = "Show" // makeButton(vbox, config.Accounts[key], nil, name, "SHOW", showAccountClick) // name = "Configure" makeButton(vbox, config.Accounts[key], nil, "Configure", "JUNK", showAccountClick) makeButton(vbox, config.Accounts[key], nil, "Delete", "JUNK", func (*gui.GuiButton) { config.Accounts[key] = config.Accounts[len(config.Accounts)-1] config.Accounts = config.Accounts[:len(config.Accounts)-1] }) name := config.Accounts[key].Nick + " (" + config.Accounts[key].Domain + ")" gui.NewLabel(vbox, name) } Xbox := gui.HardBox(box.Window, gui.Xaxis, "subdomain test") makeButton(Xbox, nil, nil, "Add Account", "ADD TAB", func (*gui.GuiButton) { log.Println("makeCloudInfoBox() Add Account") createAccount(box.Window) }) makeButton(Xbox, nil, nil, "Quit", "JUNK", func (*gui.GuiButton) { onExit(nil) }) makeButton(Xbox, nil, nil, "Debug", "DEBUG", debugClick) log.Println("makeCloudInfoBox() END") } func createAccount(gw *gui.GuiWindow) { box := gui.InitWindow(gw, "Create New Account", gui.Yaxis) if (box == nil) { return } gw = box.Window // 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.wprod.wit.org: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") txt := gui.SetText(b.Box, "SUBDOMAIN", "yourname.customers.wprod.wit.org") log.Println("generateSubdomain subdomain = ", txt) log.Println("generateSubdomain END") }