MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / displayCreateForm

Method displayCreateForm

internal/ui/components/backup_form.go:77–176  ·  view source on GitHub ↗
(storageOptions []string)

Source from the content-addressed store, hash-verified

75}
76
77func (bf *BackupForm) displayCreateForm(storageOptions []string) {
78 storageDropdown := tview.NewDropDown().
79 SetLabel("Target Storage").
80 SetOptions(storageOptions, nil).
81 SetCurrentOption(0).
82 SetFieldWidth(30)
83
84 modeOptions := []string{"snapshot", "suspend", "stop"}
85 modeDropdown := tview.NewDropDown().
86 SetLabel("Backup Mode").
87 SetOptions(modeOptions, nil).
88 SetCurrentOption(0). // Snapshot default
89 SetFieldWidth(20)
90
91 compressOptions := []string{"zstd", "gzip", "lzo", "none"}
92 compressDropdown := tview.NewDropDown().
93 SetLabel("Compression").
94 SetOptions(compressOptions, nil).
95 SetCurrentOption(0). // zstd default
96 SetFieldWidth(20)
97
98 notesField := tview.NewInputField().
99 SetLabel("Notes").
100 SetFieldWidth(40)
101
102 removeCheck := tview.NewCheckbox().
103 SetLabel("Prune (Remove old)").
104 SetChecked(false)
105
106 form := newStandardForm().
107 AddFormItem(storageDropdown).
108 AddFormItem(modeDropdown).
109 AddFormItem(compressDropdown).
110 AddFormItem(notesField).
111 AddFormItem(removeCheck)
112
113 form.AddButton("Backup", func() {
114 storageIdx, _ := storageDropdown.GetCurrentOption()
115 storage := storageOptions[storageIdx]
116
117 modeIdx, _ := modeDropdown.GetCurrentOption()
118 mode := modeOptions[modeIdx]
119
120 compressIdx, _ := compressDropdown.GetCurrentOption()
121 compress := compressOptions[compressIdx]
122 if compress == "none" {
123 compress = "0"
124 }
125
126 notes := notesField.GetText()
127 remove := removeCheck.IsChecked()
128
129 bf.app.pages.RemovePage("createBackup")
130 bf.onSuccessCallback() // Restore focus
131
132 bf.app.header.ShowLoading("Starting backup...")
133
134 go func() {

Callers 1

ShowCreateFormMethod · 0.95

Calls 11

CreateBackupMethod · 0.95
newStandardFormFunction · 0.85
NewBackupOperationsFunction · 0.85
SetFieldWidthMethod · 0.80
SetLabelMethod · 0.80
QueueUpdateDrawMethod · 0.80
ShowLoadingMethod · 0.65
ShowErrorMethod · 0.65
ShowSuccessMethod · 0.65
SetTitleMethod · 0.65
SetFocusMethod · 0.65

Tested by

no test coverage detected