// 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 (admin *adminT) 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") 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() grid.NewButton("dump", func() { t := d.FormatTEXT() log.Info(t) }) return win }