view txs: add config

pull/10/head
Edouard Paris 5 years ago
parent 229bfb6501
commit c1818672ae

@ -36,7 +36,8 @@ type Network struct {
}
type Views struct {
Channels *View `toml:"channels"`
Channels *View `toml:"channels"`
Transactions *View `toml:"transactions"`
}
type View struct {

@ -27,22 +27,19 @@ pool_capacity = %[11]d
[views]
# views.channels is the view displaying channel list.
[views.channels]
# It is possible to add, remove and order columns of
# the table with the array columns. The default value
# is:
# columns = [
# "STATUS",
# "ALIAS",
# "GAUGE",
# "LOCAL",
# "CAP",
# "HTLC",
# "UNSETTLED",
# "CFEE",
# "LAST UPDATE",
# "PRIVATE",
# "ID",
# ]
# It is possible to add, remove and order columns of the
# table with the array columns. The available values are:
# STATUS status of the channel
# ALIAS alias of the channel node
# GAUGE ascii bar with percent local/capacity
# LOCAL the local amount of the channel
# CAP the total capacity of the channel
# HTLC the number of pending HTLC
# UNSETTLED the amount unsettled in the channel
# CFEE the commit fee
# LAST UPDATE last update of the channel
# PRIVATE true if channel is private
# ID the id of the channel
columns = [
"STATUS",
@ -57,6 +54,25 @@ columns = [
"PRIVATE",
"ID",
]
[views.transactions]
# It is possible to add, remove and order columns of the
# table with the array columns. The available values are:
# DATE date of the transaction
# HEIGHT block height of the transaction
# CONFIR number of confirmations
# AMOUNT amount moved by the transaction
# FEE fee of the transaction
# ADDRESSES number of transaction output addresses
columns = [
"TIME",
"HEIGHT",
"CONFIR",
"AMOUNT",
"FEE",
"ADDRESSES",
]
`,
cfg.Logger.Type,
cfg.Logger.Dest,

@ -8,6 +8,7 @@ import (
"golang.org/x/text/language"
"golang.org/x/text/message"
"github.com/edouardparis/lntop/config"
netmodels "github.com/edouardparis/lntop/network/models"
"github.com/edouardparis/lntop/ui/color"
"github.com/edouardparis/lntop/ui/models"
@ -20,7 +21,7 @@ const (
)
var DefaultTransactionsColumns = []string{
"TIME",
"DATE",
"HEIGHT",
"CONFIR",
"AMOUNT",
@ -29,6 +30,8 @@ var DefaultTransactionsColumns = []string{
}
type Transactions struct {
cfg *config.View
columns []transactionsColumn
columnsView *gocui.View
view *gocui.View
@ -229,19 +232,24 @@ func (c *Transactions) display() {
}
}
func NewTransactions(txs *models.Transactions) *Transactions {
func NewTransactions(cfg *config.View, txs *models.Transactions) *Transactions {
transactions := &Transactions{
cfg: cfg,
transactions: txs,
}
printer := message.NewPrinter(language.English)
columns := DefaultTransactionsColumns
if cfg != nil && len(cfg.Columns) != 0 {
columns = cfg.Columns
}
transactions.columns = make([]transactionsColumn, len(columns))
for i := range columns {
switch columns[i] {
case "TIME":
case "DATE":
transactions.columns[i] = transactionsColumn{
name: fmt.Sprintf("%-15s", columns[i]),
width: 15,

@ -104,7 +104,7 @@ func New(cfg config.Views, m *models.Models) *Views {
Summary: NewSummary(m.Info, m.ChannelsBalance, m.WalletBalance, m.Channels),
Channels: main,
Channel: NewChannel(m.Channels),
Transactions: NewTransactions(m.Transactions),
Transactions: NewTransactions(cfg.Transactions, m.Transactions),
Transaction: NewTransaction(m.Transactions),
Main: main,
}

Loading…
Cancel
Save