work on add VM

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-26 13:53:54 -07:00
parent 22c687ea4d
commit b57ed75580
3 changed files with 32 additions and 23 deletions

View File

@ -91,6 +91,20 @@ func runPingClick(b *ButtonMap) {
log.Println("runPingClick END") log.Println("runPingClick END")
} }
func runAddVmClick(b *ButtonMap) {
log.Println("runPingClick START")
log.Println("runTestExecClick b.VM", b.VM)
hostname := "localhost"
if (b.VM != nil) {
hostname = b.VM.Hostname
}
spew.Dump(b)
var tmp []string
tmp = append(tmp, "xterm", "-e", "ping " + hostname + ";bash")
runCommand(tmp)
log.Println("runPingClick END")
}
func runTestExecClick(b *ButtonMap) { func runTestExecClick(b *ButtonMap) {
log.Println("runTestExecClick START") log.Println("runTestExecClick START")
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {

37
gui.go
View File

@ -124,21 +124,22 @@ func ErrorWindow(msg1 string, msg2 string) {
// TODO: clean up the text above // TODO: clean up the text above
// TODO: remove this all together going only to main() // TODO: remove this all together going only to main()
func mouseClick(b *ButtonMap) { func mouseClick(b *ButtonMap) {
log.Println("gui.mouseClick() START")
if (b == nil) { if (b == nil) {
log.Println("gui.mouseClick() START b = nil") log.Println("\tgui.mouseClick() START b = nil")
} else { } else {
log.Println("gui.mouseClick() START b.Action =", b.Action) log.Println("\tgui.mouseClick() START b.Action =", b.Action)
if (b.Action == "createAddVmBox") { if (b.Action == "createAddVmBox") {
log.Println("gui.mouseClick() createAddVmBox for b =", b) log.Println("\tgui.mouseClick() createAddVmBox for b =", b)
createAddVmBox(Data.cloudTab, "Create New Virtual Machine") createAddVmBox(Data.cloudTab, "Create New Virtual Machine")
return return
} }
} }
if (Data.MouseClick == nil) { if (Data.MouseClick == nil) {
log.Println("Data.MouseClick() IS nil. NOT DOING ANYTHING") log.Println("\tgui.mouseClick() Data.MouseClick() IS nil. NOT DOING ANYTHING")
} else { } else {
log.Println("\tData.MouseClick() START") log.Println("\tgui.mouseClick() Data.MouseClick() START")
Data.MouseClick(b) Data.MouseClick(b)
} }
} }
@ -154,39 +155,33 @@ func defaultButtonClick(button *ui.Button) {
log.Println("defaultButtonClick() LOOK FOR BUTTON button =", button) log.Println("defaultButtonClick() LOOK FOR BUTTON button =", button)
for key, foo := range Data.AllButtons { for key, foo := range Data.AllButtons {
if (Data.Debug) { if (Data.Debug) {
log.Println("Data.AllButtons =", key, foo) log.Println("defaultButtonClick() Data.AllButtons =", key, foo)
} }
if Data.AllButtons[key].B == button { if Data.AllButtons[key].B == button {
log.Println("\tBUTTON MATCHED") log.Println("\tdefaultButtonClick() BUTTON MATCHED")
// log.Println("\tData.AllButtons[key].Name =", Data.AllButtons[key].Name) // log.Println("\tData.AllButtons[key].Name =", Data.AllButtons[key].Name)
log.Println("\tData.AllButtons[key].Action =", Data.AllButtons[key].Action) log.Println("\tdefaultButtonClick() Data.AllButtons[key].Action =", Data.AllButtons[key].Action)
if Data.AllButtons[key].custom != nil { if Data.AllButtons[key].custom != nil {
log.Println("\tDOING CUSTOM FUNCTION") log.Println("\tdefaultButtonClick() DOING CUSTOM FUNCTION")
var tmp ButtonMap var tmp ButtonMap
tmp = Data.AllButtons[key] tmp = Data.AllButtons[key]
spew.Dump(tmp) spew.Dump(tmp)
Data.AllButtons[key].custom(&tmp) Data.AllButtons[key].custom(&tmp)
return return
} }
if (Data.MouseClick != nil) { mouseClick(&Data.AllButtons[key])
Data.MouseClick(&Data.AllButtons[key])
}
return return
} }
} }
log.Println("\tBUTTON NOT FOUND") log.Println("\tdefaultButtonClick() BUTTON NOT FOUND")
if (Data.Debug) { if (Data.Debug) {
panic("SHOULD NOT HAVE UNMAPPED BUTTONS") panic("defaultButtonClick() SHOULD NOT HAVE UNMAPPED BUTTONS")
}
// still run the mouse click handler if you got here
// TODO: get rid of this to make sure everything is perfectly mapped
if (Data.MouseClick != nil) {
Data.MouseClick(nil)
} }
mouseClick(nil)
} }
func CreateButton(a *pb.Account, vm *pb.Event_VM, func CreateButton(a *pb.Account, vm *pb.Event_VM,
name string, note string, custom func(*ButtonMap)) *ui.Button { name string, action string, custom func(*ButtonMap)) *ui.Button {
newB := ui.NewButton(name) newB := ui.NewButton(name)
newB.OnClicked(defaultButtonClick) newB.OnClicked(defaultButtonClick)
@ -194,7 +189,7 @@ func CreateButton(a *pb.Account, vm *pb.Event_VM,
newmap.B = newB newmap.B = newB
newmap.Account = a newmap.Account = a
newmap.VM = vm newmap.VM = vm
newmap.Action = note newmap.Action = action
newmap.custom = custom newmap.custom = custom
newmap.aTab = Data.CurrentTab newmap.aTab = Data.CurrentTab
Data.AllButtons = append(Data.AllButtons, newmap) Data.AllButtons = append(Data.AllButtons, newmap)

View File

@ -366,8 +366,8 @@ func createAddVmBox(tab *ui.Tab, name string) {
hboxButtons.SetPadded(true) hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false) vbox.Append(hboxButtons, false)
hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine", "CREATE", nil), false) hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine","createAddVmBox", nil), false)
hboxButtons.Append(CreateButton(nil, nil, "Cancel", "DONE", nil), false) hboxButtons.Append(CreateButton(nil, nil, "Cancel", "CLOSE", nil), false)
tab.Append(name, vbox) tab.Append(name, vbox)
tab.SetMargined(0, true) tab.SetMargined(0, true)