Documentation ¶
Index ¶
- Constants
- func NewErrorModal(message string, err error) *tview.Modal
- func ShowErrorModal(page *Root, message string, err error)
- func ShowErrorModalAndFocus(page *Root, message string, err error, setFocus func())
- type App
- type BaseInfo
- type Component
- func (c *Component) BroadcastEvent(event manager.EventMsg)
- func (c *Component) Disable()
- func (c *Component) Enable()
- func (c *Component) GetComponent() *Component
- func (c *Component) GetIdentifier() manager.Component
- func (c *Component) Init(app *App) error
- func (c *Component) IsEnabled() bool
- func (c *Component) SendToComponent(component manager.Component, event manager.EventMsg)
- func (c *Component) SetAfterInitFunc(afterInitFunc func() error)
- func (c *Component) Subscribe()
- func (c *Component) Toggle()
- type ComponentRenderer
- type Connector
- type Content
- type DatabaseTree
- type Databases
- type DeleteModal
- type DocModifier
- func (d *DocModifier) Duplicate(ctx context.Context, db, coll string, rawDocument string) (primitive.ObjectID, error)
- func (d *DocModifier) Edit(ctx context.Context, db, coll string, rawDocument string) (string, error)
- func (d *DocModifier) Insert(ctx context.Context, db, coll string) (primitive.ObjectID, error)
- type DocPeeker
- type Header
- type Help
- type HistoryModal
- type InputBar
- type Root
- type Welcome
Constants ¶
const ( ContentComponent = "Content" JsonViewComponent = "JsonView" )
const ( DatabaseTreeComponent manager.Component = "DatabaseTree" InputModalComponent manager.Component = "InputModal" ConfirmModalComponent manager.Component = "ConfirmModal" )
const ( DatabasesComponent manager.Component = "Databases" FilterBarComponent manager.Component = "FilterBar" )
const (
ConnectorComponent = manager.Component("Connector")
)
const (
DeleteModalComponent = "DeleteModal"
)
const (
DocModifierComponent manager.Component = "DocModifier"
)
const (
DocPeekerComponent manager.Component = "DocPeeker"
)
const (
ErrorComponent = "Error"
)
const (
HeaderComponent manager.Component = "Header"
)
const (
HelpComponent manager.Component = "Help"
)
const (
HistoryModalComponent manager.Component = "HistoryModal"
)
const (
InputBarComponent = "InputBar"
)
const (
RootComponent manager.Component = "Root"
)
const (
WelcomeComponent = manager.Component("Welcome")
)
Variables ¶
This section is empty.
Functions ¶
func ShowErrorModal ¶
ShowErrorModal shows a modal with an error message and logs the error if it's passed
func ShowErrorModalAndFocus ¶
Types ¶
type App ¶
type App struct { *tview.Application Dao *mongo.Dao Manager *manager.ComponentManager Root *Root FullScreenHelp *Help Styles *config.Styles Config *config.Config Keys *config.KeyBindings }
App is a main application struct
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component is a base struct for all components. It contains all the basic fields and functions that are used by all components. It also implements the Component interface.
func NewComponent ¶
NewComponent is a constructor for the Component struct.
func (*Component) BroadcastEvent ¶
SendEvent sends an event to the app.
func (*Component) GetComponent ¶
GetComponent returns the component.
func (*Component) GetIdentifier ¶
GetIdentifier returns the identifier of the component.
func (*Component) Init ¶
Init is a function that is called when the component is initialized. If custom initialization is needed, this function should be overriden.
func (*Component) SendToComponent ¶
SendToComponent sends an event to the component.
func (*Component) SetAfterInitFunc ¶
SetAfterInitFunc sets the optional function that will be run at the end of the Init function.
type ComponentRenderer ¶
type ComponentRenderer interface { // Render is a function that renders the component. Render() error // setStyle is a function that sets the style of the component. SetStyle(style string) }
every component should implement this interface it's used for managing components in the app
type Connector ¶
Connector is a view for connecting to mongodb using tview package
func (*Connector) SetOnSubmitFunc ¶
func (c *Connector) SetOnSubmitFunc(onSubmit func())
SetOnSubmitFunc sets callback function
type Content ¶
type Content struct { *Component *tview.Flex Table *tview.Table View *tview.TextView // contains filtered or unexported fields }
Content is a component that displays documents in a table
func NewContent ¶
func NewContent() *Content
NewContent creates a new Content component It also initializes all subcomponents
type DatabaseTree ¶
type DatabaseTree struct { *Component *tview.TreeView NodeSelectFunc func(ctx context.Context, db string, coll string, filter map[string]interface{}) error // contains filtered or unexported fields }
func NewDatabaseTree ¶
func NewDatabaseTree() *DatabaseTree
func (*DatabaseTree) Render ¶
func (t *DatabaseTree) Render(ctx context.Context, dbsWitColls []mongo.DBsWithCollections, expand bool)
type Databases ¶
Databases is flex container for DatabaseTree and InputBar
func NewDatabases ¶
func NewDatabases() *Databases
type DeleteModal ¶
func NewDeleteModal ¶
func NewDeleteModal() *DeleteModal
type DocModifier ¶
type DocModifier struct {
*Component
}
DocModifier is a component that allows editing JSON documents
func NewDocModifier ¶
func NewDocModifier() *DocModifier
func (*DocModifier) Duplicate ¶
func (d *DocModifier) Duplicate(ctx context.Context, db, coll string, rawDocument string) (primitive.ObjectID, error)
Duplicate opens the editor with the document and saves it as a new document
type DocPeeker ¶
type DocPeeker struct { *Component *primitives.ModalView // contains filtered or unexported fields }
DocPeeker is a component that provides a modal view for peeking at a document
type Header ¶
Header is a component that displays information about the database in the header of the application
type Help ¶
Help is a component that provides a help screen for keybindings
func (*Help) AddKeySection ¶
type HistoryModal ¶
type HistoryModal struct { *Component *primitives.ListModal // contains filtered or unexported fields }
HistoryModal is a modal with history of queries
func NewHistoryModal ¶
func NewHistoryModal() *HistoryModal
func (*HistoryModal) GetText ¶
func (h *HistoryModal) GetText() string
GetText returns text from selected item
func (*HistoryModal) Render ¶
func (h *HistoryModal) Render() error
Render loads history from file and renders it
func (*HistoryModal) SaveToHistory ¶
func (h *HistoryModal) SaveToHistory(text string) error
SaveToHistory saves text to history file, if it's not already there. It will overwrite oldest entry if history is full.
type InputBar ¶
type InputBar struct { *Component *tview.InputField // contains filtered or unexported fields }
func NewInputBar ¶
func (*InputBar) DoneFuncHandler ¶
DoneFuncHandler sets DoneFunc for the input bar It accepts two functions: accept and reject which are called when user accepts or rejects the input
func (*InputBar) EnableAutocomplete ¶
func (i *InputBar) EnableAutocomplete()
EnableAutocomplete enables autocomplete
func (*InputBar) EnableHistory ¶
func (i *InputBar) EnableHistory()
EnableHistory enables history modal
func (*InputBar) LoadNewKeys ¶
LoadNewKeys loads new keys for autocomplete It is used when switching databases or collections
func (*InputBar) SetDefaultText ¶
SetDefaultText sets default text for the input bar
type Root ¶
Root is a component that manages visaibility of other components
func (*Root) AddPage ¶
func (r *Root) AddPage(component manager.Component, page tview.Primitive, resize, visable bool) *tview.Pages
AddPage is a wrapper for tview.Pages.AddPage
type Welcome ¶
func NewWelcome ¶
func NewWelcome() *Welcome
func (*Welcome) SetOnSubmitFunc ¶
func (w *Welcome) SetOnSubmitFunc(onSubmit func())