2019-06-01 19:53:30 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
2019-06-03 02:20:11 -05:00
|
|
|
import "fmt"
|
2019-06-01 19:53:30 -05:00
|
|
|
|
|
|
|
import "git.wit.com/wit/gui"
|
2019-06-03 16:40:40 -05:00
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
2019-06-01 19:53:30 -05:00
|
|
|
|
|
|
|
func makeCloudInfoBox(gw *gui.GuiWindow) {
|
|
|
|
log.Println("makeCloudInfoBox() START gw =", gw)
|
2019-06-02 13:52:29 -05:00
|
|
|
|
2019-06-03 16:40:40 -05:00
|
|
|
gw.UiTab.Delete(0) // does this make things more or less stable or neither?
|
2019-06-04 02:56:36 -05:00
|
|
|
gw.Name = "Cloud Accounts"
|
|
|
|
gw = gui.InitGuiWindow(gw)
|
2019-06-03 15:58:33 -05:00
|
|
|
// TODO: make this text i18n
|
|
|
|
box := gui.HardBox(gw, gui.Yaxis, "Cloud Accounts")
|
2019-06-01 19:53:30 -05:00
|
|
|
|
|
|
|
log.Println("makeCloudInfoBox() START GW IS NOW: gw =", gw)
|
|
|
|
log.Println("makeCloudInfoBox() box =", box)
|
|
|
|
|
|
|
|
gui.NewLabel(box, "Hostname:")
|
|
|
|
|
2019-06-02 17:50:11 -05:00
|
|
|
tmp := config.Hostname + " (" + config.IPv6 + ")"
|
2019-06-01 19:53:30 -05:00
|
|
|
gui.MakeEntryHbox(box, "hostname:", tmp, true, "Hostname")
|
|
|
|
|
2019-06-03 02:49:51 -05:00
|
|
|
// box = gui.HardBox(gw, gui.Yaxis)
|
2019-06-01 19:53:30 -05:00
|
|
|
for key, a := range config.Accounts {
|
2019-06-03 02:49:51 -05:00
|
|
|
vbox := gui.NewBox(box, gui.Xaxis, fmt.Sprintf("ACCOUNT %d", key))
|
2019-06-01 19:53:30 -05:00
|
|
|
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)
|
|
|
|
|
2019-06-04 18:14:54 -05:00
|
|
|
// name := "Login" // + config.Accounts[key].Nick
|
|
|
|
// makeButton(vbox, config.Accounts[key], nil, name, "LOGIN", login)
|
2019-06-01 19:53:30 -05:00
|
|
|
|
2019-06-04 16:09:43 -05:00
|
|
|
// name = "Show " + config.Accounts[key].Nick
|
2019-06-04 18:14:54 -05:00
|
|
|
// name = "Show"
|
|
|
|
// makeButton(vbox, config.Accounts[key], nil, name, "SHOW", showAccountClick)
|
2019-06-04 16:09:43 -05:00
|
|
|
|
2019-06-04 18:14:54 -05:00
|
|
|
// name = "Configure"
|
|
|
|
makeButton(vbox, config.Accounts[key], nil, "Configure", "CONFIG", showAccountClick)
|
2019-06-04 16:09:43 -05:00
|
|
|
|
2019-06-04 18:14:54 -05:00
|
|
|
name := config.Accounts[key].Nick + " (" + config.Accounts[key].Domain + ")"
|
|
|
|
gui.NewLabel(vbox, name)
|
2019-06-01 19:53:30 -05:00
|
|
|
}
|
|
|
|
|
2019-06-03 15:58:33 -05:00
|
|
|
Xbox := gui.HardBox(gw, gui.Xaxis, "subdomain test")
|
2019-06-03 17:45:25 -05:00
|
|
|
makeButton(Xbox, nil, nil, "Add Account", "ADD TAB", func (*gui.GuiButton) {
|
|
|
|
log.Println("makeCloudInfoBox() Add Account")
|
|
|
|
createAccount(gw)
|
|
|
|
})
|
2019-06-03 15:58:33 -05:00
|
|
|
makeButton(Xbox, nil, nil, "Quit", "QUIT", nil)
|
|
|
|
makeButton(Xbox, nil, nil, "Debug", "DEBUG", debugClick)
|
2019-06-01 19:53:30 -05:00
|
|
|
log.Println("makeCloudInfoBox() END")
|
|
|
|
}
|
2019-06-03 16:40:40 -05:00
|
|
|
|
2019-06-04 00:04:54 -05:00
|
|
|
// func createAccount(gw *gui.GuiWindow) {
|
2019-06-03 20:49:58 -05:00
|
|
|
func initWindow(gw *gui.GuiWindow, name string, axis int) *gui.GuiBox {
|
2019-06-03 19:50:52 -05:00
|
|
|
window := gui.Data.WindowMap[name]
|
2019-06-03 17:45:25 -05:00
|
|
|
if (window != nil) {
|
|
|
|
box := window.BoxMap["MAINBOX"]
|
2019-06-03 19:50:52 -05:00
|
|
|
log.Println("initWindow() tab already exists name =", name)
|
|
|
|
gui.ErrorWindow(box.Window, "Create Window Error", "Window " + name + " already exists")
|
|
|
|
return nil
|
2019-06-03 17:45:25 -05:00
|
|
|
}
|
|
|
|
|
2019-06-03 16:40:40 -05:00
|
|
|
// if there is not an account, then go to 'make account'
|
2019-06-04 02:56:36 -05:00
|
|
|
gw.Name = name
|
|
|
|
newWindow := gui.InitGuiWindow(gw)
|
2019-06-03 20:49:58 -05:00
|
|
|
|
|
|
|
var box *gui.GuiBox
|
|
|
|
if (axis == gui.Xaxis) {
|
|
|
|
box = gui.HardBox(newWindow, gui.Xaxis, name)
|
|
|
|
} else {
|
|
|
|
box = gui.HardBox(newWindow, gui.Yaxis, name)
|
|
|
|
}
|
|
|
|
return box
|
2019-06-03 19:50:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func createAccount(gw *gui.GuiWindow) {
|
2019-06-03 20:49:58 -05:00
|
|
|
box := initWindow(gw, "Create New Account", gui.Yaxis)
|
|
|
|
if (box == nil) { return }
|
2019-06-03 16:40:40 -05:00
|
|
|
|
2019-06-04 00:00:37 -05:00
|
|
|
gw = box.Window
|
2019-06-03 16:40:40 -05:00
|
|
|
|
|
|
|
// 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"
|
2019-06-03 19:50:52 -05:00
|
|
|
acc.URL = "http://stackapi-api1.stackapi.customers.wprod.wit.com:4000/"
|
2019-06-03 16:40:40 -05:00
|
|
|
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")
|
|
|
|
|
2019-06-03 19:50:52 -05:00
|
|
|
txt := gui.SetText(b.Box, "SUBDOMAIN", "yourname.customers.wprod.wit.com")
|
2019-06-03 16:40:40 -05:00
|
|
|
log.Println("generateSubdomain subdomain = ", txt)
|
|
|
|
log.Println("generateSubdomain END")
|
|
|
|
}
|