fix: add E:edit to footer, generate UUID+timestamps in TUI forms
This commit is contained in:
@@ -4,10 +4,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/textinput"
|
"github.com/charmbracelet/bubbles/textinput"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
|
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
|
||||||
)
|
)
|
||||||
@@ -265,6 +267,7 @@ func (t *HostFormTab) submit() (Tab, tea.Cmd) {
|
|||||||
host.Notes = t.inputs[fieldNotes].Value()
|
host.Notes = t.inputs[fieldNotes].Value()
|
||||||
} else {
|
} else {
|
||||||
host = &models.Host{
|
host = &models.Host{
|
||||||
|
ID: uuid.New().String(),
|
||||||
Name: name,
|
Name: name,
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
Port: port,
|
Port: port,
|
||||||
@@ -273,9 +276,11 @@ func (t *HostFormTab) submit() (Tab, tea.Cmd) {
|
|||||||
Type: authType,
|
Type: authType,
|
||||||
Password: t.inputs[fieldPassword].Value(),
|
Password: t.inputs[fieldPassword].Value(),
|
||||||
},
|
},
|
||||||
Group: t.inputs[fieldGroup].Value(),
|
Group: t.inputs[fieldGroup].Value(),
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Notes: t.inputs[fieldNotes].Value(),
|
Notes: t.inputs[fieldNotes].Value(),
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ func (t *HostListTab) View() string {
|
|||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
var footer styledRow
|
var footer styledRow
|
||||||
footerText := "Ctrl+Tab:switch Ctrl+Q:close ↑↓:nav Enter:SSH Ctrl+N:add Ctrl+F:SFTP Ctrl+K:keys Ctrl+P:snippets q:quit"
|
footerText := "Ctrl+Tab:switch Ctrl+Q:close ↑↓:nav Enter:SSH Ctrl+N:add Ctrl+E:edit Ctrl+F:SFTP Ctrl+K:keys Ctrl+P:snippets q:quit"
|
||||||
footer = styledRow{text: SubtitleStyle.Render(footerText), plain: footerText}
|
footer = styledRow{text: SubtitleStyle.Render(footerText), plain: footerText}
|
||||||
rows = append(rows, footer) // for widest measurement
|
rows = append(rows, footer) // for widest measurement
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package tui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/textinput"
|
"github.com/charmbracelet/bubbles/textinput"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
|
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
|
||||||
)
|
)
|
||||||
@@ -180,10 +182,13 @@ func (t *KeyFormTab) submit() (Tab, tea.Cmd) {
|
|||||||
key.Passphrase = t.inputs[keyFieldPassphrase].Value()
|
key.Passphrase = t.inputs[keyFieldPassphrase].Value()
|
||||||
} else {
|
} else {
|
||||||
key = &models.KeyPair{
|
key = &models.KeyPair{
|
||||||
|
ID: uuid.New().String(),
|
||||||
Name: name,
|
Name: name,
|
||||||
Type: t.inputs[keyFieldType].Value(),
|
Type: t.inputs[keyFieldType].Value(),
|
||||||
PrivateKey: privateKey,
|
PrivateKey: privateKey,
|
||||||
Passphrase: t.inputs[keyFieldPassphrase].Value(),
|
Passphrase: t.inputs[keyFieldPassphrase].Value(),
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package tui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/textinput"
|
"github.com/charmbracelet/bubbles/textinput"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
|
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
|
||||||
)
|
)
|
||||||
@@ -188,10 +190,13 @@ func (t *SnippetFormTab) submit() (Tab, tea.Cmd) {
|
|||||||
sn.Tags = tags
|
sn.Tags = tags
|
||||||
} else {
|
} else {
|
||||||
sn = &models.Snippet{
|
sn = &models.Snippet{
|
||||||
|
ID: uuid.New().String(),
|
||||||
Name: name,
|
Name: name,
|
||||||
Command: command,
|
Command: command,
|
||||||
Description: t.inputs[snippetFieldDescription].Value(),
|
Description: t.inputs[snippetFieldDescription].Value(),
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user