github.com/wtfutil/wtf@v0.43.0/modules/googleanalytics/widget.go (about)

     1  package googleanalytics
     2  
     3  import (
     4  	"github.com/rivo/tview"
     5  	"github.com/wtfutil/wtf/view"
     6  )
     7  
     8  type Widget struct {
     9  	view.TextWidget
    10  
    11  	settings *Settings
    12  }
    13  
    14  func NewWidget(tviewApp *tview.Application, redrawChan chan bool, settings *Settings) *Widget {
    15  	widget := Widget{
    16  		TextWidget: view.NewTextWidget(tviewApp, redrawChan, nil, settings.Common),
    17  
    18  		settings: settings,
    19  	}
    20  
    21  	return &widget
    22  }
    23  
    24  func (widget *Widget) Refresh() {
    25  	websiteReports := widget.fetch()
    26  	contentTable := widget.createTable(websiteReports)
    27  
    28  	widget.Redraw(func() (string, string, bool) { return widget.CommonSettings().Title, contentTable, false })
    29  }