Add chart loading label

pull/42/head
Miguel Mota 5 years ago
parent 3be23ec912
commit 96cab2b405
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -92,6 +92,7 @@ func (ct *Cointop) UpdateChart() error {
}
}
ct.update(func() {
if ct.Views.Chart.Backing() == nil {
return
@ -108,6 +109,7 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
maxX := ct.maxTableWidth - 3
chartPointsLock.Lock()
defer chartPointsLock.Unlock()
// TODO: not do this (SoC)
go ct.updateMarketbar()
@ -209,6 +211,7 @@ func (ct *Cointop) PortfolioChart() error {
maxX := ct.maxTableWidth - 3
chartPointsLock.Lock()
defer chartPointsLock.Unlock()
// TODO: not do this (SoC)
go ct.updateMarketbar()
@ -374,7 +377,23 @@ func (ct *Cointop) ToggleCoinChart() error {
ct.State.selectedCoin = highlightedcoin
}
go ct.ShowChartLoader()
go ct.UpdateChart()
go ct.updateMarketbar()
return nil
}
// ShowChartLoader shows chart loading indicator
func (ct *Cointop) ShowChartLoader() error {
ct.update(func() {
if ct.Views.Chart.Backing() == nil {
return
}
content := "\n\nLoading..."
ct.Views.Chart.Backing().Clear()
fmt.Fprint(ct.Views.Chart.Backing(), ct.colorscheme.Chart(content))
})
return nil
}

@ -149,7 +149,7 @@ func (s *Service) GetAllCoinData(convert string, ch chan []apitypes.Coin) error
func (s *Service) GetCoinGraphData(symbol, name string, start, end int64) (apitypes.CoinGraph, error) {
ret := apitypes.CoinGraph{}
days := strconv.Itoa(util.CalcDays(start, end))
chart, err := s.client.CoinsIDMarketChart(strings.ToLower(name), "usd", days)
chart, err := s.client.CoinsIDMarketChart(util.NameToSlug(name), "usd", days)
if err != nil {
return ret, err
}

@ -23,6 +23,7 @@ func NewPortfolioUpdateMenuView() *PortfolioUpdateMenuView {
func (ct *Cointop) togglePortfolio() error {
ct.State.filterByFavorites = false
ct.State.portfolioVisible = !ct.State.portfolioVisible
go ct.UpdateChart()
go ct.updateTable()
return nil
}
@ -30,6 +31,7 @@ func (ct *Cointop) togglePortfolio() error {
func (ct *Cointop) toggleShowPortfolio() error {
ct.State.filterByFavorites = false
ct.State.portfolioVisible = true
go ct.UpdateChart()
go ct.updateTable()
return nil
}
@ -39,6 +41,7 @@ func (ct *Cointop) togglePortfolioUpdateMenu() error {
if ct.State.portfolioUpdateMenuVisible {
return ct.showPortfolioUpdateMenu()
}
return ct.hidePortfolioUpdateMenu()
}

@ -43,6 +43,8 @@ func tableColumnOrder() []string {
}
}
const dots = "..."
// RefreshTable refreshes the table
func (ct *Cointop) RefreshTable() error {
maxX := ct.width()
@ -74,7 +76,6 @@ func (ct *Cointop) RefreshTable() error {
color24h = ct.colorscheme.TableColumnChangeDown
}
name := coin.Name
dots := "..."
star := " "
rank := fmt.Sprintf("%s%v", star, ct.colorscheme.TableRow(fmt.Sprintf("%6v ", coin.Rank)))
if len(name) > 20 {
@ -143,7 +144,6 @@ func (ct *Cointop) RefreshTable() error {
color7d = ct.colorscheme.TableColumnChangeDown
}
name := coin.Name
dots := "..."
star := ct.colorscheme.TableRow(" ")
if coin.Favorite {
star = ct.colorscheme.TableRowFavorite("*")
@ -312,7 +312,7 @@ func (ct *Cointop) RowLinkShort() string {
path = parts[len(parts)-1]
}
return fmt.Sprintf("http://%s/.../%s", host, path)
return fmt.Sprintf("http://%s/%s/%s", host, dots, path)
}
return ""

@ -36,12 +36,18 @@ func (view *View) SetBacking(gocuiView *gocui.View) {
view.backing = gocuiView
}
// Height returns thejview height
// Height returns the view height
func (view *View) Height() int {
_, h := view.backing.Size()
return h
}
// Width returns the view width
func (view *View) Width() int {
w, _ := view.backing.Size()
return w
}
// Name returns the view's name
func (view *View) Name() string {
return view.name

Loading…
Cancel
Save