working on a droplet edit window
This commit is contained in:
parent
2c5701eeca
commit
4332b3d31a
|
@ -22,14 +22,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// refresh the windows & tables the user has open
|
// refresh the windows & tables the user has open
|
||||||
func (admin *adminT) refresh() {
|
func (admin *adminT) refresh() error {
|
||||||
if argv.Verbose {
|
if argv.Verbose {
|
||||||
log.Info("virtigo scan here")
|
log.Info("virtigo scan here")
|
||||||
}
|
}
|
||||||
|
|
||||||
if admin.url == nil {
|
if admin.url == nil {
|
||||||
log.Info("admin url == nil")
|
log.Info("admin url == nil")
|
||||||
return
|
return fmt.Errorf("admin url == nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := []byte(`{"message": "Hello"}`)
|
msg := []byte(`{"message": "Hello"}`)
|
||||||
|
@ -50,7 +50,7 @@ func (admin *adminT) refresh() {
|
||||||
admin.cluster.Droplets = new(virtpb.Droplets)
|
admin.cluster.Droplets = new(virtpb.Droplets)
|
||||||
if err := admin.cluster.Droplets.Unmarshal(data); err != nil {
|
if err := admin.cluster.Droplets.Unmarshal(data); err != nil {
|
||||||
fmt.Println("droplets marshal failed", err)
|
fmt.Println("droplets marshal failed", err)
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("Droplet len=", admin.cluster.Droplets.Len())
|
fmt.Println("Droplet len=", admin.cluster.Droplets.Len())
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ func (admin *adminT) refresh() {
|
||||||
admin.cluster.Hypervisors = new(virtpb.Hypervisors)
|
admin.cluster.Hypervisors = new(virtpb.Hypervisors)
|
||||||
if err := admin.cluster.Hypervisors.Unmarshal(data); err != nil {
|
if err := admin.cluster.Hypervisors.Unmarshal(data); err != nil {
|
||||||
fmt.Println("hypervisors marshal failed", err)
|
fmt.Println("hypervisors marshal failed", err)
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("Hypervisors len=", admin.cluster.Hypervisors.Len())
|
fmt.Println("Hypervisors len=", admin.cluster.Hypervisors.Len())
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,11 @@ func (admin *adminT) refresh() {
|
||||||
admin.cluster.Events = new(virtpb.Events)
|
admin.cluster.Events = new(virtpb.Events)
|
||||||
if err := admin.cluster.Events.Unmarshal(data); err != nil {
|
if err := admin.cluster.Events.Unmarshal(data); err != nil {
|
||||||
fmt.Println("events marshal failed", err)
|
fmt.Println("events marshal failed", err)
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("Events len=", admin.cluster.Events.Len())
|
fmt.Println("Events len=", admin.cluster.Events.Len())
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var client *http.Client
|
var client *http.Client
|
||||||
|
@ -356,6 +357,10 @@ func (admin *adminT) makeClusterGroup(c *virtpb.Cluster) {
|
||||||
admin.refresh()
|
admin.refresh()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if err := admin.refresh(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
grid.NewButton("save cluster.pb", func() {
|
grid.NewButton("save cluster.pb", func() {
|
||||||
admin.cluster.ConfigSave()
|
admin.cluster.ConfigSave()
|
||||||
})
|
})
|
||||||
|
@ -407,7 +412,7 @@ func (admin *adminT) postEvent(e *virtpb.Event) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if result.Error != "" {
|
if result.Error != "" {
|
||||||
return fmt.Errorf(result.Error)
|
return fmt.Errorf("%s", result.Error)
|
||||||
}
|
}
|
||||||
log.Printf("Event worked: %s\n", result.DropletUuid)
|
log.Printf("Event worked: %s\n", result.DropletUuid)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -31,25 +31,3 @@ func createWindow() *gadgets.GenericWindow {
|
||||||
|
|
||||||
return createWindow
|
return createWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
func editDropletWindow() *gadgets.GenericWindow {
|
|
||||||
editDropletWindow := gadgets.NewGenericWindow("Create Droplet", "settings")
|
|
||||||
editDropletWindow.Custom = func() {
|
|
||||||
log.Warn("create window close")
|
|
||||||
}
|
|
||||||
|
|
||||||
grid := editDropletWindow.Group.RawGrid()
|
|
||||||
|
|
||||||
gadgets.NewBasicEntry(grid, "memory")
|
|
||||||
grid.NextRow()
|
|
||||||
|
|
||||||
grid.NewLabel("name")
|
|
||||||
grid.NewTextbox("something")
|
|
||||||
grid.NextRow()
|
|
||||||
|
|
||||||
grid.NewButton("Start", func() {
|
|
||||||
log.Info("make a box")
|
|
||||||
})
|
|
||||||
|
|
||||||
return editDropletWindow
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the GPL 3.0
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
// An app to submit patches for the 30 GO GUI repos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func editDropletWindow(d *virtpb.Droplet) *gadgets.GenericWindow {
|
||||||
|
win := gadgets.NewGenericWindow("Edit Droplet "+d.Hostname, "settings")
|
||||||
|
win.Custom = func() {
|
||||||
|
log.Warn("edit window close")
|
||||||
|
}
|
||||||
|
|
||||||
|
grid := win.Group.RawGrid()
|
||||||
|
|
||||||
|
var save *gui.Node
|
||||||
|
|
||||||
|
grid.NewLabel("name")
|
||||||
|
name := grid.NewTextbox("something")
|
||||||
|
name.SetText(d.Hostname)
|
||||||
|
name.Custom = func() {
|
||||||
|
log.Info("changed droplet name")
|
||||||
|
}
|
||||||
|
grid.NextRow()
|
||||||
|
|
||||||
|
mem := gadgets.NewBasicEntry(grid, "memory (GB)")
|
||||||
|
mem.SetText(fmt.Sprintf("%d", d.Memory/(1024*1024*1024)))
|
||||||
|
grid.NextRow()
|
||||||
|
mem.Custom = func() {
|
||||||
|
save.Enable()
|
||||||
|
log.Info("changed mem value. new val =", mem.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
cpus := gadgets.NewBasicEntry(grid, "cpus")
|
||||||
|
cpus.SetText(fmt.Sprintf("%d", d.Cpus))
|
||||||
|
grid.NextRow()
|
||||||
|
cpus.Custom = func() {
|
||||||
|
log.Info("changed cpus value")
|
||||||
|
}
|
||||||
|
|
||||||
|
grid.NewLabel("hypervisor")
|
||||||
|
hyper := grid.NewDropdown()
|
||||||
|
hyper.AddText("farm03")
|
||||||
|
hyper.AddText("farm04")
|
||||||
|
hyper.AddText("farm05")
|
||||||
|
if d.Current != nil {
|
||||||
|
hyper.SetText(d.Current.Hypervisor)
|
||||||
|
}
|
||||||
|
grid.NextRow()
|
||||||
|
|
||||||
|
grid.NewButton("Start", func() {
|
||||||
|
log.Info("make a box")
|
||||||
|
})
|
||||||
|
|
||||||
|
save = grid.NewButton("save", func() {
|
||||||
|
log.Info("save droplet changes here")
|
||||||
|
})
|
||||||
|
save.Disable()
|
||||||
|
|
||||||
|
grid.NewButton("dump", func() {
|
||||||
|
t := d.FormatTEXT()
|
||||||
|
log.Info(t)
|
||||||
|
})
|
||||||
|
|
||||||
|
return win
|
||||||
|
}
|
|
@ -91,9 +91,7 @@ func makeWindownDropletsPB(pb *virtpb.Droplets) *stdDropletTableWin {
|
||||||
|
|
||||||
return dwin
|
return dwin
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
func (dwin *stdDropletTableWin) doDropletsTable(currentDroplets *virtpb.Droplets) {
|
func (dwin *stdDropletTableWin) doDropletsTable(currentDroplets *virtpb.Droplets) {
|
||||||
dwin.Lock()
|
dwin.Lock()
|
||||||
defer dwin.Unlock()
|
defer dwin.Unlock()
|
||||||
|
@ -147,32 +145,28 @@ func (dw *stdDropletTableWin) doInactiveDroplets(pb *virtpb.Droplets) {
|
||||||
t.NewUuid()
|
t.NewUuid()
|
||||||
t.SetParent(dw.box)
|
t.SetParent(dw.box)
|
||||||
|
|
||||||
// pick the columns
|
dropedit := t.AddButtonFunc("Edit", func(d *virtpb.Droplet) string {
|
||||||
// t.AddHostname()
|
return "edit"
|
||||||
|
})
|
||||||
|
dropedit.Custom = func(d *virtpb.Droplet) {
|
||||||
|
log.Info("edit droplet here", d.Hostname)
|
||||||
|
editDropletWindow(d)
|
||||||
|
}
|
||||||
|
|
||||||
dropon := t.AddButtonFunc("Start", func(d *virtpb.Droplet) string {
|
dropon := t.AddButtonFunc("Start", func(d *virtpb.Droplet) string {
|
||||||
return "poweron"
|
return "poweron"
|
||||||
})
|
})
|
||||||
dropon.Custom = func(d *virtpb.Droplet) {
|
dropon.Custom = func(d *virtpb.Droplet) {
|
||||||
log.Info("start droplet here", d.Hostname)
|
log.Info("start droplet here", d.Hostname)
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
t.AddHostname()
|
|
||||||
t.AddStringFunc("location", func(d *virtpb.Droplet) string {
|
|
||||||
return d.Current.Hypervisor
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
vp := t.AddButtonFunc("Verify Config", func(p *virtpb.Droplet) string {
|
vp := t.AddButtonFunc("Verify Config", func(p *virtpb.Droplet) string {
|
||||||
return p.Hostname
|
return p.Hostname
|
||||||
})
|
})
|
||||||
vp.Custom = func(d *virtpb.Droplet) {
|
vp.Custom = func(d *virtpb.Droplet) {
|
||||||
log.Info("open config window", d.Hostname)
|
log.Info("open config window", d.Hostname)
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
t.AddHostname()
|
|
||||||
t.AddStringFunc("location", func(d *virtpb.Droplet) string {
|
|
||||||
return d.Current.Hypervisor
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
t.AddMemory()
|
t.AddMemory()
|
||||||
t.AddCpus()
|
t.AddCpus()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue