124 lines
3.8 KiB
Go
124 lines
3.8 KiB
Go
package main
|
|
|
|
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)
|
|
|
|
// 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)
|
|
|
|
gui.NewLabel(box, "Hostname:")
|
|
|
|
tmp := config.Hostname + " (" + config.IPv6 + ")"
|
|
gui.MakeEntryHbox(box, "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])
|
|
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", "CONFIG", showAccountClick)
|
|
|
|
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", "QUIT", 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.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")
|
|
|
|
txt := gui.SetText(b.Box, "SUBDOMAIN", "yourname.customers.wprod.wit.com")
|
|
log.Println("generateSubdomain subdomain = ", txt)
|
|
log.Println("generateSubdomain END")
|
|
}
|