start moving vm logic back into here

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-31 23:29:46 -07:00
parent 38bb9d0b16
commit 3b746c5d72
3 changed files with 91 additions and 3 deletions

View File

@ -64,3 +64,8 @@ build-darwin:
build-windows:
env GOOS=windows GOARCH=amd64 go build
# git branch devel
# git push --set-upstream origin devel
devel:
git checkout devel

10
main.go
View File

@ -312,7 +312,9 @@ func mainMouseClick(b *gui.GuiButton) {
time.Sleep(200 * time.Millisecond)
if (gui.Data.State == "NEW PROTOBUF") {
if (currentMessage == nil) {
gui.SocketError(gw)
gui.ErrorWindow(gw,
"There was a socket error",
"More detailed information can be shown here.")
gui.Data.State = "done"
} else {
log.Println("LOGIN currentMessage =", currentMessage)
@ -381,7 +383,9 @@ func mainMouseClick(b *gui.GuiButton) {
time.Sleep(200 * time.Millisecond)
if (gui.Data.State == "NEW PROTOBUF") {
if (currentMessage == nil) {
gui.SocketError(gw)
gui.ErrorWindow(gw,
"There was a socket error",
"More detailed information can be shown here.")
gui.Data.State = "done"
} else {
count := countVMS(currentMessage)
@ -390,7 +394,7 @@ func mainMouseClick(b *gui.GuiButton) {
// TODO: make sure login worked & the account really has zero VMs
// if (count != 0) {
name := "Virtual Machines (" + b.Account.Nick + ")"
mh := gui.AddVmsTab(gw, name, count, b.Account)
mh := AddVmsTab(gw, name, count, b.Account)
ReadReceivedData(currentMessage, mh, b.GW)
// }
currentMessage = nil

79
vm.go Normal file
View File

@ -0,0 +1,79 @@
package main
// import "log"
// import "fmt"
// import "github.com/andlabs/ui"
// import _ "github.com/andlabs/ui/winmanifest"
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
//
func AddVmsTab(gw *gui.GuiWindow, name string, count int, a *pb.Account) *gui.TableData {
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)
return mh
}