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
|
|
|
|
2021-08-09 00:35:28 -05:00
|
|
|
import "git.wit.org/wit/gui"
|
2021-08-09 00:45:36 -05:00
|
|
|
import pb "git.wit.org/jcarr/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 15:58:33 -05:00
|
|
|
// TODO: make this text i18n
|
2019-06-13 14:08:16 -05:00
|
|
|
box := gui.InitWindow(gw, "Cloud Accounts", gui.Yaxis)
|
|
|
|
if (box == nil) {
|
|
|
|
log.Println("gui.InitWindow() FAILED")
|
|
|
|
return
|
|
|
|
}
|
2019-06-13 15:09:24 -05:00
|
|
|
gw = box.Window
|
2019-06-01 19:53:30 -05:00
|
|
|
|
|
|
|
log.Println("makeCloudInfoBox() START GW IS NOW: gw =", gw)
|
|
|
|
log.Println("makeCloudInfoBox() box =", box)
|
|
|
|
|
2019-06-13 20:53:03 -05:00
|
|
|
yBox := gui.HardBox(gw, gui.Yaxis, "hostname test")
|
|
|
|
gui.NewLabel(yBox, "Hostname:")
|
2019-06-01 19:53:30 -05:00
|
|
|
|
2019-06-02 17:50:11 -05:00
|
|
|
tmp := config.Hostname + " (" + config.IPv6 + ")"
|
2019-06-13 20:53:03 -05:00
|
|
|
gui.MakeEntryHbox(yBox, "hostname:", tmp, true, "Hostname")
|
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])
|
2019-06-28 16:06:15 -05:00
|
|
|
if config.Accounts[key] == nil {
|
|
|
|
continue;
|
|
|
|
}
|
2019-06-01 19:53:30 -05:00
|
|
|
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"
|
2019-06-13 18:37:17 -05:00
|
|
|
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]
|
|
|
|
})
|
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-13 15:09:24 -05:00
|
|
|
Xbox := gui.HardBox(box.Window, 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")
|
2019-06-13 15:09:24 -05:00
|
|
|
createAccount(box.Window)
|
2019-06-03 17:45:25 -05:00
|
|
|
})
|
2019-06-15 02:04:05 -05:00
|
|
|
makeButton(Xbox, nil, nil, "Quit", "JUNK", func (*gui.GuiButton) {
|
2019-06-13 18:37:17 -05:00
|
|
|
onExit(nil)
|
|
|
|
})
|
2019-06-03 15:58:33 -05:00
|
|
|
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-03 19:50:52 -05:00
|
|
|
func createAccount(gw *gui.GuiWindow) {
|
2019-06-13 14:08:16 -05:00
|
|
|
box := gui.InitWindow(gw, "Create New Account", gui.Yaxis)
|
2019-06-03 20:49:58 -05:00
|
|
|
if (box == nil) { return }
|
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"
|
2021-08-09 00:35:28 -05:00
|
|
|
acc.URL = "http://stackapi-api1.stackapi.customers.wprod.wit.org: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")
|
|
|
|
|
2021-08-09 00:35:28 -05:00
|
|
|
txt := gui.SetText(b.Box, "SUBDOMAIN", "yourname.customers.wprod.wit.org")
|
2019-06-03 16:40:40 -05:00
|
|
|
log.Println("generateSubdomain subdomain = ", txt)
|
|
|
|
log.Println("generateSubdomain END")
|
|
|
|
}
|