summaryrefslogtreecommitdiff
path: root/windowDropletEdit.go
blob: 1bb54c5de76dd1e8f20c68e96f2ea903bd6caf35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
}