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

Method ShowCreateForm

internal/ui/components/backup_form.go:34–75  ·  view source on GitHub ↗

ShowCreateForm displays the create backup form.

(onSuccess func())

Source from the content-addressed store, hash-verified

32
33// ShowCreateForm displays the create backup form.
34func (bf *BackupForm) ShowCreateForm(onSuccess func()) {
35 bf.onSuccessCallback = onSuccess
36 bf.app.header.ShowLoading("Loading storages...")
37
38 go func() {
39 client, err := bf.app.getClientForVM(bf.vm)
40 if err != nil {
41 bf.app.Application.QueueUpdateDraw(func() {
42 bf.app.header.ShowActiveProfile(bf.app.header.GetCurrentProfile())
43 bf.app.header.ShowError(fmt.Sprintf("Failed to get client: %v", err))
44 })
45 return
46 }
47
48 storages, err := client.GetNodeStorages(bf.vm.Node)
49
50 bf.app.Application.QueueUpdateDraw(func() {
51 bf.app.header.ShowActiveProfile(bf.app.header.GetCurrentProfile())
52
53 if err != nil {
54 bf.app.header.ShowError(fmt.Sprintf("Failed to load storages: %v", err))
55 return
56 }
57
58 var storageOptions []string
59
60 // Filter storages
61 for _, s := range storages {
62 if strings.Contains(s.Content, "backup") {
63 storageOptions = append(storageOptions, s.Name)
64 }
65 }
66
67 if len(storageOptions) == 0 {
68 bf.app.showMessageSafe("No storage supports backups on this node.")
69 return
70 }
71
72 bf.displayCreateForm(storageOptions)
73 })
74 }()
75}
76
77func (bf *BackupForm) displayCreateForm(storageOptions []string) {
78 storageDropdown := tview.NewDropDown().

Callers 2

createSnapshotMethod · 0.45
createBackupMethod · 0.45

Calls 9

displayCreateFormMethod · 0.95
getClientForVMMethod · 0.80
QueueUpdateDrawMethod · 0.80
GetNodeStoragesMethod · 0.80
showMessageSafeMethod · 0.80
ShowLoadingMethod · 0.65
ShowActiveProfileMethod · 0.65
GetCurrentProfileMethod · 0.65
ShowErrorMethod · 0.65

Tested by

no test coverage detected