mirror of
https://github.com/openziti/zrok.git
synced 2024-11-24 17:13:51 +01:00
Merge branch 'v0.4.0' into v0.4_backend_mode_tunnel
This commit is contained in:
commit
74fd8d9956
@ -8,6 +8,10 @@ CHANGE: The controller configuration version bumps from `v: 2` to `v: 3` to supp
|
||||
|
||||
CHANGE: The underlying database store now utilizes a `deleted` flag on all tables to implement "soft deletes". This was necessary for the new metrics infrastructure, where we need to account for metrics data that arrived after the lifetime of a share or environment; and also we're going to need this for limits, where we need to see historical information about activity in the past (https://github.com/openziti/zrok/issues/262)
|
||||
|
||||
# v0.3.7
|
||||
|
||||
FIX: Improved TUI word-wrapping (https://github.com/openziti/zrok/issues/180)
|
||||
|
||||
# v0.3.6
|
||||
|
||||
CHANGE: Additional change to support branch builds (for CI purposes) and additional containerization efforts around k8s.
|
||||
|
@ -2,16 +2,20 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/muesli/reflow/wordwrap"
|
||||
"github.com/openziti/zrok/endpoints"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const shareTuiBacklog = 256
|
||||
|
||||
var wordwrapCharacters = " -"
|
||||
var wordwrapBreakpoints = map[rune]bool{' ': true, '-': true}
|
||||
|
||||
type shareModel struct {
|
||||
shrToken string
|
||||
frontendDescriptions []string
|
||||
@ -144,6 +148,7 @@ func (m *shareModel) renderRequests() string {
|
||||
}
|
||||
}
|
||||
}
|
||||
requestLines = wrap(requestLines, m.width-2)
|
||||
maxRows := shareRequestsStyle.GetHeight()
|
||||
startRow := 0
|
||||
if len(requestLines) > maxRows {
|
||||
@ -183,6 +188,7 @@ func (m *shareModel) renderLog() string {
|
||||
}
|
||||
}
|
||||
}
|
||||
splitLines = wrap(splitLines, m.width-2)
|
||||
maxRows := shareLogStyle.GetHeight()
|
||||
startRow := 0
|
||||
if len(splitLines) > maxRows {
|
||||
@ -211,6 +217,38 @@ func (m *shareModel) Write(p []byte) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func wrap(lines []string, width int) []string {
|
||||
ret := make([]string, 0)
|
||||
for _, line := range lines {
|
||||
if width <= 0 || len(line) <= width {
|
||||
ret = append(ret, line)
|
||||
continue
|
||||
}
|
||||
for i := 0; i <= len(line); {
|
||||
max := i + width
|
||||
if max > len(line) {
|
||||
max = len(line)
|
||||
}
|
||||
if line[i:max] == "" {
|
||||
continue
|
||||
}
|
||||
nextI := i + width
|
||||
if max < len(line)-1 {
|
||||
if !wordwrapBreakpoints[rune(line[max])] || !wordwrapBreakpoints[rune(line[max+1])] {
|
||||
lastSpace := strings.LastIndexAny(line[:max], wordwrapCharacters)
|
||||
if lastSpace > -1 {
|
||||
max = lastSpace
|
||||
nextI = lastSpace
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = append(ret, strings.TrimSpace(line[i:max]))
|
||||
i = nextI
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
var shareHeaderStyle = lipgloss.NewStyle().
|
||||
BorderStyle(lipgloss.RoundedBorder()).
|
||||
BorderForeground(lipgloss.Color("63")).
|
||||
|
Loading…
Reference in New Issue
Block a user