2019-06-01 01:29:46 -05:00
|
|
|
package main
|
|
|
|
|
2019-06-01 04:40:40 -05:00
|
|
|
import "log"
|
2019-06-01 05:24:53 -05:00
|
|
|
import "fmt"
|
2019-06-01 01:29:46 -05:00
|
|
|
|
|
|
|
import "git.wit.com/wit/gui"
|
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
|
|
|
//
|
|
|
|
// THIS IS THE STANDARD VM DISPLAY TABLE
|
|
|
|
// This maps the 'human' indexed cells in the table
|
|
|
|
// to the machine's andlabs/libui values. That way
|
|
|
|
// if you want to work against column 4, then you
|
|
|
|
// can just reference 4 instead of the internal number
|
|
|
|
// which could be anything since TEXTCOLOR, TEXT, BG, etc
|
|
|
|
// fields use between 1 and 3 values internally
|
|
|
|
//
|
2019-06-01 01:45:28 -05:00
|
|
|
func addVmsTab(gw *gui.GuiWindow, name string, count int, a *pb.Account) *gui.TableData {
|
2019-06-01 01:29:46 -05:00
|
|
|
var parts []gui.TableColumnData
|
|
|
|
|
|
|
|
human := 0
|
|
|
|
|
|
|
|
tmp := gui.TableColumnData{}
|
|
|
|
tmp.CellType = "BG"
|
|
|
|
tmp.Heading = "background"
|
|
|
|
tmp.Index = human
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
human += 1
|
|
|
|
|
|
|
|
tmp = gui.TableColumnData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "name"
|
|
|
|
tmp.Index = human
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
human += 1
|
|
|
|
|
|
|
|
tmp = gui.TableColumnData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "hostname"
|
|
|
|
tmp.Index = human
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
human += 1
|
|
|
|
|
|
|
|
tmp = gui.TableColumnData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "IPv6"
|
|
|
|
tmp.Index = human
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
human += 1
|
|
|
|
|
|
|
|
tmp = gui.TableColumnData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "cpus"
|
|
|
|
tmp.Index = human
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
human += 1
|
|
|
|
|
|
|
|
tmp = gui.TableColumnData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "memory"
|
|
|
|
tmp.Index = human
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
human += 1
|
|
|
|
|
|
|
|
tmp = gui.TableColumnData{}
|
|
|
|
tmp.CellType = "BUTTON"
|
|
|
|
tmp.Heading = "Details"
|
|
|
|
tmp.Index = human
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
human += 1
|
|
|
|
|
|
|
|
mh := gui.AddTableTab(gw, name, count, parts, a)
|
2019-06-01 04:40:40 -05:00
|
|
|
|
|
|
|
box := mh.Box
|
2019-06-01 05:24:53 -05:00
|
|
|
okButton := gui.CreateButton(box, a, nil, "Add Virtual Machine", "JUNK", createAddVmBox)
|
2019-06-01 04:40:40 -05:00
|
|
|
gui.AddButtonToBox(box, okButton)
|
|
|
|
|
2019-06-01 01:29:46 -05:00
|
|
|
return mh
|
|
|
|
}
|
2019-06-01 04:40:40 -05:00
|
|
|
|
|
|
|
func createAddVmBox(b *gui.GuiButton) {
|
|
|
|
log.Println("createAddVmBox() START")
|
|
|
|
gw := b.GW
|
|
|
|
log.Println("createAddVmBox() gw =", gw)
|
|
|
|
name := "(" + b.Account.Nick + ")"
|
|
|
|
|
|
|
|
// gw.BoxMap["ADD VM" + name] = box
|
|
|
|
|
2019-06-01 04:58:42 -05:00
|
|
|
box := gui.CreateGenericBox(gw, b, name)
|
2019-06-01 04:40:40 -05:00
|
|
|
|
|
|
|
// Add hostname entry box
|
|
|
|
hostname := gui.MakeEntryHbox(box, "Hostname:", "testhost", true, "Hostname")
|
|
|
|
memory := gui.MakeEntryHbox(box, "Memory:", "512", true, "Memory")
|
|
|
|
disk := gui.MakeEntryHbox(box, "Disk:", "20", true, "Disk")
|
|
|
|
|
|
|
|
log.Println("createAddVmBox() hostname, memory, disk =", hostname, memory, disk)
|
|
|
|
|
|
|
|
gui.HorizontalBreak(box)
|
|
|
|
|
2019-06-01 05:24:53 -05:00
|
|
|
add := gui.CreateButton(box, b.Account, nil, "Add Virtual Machine", "CREATE", nil)
|
|
|
|
gui.AddButtonToBox(box, add)
|
2019-06-01 04:40:40 -05:00
|
|
|
|
2019-06-01 05:24:53 -05:00
|
|
|
cancel := gui.CreateButton(box, b.Account, nil, "Cancel", "CLOSE", nil)
|
|
|
|
gui.AddButtonToBox(box, cancel)
|
|
|
|
}
|
|
|
|
|
|
|
|
func createVmBox(gw *gui.GuiWindow, vm *pb.Event_VM) {
|
|
|
|
log.Println("CreateVmBox() START")
|
|
|
|
log.Println("CreateVmBox() vm.Name =", vm.Name)
|
|
|
|
log.Println("CreateVmBox() gw =", gw)
|
|
|
|
|
|
|
|
box := gui.CreateBox(gw, vm.Name)
|
|
|
|
|
|
|
|
// Add hostname entry box
|
|
|
|
gui.MakeEntryVbox(box, "hostname:", vm.Hostname, true, "Hostname")
|
|
|
|
gui.MakeEntryVbox(box, "IPv6:", vm.IPv6, true, "IPv6")
|
|
|
|
gui.MakeEntryVbox(box, "RAM:", fmt.Sprintf("%d",vm.Memory), true, "Memory")
|
|
|
|
gui.MakeEntryVbox(box, "CPU:", fmt.Sprintf("%d",vm.Cpus), true, "Cpus")
|
|
|
|
gui.MakeEntryVbox(box, "Disk (GB):", fmt.Sprintf("%d",vm.Disk), true, "Disk")
|
|
|
|
gui.MakeEntryVbox(box, "OS Image:", vm.BaseImage, true, "BaseImage")
|
2019-06-01 04:40:40 -05:00
|
|
|
|
|
|
|
/*
|
2019-06-01 05:24:53 -05:00
|
|
|
vbox.Append(ui.NewHorizontalSeparator(), false)
|
|
|
|
|
|
|
|
hboxButtons := ui.NewHorizontalBox()
|
|
|
|
hboxButtons.SetPadded(true)
|
|
|
|
vbox.Append(hboxButtons, false)
|
|
|
|
|
|
|
|
a := CreateButton(box, nil, vm, "Power On", "POWERON", nil)
|
|
|
|
hboxButtons.Append(a.B, false)
|
|
|
|
a = CreateButton(box, nil, vm, "Power Off", "POWEROFF", nil)
|
|
|
|
hboxButtons.Append(a.B, false)
|
|
|
|
a = CreateButton(box, nil, vm, "Destroy", "DESTROY", nil)
|
|
|
|
hboxButtons.Append(a.B, false)
|
|
|
|
a = CreateButton(box, nil, vm, "ping", "PING", runPingClick)
|
|
|
|
hboxButtons.Append(a.B, false)
|
|
|
|
a = CreateButton(box, nil, vm, "Console", "XTERM", runTestExecClick)
|
|
|
|
hboxButtons.Append(a.B, false)
|
|
|
|
a = CreateButton(box, nil, vm, "Save", "SAVE", nil)
|
|
|
|
hboxButtons.Append(a.B, false)
|
|
|
|
a = CreateButton(box, nil, vm, "Done", "DONE", nil)
|
2019-06-01 04:40:40 -05:00
|
|
|
hboxButtons.Append(a.B, false)
|
|
|
|
*/
|
|
|
|
}
|