2019-05-15 13:03:42 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
2019-05-15 13:03:42 -05:00
|
|
|
func ShowVM() {
|
2019-05-22 21:18:55 -05:00
|
|
|
name := Data.CurrentVM
|
2019-05-24 03:17:14 -05:00
|
|
|
log.Println("ShowVM() START Data.CurrentVM=", Data.CurrentVM)
|
2019-05-15 13:03:42 -05:00
|
|
|
VMwin := ui.NewWindow("VM " + name, 500, 300, false)
|
|
|
|
VMwin.OnClosing(func(*ui.Window) bool {
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
ui.OnShouldQuit(func() bool {
|
|
|
|
VMwin.Destroy()
|
|
|
|
VMwin = nil
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
|
|
|
VMtab := ui.NewTab()
|
|
|
|
VMwin.SetChild(VMtab)
|
|
|
|
VMwin.SetMargined(true)
|
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
createVmBox(VMtab, buttonVmClick, Data.CurrentPbVM)
|
2019-05-24 03:51:37 -05:00
|
|
|
// vmBox := createVmBox(buttonVmClick)
|
|
|
|
// VMtab.Append(Data.CurrentVM, vmBox)
|
|
|
|
// VMtab.SetMargined(0, true)
|
2019-05-15 13:03:42 -05:00
|
|
|
|
|
|
|
VMwin.Show()
|
|
|
|
}
|
2019-05-24 03:17:14 -05:00
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
|
|
|
|
createVmBox(Data.cloudTab, buttonVmClick, Data.CurrentPbVM)
|
2019-05-24 03:51:37 -05:00
|
|
|
// vmBox := createVmBox(Data.cloudTab, buttonVmClick)
|
|
|
|
// Data.cloudTab.Append(name, vmBox)
|
|
|
|
// Data.cloudTab.SetMargined(0, true)
|
2019-05-24 03:17:14 -05:00
|
|
|
}
|
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
// makeEntryBox(box, "hostname:", "blah.foo.org") {
|
|
|
|
func makeEntryBox(hbox *ui.Box, a string, b string) {
|
2019-05-24 03:17:14 -05:00
|
|
|
// Start 'Nickname' vertical box
|
|
|
|
vboxN := ui.NewVerticalBox()
|
|
|
|
vboxN.SetPadded(true)
|
2019-05-24 13:32:47 -05:00
|
|
|
vboxN.Append(ui.NewLabel(a), false)
|
2019-05-24 03:17:14 -05:00
|
|
|
|
|
|
|
entryNick := ui.NewEntry()
|
2019-05-24 13:32:47 -05:00
|
|
|
entryNick.SetText(b)
|
2019-05-24 03:17:14 -05:00
|
|
|
entryNick.SetReadOnly(false)
|
|
|
|
|
|
|
|
vboxN.Append(entryNick, false)
|
|
|
|
|
|
|
|
entryNick.OnChanged(func(*ui.Entry) {
|
2019-05-24 13:32:47 -05:00
|
|
|
log.Println("OK. TEXT WAS CHANGED TO =", entryNick.Text())
|
|
|
|
// Data.AccNick = entryNick.Text()
|
2019-05-24 03:17:14 -05:00
|
|
|
})
|
2019-05-24 13:32:47 -05:00
|
|
|
hbox.Append(vboxN, false)
|
2019-05-24 03:17:14 -05:00
|
|
|
// End 'Nickname' vertical box
|
2019-05-24 13:32:47 -05:00
|
|
|
}
|
2019-05-24 03:17:14 -05:00
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
func createVmBox(tab *ui.Tab, custom func(b *ButtonMap,s string), pbVM *pb.Event_VM) {
|
|
|
|
log.Println("createVmBox() START")
|
|
|
|
log.Println("createVmBox() pbVM.Name", pbVM.Name)
|
|
|
|
spew.Dump(pbVM)
|
|
|
|
if (Data.Debug) {
|
|
|
|
spew.Dump(pbVM)
|
|
|
|
}
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
2019-05-24 03:17:14 -05:00
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
hboxAccount := ui.NewHorizontalBox()
|
|
|
|
hboxAccount.SetPadded(true)
|
|
|
|
vbox.Append(hboxAccount, false)
|
2019-05-24 03:17:14 -05:00
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
// Add hostname entry box
|
|
|
|
makeEntryBox(hboxAccount, "hostname:", pbVM.Hostname)
|
|
|
|
makeEntryBox(hboxAccount, "IPv6:", pbVM.IPv6)
|
|
|
|
makeEntryBox(hboxAccount, "RAM:", string(pbVM.Memory))
|
|
|
|
makeEntryBox(hboxAccount, "CPU:", string(pbVM.Cpus))
|
2019-05-24 03:17:14 -05:00
|
|
|
|
|
|
|
vbox.Append(ui.NewHorizontalSeparator(), false)
|
|
|
|
|
|
|
|
hboxButtons := ui.NewHorizontalBox()
|
|
|
|
hboxButtons.SetPadded(true)
|
|
|
|
vbox.Append(hboxButtons, false)
|
|
|
|
|
2019-05-24 03:51:37 -05:00
|
|
|
hboxButtons.Append(CreateButton("Power On", "POWERON", custom), false)
|
|
|
|
hboxButtons.Append(CreateButton("Power Off", "POWEROFF", custom), false)
|
|
|
|
hboxButtons.Append(CreateButton("Destroy", "DESTROY", custom), false)
|
2019-05-24 13:32:47 -05:00
|
|
|
hboxButtons.Append(CreateButton("Console", "XTERM", runTestExecClick), false)
|
|
|
|
hboxButtons.Append(CreateButton("Done", "DONE", custom), false)
|
2019-05-24 03:51:37 -05:00
|
|
|
|
|
|
|
tab.Append(Data.CurrentVM, vbox)
|
|
|
|
tab.SetMargined(0, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func buttonVmClick(b *ButtonMap, s string) {
|
|
|
|
log.Println("gui.buttonVmClick() START")
|
2019-05-24 11:02:35 -05:00
|
|
|
if (Data.MouseClick != nil) {
|
2019-05-24 03:51:37 -05:00
|
|
|
log.Println("Data.ButtonClick() START")
|
2019-05-24 11:02:35 -05:00
|
|
|
Data.MouseClick(nil)
|
2019-05-24 03:51:37 -05:00
|
|
|
}
|
2019-05-24 03:17:14 -05:00
|
|
|
}
|