fix ui channels

pull/1/head
Edouard Paris 5 years ago
parent b8dad61642
commit 480040c09c

@ -52,6 +52,8 @@ func (c *Channels) Update(newChannel *models.Channel) {
c.Add(newChannel) c.Add(newChannel)
return return
} }
oldChannel.ID = newChannel.ID
oldChannel.Status = newChannel.Status oldChannel.Status = newChannel.Status
oldChannel.LocalBalance = newChannel.LocalBalance oldChannel.LocalBalance = newChannel.LocalBalance
oldChannel.RemoteBalance = newChannel.RemoteBalance oldChannel.RemoteBalance = newChannel.RemoteBalance

@ -114,14 +114,17 @@ func (c *Channels) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
func displayChannelsColumns(v *gocui.View) { func displayChannelsColumns(v *gocui.View) {
v.Clear() v.Clear()
fmt.Fprintln(v, fmt.Sprintf("%-13s %-25s %-21s %12s %12s %5s %-15s %s", fmt.Fprintln(v, fmt.Sprintf("%-13s %-25s %-21s %12s %12s %5s %-10s %-6s %-15s %s %-19s",
"STATUS", "STATUS",
"ALIAS", "ALIAS",
"GAUGE", "GAUGE",
"LOCAL", "LOCAL",
"CAP", "CAP",
"HTLC", "HTLC",
"UNSETTLED",
"CFEE",
"Last Update", "Last Update",
"PRIVATE",
"ID", "ID",
)) ))
} }
@ -130,21 +133,40 @@ func (c *Channels) display() {
p := message.NewPrinter(language.English) p := message.NewPrinter(language.English)
c.view.Clear() c.view.Clear()
for _, item := range c.channels.List() { for _, item := range c.channels.List() {
line := fmt.Sprintf("%s %-25s %s %s %s %5d %15s %d %500s", line := fmt.Sprintf("%s %-25s %s %s %s %5d %s %s %s %s %19s %500s",
status(item), status(item),
alias(item), alias(item),
gauge(item), gauge(item),
color.Cyan(p.Sprintf("%12d", item.LocalBalance)), color.Cyan(p.Sprintf("%12d", item.LocalBalance)),
p.Sprintf("%12d", item.Capacity), p.Sprintf("%12d", item.Capacity),
len(item.PendingHTLC), len(item.PendingHTLC),
color.Yellow(p.Sprintf("%10d", item.UnsettledBalance)),
p.Sprintf("%6d", item.CommitFee),
lastUpdate(item), lastUpdate(item),
item.ID, channelPrivate(item),
channelID(item),
"", "",
) )
fmt.Fprintln(c.view, line) fmt.Fprintln(c.view, line)
} }
} }
func channelPrivate(c *netmodels.Channel) string {
if c.Private {
return color.Red("private")
}
return color.Green("public ")
}
func channelID(c *netmodels.Channel) string {
if c.ID == 0 {
return ""
}
return fmt.Sprintf("%d", c.ID)
}
func alias(c *netmodels.Channel) string { func alias(c *netmodels.Channel) string {
if c.Node == nil || c.Node.Alias == "" { if c.Node == nil || c.Node.Alias == "" {
return c.RemotePubKey[:19] return c.RemotePubKey[:19]
@ -155,10 +177,12 @@ func alias(c *netmodels.Channel) string {
func lastUpdate(c *netmodels.Channel) string { func lastUpdate(c *netmodels.Channel) string {
if c.LastUpdate != nil { if c.LastUpdate != nil {
return c.LastUpdate.Format("15:04:05 Jan _2") return color.Cyan(
fmt.Sprintf("%15s", c.LastUpdate.Format("15:04:05 Jan _2")),
)
} }
return "" return fmt.Sprintf("%15s", "")
} }
func status(c *netmodels.Channel) string { func status(c *netmodels.Channel) string {

Loading…
Cancel
Save