refactor(tui): replace database ID column with row counter
Display sequential # instead of internal database IDs in sites, alerts, and users tables for a cleaner view without gaps from deleted records.
This commit is contained in:
@@ -108,7 +108,7 @@ func (m Model) viewAlertsTab() string {
|
|||||||
for i := m.tableOffset; i < end; i++ {
|
for i := m.tableOffset; i < end; i++ {
|
||||||
alert := m.alerts[i]
|
alert := m.alerts[i]
|
||||||
rows = append(rows, []string{
|
rows = append(rows, []string{
|
||||||
fmt.Sprintf("%d", alert.ID),
|
fmt.Sprintf("%d", i+1),
|
||||||
m.zones.Mark(fmt.Sprintf("alert-%d", i), limitStr(alert.Name, 15)),
|
m.zones.Mark(fmt.Sprintf("alert-%d", i), limitStr(alert.Name, 15)),
|
||||||
fmtAlertType(alert.Type),
|
fmtAlertType(alert.Type),
|
||||||
fmtAlertConfig(struct {
|
fmtAlertConfig(struct {
|
||||||
@@ -127,7 +127,7 @@ func (m Model) viewAlertsTab() string {
|
|||||||
Border(lipgloss.RoundedBorder()).
|
Border(lipgloss.RoundedBorder()).
|
||||||
BorderStyle(alertBorderStyle).
|
BorderStyle(alertBorderStyle).
|
||||||
Width(tableWidth).
|
Width(tableWidth).
|
||||||
Headers("ID", "NAME", "TYPE", "CONFIG").
|
Headers("#", "NAME", "TYPE", "CONFIG").
|
||||||
Rows(rows...).
|
Rows(rows...).
|
||||||
StyleFunc(func(row, col int) lipgloss.Style {
|
StyleFunc(func(row, col int) lipgloss.Style {
|
||||||
if row == table.HeaderRow {
|
if row == table.HeaderRow {
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ func (m Model) viewSitesTab() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rows = append(rows, []string{
|
rows = append(rows, []string{
|
||||||
strconv.Itoa(site.ID),
|
strconv.Itoa(i + 1),
|
||||||
m.zones.Mark(fmt.Sprintf("site-%d", i), limitStr(site.Name, 13)),
|
m.zones.Mark(fmt.Sprintf("site-%d", i), limitStr(site.Name, 13)),
|
||||||
site.Type,
|
site.Type,
|
||||||
fmtStatus(site.Status, site.Paused),
|
fmtStatus(site.Status, site.Paused),
|
||||||
@@ -255,7 +255,7 @@ func (m Model) viewSitesTab() string {
|
|||||||
Border(lipgloss.RoundedBorder()).
|
Border(lipgloss.RoundedBorder()).
|
||||||
BorderStyle(siteBorderStyle).
|
BorderStyle(siteBorderStyle).
|
||||||
Width(tableWidth).
|
Width(tableWidth).
|
||||||
Headers("ID", "NAME", "TYPE", "STATUS", "LATENCY", "UPTIME", "HISTORY", "SSL", "RETRY").
|
Headers("#", "NAME", "TYPE", "STATUS", "LATENCY", "UPTIME", "HISTORY", "SSL", "RETRY").
|
||||||
Rows(rows...).
|
Rows(rows...).
|
||||||
StyleFunc(func(row, col int) lipgloss.Style {
|
StyleFunc(func(row, col int) lipgloss.Style {
|
||||||
if row == table.HeaderRow {
|
if row == table.HeaderRow {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (m Model) viewUsersTab() string {
|
|||||||
for i := m.tableOffset; i < end; i++ {
|
for i := m.tableOffset; i < end; i++ {
|
||||||
u := m.users[i]
|
u := m.users[i]
|
||||||
rows = append(rows, []string{
|
rows = append(rows, []string{
|
||||||
fmt.Sprintf("%d", u.ID),
|
fmt.Sprintf("%d", i+1),
|
||||||
m.zones.Mark(fmt.Sprintf("user-%d", i), limitStr(u.Username, 15)),
|
m.zones.Mark(fmt.Sprintf("user-%d", i), limitStr(u.Username, 15)),
|
||||||
fmtRole(u.Role),
|
fmtRole(u.Role),
|
||||||
fmtKey(u.PublicKey),
|
fmtKey(u.PublicKey),
|
||||||
@@ -80,7 +80,7 @@ func (m Model) viewUsersTab() string {
|
|||||||
Border(lipgloss.RoundedBorder()).
|
Border(lipgloss.RoundedBorder()).
|
||||||
BorderStyle(userBorderStyle).
|
BorderStyle(userBorderStyle).
|
||||||
Width(tableWidth).
|
Width(tableWidth).
|
||||||
Headers("ID", "USERNAME", "ROLE", "PUBLIC KEY").
|
Headers("#", "USERNAME", "ROLE", "PUBLIC KEY").
|
||||||
Rows(rows...).
|
Rows(rows...).
|
||||||
StyleFunc(func(row, col int) lipgloss.Style {
|
StyleFunc(func(row, col int) lipgloss.Style {
|
||||||
if row == table.HeaderRow {
|
if row == table.HeaderRow {
|
||||||
|
|||||||
Reference in New Issue
Block a user