Merge branch 'devel'
This commit is contained in:
commit
0e8644cfbb
200
addAccount.go
200
addAccount.go
|
@ -1,200 +0,0 @@
|
|||
package gui
|
||||
|
||||
import "log"
|
||||
// import "fmt"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
// var subdomain *ui.Entry
|
||||
|
||||
func AddEntry(box *GuiBox, name string) *GuiEntry {
|
||||
var ge *GuiEntry
|
||||
ge = new(GuiEntry)
|
||||
|
||||
ue := ui.NewEntry()
|
||||
ue.SetReadOnly(false)
|
||||
ue.OnChanged(func(*ui.Entry) {
|
||||
log.Println("gui.AddEntry() OK. ue.Text() =", ue.Text())
|
||||
})
|
||||
box.UiBox.Append(ue, false)
|
||||
|
||||
ge.UiEntry = ue
|
||||
box.EntryMap[name] = ge
|
||||
|
||||
return ge
|
||||
}
|
||||
|
||||
func AddAccountQuestionBox(gw *GuiWindow) *GuiBox {
|
||||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
|
||||
gb.EntryMap = make(map[string]*GuiEntry)
|
||||
gb.EntryMap["test"] = nil
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
// gw.Box1 = vbox
|
||||
gb.UiBox = vbox
|
||||
gb.W = gw
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
vbox.Append(hbox, false)
|
||||
|
||||
hbox.Append(ui.NewLabel("Enter your Subdomain or"), false)
|
||||
|
||||
button1 := CreateButton(gb, nil, nil, "Generate", "SUBDOMAIN", generateSubdomain)
|
||||
button1.Box = gb
|
||||
hbox.Append(button1.B, false)
|
||||
|
||||
AddEntry(gb, "SUBDOMAIN")
|
||||
// AddEntry(gb, "USERNAME")
|
||||
|
||||
vbox.Append(ui.NewHorizontalSeparator(), false)
|
||||
|
||||
button2 := CreateButton(gb, nil, nil, "Create Subdomain Account", "ADD", nil)
|
||||
button2.Box = gb
|
||||
vbox.Append(button2.B, false)
|
||||
|
||||
return gb
|
||||
}
|
||||
|
||||
func generateSubdomain(b *GuiButton) {
|
||||
log.Println("generateSubdomain START")
|
||||
if (b == nil) {
|
||||
log.Println("generateSubdomain ERROR b == nil")
|
||||
return
|
||||
}
|
||||
// subdomain.SetText("cust00013.wit.dev")
|
||||
|
||||
txt := SetText(b.Box, "SUBDOMAIN", "cust001.testing.com.customers.wprod.wit.com")
|
||||
log.Println("generateSubdomain subdomain = ", txt)
|
||||
log.Println("generateSubdomain END")
|
||||
}
|
||||
|
||||
/*
|
||||
func addSubdomain(b *GuiButton) {
|
||||
log.Println("addSubdomain START")
|
||||
// sub := subdomain.Text()
|
||||
// log.Println("generateSubdomain subdomain =", sub)
|
||||
log.Println("addSubdomain END")
|
||||
}
|
||||
*/
|
||||
|
||||
func AddAccountBox(gw *GuiWindow) *GuiBox {
|
||||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
|
||||
gb.EntryMap = make(map[string]*GuiEntry)
|
||||
gb.EntryMap["test"] = nil
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
// gw.Box1 = vbox
|
||||
gb.UiBox = vbox
|
||||
|
||||
hboxAccount := ui.NewHorizontalBox()
|
||||
hboxAccount.SetPadded(true)
|
||||
vbox.Append(hboxAccount, false)
|
||||
|
||||
// Start 'Provider' vertical box
|
||||
vboxC := ui.NewVerticalBox()
|
||||
vboxC.SetPadded(true)
|
||||
vboxC.Append(ui.NewLabel("Cloud Provider:"), false)
|
||||
|
||||
cbox := ui.NewCombobox()
|
||||
cbox.Append("WIT")
|
||||
cbox.Append("Evocative")
|
||||
vboxC.Append(cbox, false)
|
||||
cbox.SetSelected(0)
|
||||
|
||||
cbox.OnSelected(func(*ui.Combobox) {
|
||||
log.Println("OK. Selected Cloud Provider =", cbox.Selected())
|
||||
})
|
||||
hboxAccount.Append(vboxC, false)
|
||||
// End 'Cloud Provider' vertical box
|
||||
|
||||
// Start 'Region' vertical box
|
||||
vboxR := ui.NewVerticalBox()
|
||||
vboxR.SetPadded(true)
|
||||
vboxR.Append(ui.NewLabel("Region:"), false)
|
||||
|
||||
regbox := ui.NewCombobox()
|
||||
regbox.Append("Any")
|
||||
regbox.Append("SF")
|
||||
vboxR.Append(regbox, false)
|
||||
regbox.SetSelected(0)
|
||||
|
||||
regbox.OnSelected(func(*ui.Combobox) {
|
||||
log.Println("OK. Selected something =", regbox.Selected())
|
||||
})
|
||||
hboxAccount.Append(vboxR, false)
|
||||
// End 'Region' vertical box
|
||||
|
||||
// Start 'Nickname' vertical box
|
||||
vboxN := ui.NewVerticalBox()
|
||||
vboxN.SetPadded(true)
|
||||
vboxN.Append(ui.NewLabel("Account Nickname:"), false)
|
||||
|
||||
Data.EntryNick = ui.NewEntry()
|
||||
Data.EntryNick.SetReadOnly(false)
|
||||
|
||||
vboxN.Append(Data.EntryNick, false)
|
||||
|
||||
Data.EntryNick.OnChanged(func(*ui.Entry) {
|
||||
log.Println("OK. nickname =", Data.EntryNick.Text())
|
||||
// Data.AccNick = entryNick.Text()
|
||||
})
|
||||
hboxAccount.Append(vboxN, false)
|
||||
// End 'Nickname' vertical box
|
||||
|
||||
// Start 'Username' vertical box
|
||||
vboxU := ui.NewVerticalBox()
|
||||
vboxU.SetPadded(true)
|
||||
vboxU.Append(ui.NewLabel("Account Username:"), false)
|
||||
|
||||
Data.EntryUser = ui.NewEntry()
|
||||
Data.EntryUser.SetReadOnly(false)
|
||||
|
||||
vboxU.Append(Data.EntryUser, false)
|
||||
|
||||
Data.EntryUser.OnChanged(func(*ui.Entry) {
|
||||
log.Println("OK. username =", Data.EntryUser.Text())
|
||||
// Data.AccUser = entryUser.Text()
|
||||
})
|
||||
hboxAccount.Append(vboxU, false)
|
||||
// End 'Username' vertical box
|
||||
|
||||
// Start 'Password' vertical box
|
||||
vboxP := ui.NewVerticalBox()
|
||||
vboxP.SetPadded(true)
|
||||
vboxP.Append(ui.NewLabel("Account Password:"), false)
|
||||
|
||||
Data.EntryPass = ui.NewEntry()
|
||||
Data.EntryPass.SetReadOnly(false)
|
||||
|
||||
vboxP.Append(Data.EntryPass, false)
|
||||
|
||||
Data.EntryPass.OnChanged(func(*ui.Entry) {
|
||||
log.Println("OK. password =", Data.EntryPass.Text())
|
||||
// Data.AccPass = entryPass.Text()
|
||||
})
|
||||
hboxAccount.Append(vboxP, false)
|
||||
// End 'Password' vertical box
|
||||
|
||||
vbox.Append(ui.NewHorizontalSeparator(), false)
|
||||
|
||||
hboxButtons := ui.NewHorizontalBox()
|
||||
hboxButtons.SetPadded(true)
|
||||
vbox.Append(hboxButtons, false)
|
||||
|
||||
okButton := CreateButton(gb, nil, nil, "Add Account", "ADD", nil)
|
||||
hboxButtons.Append(okButton.B, false)
|
||||
|
||||
backButton := CreateButton(gb, nil, nil, "Back", "BACK", nil)
|
||||
hboxButtons.Append(backButton.B, false)
|
||||
|
||||
return gb
|
||||
}
|
50
area.go
50
area.go
|
@ -15,20 +15,21 @@ func makeSplashArea(gb *GuiBox, newText *ui.AttributedString) {
|
|||
var newB *GuiButton
|
||||
newB = CreateFontButton(gb, "AREA")
|
||||
newB.Box = gb
|
||||
newB.GW = gb.W
|
||||
newB.GW = gb.Window
|
||||
|
||||
gw := gb.Window
|
||||
// initialize the GuiArea{}
|
||||
gb.Area = new(GuiArea)
|
||||
gb.Area.Button = newB
|
||||
gb.Area.Box = gb
|
||||
gb.Area.UiAttrstr = newText
|
||||
gb.Area.UiArea = ui.NewArea(gb.Area)
|
||||
gw.Area = new(GuiArea)
|
||||
gw.Area.Button = newB
|
||||
gw.Area.Box = gb
|
||||
gw.Area.UiAttrstr = newText
|
||||
gw.Area.UiArea = ui.NewArea(gw.Area)
|
||||
|
||||
if (Data.Debug) {
|
||||
spew.Dump(gb.Area.UiArea)
|
||||
spew.Dump(gw.Area.UiArea)
|
||||
log.Println("DEBUGGING", Data.Debug)
|
||||
} else {
|
||||
log.Println("NOT DEBUGGING AREA mhAH.Button =", gb.Area.Button)
|
||||
log.Println("NOT DEBUGGING AREA mhAH.Button =", gw.Area.Button)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +76,9 @@ func (ah GuiArea) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
|
|||
log.Println("GOT MOUSE UP")
|
||||
log.Println("GOT MOUSE UP ah.Button =", ah.Button)
|
||||
log.Println("GOT MOUSE UP ah.Button.FB =", ah.Button.FB)
|
||||
mouseClick(ah.Button)
|
||||
if (Data.MouseClick != nil) {
|
||||
Data.MouseClick(ah.Button)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +104,32 @@ func (ah GuiArea) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
|
|||
log.Println("GOT ENTER")
|
||||
}
|
||||
spew.Dump(ke)
|
||||
// splashWin.Destroy()
|
||||
// ui.Quit()
|
||||
return false
|
||||
}
|
||||
|
||||
func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
|
||||
log.Println("ShowTextBox() START")
|
||||
if (gw == nil) {
|
||||
log.Println("ShowTextBox() ERROR gw = nil")
|
||||
return nil
|
||||
}
|
||||
log.Println("ShowTextBox() START gw =", gw)
|
||||
|
||||
// create and setup a new GuiBox
|
||||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
|
||||
// gw.EntryMap = make(map[string]*GuiEntry)
|
||||
// gw.EntryMap["test"] = nil
|
||||
|
||||
newbox := ui.NewVerticalBox()
|
||||
newbox.SetPadded(true)
|
||||
gb.UiBox = newbox
|
||||
gb.Window = gw
|
||||
gw.BoxMap["Splash"] = gb
|
||||
|
||||
makeSplashArea(gb, newText)
|
||||
newbox.Append(gw.Area.UiArea, true)
|
||||
|
||||
return gb
|
||||
}
|
||||
|
|
2
debug.go
2
debug.go
|
@ -14,6 +14,8 @@ import "github.com/davecgh/go-spew/spew"
|
|||
|
||||
// import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
// THIS IS NOT CLEAN (but probably doesn't need to be. it's debugging)
|
||||
|
||||
// can not pass any args to this (?)
|
||||
/*
|
||||
func setupCloudUI() {
|
||||
|
|
290
gui.go
290
gui.go
|
@ -10,6 +10,8 @@ import pb "git.wit.com/wit/witProtobuf"
|
|||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
// THIS IS CLEAN (all that is left is the 'ADD VM')
|
||||
|
||||
func InitColumns(mh *TableData, parts []TableColumnData) {
|
||||
tmpBTindex := 0
|
||||
humanID := 0
|
||||
|
@ -82,39 +84,29 @@ func AddTableTab(gw *GuiWindow, name string, rowcount int, parts []TableColumnDa
|
|||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
|
||||
gb.EntryMap = make(map[string]*GuiEntry)
|
||||
gb.EntryMap["test"] = nil
|
||||
// gb.EntryMap = make(map[string]*GuiEntry)
|
||||
// gb.EntryMap["test"] = nil
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
gb.UiBox = vbox
|
||||
gb.W = gw
|
||||
gb.Window = gw
|
||||
gw.BoxMap[name] = gb
|
||||
mh.Box = gb
|
||||
|
||||
vbox.Append(table, true)
|
||||
gw.UiTab.Append(name, vbox)
|
||||
// mytab.SetMargined(mytabcount, true)
|
||||
|
||||
vbox.Append(ui.NewVerticalSeparator(), false)
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
|
||||
a := CreateButton(gb, account, nil, "Add Virtual Machine", "createAddVmBox", nil)
|
||||
hbox.Append(a.B, false)
|
||||
|
||||
vbox.Append(hbox, false)
|
||||
|
||||
return mh
|
||||
}
|
||||
|
||||
func SocketError(gw *GuiWindow) {
|
||||
ui.MsgBoxError(gw.UiWindow,
|
||||
"There was a socket error",
|
||||
"More detailed information can be shown here.")
|
||||
}
|
||||
|
||||
func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) {
|
||||
ui.MsgBox(gw.UiWindow, msg1, msg2)
|
||||
}
|
||||
|
@ -128,45 +120,6 @@ func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
|
|||
// something specific will fall into this routine
|
||||
// By default, all it runs is the call back to
|
||||
// the main program that is using this library
|
||||
|
||||
// This is one of the routines that is called from the
|
||||
// defaultButtonClick() below when the button is found
|
||||
// in the AllButtons %map
|
||||
// TODO: clean up the text above
|
||||
// TODO: remove this all together going only to main()
|
||||
func mouseClick(b *GuiButton) {
|
||||
log.Println("gui.mouseClick() START")
|
||||
if (b == nil) {
|
||||
log.Println("\tgui.mouseClick() START b = nil")
|
||||
} else {
|
||||
log.Println("\tgui.mouseClick() START b.Action =", b.Action)
|
||||
if (b.Action == "createAddVmBox") {
|
||||
log.Println("\tgui.mouseClick() createAddVmBox for b =", b)
|
||||
createAddVmBox(b.GW, b)
|
||||
return
|
||||
}
|
||||
/*
|
||||
if (b.Action == "WINDOW CLOSE") {
|
||||
b.W.Hide()
|
||||
// TODO: fix this (seems to crash? maybe because we are in the button here?)
|
||||
// b.W.Destroy()
|
||||
return
|
||||
}
|
||||
if (b.Action == "ADD") {
|
||||
log.Println("\tgui.mouseClick() SHOULD ADD VM HERE?")
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (Data.MouseClick == nil) {
|
||||
log.Println("\tgui.mouseClick() Data.MouseClick() IS nil. NOT DOING ANYTHING")
|
||||
log.Println("\tgui.mouseClick() Your application did not set a MouseClick() callback function")
|
||||
} else {
|
||||
log.Println("\tgui.mouseClick() Data.MouseClick() START")
|
||||
Data.MouseClick(b)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This routine MUST be here as this is how the andlabs/ui works
|
||||
// This is the raw routine passed to every button in andlabs libui / ui
|
||||
|
@ -179,21 +132,21 @@ func defaultButtonClick(button *ui.Button) {
|
|||
for key, foo := range Data.AllButtons {
|
||||
if (Data.Debug) {
|
||||
log.Println("defaultButtonClick() Data.AllButtons =", key, foo)
|
||||
spew.Dump(foo)
|
||||
// spew.Dump(foo)
|
||||
}
|
||||
if Data.AllButtons[key].B == button {
|
||||
log.Println("\tdefaultButtonClick() BUTTON MATCHED")
|
||||
// log.Println("\tData.AllButtons[key].Name =", Data.AllButtons[key].Name)
|
||||
log.Println("\tdefaultButtonClick() Data.AllButtons[key].Action =", Data.AllButtons[key].Action)
|
||||
if Data.AllButtons[key].custom != nil {
|
||||
log.Println("\tdefaultButtonClick() DOING CUSTOM FUNCTION")
|
||||
var tmp *GuiButton
|
||||
tmp = Data.AllButtons[key]
|
||||
// spew.Dump(tmp)
|
||||
Data.AllButtons[key].custom(tmp)
|
||||
Data.AllButtons[key].custom(Data.AllButtons[key])
|
||||
return
|
||||
}
|
||||
mouseClick(Data.AllButtons[key])
|
||||
if (Data.MouseClick != nil) {
|
||||
Data.MouseClick(Data.AllButtons[key])
|
||||
} else {
|
||||
log.Println("\tdefaultButtonClick() IGNORING BUTTON. MouseClick() is nil")
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +154,6 @@ func defaultButtonClick(button *ui.Button) {
|
|||
if (Data.Debug) {
|
||||
panic("defaultButtonClick() SHOULD NOT HAVE UNMAPPED BUTTONS")
|
||||
}
|
||||
mouseClick(nil)
|
||||
}
|
||||
|
||||
func AddButton(b *GuiButton, name string) *ui.Button {
|
||||
|
@ -213,6 +165,10 @@ func AddButton(b *GuiButton, name string) *ui.Button {
|
|||
return newB
|
||||
}
|
||||
|
||||
func AddButtonToBox(box *GuiBox, button *GuiButton) {
|
||||
box.UiBox.Append(button.B, false)
|
||||
}
|
||||
|
||||
func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM, name string, action string, custom func(*GuiButton)) *GuiButton {
|
||||
newUiB := ui.NewButton(name)
|
||||
newUiB.OnClicked(defaultButtonClick)
|
||||
|
@ -220,18 +176,17 @@ func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM, name string, acti
|
|||
var newB *GuiButton
|
||||
newB = new(GuiButton)
|
||||
newB.B = newUiB
|
||||
if (box.W == nil) {
|
||||
log.Println("CreateButton() box.W == nil")
|
||||
if (box.Window == nil) {
|
||||
log.Println("CreateButton() box.Window == nil")
|
||||
panic("crap")
|
||||
}
|
||||
newB.GW = box.W
|
||||
newB.GW = box.Window
|
||||
newB.Account = a
|
||||
newB.VM = vm
|
||||
newB.Box = box
|
||||
newB.Action = action
|
||||
newB.custom = custom
|
||||
Data.AllButtons = append(Data.AllButtons, newB)
|
||||
|
||||
return newB
|
||||
}
|
||||
|
||||
|
@ -242,12 +197,14 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton {
|
|||
newGB.Action = action
|
||||
newGB.FB = ui.NewFontButton()
|
||||
newGB.Box = box
|
||||
newGB.Area = box.Area
|
||||
newGB.Area = box.Window.Area
|
||||
Data.AllButtons = append(Data.AllButtons, &newGB)
|
||||
|
||||
newGB.FB.OnChanged(func (*ui.FontButton) {
|
||||
log.Println("FontButton.OnChanged() START mouseClick(&newBM)", newGB)
|
||||
mouseClick(&newGB)
|
||||
if (Data.MouseClick != nil) {
|
||||
Data.MouseClick(&newGB)
|
||||
}
|
||||
})
|
||||
return &newGB
|
||||
}
|
||||
|
@ -257,17 +214,17 @@ func GetText(box *GuiBox, name string) string {
|
|||
log.Println("gui.GetText() ERROR box == nil")
|
||||
return ""
|
||||
}
|
||||
if (box.EntryMap == nil) {
|
||||
log.Println("gui.GetText() ERROR b.Box.EntryMap == nil")
|
||||
if (box.Window.EntryMap == nil) {
|
||||
log.Println("gui.GetText() ERROR b.Box.Window.EntryMap == nil")
|
||||
return ""
|
||||
}
|
||||
spew.Dump(box.EntryMap)
|
||||
if (box.EntryMap[name] == nil) {
|
||||
log.Println("gui.GetText() ERROR box.EntryMap[", name, "] == nil ")
|
||||
spew.Dump(box.Window.EntryMap)
|
||||
if (box.Window.EntryMap[name] == nil) {
|
||||
log.Println("gui.GetText() ERROR box.Window.EntryMap[", name, "] == nil ")
|
||||
return ""
|
||||
}
|
||||
e := box.EntryMap[name]
|
||||
log.Println("gui.GetText() box.EntryMap[", name, "] = ", e.UiEntry.Text())
|
||||
e := box.Window.EntryMap[name]
|
||||
log.Println("gui.GetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
|
||||
log.Println("gui.GetText() END")
|
||||
return e.UiEntry.Text()
|
||||
}
|
||||
|
@ -276,17 +233,188 @@ func SetText(box *GuiBox, name string, value string) error {
|
|||
if (box == nil) {
|
||||
return fmt.Errorf("gui.SetText() ERROR box == nil")
|
||||
}
|
||||
if (box.EntryMap == nil) {
|
||||
return fmt.Errorf("gui.SetText() ERROR b.Box.EntryMap == nil")
|
||||
if (box.Window.EntryMap == nil) {
|
||||
return fmt.Errorf("gui.SetText() ERROR b.Box.Window.EntryMap == nil")
|
||||
}
|
||||
spew.Dump(box.EntryMap)
|
||||
if (box.EntryMap[name] == nil) {
|
||||
return fmt.Errorf("gui.SetText() ERROR box.EntryMap[", name, "] == nil ")
|
||||
spew.Dump(box.Window.EntryMap)
|
||||
if (box.Window.EntryMap[name] == nil) {
|
||||
return fmt.Errorf("gui.SetText() ERROR box.Window.EntryMap[", name, "] == nil ")
|
||||
}
|
||||
e := box.EntryMap[name]
|
||||
log.Println("gui.SetText() box.EntryMap[", name, "] = ", e.UiEntry.Text())
|
||||
e := box.Window.EntryMap[name]
|
||||
log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
|
||||
e.UiEntry.SetText(value)
|
||||
log.Println("gui.SetText() box.EntryMap[", name, "] = ", e.UiEntry.Text())
|
||||
log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
|
||||
log.Println("gui.SetText() END")
|
||||
return nil
|
||||
}
|
||||
|
||||
// makeEntryBox(box, "hostname:", "blah.foo.org") {
|
||||
func MakeEntryVbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry {
|
||||
// Start 'Nickname' vertical box
|
||||
vboxN := ui.NewVerticalBox()
|
||||
vboxN.SetPadded(true)
|
||||
vboxN.Append(ui.NewLabel(a), false)
|
||||
|
||||
e := defaultMakeEntry(startValue, edit, action)
|
||||
|
||||
vboxN.Append(e.UiEntry, false)
|
||||
box.UiBox.Append(vboxN, false)
|
||||
// End 'Nickname' vertical box
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
func MakeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry {
|
||||
// Start 'Nickname' vertical box
|
||||
hboxN := ui.NewHorizontalBox()
|
||||
hboxN.SetPadded(true)
|
||||
hboxN.Append(ui.NewLabel(a), false)
|
||||
|
||||
e := defaultMakeEntry(startValue, edit, action)
|
||||
hboxN.Append(e.UiEntry, false)
|
||||
|
||||
box.UiBox.Append(hboxN, false)
|
||||
// End 'Nickname' vertical box
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
func NewLabel(box *GuiBox, text string) {
|
||||
box.UiBox.Append(ui.NewLabel(text), false)
|
||||
}
|
||||
|
||||
func AddEntry(box *GuiBox, name string) *GuiEntry {
|
||||
var ge *GuiEntry
|
||||
ge = new(GuiEntry)
|
||||
|
||||
ue := ui.NewEntry()
|
||||
ue.SetReadOnly(false)
|
||||
ue.OnChanged(func(*ui.Entry) {
|
||||
log.Println("gui.AddEntry() OK. ue.Text() =", ue.Text())
|
||||
})
|
||||
box.UiBox.Append(ue, false)
|
||||
|
||||
ge.UiEntry = ue
|
||||
box.Window.EntryMap[name] = ge
|
||||
|
||||
return ge
|
||||
}
|
||||
|
||||
func HardHorizontalBreak(box *GuiBox) {
|
||||
log.Println("HardHorizontalBreak START")
|
||||
gw := box.Window
|
||||
mainbox := gw.BoxMap["MAIN"]
|
||||
if (mainbox == nil) {
|
||||
log.Println("HardHorizontalBreak ERROR MAIN box == nil")
|
||||
return
|
||||
}
|
||||
uibox := mainbox.UiBox
|
||||
|
||||
tmp := ui.NewHorizontalSeparator()
|
||||
uibox.Append(tmp, false)
|
||||
|
||||
hbox := ui.NewVerticalBox()
|
||||
hbox.SetPadded(true)
|
||||
box.UiBox = hbox
|
||||
uibox.Append(hbox, true)
|
||||
log.Println("HardHorizontalBreak END")
|
||||
}
|
||||
|
||||
func HardVerticalBreak(box *GuiBox) {
|
||||
log.Println("HardVerticalBreak START")
|
||||
gw := box.Window
|
||||
mainbox := gw.BoxMap["MAIN"]
|
||||
if (mainbox == nil) {
|
||||
log.Println("HardHorizontalBreak ERROR MAIN box == nil")
|
||||
return
|
||||
}
|
||||
|
||||
tmp := ui.NewVerticalSeparator()
|
||||
mainbox.UiBox.Append(tmp, false)
|
||||
|
||||
hbox := ui.NewVerticalBox()
|
||||
hbox.SetPadded(true)
|
||||
box.UiBox = hbox
|
||||
mainbox.UiBox.Append(hbox, false)
|
||||
log.Println("HardVerticalBreak END")
|
||||
}
|
||||
|
||||
func HorizontalBreak(box *GuiBox) {
|
||||
tmp := ui.NewHorizontalSeparator()
|
||||
box.UiBox.Append(tmp, false)
|
||||
}
|
||||
|
||||
func VerticalBreak(box *GuiBox) {
|
||||
tmp := ui.NewVerticalSeparator()
|
||||
box.UiBox.Append(tmp, false)
|
||||
}
|
||||
|
||||
func AddGenericBox(gw *GuiWindow) *GuiBox {
|
||||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
|
||||
// gb.EntryMap = make(map[string]*GuiEntry)
|
||||
// gb.EntryMap["test"] = nil
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
// gw.Box1 = vbox
|
||||
gb.UiBox = vbox
|
||||
gb.Window = gw
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
vbox.Append(hbox, false)
|
||||
|
||||
return gb
|
||||
}
|
||||
|
||||
func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
||||
log.Println("CreateAddVmBox() START name =", name)
|
||||
|
||||
var box *GuiBox
|
||||
box = new(GuiBox)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
box.UiBox = vbox
|
||||
box.Window = gw
|
||||
gw.BoxMap["ADD VM" + name] = box
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
vbox.Append(hbox, false)
|
||||
|
||||
AddBoxToTab(name, gw.UiTab, vbox)
|
||||
|
||||
return box
|
||||
}
|
||||
|
||||
func CreateBox(gw *GuiWindow, name string) *GuiBox {
|
||||
log.Println("CreateVmBox() START")
|
||||
log.Println("CreateVmBox() vm.Name =", name)
|
||||
log.Println("CreateVmBox() gw =", gw)
|
||||
|
||||
var box *GuiBox
|
||||
box = new(GuiBox)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
log.Println("CreateVmBox() vbox =", vbox)
|
||||
log.Println("CreateVmBox() box.UiBox =", box.UiBox)
|
||||
box.UiBox = vbox
|
||||
log.Println("CreateVmBox() box.Window =", box.Window)
|
||||
box.Window = gw
|
||||
log.Println("CreateVmBox() gw.BoxMap =", gw.BoxMap)
|
||||
gw.BoxMap[name] = box
|
||||
|
||||
hboxAccount := ui.NewHorizontalBox()
|
||||
hboxAccount.SetPadded(true)
|
||||
vbox.Append(hboxAccount, false)
|
||||
|
||||
box.UiBox = hboxAccount
|
||||
|
||||
AddBoxToTab(name, gw.UiTab, vbox)
|
||||
|
||||
return box
|
||||
}
|
||||
|
|
362
mainCloudBox.go
362
mainCloudBox.go
|
@ -1,362 +0,0 @@
|
|||
package gui
|
||||
|
||||
import "log"
|
||||
import "time"
|
||||
import "regexp"
|
||||
import "os"
|
||||
// import "reflect"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
func makeCloudInfoBox(gw *GuiWindow) *GuiBox {
|
||||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
gb.W = gw
|
||||
|
||||
gb.EntryMap = make(map[string]*GuiEntry)
|
||||
gb.EntryMap["test"] = nil
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
// gw.Box1 = hbox
|
||||
gb.UiBox = hbox
|
||||
|
||||
if (Data.Debug) {
|
||||
log.Println("makeCloudInfoBox() add debugging buttons")
|
||||
/*
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
hbox.Append(vbox, false)
|
||||
*/
|
||||
|
||||
addDebuggingButtons(gb)
|
||||
|
||||
hbox.Append(ui.NewVerticalSeparator(), false)
|
||||
}
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
hbox.Append(vbox, true)
|
||||
|
||||
hostnamebox := ui.NewHorizontalBox()
|
||||
hostnamebox.SetPadded(true)
|
||||
vbox.Append(hostnamebox, false)
|
||||
|
||||
entryForm := ui.NewForm()
|
||||
entryForm.SetPadded(true)
|
||||
hostnamebox.Append(entryForm, true)
|
||||
|
||||
hostnameEntry := ui.NewEntry()
|
||||
entryForm.Append("hostname:", hostnameEntry, false)
|
||||
tmp := Data.Hostname + " (" + Data.IPv6 + ")"
|
||||
hostnameEntry.SetText(tmp)
|
||||
hostnameEntry.SetReadOnly(true)
|
||||
|
||||
anew := CreateButton(gb, nil, nil, "Edit", "EDIT", nil)
|
||||
hostnamebox.Append(anew.B, false)
|
||||
|
||||
vbox.Append(ui.NewHorizontalSeparator(), false)
|
||||
|
||||
agrid := ui.NewGrid()
|
||||
agrid.SetPadded(true)
|
||||
|
||||
agrid.Append(ui.NewLabel("Accounts:"), 0, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
agrid.Append(ui.NewLabel("Domain Name"), 1, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
agrid.Append(ui.NewLabel("Email"), 2, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
row := 1
|
||||
|
||||
for key, a := range Data.Config.Accounts {
|
||||
log.Println("account = ", key, a)
|
||||
log.Println("Accounts[key] = ", Data.Config.Accounts[key])
|
||||
log.Println("account.Nick = ", Data.Config.Accounts[key].Nick)
|
||||
log.Println("account.Username = ", Data.Config.Accounts[key].Username)
|
||||
log.Println("account.Token = ", Data.Config.Accounts[key].Token)
|
||||
|
||||
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Domain), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Email), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
name := "Login " + Data.Config.Accounts[key].Nick
|
||||
l := CreateButton(gb, Data.Config.Accounts[key], nil, name, "LOGIN", nil)
|
||||
agrid.Append(l.B, 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
name = "Show " + Data.Config.Accounts[key].Nick
|
||||
b := CreateButton(gb, Data.Config.Accounts[key], nil, name, "SHOW", nil)
|
||||
agrid.Append(b.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
row += 1
|
||||
}
|
||||
|
||||
row += 1
|
||||
agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
row += 1
|
||||
a := CreateButton(gb, nil, nil, "Add Account", "ADD TAB", nil)
|
||||
agrid.Append(a.B, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
q := CreateButton(gb, nil, nil, "Quit", "QUIT", nil)
|
||||
agrid.Append(q.B, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
||||
|
||||
vbox.Append(agrid, false)
|
||||
return gb
|
||||
}
|
||||
|
||||
func ShowAccountQuestionTab(gw *GuiWindow) {
|
||||
log.Println("ShowAccountQuestionTab() gw =", gw)
|
||||
if (gw.UiTab == nil) {
|
||||
log.Println("ShowAccountQuestionTab() gw.UiTab = nil THIS IS BAD")
|
||||
os.Exit(-1)
|
||||
}
|
||||
gw.UiTab.Delete(0)
|
||||
|
||||
log.Println("Sleep(200)")
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
abox := AddAccountQuestionBox(gw)
|
||||
gw.BoxMap["Box2"] = abox
|
||||
// gw.Box2 = AddAccountQuestionBox(gw)
|
||||
gw.UiTab.InsertAt("New Account?", 0, abox.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
}
|
||||
|
||||
func ShowAccountTab(gw *GuiWindow, i int) {
|
||||
log.Println("ShowAccountTab() START")
|
||||
|
||||
log.Println("Sleep(200)")
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
// Create the things for the Account Tab
|
||||
abox := AddAccountBox(gw)
|
||||
|
||||
// Set the parents and data structure links
|
||||
// aTab.me = gw.UiTab
|
||||
// aTab.parentWindow = Data.Window1.W
|
||||
// aTab.tabOffset = 0
|
||||
|
||||
if (i >= 0) {
|
||||
log.Println("ShowAccountTab() InsertAt i=", i)
|
||||
gw.UiTab.Delete(0)
|
||||
gw.UiTab.InsertAt("Add Account", i, abox.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
} else {
|
||||
// TODO: After append try to discover the tab index #
|
||||
log.Println("ShowAccountTab() Append")
|
||||
AddBoxToTab("Create New Account", gw.UiTab, abox.UiBox)
|
||||
}
|
||||
}
|
||||
|
||||
func ShowMainTab(gw *GuiWindow) {
|
||||
log.Println("ShowMainTab() gw =", gw)
|
||||
log.Println("ShowMainTab() gw.UiTab =", gw.UiTab)
|
||||
gw.UiTab.Delete(0)
|
||||
|
||||
log.Println("Sleep(200)")
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
abox := makeCloudInfoBox(gw)
|
||||
gw.BoxMap["Box3"] = abox
|
||||
gw.UiTab.InsertAt("Main", 0, abox.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
}
|
||||
|
||||
func GuiInit() {
|
||||
ui.OnShouldQuit(func() bool {
|
||||
// mouseClick(&newBM)
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func StartNewWindow(c *pb.Config, bg bool, action string, text func() *ui.AttributedString) {
|
||||
log.Println("InitNewWindow() Create a new window")
|
||||
var newGuiWindow GuiWindow
|
||||
newGuiWindow.Width = int(c.Width)
|
||||
newGuiWindow.Height = int(c.Height)
|
||||
newGuiWindow.Action = action
|
||||
newGuiWindow.GetText = text
|
||||
Data.Windows = append(Data.Windows, &newGuiWindow)
|
||||
|
||||
// make(newGuiWindow.BoxMap)
|
||||
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
||||
|
||||
if (bg) {
|
||||
log.Println("ShowWindow() IN NEW GOROUTINE")
|
||||
go ui.Main(func() {
|
||||
InitWindow(&newGuiWindow)
|
||||
})
|
||||
time.Sleep(2000 * time.Millisecond)
|
||||
} else {
|
||||
log.Println("ShowWindow() WAITING for ui.Main()")
|
||||
ui.Main(func() {
|
||||
InitWindow(&newGuiWindow)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func getSplashText(a string) *ui.AttributedString {
|
||||
var aText *ui.AttributedString
|
||||
aText = ui.NewAttributedString(a)
|
||||
return aText
|
||||
}
|
||||
|
||||
func InitWindow(gw *GuiWindow) {
|
||||
log.Println("InitWindow() THIS WINDOW IS NOT YET SHOWN")
|
||||
|
||||
gw.UiWindow = ui.NewWindow("", int(gw.Width), int(gw.Height), true)
|
||||
gw.UiWindow.SetBorderless(false)
|
||||
|
||||
// create a 'fake' button entry for the mouse clicks
|
||||
var newBM GuiButton
|
||||
newBM.Action = "QUIT"
|
||||
// newBM.W = gw.UiWindow
|
||||
newBM.GW = gw
|
||||
Data.AllButtons = append(Data.AllButtons, &newBM)
|
||||
|
||||
gw.UiWindow.OnClosing(func(*ui.Window) bool {
|
||||
log.Println("InitWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw)
|
||||
// mouseClick(&newBM)
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
|
||||
gw.UiTab = ui.NewTab()
|
||||
gw.UiWindow.SetChild(gw.UiTab)
|
||||
gw.UiWindow.SetMargined(true)
|
||||
|
||||
log.Println("InitWindow() gw =", gw)
|
||||
log.Println("InitWindow() gw.Action =", gw.Action)
|
||||
|
||||
if (gw.Action == "SPLASH") {
|
||||
log.Println("InitWindow() TRYING SPLASH")
|
||||
damnit := "click" + string(Data.Config.Hostname)
|
||||
var tmp *ui.AttributedString
|
||||
if (gw.GetText == nil) {
|
||||
tmp = getSplashText(damnit)
|
||||
} else {
|
||||
tmp = gw.GetText()
|
||||
}
|
||||
log.Println("InitWindow() TRYING SPLASH tmp =", tmp)
|
||||
abox := ShowSplashBox(gw, tmp)
|
||||
|
||||
gw.UiTab.Append("WIT Splash", abox.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
}
|
||||
|
||||
Data.State = "splash"
|
||||
gw.UiWindow.Show()
|
||||
}
|
||||
|
||||
// makeEntryBox(box, "hostname:", "blah.foo.org") {
|
||||
func makeEntryVbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *GuiEntry {
|
||||
// Start 'Nickname' vertical box
|
||||
vboxN := ui.NewVerticalBox()
|
||||
vboxN.SetPadded(true)
|
||||
vboxN.Append(ui.NewLabel(a), false)
|
||||
|
||||
e := defaultMakeEntry(startValue, edit, action)
|
||||
|
||||
vboxN.Append(e.UiEntry, false)
|
||||
hbox.Append(vboxN, false)
|
||||
// End 'Nickname' vertical box
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
/*
|
||||
// string handling examples that might be helpful for normalizeInt()
|
||||
isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString
|
||||
|
||||
for _, username := range []string{"userone", "user2", "user-three"} {
|
||||
if !isAlpha(username) {
|
||||
fmt.Printf("%q is not valid\n", username)
|
||||
}
|
||||
}
|
||||
|
||||
const alpha = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
func alphaOnly(s string) bool {
|
||||
for _, char := range s {
|
||||
if !strings.Contains(alpha, strings.ToLower(string(char))) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
*/
|
||||
|
||||
func normalizeInt(s string) string {
|
||||
// reg, err := regexp.Compile("[^a-zA-Z0-9]+")
|
||||
reg, err := regexp.Compile("[^0-9]+")
|
||||
if err != nil {
|
||||
log.Println("normalizeInt() regexp.Compile() ERROR =", err)
|
||||
return s
|
||||
}
|
||||
clean := reg.ReplaceAllString(s, "")
|
||||
log.Println("normalizeInt() s =", clean)
|
||||
return clean
|
||||
}
|
||||
|
||||
func defaultEntryChange(e *ui.Entry) {
|
||||
for key, em := range Data.AllEntries {
|
||||
if (Data.Debug) {
|
||||
log.Println("\tdefaultEntryChange() Data.AllEntries =", key, em)
|
||||
}
|
||||
if Data.AllEntries[key].UiEntry == e {
|
||||
log.Println("defaultEntryChange() FOUND",
|
||||
"action =", Data.AllEntries[key].Action,
|
||||
"Last =", Data.AllEntries[key].Last,
|
||||
"e.Text() =", e.Text())
|
||||
Data.AllEntries[key].Last = e.Text()
|
||||
if Data.AllEntries[key].Normalize != nil {
|
||||
fixed := Data.AllEntries[key].Normalize(e.Text())
|
||||
e.SetText(fixed)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Println("defaultEntryChange() ERROR. MISSING ENTRY MAP. e.Text() =", e.Text())
|
||||
}
|
||||
|
||||
func defaultMakeEntry(startValue string, edit bool, action string) *GuiEntry {
|
||||
e := ui.NewEntry()
|
||||
e.SetText(startValue)
|
||||
if (edit == false) {
|
||||
e.SetReadOnly(true)
|
||||
}
|
||||
e.OnChanged(defaultEntryChange)
|
||||
|
||||
// add the entry field to the global map
|
||||
var newEntry GuiEntry
|
||||
newEntry.UiEntry = e
|
||||
newEntry.Edit = edit
|
||||
newEntry.Action = action
|
||||
if (action == "Memory") {
|
||||
newEntry.Normalize = normalizeInt
|
||||
}
|
||||
Data.AllEntries = append(Data.AllEntries, &newEntry)
|
||||
|
||||
return &newEntry
|
||||
}
|
||||
|
||||
func makeEntryHbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *GuiEntry {
|
||||
// Start 'Nickname' vertical box
|
||||
hboxN := ui.NewHorizontalBox()
|
||||
hboxN.SetPadded(true)
|
||||
hboxN.Append(ui.NewLabel(a), false)
|
||||
|
||||
e := defaultMakeEntry(startValue, edit, action)
|
||||
hboxN.Append(e.UiEntry, false)
|
||||
|
||||
hbox.Append(hboxN, false)
|
||||
// End 'Nickname' vertical box
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
func AddBoxToTab(name string, tab *ui.Tab, box *ui.Box) {
|
||||
tab.Append(name, box)
|
||||
tab.SetMargined(0, true)
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
package gui
|
||||
|
||||
import "log"
|
||||
import "time"
|
||||
import "regexp"
|
||||
import "os"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
// THIS IS NOT CLEAN (almost?)
|
||||
|
||||
func ShowTab(gw *GuiWindow, tabname string, title string) *GuiWindow {
|
||||
log.Println("ShowTab() gw =", gw)
|
||||
if (gw.UiTab == nil) {
|
||||
log.Println("ShowTab() gw.UiTab = nil THIS IS BAD")
|
||||
os.Exit(-1)
|
||||
}
|
||||
window := InitGuiWindow(Data.Config, tabname, gw.MakeWindow, gw.UiWindow, gw.UiTab)
|
||||
window.UiTab.Delete(0)
|
||||
|
||||
abox := window.MakeWindow(window)
|
||||
window.BoxMap[tabname] = abox
|
||||
window.UiTab.InsertAt(title, 0, abox.UiBox)
|
||||
window.UiTab.SetMargined(0, true)
|
||||
return window
|
||||
}
|
||||
|
||||
func GuiInit() {
|
||||
ui.OnShouldQuit(func() bool {
|
||||
// mouseClick(&newBM)
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func AddMainTab(gw *GuiWindow) *GuiBox {
|
||||
log.Println("ShowMainTab() gw =", gw)
|
||||
log.Println("ShowMainTab() gw.UiTab =", gw.UiTab)
|
||||
|
||||
window := InitGuiWindow(Data.Config, "MAIN", nil, gw.UiWindow, gw.UiTab)
|
||||
|
||||
box := InitGuiBox(window, nil, ui.NewHorizontalBox(), "MAIN")
|
||||
|
||||
if (Data.Debug) {
|
||||
log.Println("makeCloudInfoBox() add debugging buttons")
|
||||
addDebuggingButtons(box)
|
||||
box.UiBox.Append(ui.NewVerticalSeparator(), false)
|
||||
}
|
||||
|
||||
// box := gw.MakeWindow(gw)
|
||||
// abox := makeCloudInfoBox(gw, box)
|
||||
return box
|
||||
}
|
||||
|
||||
func ShowMainTabShowBox(gw *GuiWindow, box *GuiBox) {
|
||||
log.Println("gui.ShowMainTabShowBox() box =", box)
|
||||
// gw.UiTab.Delete(0)
|
||||
gw.BoxMap["MAIN3"] = box
|
||||
// gw.UiTab.InsertAt("Main", 0, box.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
}
|
||||
|
||||
func InitGuiBox(gw *GuiWindow, box *GuiBox, uiBox *ui.Box, name string) *GuiBox {
|
||||
log.Println("InitGuiBox() START")
|
||||
var newGuiBox GuiBox
|
||||
newGuiBox.UiBox = uiBox
|
||||
newGuiBox.Window = gw
|
||||
uiBox.SetPadded(true)
|
||||
|
||||
if (box != nil) {
|
||||
log.Println("InitGuiBox() APPEND NEW BOX TO OLD BOX")
|
||||
box.UiBox.Append(uiBox, false)
|
||||
} else {
|
||||
log.Println("InitGuiBox() APPEND NEW BOX TO TAB")
|
||||
gw.UiTab.Append(name, uiBox)
|
||||
}
|
||||
gw.BoxMap[name] = &newGuiBox
|
||||
log.Println("InitGuiBox() END")
|
||||
return &newGuiBox
|
||||
}
|
||||
|
||||
func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox, uiW *ui.Window, uiT *ui.Tab) *GuiWindow {
|
||||
log.Println("InitGuiWindow() START")
|
||||
var newGuiWindow GuiWindow
|
||||
newGuiWindow.Width = int(c.Width)
|
||||
newGuiWindow.Height = int(c.Height)
|
||||
newGuiWindow.Action = action
|
||||
newGuiWindow.MakeWindow = maketab
|
||||
newGuiWindow.UiWindow = uiW
|
||||
newGuiWindow.UiTab = uiT
|
||||
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
||||
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
||||
newGuiWindow.EntryMap["test"] = nil
|
||||
Data.Windows = append(Data.Windows, &newGuiWindow)
|
||||
|
||||
log.Println("InitGuiWindow() END *GuiWindow =", &newGuiWindow)
|
||||
return &newGuiWindow
|
||||
}
|
||||
|
||||
|
||||
func StartNewWindow(c *pb.Config, bg bool, action string, maketab func(*GuiWindow) *GuiBox) {
|
||||
log.Println("InitNewWindow() Create a new window")
|
||||
window := InitGuiWindow(c, action, maketab, nil, nil)
|
||||
/*
|
||||
newGuiWindow.Width = int(c.Width)
|
||||
newGuiWindow.Height = int(c.Height)
|
||||
newGuiWindow.Action = action
|
||||
newGuiWindow.MakeWindow = maketab
|
||||
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
||||
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
||||
newGuiWindow.EntryMap["test"] = nil
|
||||
Data.Windows = append(Data.Windows, &newGuiWindow)
|
||||
*/
|
||||
|
||||
if (bg) {
|
||||
log.Println("ShowWindow() IN NEW GOROUTINE")
|
||||
go ui.Main(func() {
|
||||
InitTabWindow(window)
|
||||
})
|
||||
time.Sleep(2000 * time.Millisecond)
|
||||
} else {
|
||||
log.Println("ShowWindow() WAITING for ui.Main()")
|
||||
ui.Main(func() {
|
||||
InitTabWindow(window)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func getSplashText(a string) *ui.AttributedString {
|
||||
var aText *ui.AttributedString
|
||||
aText = ui.NewAttributedString(a)
|
||||
return aText
|
||||
}
|
||||
|
||||
func InitTabWindow(gw *GuiWindow) {
|
||||
log.Println("InitTabWindow() THIS WINDOW IS NOT YET SHOWN")
|
||||
|
||||
gw.UiWindow = ui.NewWindow("", int(gw.Width), int(gw.Height), true)
|
||||
gw.UiWindow.SetBorderless(false)
|
||||
|
||||
// create a 'fake' button entry for the mouse clicks
|
||||
var newBM GuiButton
|
||||
newBM.Action = "QUIT"
|
||||
// newBM.W = gw.UiWindow
|
||||
newBM.GW = gw
|
||||
Data.AllButtons = append(Data.AllButtons, &newBM)
|
||||
|
||||
gw.UiWindow.OnClosing(func(*ui.Window) bool {
|
||||
log.Println("InitTabWindow() OnClosing() THIS WINDOW IS CLOSING gw=", gw)
|
||||
// mouseClick(&newBM)
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
|
||||
gw.UiTab = ui.NewTab()
|
||||
gw.UiWindow.SetChild(gw.UiTab)
|
||||
gw.UiWindow.SetMargined(true)
|
||||
|
||||
log.Println("InitTabWindow() gw =", gw)
|
||||
|
||||
abox := gw.MakeWindow(gw)
|
||||
|
||||
gw.UiTab.Append("WIT Splash", abox.UiBox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
|
||||
Data.State = "splash"
|
||||
gw.UiWindow.Show()
|
||||
}
|
||||
|
||||
func AddBoxToTab(name string, tab *ui.Tab, box *ui.Box) {
|
||||
tab.Append(name, box)
|
||||
tab.SetMargined(0, true)
|
||||
}
|
||||
|
||||
/*
|
||||
// string handling examples that might be helpful for normalizeInt()
|
||||
isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString
|
||||
|
||||
for _, username := range []string{"userone", "user2", "user-three"} {
|
||||
if !isAlpha(username) {
|
||||
fmt.Printf("%q is not valid\n", username)
|
||||
}
|
||||
}
|
||||
|
||||
const alpha = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
func alphaOnly(s string) bool {
|
||||
for _, char := range s {
|
||||
if !strings.Contains(alpha, strings.ToLower(string(char))) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
*/
|
||||
|
||||
func normalizeInt(s string) string {
|
||||
// reg, err := regexp.Compile("[^a-zA-Z0-9]+")
|
||||
reg, err := regexp.Compile("[^0-9]+")
|
||||
if err != nil {
|
||||
log.Println("normalizeInt() regexp.Compile() ERROR =", err)
|
||||
return s
|
||||
}
|
||||
clean := reg.ReplaceAllString(s, "")
|
||||
log.Println("normalizeInt() s =", clean)
|
||||
return clean
|
||||
}
|
||||
|
||||
func defaultEntryChange(e *ui.Entry) {
|
||||
for key, em := range Data.AllEntries {
|
||||
if (Data.Debug) {
|
||||
log.Println("\tdefaultEntryChange() Data.AllEntries =", key, em)
|
||||
}
|
||||
if Data.AllEntries[key].UiEntry == e {
|
||||
log.Println("defaultEntryChange() FOUND",
|
||||
"action =", Data.AllEntries[key].Action,
|
||||
"Last =", Data.AllEntries[key].Last,
|
||||
"e.Text() =", e.Text())
|
||||
Data.AllEntries[key].Last = e.Text()
|
||||
if Data.AllEntries[key].Normalize != nil {
|
||||
fixed := Data.AllEntries[key].Normalize(e.Text())
|
||||
e.SetText(fixed)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Println("defaultEntryChange() ERROR. MISSING ENTRY MAP. e.Text() =", e.Text())
|
||||
}
|
||||
|
||||
func defaultMakeEntry(startValue string, edit bool, action string) *GuiEntry {
|
||||
e := ui.NewEntry()
|
||||
e.SetText(startValue)
|
||||
if (edit == false) {
|
||||
e.SetReadOnly(true)
|
||||
}
|
||||
e.OnChanged(defaultEntryChange)
|
||||
|
||||
// add the entry field to the global map
|
||||
var newEntry GuiEntry
|
||||
newEntry.UiEntry = e
|
||||
newEntry.Edit = edit
|
||||
newEntry.Action = action
|
||||
if (action == "Memory") {
|
||||
newEntry.Normalize = normalizeInt
|
||||
}
|
||||
Data.AllEntries = append(Data.AllEntries, &newEntry)
|
||||
|
||||
return &newEntry
|
||||
}
|
79
splash.go
79
splash.go
|
@ -1,79 +0,0 @@
|
|||
package gui
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
// import "time"
|
||||
// import "fmt"
|
||||
|
||||
import "os"
|
||||
import "log"
|
||||
import "runtime"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
func ShowSplashBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
|
||||
log.Println("ShowSplashBox() START")
|
||||
log.Println("ShowSplashBox() START gw =", gw)
|
||||
if (gw == nil) {
|
||||
log.Println("ShowSplashBox() WE ARE FUCKED BECAUSE WE DON'T KNOW WHAT WINDOW TO DO THIS IN")
|
||||
os.Exit(0)
|
||||
return nil
|
||||
}
|
||||
var gb *GuiBox
|
||||
gb = new(GuiBox)
|
||||
|
||||
gb.EntryMap = make(map[string]*GuiEntry)
|
||||
gb.EntryMap["test"] = nil
|
||||
|
||||
newbox := ui.NewVerticalBox()
|
||||
newbox.SetPadded(true)
|
||||
// gw.Box1 = hbox
|
||||
gb.UiBox = newbox
|
||||
gb.W = gw
|
||||
gw.BoxMap["Splash"] = gb
|
||||
|
||||
/*
|
||||
// initialize the GuiArea{}
|
||||
gb.Area = new(GuiArea)
|
||||
gb.Area.Window = gw
|
||||
gb.Area.UiAttrstr = newText
|
||||
*/
|
||||
|
||||
makeSplashArea(gb, newText)
|
||||
|
||||
newbox.Append(gb.Area.UiArea, true)
|
||||
|
||||
if runtime.GOOS == "linux" {
|
||||
newbox.Append(ui.NewLabel("OS: Linux"), false)
|
||||
} else if runtime.GOOS == "windows" {
|
||||
newbox.Append(ui.NewLabel("OS: Windows"), false)
|
||||
} else {
|
||||
newbox.Append(ui.NewLabel("OS: " + runtime.GOOS), false)
|
||||
}
|
||||
|
||||
version := "Version: " + Data.Version
|
||||
newbox.Append(ui.NewLabel(version), false)
|
||||
|
||||
if (Data.Debug) {
|
||||
if (Data.GitCommit != "") {
|
||||
tmp := "git rev-list: " + Data.GitCommit
|
||||
newbox.Append(ui.NewLabel(tmp), false)
|
||||
}
|
||||
if (Data.GoVersion != "") {
|
||||
tmp := "go build version: " + Data.GoVersion
|
||||
newbox.Append(ui.NewLabel(tmp), false)
|
||||
}
|
||||
if (Data.Buildtime != "") {
|
||||
tmp := "build date: " + Data.Buildtime
|
||||
newbox.Append(ui.NewLabel(tmp), false)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("ShowSplashBox() START gb =", gb)
|
||||
|
||||
okButton := CreateButton(gb, nil, nil, "OK", "AREA", nil)
|
||||
newbox.Append(okButton.B, false)
|
||||
|
||||
// os.Exit(0)
|
||||
return gb
|
||||
}
|
40
structs.go
40
structs.go
|
@ -8,6 +8,8 @@ import _ "github.com/andlabs/ui/winmanifest"
|
|||
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
// THIS IS CLEAN
|
||||
|
||||
//
|
||||
// All GUI Data Structures and functions that are external
|
||||
// If you need cross platform support, these might only
|
||||
|
@ -47,38 +49,52 @@ type GuiData struct {
|
|||
// A map of all buttons everywhere on all
|
||||
// windows, all tabs, across all goroutines
|
||||
// This is "GLOBAL"
|
||||
//
|
||||
// This has to work this way because of how
|
||||
// andlabs/ui & andlabs/libui work
|
||||
AllButtons []*GuiButton
|
||||
ButtonMap map[*GuiButton][]func (*GuiButton)
|
||||
|
||||
EntryNick *ui.Entry
|
||||
EntryUser *ui.Entry
|
||||
EntryPass *ui.Entry
|
||||
}
|
||||
|
||||
// stores information on 'the' window
|
||||
|
||||
//
|
||||
// stores information on the 'window'
|
||||
//
|
||||
// This merges the concept of andlabs/ui *Window and *Tab
|
||||
//
|
||||
// More than one Window is not supported in a cross platform
|
||||
// sense & may never be. On Windows and MacOS, you have to have
|
||||
// 'tabs'. Even under Linux, more than one Window is currently
|
||||
// unstable
|
||||
//
|
||||
// This code will keep track of if the windows is 'tabbed' or
|
||||
// not. You can draw one thing in the window, then destroy
|
||||
// that, then redraw the window with something else
|
||||
// This code will make a 'GuiWindow' regardless of if it is
|
||||
// a stand alone window (which is more or less working on Linux)
|
||||
// or a 'tab' inside a window (which is all that works on MacOS
|
||||
// and MSWindows.
|
||||
//
|
||||
// This struct keeps track of what is in the window so you
|
||||
// can destroy and replace it with something else
|
||||
//
|
||||
type GuiWindow struct {
|
||||
Action string
|
||||
BoxMap map[string]*GuiBox
|
||||
Width int
|
||||
Height int
|
||||
|
||||
// mainbox *ui.Box
|
||||
|
||||
// the callback function to make the window contents
|
||||
MakeWindow func(*GuiWindow) *GuiBox
|
||||
|
||||
// the components of the window
|
||||
BoxMap map[string]*GuiBox
|
||||
EntryMap map[string]*GuiEntry
|
||||
Area *GuiArea
|
||||
|
||||
// andlabs/ui abstraction mapping
|
||||
UiWindow *ui.Window
|
||||
UiTab *ui.Tab // if this != nil, the window is 'tabbed'
|
||||
GetText func() *ui.AttributedString
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,10 +119,11 @@ type GuiButton struct {
|
|||
FB *ui.FontButton
|
||||
}
|
||||
|
||||
// GuiBox is any type of ui.Hbox or ui.Vbox
|
||||
// There can be lots of these for each GuiWindow
|
||||
type GuiBox struct {
|
||||
W *GuiWindow
|
||||
EntryMap map[string]*GuiEntry
|
||||
Area *GuiArea
|
||||
Window *GuiWindow
|
||||
// EntryMap map[string]*GuiEntry
|
||||
|
||||
// andlabs/ui abstraction mapping
|
||||
UiBox *ui.Box
|
||||
|
@ -120,6 +137,7 @@ type GuiEntry struct {
|
|||
|
||||
B *GuiButton
|
||||
Box *GuiBox
|
||||
|
||||
Account *pb.Account
|
||||
VM *pb.Event_VM
|
||||
|
||||
|
|
2
table.go
2
table.go
|
@ -9,6 +9,8 @@ import _ "github.com/andlabs/ui/winmanifest"
|
|||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
// THIS IS CLEAN
|
||||
|
||||
func initRowBTcolor(mh *TableData, intBG int, cell TableColumnData) {
|
||||
humanInt := cell.Index
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ import "runtime"
|
|||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
// THIS IS CLEAN
|
||||
|
||||
func (mh *TableData) NumRows(m *ui.TableModel) int {
|
||||
if (Data.Debug) {
|
||||
log.Println("NumRows = mh.RowCount = ", mh.RowCount, "(last Row & Column =", mh.lastRow, mh.lastColumn, ")")
|
||||
|
@ -108,7 +110,9 @@ func defaultSetCellValue(mh *TableData, row int, column int) {
|
|||
|
||||
button := mh.Rows[row].HumanData[humanID].Button
|
||||
if (button != nil) {
|
||||
mouseClick(button)
|
||||
if (Data.MouseClick != nil) {
|
||||
Data.MouseClick(button)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (Data.Debug) {
|
||||
|
|
182
vmBox.go
182
vmBox.go
|
@ -1,182 +0,0 @@
|
|||
package gui
|
||||
|
||||
import "log"
|
||||
import "fmt"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
func CreateVmBox(gw *GuiWindow, vm *pb.Event_VM) {
|
||||
log.Println("CreateVmBox() START")
|
||||
log.Println("CreateVmBox() vm.Name =", vm.Name)
|
||||
log.Println("CreateVmBox() gw =", gw)
|
||||
|
||||
var box *GuiBox
|
||||
box = new(GuiBox)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
log.Println("CreateVmBox() vbox =", vbox)
|
||||
log.Println("CreateVmBox() box.UiBox =", box.UiBox)
|
||||
box.UiBox = vbox
|
||||
log.Println("CreateVmBox() box.W =", box.W)
|
||||
box.W = gw
|
||||
log.Println("CreateVmBox() gw.BoxMap =", gw.BoxMap)
|
||||
gw.BoxMap[vm.Name] = box
|
||||
|
||||
if (Data.Debug) {
|
||||
spew.Dump(vm)
|
||||
}
|
||||
|
||||
hboxAccount := ui.NewHorizontalBox()
|
||||
hboxAccount.SetPadded(true)
|
||||
vbox.Append(hboxAccount, false)
|
||||
|
||||
// Add hostname entry box
|
||||
makeEntryVbox(hboxAccount, "hostname:", vm.Hostname, true, "Hostname")
|
||||
makeEntryVbox(hboxAccount, "IPv6:", vm.IPv6, true, "IPv6")
|
||||
makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",vm.Memory), true, "Memory")
|
||||
makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",vm.Cpus), true, "Cpus")
|
||||
makeEntryVbox(hboxAccount, "Disk (GB):",fmt.Sprintf("%d",vm.Disk), true, "Disk")
|
||||
makeEntryVbox(hboxAccount, "OS Image:", vm.BaseImage, true, "BaseImage")
|
||||
|
||||
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)
|
||||
hboxButtons.Append(a.B, false)
|
||||
|
||||
AddBoxToTab(vm.Name, gw.UiTab, vbox)
|
||||
}
|
||||
|
||||
func createAddVmBox(gw *GuiWindow, b *GuiButton) {
|
||||
log.Println("createAddVmBox() START")
|
||||
name := "(" + b.Account.Nick + ")"
|
||||
|
||||
var box *GuiBox
|
||||
box = new(GuiBox)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
box.UiBox = vbox
|
||||
box.W = gw
|
||||
gw.BoxMap["ADD VM" + name] = box
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
vbox.Append(hbox, false)
|
||||
|
||||
// Add hostname entry box
|
||||
hostname := makeEntryHbox(vbox, "Hostname:", "testhost", true, "Hostname")
|
||||
memory := makeEntryHbox(vbox, "Memory:", "512", true, "Memory")
|
||||
disk := makeEntryHbox(vbox, "Disk:", "20", true, "Disk")
|
||||
|
||||
log.Println("createAddVmBox() hostname, memory, disk =", hostname, memory, disk)
|
||||
|
||||
vbox.Append(ui.NewHorizontalSeparator(), false)
|
||||
|
||||
hboxButtons := ui.NewHorizontalBox()
|
||||
hboxButtons.SetPadded(true)
|
||||
vbox.Append(hboxButtons, false)
|
||||
|
||||
var newb GuiButton
|
||||
newb.Action = "CREATE"
|
||||
newb.VM = b.VM
|
||||
newb.Account = b.Account
|
||||
hostname.B = &newb
|
||||
memory.B = &newb
|
||||
disk.B = &newb
|
||||
hboxButtons.Append(AddButton(&newb, "Add Virtual Machine"), false)
|
||||
|
||||
a := CreateButton(box, nil, nil, "Cancel", "CLOSE", nil)
|
||||
hboxButtons.Append(a.B, false)
|
||||
|
||||
AddBoxToTab(name, gw.UiTab, vbox)
|
||||
}
|
||||
|
||||
//
|
||||
// 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 *GuiWindow, name string, count int, a *pb.Account) *TableData {
|
||||
var parts []TableColumnData
|
||||
|
||||
human := 0
|
||||
|
||||
tmp := TableColumnData{}
|
||||
tmp.CellType = "BG"
|
||||
tmp.Heading = "background"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = TableColumnData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "name"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = TableColumnData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "hostname"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = TableColumnData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "IPv6"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = TableColumnData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "cpus"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = TableColumnData{}
|
||||
tmp.CellType = "TEXTCOLOR"
|
||||
tmp.Heading = "memory"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
tmp = TableColumnData{}
|
||||
tmp.CellType = "BUTTON"
|
||||
tmp.Heading = "Details"
|
||||
tmp.Index = human
|
||||
parts = append(parts, tmp)
|
||||
human += 1
|
||||
|
||||
mh := AddTableTab(gw, name, count, parts, a)
|
||||
// mh :=
|
||||
return mh
|
||||
}
|
Loading…
Reference in New Issue