sends an edit event

This commit is contained in:
Jeff Carr 2025-04-22 20:49:47 -05:00
parent 4332b3d31a
commit c8a50fbb18
4 changed files with 18 additions and 56 deletions

View File

@ -207,7 +207,7 @@ func makeEventsWindow(pb *virtpb.Events) *gadgets.GenericWindow {
t := pb.NewTable("test 2")
t.NewUuid()
t.SetParent(tbox)
t.AddDroplet()
t.AddDropletName()
t.AddHypervisor()
t.ShowTable()
return win

View File

@ -14,7 +14,7 @@ import (
"go.wit.com/log"
)
func editDropletWindow(d *virtpb.Droplet) *gadgets.GenericWindow {
func (admin *adminT) editDropletWindow(d *virtpb.Droplet) *gadgets.GenericWindow {
win := gadgets.NewGenericWindow("Edit Droplet "+d.Hostname, "settings")
win.Custom = func() {
log.Warn("edit window close")
@ -63,6 +63,18 @@ func editDropletWindow(d *virtpb.Droplet) *gadgets.GenericWindow {
save = grid.NewButton("save", func() {
log.Info("save droplet changes here")
e := new(virtpb.Event)
e.Etype = virtpb.EventType_EDIT
e.Droplet = new(virtpb.Droplet)
e.Droplet.Uuid = d.Uuid
e.Droplet.Cpus = 4
e.Droplet.Memory = 8 * (1024 * 1024 * 1024)
e.Droplet.Hostname = name.String()
if err := admin.postEvent(e); err != nil {
log.Info("event edit err", err)
}
})
save.Disable()

View File

@ -23,6 +23,7 @@ type stdDropletTableWin struct {
TB *virtpb.DropletsTable // the gui table buffer
update bool // if the window should be updated
Close func() // this function is called when the window is closed
admin *adminT
}
func (w *stdDropletTableWin) Toggle() {
@ -37,6 +38,7 @@ func (w *stdDropletTableWin) Toggle() {
func newDropletsWindow(admin *adminT) *stdDropletTableWin {
dwin := new(stdDropletTableWin)
dwin.admin = admin
dwin.win = gadgets.NewGenericWindow("virtigo current droplets", "Options")
dwin.win.Custom = func() {
log.Info("test delete window here")
@ -76,58 +78,6 @@ func newDropletsWindow(admin *adminT) *stdDropletTableWin {
return dwin
}
/*
func makeWindownDropletsPB(pb *virtpb.Droplets) *stdDropletTableWin {
dwin := new(stdDropletTableWin)
dwin.win = gadgets.NewGenericWindow("virtigo current droplets", "")
dwin.win.Custom = func() {
log.Info("test delete window here")
}
// make a box at the bottom of the window for the protobuf table
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
dwin.doDropletsTable(pb)
return dwin
}
func (dwin *stdDropletTableWin) doDropletsTable(currentDroplets *virtpb.Droplets) {
dwin.Lock()
defer dwin.Unlock()
if dwin.TB != nil {
dwin.TB.Delete()
dwin.TB = nil
}
// display the protobuf
dwin.TB = addDropletsPB(dwin.box, currentDroplets)
f := func(e *virtpb.Droplet) {
log.Info("Triggered. do something here", e.Hostname)
// m.Enabled = true
}
dwin.TB.Custom(f)
}
func addDropletsPB(tbox *gui.Node, pb *virtpb.Droplets) *virtpb.DropletsTable {
t := pb.NewTable("DropletsPB")
t.NewUuid()
t.SetParent(tbox)
vp := t.AddButtonFunc("start", func(p *virtpb.Droplet) string {
return "poweron"
})
vp.Custom = func(d *virtpb.Droplet) {
log.Info("power on the droplet here:", d.Hostname)
}
t.AddHostname()
t.AddMemory()
t.AddCpus()
t.ShowTable()
return t
}
*/
// default window for active running droplets
func (dw *stdDropletTableWin) doInactiveDroplets(pb *virtpb.Droplets) {
dw.Lock()
@ -150,7 +100,7 @@ func (dw *stdDropletTableWin) doInactiveDroplets(pb *virtpb.Droplets) {
})
dropedit.Custom = func(d *virtpb.Droplet) {
log.Info("edit droplet here", d.Hostname)
editDropletWindow(d)
dw.admin.editDropletWindow(d)
}
dropon := t.AddButtonFunc("Start", func(d *virtpb.Droplet) string {

View File

@ -61,7 +61,7 @@ func (dw *stdEventTableWin) doStdEvents(pb *virtpb.Events) {
t.SetParent(dw.box)
// pick the columns
t.AddDroplet()
t.AddDropletName()
t.AddDropletUuid()
t.AddHypervisor()