2019-05-10 01:25:27 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
2019-05-10 03:27:28 -05:00
|
|
|
import "time"
|
|
|
|
import "fmt"
|
2019-05-12 02:01:23 -05:00
|
|
|
import "runtime/debug"
|
|
|
|
import "runtime"
|
2019-05-10 01:25:27 -05:00
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
import "github.com/gookit/config"
|
2019-05-10 01:25:27 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
2019-05-10 03:27:28 -05:00
|
|
|
import "git.wit.com/wit/gui"
|
|
|
|
|
2019-05-12 20:49:59 -05:00
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
2019-05-10 01:25:27 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2019-05-11 22:57:06 -05:00
|
|
|
var cloudwin *ui.Window
|
|
|
|
var cloudtab *ui.Tab
|
2019-05-10 03:21:32 -05:00
|
|
|
var tabcount int
|
2019-05-10 01:25:27 -05:00
|
|
|
|
|
|
|
func makeCloudInfoBox() ui.Control {
|
|
|
|
hbox := ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
hbox.Append(vbox, false)
|
|
|
|
|
|
|
|
vbox.Append(ui.NewColorButton(), false)
|
|
|
|
|
2019-05-12 02:01:23 -05:00
|
|
|
vbox.Append(ui.NewLabel("Debugging:"), false)
|
2019-05-10 01:25:27 -05:00
|
|
|
|
2019-05-10 03:35:20 -05:00
|
|
|
// ATTEMPT TO ADD THE TABLE HERE
|
|
|
|
add2button := ui.NewButton("Add a Test Table")
|
|
|
|
add2button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("send over socket")
|
2019-05-12 02:01:23 -05:00
|
|
|
addTableTab()
|
2019-05-10 03:35:20 -05:00
|
|
|
})
|
|
|
|
vbox.Append(add2button, false)
|
|
|
|
// ATTEMPT TO ADD THE TABLE HERE END
|
2019-05-11 15:20:51 -05:00
|
|
|
|
2019-05-11 09:53:32 -05:00
|
|
|
hbox.Append(ui.NewVerticalSeparator(), false)
|
|
|
|
|
2019-05-11 12:55:37 -05:00
|
|
|
// Send a test protobuf Event to localhost
|
2019-05-11 09:53:32 -05:00
|
|
|
add3button := ui.NewButton("Add buf to chann")
|
|
|
|
add3button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("add protobuf event to the channel")
|
2019-05-12 14:32:29 -05:00
|
|
|
addSampleEvent()
|
2019-05-11 09:53:32 -05:00
|
|
|
})
|
|
|
|
vbox.Append(add3button, false)
|
|
|
|
|
2019-05-12 20:49:59 -05:00
|
|
|
add4button := ui.NewButton("Add Demo Event")
|
|
|
|
add4button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("add demo protobuf event to the channel")
|
|
|
|
msg := pb.CreateSampleEvent()
|
|
|
|
msg.Name = "generated in addSampleEvent()"
|
|
|
|
msg.Type = pb.Event_DEMO
|
|
|
|
addEvent(msg)
|
|
|
|
})
|
|
|
|
vbox.Append(add4button, false)
|
|
|
|
|
2019-05-11 15:20:51 -05:00
|
|
|
// Send a protobuf Event over the WIT socket
|
|
|
|
add5button := ui.NewButton("Send protobuf to localhost")
|
|
|
|
add5button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("sent a Marshal'd protobuf to a localhost socket")
|
|
|
|
sendDataToDest()
|
|
|
|
})
|
|
|
|
vbox.Append(add5button, false)
|
|
|
|
|
2019-05-12 01:21:57 -05:00
|
|
|
// Send a protobuf over a gorilla websocket
|
|
|
|
add6button := ui.NewButton("gorillaSendProtobuf()")
|
|
|
|
add6button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("gorillaSendProtobuf()")
|
|
|
|
gorillaSendProtobuf()
|
|
|
|
})
|
|
|
|
vbox.Append(add6button, false)
|
|
|
|
|
2019-05-12 02:01:23 -05:00
|
|
|
// debug all the golang goroutines
|
|
|
|
add7button := ui.NewButton("debug.PrintStack()")
|
|
|
|
add7button.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("debug.PrintStack() (SHOULD BE JUST THIS goroutine)")
|
|
|
|
debug.PrintStack()
|
|
|
|
|
|
|
|
log.Println("ATTEMPT FULL STACK DUMP")
|
|
|
|
log.Println("ATTEMPT FULL STACK DUMP")
|
|
|
|
log.Println("ATTEMPT FULL STACK DUMP")
|
|
|
|
buf := make([]byte, 1<<16)
|
|
|
|
runtime.Stack(buf, true)
|
|
|
|
fmt.Printf("%s", buf)
|
|
|
|
})
|
|
|
|
vbox.Append(add7button, false)
|
|
|
|
|
2019-05-10 01:25:27 -05:00
|
|
|
hbox.Append(ui.NewVerticalSeparator(), false)
|
|
|
|
|
|
|
|
vbox = ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
hbox.Append(vbox, true)
|
|
|
|
|
|
|
|
grid := ui.NewGrid()
|
|
|
|
grid.SetPadded(true)
|
|
|
|
vbox.Append(grid, false)
|
|
|
|
|
|
|
|
msggrid := ui.NewGrid()
|
|
|
|
msggrid.SetPadded(true)
|
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
entryForm := ui.NewForm()
|
|
|
|
entryForm.SetPadded(true)
|
|
|
|
vbox.Append(entryForm, false)
|
|
|
|
|
|
|
|
hostnameEntry := ui.NewEntry()
|
|
|
|
entryForm.Append("hostname:", hostnameEntry, false)
|
|
|
|
hostnameEntry.SetText("librem15.lab.wit.com")
|
|
|
|
|
|
|
|
IPv6entry := ui.NewEntry()
|
|
|
|
entryForm.Append("IPv6:", IPv6entry, false)
|
|
|
|
IPv6entry.SetText("2604:bbc0:3:3:0:10:0:1003")
|
|
|
|
|
2019-05-10 01:25:27 -05:00
|
|
|
return hbox
|
|
|
|
}
|
2019-05-10 03:21:32 -05:00
|
|
|
|
2019-05-12 20:49:59 -05:00
|
|
|
// can not pass any args to this (?)
|
2019-05-10 03:21:32 -05:00
|
|
|
func setupCloudUI() {
|
2019-05-11 22:57:06 -05:00
|
|
|
cloudwin = ui.NewWindow("Cloud Control Panel", config.Int("width"), config.Int("height"), false)
|
|
|
|
cloudwin.OnClosing(func(*ui.Window) bool {
|
2019-05-10 03:21:32 -05:00
|
|
|
ui.Quit()
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
ui.OnShouldQuit(func() bool {
|
2019-05-11 22:57:06 -05:00
|
|
|
cloudwin.Destroy()
|
2019-05-10 03:21:32 -05:00
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
2019-05-11 22:57:06 -05:00
|
|
|
cloudtab = ui.NewTab()
|
|
|
|
cloudwin.SetChild(cloudtab)
|
|
|
|
cloudwin.SetMargined(true)
|
2019-05-10 03:21:32 -05:00
|
|
|
|
|
|
|
tabcount = 0
|
2019-05-11 22:57:06 -05:00
|
|
|
cloudtab.Append("Cloud Info", makeCloudInfoBox())
|
|
|
|
cloudtab.SetMargined(tabcount, true)
|
2019-05-10 03:21:32 -05:00
|
|
|
|
2019-05-11 22:57:06 -05:00
|
|
|
cloudwin.Show()
|
2019-05-10 03:21:32 -05:00
|
|
|
}
|
2019-05-10 03:27:28 -05:00
|
|
|
|
2019-05-12 15:08:26 -05:00
|
|
|
func addTableTab() {
|
2019-05-12 14:55:11 -05:00
|
|
|
var parts []gui.InputData
|
|
|
|
|
2019-05-12 15:08:26 -05:00
|
|
|
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
2019-05-12 14:55:11 -05:00
|
|
|
log.Println(key, foo)
|
|
|
|
|
|
|
|
var b gui.InputData
|
|
|
|
b.CellType = foo
|
|
|
|
b.Heading = fmt.Sprintf("heading%d", key)
|
|
|
|
parts = append(parts, b)
|
|
|
|
}
|
|
|
|
|
2019-05-12 15:08:26 -05:00
|
|
|
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
|
|
|
time.Sleep(1 * 1000 * 1000 * 1000)
|
|
|
|
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
2019-05-12 14:55:11 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 15:08:26 -05:00
|
|
|
func addProtobufTab() {
|
2019-05-10 03:27:28 -05:00
|
|
|
var parts []gui.InputData
|
|
|
|
|
|
|
|
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
|
|
|
log.Println(key, foo)
|
|
|
|
|
|
|
|
var b gui.InputData
|
|
|
|
b.CellType = foo
|
|
|
|
b.Heading = fmt.Sprintf("heading%d", key)
|
|
|
|
parts = append(parts, b)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
|
|
|
time.Sleep(1 * 1000 * 1000 * 1000)
|
2019-05-11 22:57:06 -05:00
|
|
|
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
2019-05-10 03:27:28 -05:00
|
|
|
}
|
2019-05-12 14:32:29 -05:00
|
|
|
|
2019-05-12 15:08:26 -05:00
|
|
|
type aheader struct {
|
|
|
|
headtype string
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2019-05-12 17:32:38 -05:00
|
|
|
func addVmsTab(count int) *gui.TableData {
|
2019-05-12 14:32:29 -05:00
|
|
|
var parts []gui.InputData
|
|
|
|
|
2019-05-12 20:36:31 -05:00
|
|
|
human := 0
|
|
|
|
|
2019-05-12 15:15:34 -05:00
|
|
|
tmp := gui.InputData{}
|
|
|
|
tmp.CellType = "BG"
|
|
|
|
tmp.Heading = "background"
|
2019-05-12 20:36:31 -05:00
|
|
|
tmp.Index = human
|
2019-05-12 15:15:34 -05:00
|
|
|
parts = append(parts, tmp)
|
2019-05-12 20:36:31 -05:00
|
|
|
human += 1
|
2019-05-12 15:15:34 -05:00
|
|
|
|
|
|
|
tmp = gui.InputData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "name"
|
2019-05-12 20:36:31 -05:00
|
|
|
tmp.Index = human
|
2019-05-12 15:15:34 -05:00
|
|
|
parts = append(parts, tmp)
|
|
|
|
|
|
|
|
tmp = gui.InputData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "hostname"
|
2019-05-12 20:36:31 -05:00
|
|
|
tmp.Index = human
|
2019-05-12 15:15:34 -05:00
|
|
|
parts = append(parts, tmp)
|
|
|
|
|
|
|
|
tmp = gui.InputData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "IPv6"
|
2019-05-12 20:36:31 -05:00
|
|
|
tmp.Index = human
|
2019-05-12 15:15:34 -05:00
|
|
|
parts = append(parts, tmp)
|
|
|
|
|
|
|
|
tmp = gui.InputData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "cpus"
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
|
|
|
|
tmp = gui.InputData{}
|
|
|
|
tmp.CellType = "TEXTCOLOR"
|
|
|
|
tmp.Heading = "memory"
|
|
|
|
parts = append(parts, tmp)
|
|
|
|
|
|
|
|
tmp = gui.InputData{}
|
|
|
|
tmp.CellType = "BUTTON"
|
|
|
|
tmp.Heading = "Details"
|
|
|
|
parts = append(parts, tmp)
|
2019-05-12 14:32:29 -05:00
|
|
|
|
2019-05-12 17:32:38 -05:00
|
|
|
mh := gui.AddTableTab(cloudtab, 1, "Virtual Machines", count, parts)
|
|
|
|
return mh
|
2019-05-12 14:32:29 -05:00
|
|
|
}
|