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
|
|
|
|
2021-08-09 00:35:28 -05:00
|
|
|
import "git.wit.org/wit/gui"
|
|
|
|
import pb "git.wit.org/wit/witProtobuf"
|
2019-06-01 01:29:46 -05:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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-13 14:29:00 -05:00
|
|
|
// func addVmsTab(gw *gui.GuiWindow, name string, count int, a *pb.Account) *gui.TableData {
|
|
|
|
func addVmsTab(box *gui.GuiBox, 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
|
|
|
|
|
2019-06-13 20:53:03 -05:00
|
|
|
mh := gui.AddTableBox(box, name, count, parts)
|
|
|
|
xBox := gui.HardBox(box.Window, gui.Xaxis, "below mh box")
|
2019-06-16 14:02:03 -05:00
|
|
|
gw := box.Window
|
2019-06-04 18:14:54 -05:00
|
|
|
|
2019-06-13 20:53:03 -05:00
|
|
|
makeButton(xBox, a, nil, "Add Virtual Machine", "JUNK", createAddVmBox)
|
|
|
|
makeButton(xBox, a, nil, "Login", "JUNK", login)
|
2019-06-16 14:02:03 -05:00
|
|
|
makeButton(xBox, a, nil, "Logout", "JUNK", func (*gui.GuiButton) {
|
|
|
|
gui.DeleteWindow(name)
|
|
|
|
makeCloudInfoBox(gw)
|
|
|
|
})
|
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")
|
2019-06-02 17:19:36 -05:00
|
|
|
gw := b.Box.Window
|
2019-06-01 04:40:40 -05:00
|
|
|
log.Println("createAddVmBox() gw =", gw)
|
2019-06-02 22:50:16 -05:00
|
|
|
values, _ := b.Values.(*myButtonInfo)
|
|
|
|
name := "(" + values.Account.Nick + ")"
|
2019-06-01 04:40:40 -05:00
|
|
|
|
|
|
|
// gw.BoxMap["ADD VM" + name] = box
|
|
|
|
|
2019-06-02 17:19:36 -05:00
|
|
|
txt := "ADD VM " + name
|
2019-06-13 14:08:16 -05:00
|
|
|
box := gui.InitWindow(gw, txt, gui.Yaxis)
|
|
|
|
if (box == nil) {
|
|
|
|
log.Println("initWindow() FAILED")
|
|
|
|
return
|
|
|
|
}
|
2019-06-13 15:09:24 -05:00
|
|
|
gw = box.Window
|
2019-06-03 19:05:36 -05:00
|
|
|
box = gui.HardBox(gw, gui.Xaxis, txt)
|
2019-06-03 02:49:51 -05:00
|
|
|
// box := gui.AddGenericBox(gw, 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)
|
|
|
|
|
2019-06-03 19:05:36 -05:00
|
|
|
// gui.HorizontalBreak(box)
|
|
|
|
box = gui.HardBox(gw, gui.Xaxis, txt)
|
2019-06-01 04:40:40 -05:00
|
|
|
|
2019-06-03 19:05:36 -05:00
|
|
|
makeButton(box, values.Account, nil, "Add Virtual Machine", "CREATE", createVmClick)
|
2019-06-16 14:02:03 -05:00
|
|
|
makeButton(box, values.Account, nil, "Cancel", "CLOSE", func (*gui.GuiButton) {
|
|
|
|
gui.DeleteWindow(txt)
|
|
|
|
})
|
2019-06-01 05:24:53 -05:00
|
|
|
}
|
|
|
|
|
2019-06-02 17:19:36 -05:00
|
|
|
func showVmMouseClick(b *gui.GuiButton) {
|
|
|
|
log.Println("showVmMouseClick() START b.Box.Window =", b.Box.Window)
|
2019-06-02 22:50:16 -05:00
|
|
|
values, _ := b.Values.(*myButtonInfo)
|
|
|
|
createVmBox(b.Box.Window, values.VM)
|
2019-06-02 17:19:36 -05:00
|
|
|
log.Println("showVmMouseClick() END")
|
|
|
|
}
|
|
|
|
|
2019-06-01 05:24:53 -05:00
|
|
|
func createVmBox(gw *gui.GuiWindow, vm *pb.Event_VM) {
|
2019-06-03 02:49:51 -05:00
|
|
|
log.Println("CreateVmBox() START vm.Name =", vm.Name)
|
2019-06-01 05:24:53 -05:00
|
|
|
|
2019-06-03 16:53:45 -05:00
|
|
|
txt := "VM " + vm.Name
|
2019-06-13 14:08:16 -05:00
|
|
|
// TODO: make this text i18n
|
|
|
|
box := gui.InitWindow(gw, txt, gui.Yaxis)
|
|
|
|
if (box == nil) {
|
|
|
|
log.Println("initWindow() FAILED")
|
|
|
|
return
|
|
|
|
}
|
2019-06-13 15:09:24 -05:00
|
|
|
gw = box.Window
|
2019-06-03 16:53:45 -05:00
|
|
|
box = gui.HardBox(gw, gui.Xaxis, txt)
|
2019-06-01 05:24:53 -05:00
|
|
|
|
|
|
|
// Add hostname entry box
|
2019-06-28 14:06:53 -05:00
|
|
|
gui.MakeEntryVbox(box, "hostname:", vm.Hostname, false, "Hostname")
|
|
|
|
gui.MakeEntryVbox(box, "IPv6:", vm.IPv6, false, "IPv6")
|
|
|
|
gui.MakeEntryVbox(box, "RAM:", fmt.Sprintf("%d",vm.Memory), false, "Memory")
|
|
|
|
gui.MakeEntryVbox(box, "CPU:", fmt.Sprintf("%d",vm.Cpus), false, "Cpus")
|
2019-06-01 05:24:53 -05:00
|
|
|
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-03 02:49:51 -05:00
|
|
|
box = gui.HardBox(gw, gui.Xaxis, "VM BUTTONS")
|
2019-06-02 08:40:19 -05:00
|
|
|
|
2019-06-02 22:50:16 -05:00
|
|
|
makeButton(box, nil, vm, "Power On", "POWERON", nil)
|
|
|
|
makeButton(box, nil, vm, "Power Off", "POWEROFF", nil)
|
|
|
|
makeButton(box, nil, vm, "Destroy", "DESTROY", nil)
|
|
|
|
makeButton(box, nil, vm, "ping", "PING", runPingClick)
|
|
|
|
makeButton(box, nil, vm, "Console", "XTERM", runTestExecClick)
|
|
|
|
makeButton(box, nil, vm, "Save", "SAVE", nil)
|
2019-06-15 00:07:29 -05:00
|
|
|
makeButton(box, nil, vm, "Close", "JUNK", func (*gui.GuiButton) {
|
|
|
|
gui.DeleteWindow(txt)
|
|
|
|
})
|
2019-06-02 08:40:19 -05:00
|
|
|
}
|