- Fix format detection to read database_type from .meta.json metadata file - Add ensureMySQLDatabaseExists() for MySQL/MariaDB database creation - Route database creation to correct implementation based on db type - Add TUI auto-forward in auto-confirm mode (no input required for debugging) - All TUI components now exit automatically when --auto-confirm is set - Fix status view to skip loading in auto-confirm mode
63 lines
1.2 KiB
Go
Executable File
63 lines
1.2 KiB
Go
Executable File
package tui
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"dbbackup/internal/config"
|
|
"dbbackup/internal/logger"
|
|
)
|
|
|
|
// OperationsViewModel shows active operations
|
|
type OperationsViewModel struct {
|
|
config *config.Config
|
|
logger logger.Logger
|
|
parent tea.Model
|
|
}
|
|
|
|
func NewOperationsView(cfg *config.Config, log logger.Logger, parent tea.Model) OperationsViewModel {
|
|
return OperationsViewModel{
|
|
config: cfg,
|
|
logger: log,
|
|
parent: parent,
|
|
}
|
|
}
|
|
|
|
func (m OperationsViewModel) Init() tea.Cmd {
|
|
return nil
|
|
}
|
|
|
|
func (m OperationsViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
// Auto-forward in auto-confirm mode
|
|
if m.config.TUIAutoConfirm {
|
|
return m.parent, tea.Quit
|
|
}
|
|
|
|
switch msg := msg.(type) {
|
|
case tea.KeyMsg:
|
|
switch msg.String() {
|
|
case "ctrl+c", "q", "esc", "enter":
|
|
return m.parent, nil
|
|
}
|
|
}
|
|
|
|
return m, nil
|
|
}
|
|
|
|
func (m OperationsViewModel) View() string {
|
|
var s strings.Builder
|
|
|
|
header := titleStyle.Render("📊 Active Operations")
|
|
s.WriteString(fmt.Sprintf("\n%s\n\n", header))
|
|
|
|
s.WriteString("Currently running operations:\n\n")
|
|
s.WriteString(infoStyle.Render("📭 No active operations"))
|
|
s.WriteString("\n\n")
|
|
|
|
s.WriteString("⌨️ Press any key to return to menu\n")
|
|
|
|
return s.String()
|
|
}
|