ShowCreateForm displays the create backup form.
(onSuccess func())
| 32 | |
| 33 | // ShowCreateForm displays the create backup form. |
| 34 | func (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 | |
| 77 | func (bf *BackupForm) displayCreateForm(storageOptions []string) { |
| 78 | storageDropdown := tview.NewDropDown(). |
no test coverage detected