login and vm list still works

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-24 19:45:19 -07:00
parent e459ec7fbb
commit 4e946e456f
1 changed files with 20 additions and 31 deletions

51
main.go
View File

@ -154,20 +154,16 @@ func mainButtonClick(b *gui.ButtonMap) {
gui.Data.Current = b.Account
log.Println("mainButtonClick() setting current account = ", b.Account)
log.Println("main() BACK IN CONTROL PANEL CODE (button b.Name =", b.Name, ")")
log.Println("\tb.Name", b.Name)
log.Println("\tb.Note", b.Note)
// log.Println("\tb.AccNick", b.AccNick)
if (b.Note == "BACK") {
log.Println("main() BACK IN CONTROL PANEL CODE (button =", b, ")")
if (b.Action == "BACK") {
gui.Data.State = "splash"
} else if (b.Note == "QUIT") {
} else if (b.Action == "QUIT") {
onExit(nil)
} else if (b.Note == "CREATE") {
} else if (b.Action == "CREATE") {
log.Println("TRY TO ADD A NEW VIRTUAL MACHINE")
log.Println("\tTRIGGER CREATE VM")
gui.Data.State = "CREATE"
// gui.Data.AccNick = b.AccNick
} else if (b.Note == "CONFIG") {
} else if (b.Action == "CONFIG") {
log.Println("TRY TO LOAD DEFAULT CONFIG")
defaultConfig, _ := packrBox.FindString("protobuf-config.json")
log.Println("defaultConfig =", defaultConfig)
@ -179,7 +175,7 @@ func mainButtonClick(b *gui.ButtonMap) {
log.Println("ATTEMTED TO UNMARSHAL err =", err)
spew.Dump(newpb)
gui.Data.State = "done"
} else if (b.Note == "DEBUG") {
} else if (b.Action == "DEBUG") {
log.Println("debug.PrintStack() (SHOULD BE JUST THIS goroutine)")
debug.PrintStack()
@ -188,25 +184,18 @@ func mainButtonClick(b *gui.ButtonMap) {
runtime.Stack(buf, true)
log.Printf("%s", buf)
log.Println("FINISHED FULL STACK DUMP")
} else if (b.Note == "ADD") {
} else if (b.Action == "ADD") {
log.Println("\tSHOULD ADD ACCOUNT HERE")
/*
if (gui.Data.AccNick != "") {
log.Println("\tADDING ACCOUNT HERE")
log.Println("\tADDING ACCOUNT HERE")
log.Println("\tADDING ACCOUNT HERE")
log.Println("\tData.AccNick = ", gui.Data.AccNick)
log.Println("\tData.AccUser = ", gui.Data.AccUser)
log.Println("\tData.AccPass = ", gui.Data.AccPass)
config.Set("accounts." + gui.Data.AccNick + ".username", gui.Data.AccUser)
config.Set("accounts." + gui.Data.AccNick + ".password", gui.Data.AccPass)
config.Set("accounts." + gui.Data.AccNick + ".hostname", "v000185.testing.com.customers.wprod.wit.com")
}
*/
} else if (b.Note == "LOGIN") {
} else if (b.Action == "LOGIN") {
log.Println("\tTRIGGER LOGIN ACCOUNT")
gui.Data.State = "SEND LOGIN"
gui.Data.AccNick = b.AccNick
count := 0
for {
log.Println("Sleep() in buttonClick() gui.Data.State =", gui.Data.State)
@ -221,14 +210,14 @@ func mainButtonClick(b *gui.ButtonMap) {
log.Println("LOGIN WAS OK!")
log.Println("LOGIN WAS OK!")
log.Println("LOGIN WAS OK!")
msg := "On account " + gui.Data.AccNick + "\n"
msg := "On account " + b.Account.Nick + "\n"
gui.ErrorWindow("Login OK", msg)
}
if (currentMessage.Type == pb.Event_FAIL) {
log.Println("LOGIN FAILED")
log.Println("LOGIN FAILED")
log.Println("LOGIN FAILED")
msg := "On account " + gui.Data.AccNick + "\n"
msg := "On account " + b.Account.Nick + "\n"
msg += "pb.Comment = " + currentMessage.Comment + "\n"
msg += "pb.Id = " + fmt.Sprintf("%d", currentMessage.Id) + "\n"
msg += "pb.Email = " + currentMessage.Email + "\n"
@ -248,10 +237,9 @@ func mainButtonClick(b *gui.ButtonMap) {
return
}
}
} else if (b.Note == "SHOW") {
} else if (b.Action == "SHOW") {
log.Println("\tTRIGGER DISPLAY ACCOUNT")
gui.Data.State = "SEND WEBSOCKET"
gui.Data.AccNick = b.AccNick
count := 0
for {
log.Println("Sleep() in buttonClick() gui.Data.State =", gui.Data.State)
@ -265,7 +253,7 @@ func mainButtonClick(b *gui.ButtonMap) {
log.Println("SHOW VMS currentMessage =", currentMessage)
log.Println("SHOW VMS count =", count)
if (count != 0) {
name := "Virtual Machines (" + b.AccNick + ")"
name := "Virtual Machines (" + "FIXME" + ")"
mh := gui.AddVmsTab(name, count)
ReadReceivedData(currentMessage, mh)
}
@ -312,6 +300,7 @@ func getToken() string {
func watchGUI() {
count := 0
/*
// This is how you marshal into JSON from a Protobuf
event := pb.MakeGetEvent()
if (gui.Data.Current == nil) {
@ -319,11 +308,11 @@ func watchGUI() {
} else {
event.Token = gui.Data.Current.Token
}
// event.Token = config.String("accounts." + gui.Data.AccNick + ".token")
marshaler := &jsonpb.Marshaler{}
stuff, _ := marshaler.MarshalToString(event)
log.Println(stuff)
*/
// also:
// var j *bytes.Buffer
@ -339,9 +328,9 @@ func watchGUI() {
time.Sleep(200 * time.Millisecond)
if (gui.Data.State == "SEND WEBSOCKET") {
log.Println("\tTRIGGERING WEBSOCKET HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING WEBSOCKET HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING WEBSOCKET HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING WEBSOCKET HERE on AccNick =")
log.Println("\tTRIGGERING WEBSOCKET HERE on AccNick =")
log.Println("\tTRIGGERING WEBSOCKET HERE on AccNick =")
event := pb.MakeGetEvent()
event.Token = getToken()
@ -351,9 +340,9 @@ func watchGUI() {
gui.Data.State = "READ PROTOBUF"
}
if (gui.Data.State == "SEND LOGIN") {
log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING LOGIN HERE on AccNick =", gui.Data.AccNick)
log.Println("\tTRIGGERING LOGIN HERE on AccNick =")
log.Println("\tTRIGGERING LOGIN HERE on AccNick =")
log.Println("\tTRIGGERING LOGIN HERE on AccNick =")
event := pb.MakeLoginEvent()
event.Token = getToken()