162 lines
3.8 KiB
Go
162 lines
3.8 KiB
Go
package main
|
|
|
|
import "log"
|
|
import "time"
|
|
import "fmt"
|
|
|
|
import "github.com/gookit/config"
|
|
|
|
import "github.com/andlabs/ui"
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
import "git.wit.com/wit/gui"
|
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
var cloudwin *ui.Window
|
|
var cloudtab *ui.Tab
|
|
var tabcount int
|
|
|
|
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)
|
|
|
|
mybutton := ui.NewButton("cpuinfo")
|
|
mybutton.OnClicked(func(*ui.Button) {
|
|
log.Println("send over socket")
|
|
writelnToSocket("cpuinfo")
|
|
})
|
|
vbox.Append(mybutton, false)
|
|
|
|
// VM list test button
|
|
listVMbutton := ui.NewButton("list")
|
|
listVMbutton.OnClicked(func(*ui.Button) {
|
|
log.Println("send over socket")
|
|
writelnToSocket("list")
|
|
})
|
|
vbox.Append(listVMbutton, false)
|
|
|
|
|
|
vbox.Append(ui.NewLabel("Hostname:"), false)
|
|
|
|
// ATTEMPT TO ADD THE TABLE HERE
|
|
add2button := ui.NewButton("Add a Test Table")
|
|
add2button.OnClicked(func(*ui.Button) {
|
|
log.Println("send over socket")
|
|
add2()
|
|
})
|
|
vbox.Append(add2button, false)
|
|
// ATTEMPT TO ADD THE TABLE HERE END
|
|
|
|
hbox.Append(ui.NewVerticalSeparator(), false)
|
|
|
|
// Send a test protobuf Event to localhost
|
|
add3button := ui.NewButton("Add buf to chann")
|
|
add3button.OnClicked(func(*ui.Button) {
|
|
log.Println("add protobuf event to the channel")
|
|
addEvent()
|
|
})
|
|
vbox.Append(add3button, false)
|
|
|
|
// Send a protobuf Event over the WIT socket
|
|
add4button := ui.NewButton("Send protobuf")
|
|
add4button.OnClicked(func(*ui.Button) {
|
|
log.Println("sent a protobuf over the TCP socket")
|
|
sendEventToWIT()
|
|
})
|
|
vbox.Append(add4button, false)
|
|
|
|
// 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)
|
|
|
|
// Send a protobuf over a gorilla websocket
|
|
add6button := ui.NewButton("gorillaSendProtobuf()")
|
|
add6button.OnClicked(func(*ui.Button) {
|
|
log.Println("gorillaSendProtobuf()")
|
|
gorillaSendProtobuf()
|
|
})
|
|
vbox.Append(add6button, false)
|
|
|
|
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)
|
|
|
|
/*
|
|
vbox.Append(ui.NewLabel("Hostname:"), false)
|
|
vbox.Append(ui.NewLabel("librem15.lab.wit.com"), false)
|
|
*/
|
|
|
|
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")
|
|
|
|
return hbox
|
|
}
|
|
|
|
func setupCloudUI() {
|
|
cloudwin = ui.NewWindow("Cloud Control Panel", config.Int("width"), config.Int("height"), false)
|
|
cloudwin.OnClosing(func(*ui.Window) bool {
|
|
ui.Quit()
|
|
return true
|
|
})
|
|
ui.OnShouldQuit(func() bool {
|
|
cloudwin.Destroy()
|
|
return true
|
|
})
|
|
|
|
cloudtab = ui.NewTab()
|
|
cloudwin.SetChild(cloudtab)
|
|
cloudwin.SetMargined(true)
|
|
|
|
tabcount = 0
|
|
cloudtab.Append("Cloud Info", makeCloudInfoBox())
|
|
cloudtab.SetMargined(tabcount, true)
|
|
|
|
cloudwin.Show()
|
|
}
|
|
|
|
func add2() {
|
|
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)
|
|
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
|
}
|