Skip to content
Snippets Groups Projects
datbaseStatusView.go 1.14 KiB
Newer Older
  • Learn to ignore specific revisions
  • Malte Bauch's avatar
    Malte Bauch committed
    package views
    
    import (
    	"code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn-tview/app"
    	"github.com/rivo/tview"
    
    	//"time"
    
    Malte Bauch's avatar
    Malte Bauch committed
    )
    
    
    //DatabaseStatusView is an application view to display the current status of
    //the database (e.g. connected, disconnected,...)
    
    Malte Bauch's avatar
    Malte Bauch committed
    type DatabaseStatusView struct {
    	databaseStatusView *tview.TextView
    }
    
    
    //NewDatabaseStatusView creates a new DatabaseStatusView
    
    Malte Bauch's avatar
    Malte Bauch committed
    func NewDatabaseStatusView(app *app.App) *DatabaseStatusView {
    	dv := &DatabaseStatusView{
    		databaseStatusView: tview.NewTextView(),
    	}
    	dv.databaseStatusView.
    		SetDynamicColors(true).
    		SetTextAlign(tview.AlignCenter).
    		SetRegions(true).
    		SetBorder(true).
    		SetTitle("Database")
    
    
    	//TODO: dummy text at the moment. database status check has to be initilized
    	//here
    	dv.databaseStatusView.SetText("[green]" + "connected")
    
    Malte Bauch's avatar
    Malte Bauch committed
    
    	return dv
    }
    
    
    //GetContent returns the tview.Primitive belonging to the DatabaseStatusView
    
    Malte Bauch's avatar
    Malte Bauch committed
    func (dv *DatabaseStatusView) GetContent() tview.Primitive {
    	return dv.databaseStatusView
    }
    
    
    //SetContent sets new string content for the DatabaseStatusView
    
    Malte Bauch's avatar
    Malte Bauch committed
    func (dv *DatabaseStatusView) SetContent(s string) {
    	dv.databaseStatusView.Clear()
    	dv.databaseStatusView.SetText(s)
    }