2019-05-22 22:49:28 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
|
2019-05-24 20:17:05 -05:00
|
|
|
// import "github.com/gookit/config"
|
2019-05-22 22:49:28 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-24 22:54:09 -05:00
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
2019-05-22 22:49:28 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2019-05-24 15:23:50 -05:00
|
|
|
func makeCloudInfoBox(custom func(*ButtonMap)) *ui.Box {
|
2019-05-22 22:49:28 -05:00
|
|
|
hbox := ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
|
2019-05-24 20:17:05 -05:00
|
|
|
if (Data.Debug) {
|
2019-05-24 02:40:52 -05:00
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
hbox.Append(vbox, false)
|
2019-05-22 22:49:28 -05:00
|
|
|
|
|
|
|
addDebuggingButtons(vbox, custom)
|
|
|
|
|
2019-05-24 02:40:52 -05:00
|
|
|
hbox.Append(ui.NewVerticalSeparator(), false)
|
|
|
|
}
|
2019-05-22 22:49:28 -05:00
|
|
|
|
2019-05-24 02:40:52 -05:00
|
|
|
vbox := ui.NewVerticalBox()
|
2019-05-22 22:49:28 -05:00
|
|
|
vbox.SetPadded(true)
|
|
|
|
hbox.Append(vbox, true)
|
|
|
|
|
2019-05-23 11:48:12 -05:00
|
|
|
/*
|
2019-05-22 22:49:28 -05:00
|
|
|
grid := ui.NewGrid()
|
|
|
|
grid.SetPadded(true)
|
|
|
|
vbox.Append(grid, false)
|
2019-05-23 11:48:12 -05:00
|
|
|
*/
|
2019-05-22 22:49:28 -05:00
|
|
|
|
2019-05-24 02:04:14 -05:00
|
|
|
hostnamebox := ui.NewHorizontalBox()
|
|
|
|
hostnamebox.SetPadded(true)
|
|
|
|
vbox.Append(hostnamebox, false)
|
|
|
|
|
2019-05-22 22:49:28 -05:00
|
|
|
entryForm := ui.NewForm()
|
|
|
|
entryForm.SetPadded(true)
|
2019-05-24 02:04:14 -05:00
|
|
|
hostnamebox.Append(entryForm, true)
|
2019-05-22 22:49:28 -05:00
|
|
|
|
|
|
|
hostnameEntry := ui.NewEntry()
|
|
|
|
entryForm.Append("hostname:", hostnameEntry, false)
|
2019-05-24 02:04:14 -05:00
|
|
|
tmp := Data.Hostname + " (" + Data.IPv6 + ")"
|
|
|
|
hostnameEntry.SetText(tmp)
|
|
|
|
hostnameEntry.SetReadOnly(true)
|
2019-05-22 22:49:28 -05:00
|
|
|
|
2019-05-24 22:54:09 -05:00
|
|
|
hostnamebox.Append(CreateButton(nil, nil, "Edit", "EDIT", custom), false)
|
2019-05-22 22:49:28 -05:00
|
|
|
|
2019-05-23 11:48:12 -05:00
|
|
|
vbox.Append(ui.NewHorizontalSeparator(), false)
|
|
|
|
|
|
|
|
agrid := ui.NewGrid()
|
|
|
|
agrid.SetPadded(true)
|
|
|
|
|
2019-05-23 17:07:10 -05:00
|
|
|
agrid.Append(ui.NewLabel("Accounts:"), 0, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
agrid.Append(ui.NewLabel("Nickname"), 1, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
agrid.Append(ui.NewLabel("Username"), 2, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
agrid.Append(ui.NewLabel("Domain Name"), 3, 0, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
|
|
|
|
row := 1
|
|
|
|
|
2019-05-24 20:17:05 -05:00
|
|
|
for key, foo := range Data.Config.Accounts {
|
|
|
|
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)
|
|
|
|
log.Println("account = ", key, foo)
|
2019-05-23 17:07:10 -05:00
|
|
|
|
2019-05-24 20:17:05 -05:00
|
|
|
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Nick), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Username), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Domainname), 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
2019-05-23 19:44:00 -05:00
|
|
|
|
2019-05-24 22:54:09 -05:00
|
|
|
name := "Login " + Data.Config.Accounts[key].Nick
|
|
|
|
l := CreateButton(Data.Config.Accounts[key], nil, name, "LOGIN", custom)
|
2019-05-24 02:04:14 -05:00
|
|
|
agrid.Append(l, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
|
2019-05-24 22:54:09 -05:00
|
|
|
name = "Show " + Data.Config.Accounts[key].Nick
|
|
|
|
b := CreateButton(Data.Config.Accounts[key], nil, name, "SHOW", custom)
|
2019-05-24 02:04:14 -05:00
|
|
|
agrid.Append(b, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
2019-05-23 17:07:10 -05:00
|
|
|
|
|
|
|
row += 1
|
2019-05-23 11:48:12 -05:00
|
|
|
}
|
2019-05-24 20:17:05 -05:00
|
|
|
|
2019-05-24 02:40:52 -05:00
|
|
|
row += 1
|
|
|
|
agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
|
|
|
row += 1
|
2019-05-24 22:54:09 -05:00
|
|
|
a := CreateButton(nil, nil, "Add Account", "ADD", custom)
|
2019-05-24 02:40:52 -05:00
|
|
|
agrid.Append(a, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
2019-05-24 22:54:09 -05:00
|
|
|
q := CreateButton(nil, nil, "Quit", "QUIT", custom)
|
2019-05-24 02:40:52 -05:00
|
|
|
agrid.Append(q, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
|
2019-05-23 17:07:10 -05:00
|
|
|
|
|
|
|
vbox.Append(agrid, false)
|
2019-05-22 22:49:28 -05:00
|
|
|
return hbox
|
|
|
|
}
|
|
|
|
|
2019-05-24 22:54:09 -05:00
|
|
|
func AddVmsTab(name string, count int, a *pb.Config_Account) *TableData {
|
2019-05-22 22:49:28 -05:00
|
|
|
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
|
|
|
|
|
2019-05-24 22:54:09 -05:00
|
|
|
mh := AddTableTab(Data.cloudTab, 1, name, count, parts, a)
|
2019-05-22 22:49:28 -05:00
|
|
|
return mh
|
|
|
|
}
|