db

package
v0.0.0-...-4dd6cf4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package db has the utilities required for the db interaction for the service

Index

Constants

View Source
const (
	//PageDefaultWidth is the default width of the page
	PageDefaultWidth = uint(100)
	//PageDefaultHeight is the default height of the page
	PageDefaultHeight = uint(100)
	//PageDefaultGridSize is the default page grid size
	PageDefaultGridSize = uint(10)
)

Variables

This section is empty.

Functions

func Exec

func Exec(a config.AppContext, q interpreter.Query) ([]map[string]interface{}, error)

Exec will execute a query and return the result

func SingleTableMode

func SingleTableMode(a config.AppContext, q interpreter.Query) ([]map[string]interface{}, error)

SingleTableMode execute the given query in a single table mode. So the query is expected not to have any joins or so

Types

type Dashboard

type Dashboard struct {
	gorm.Model
	//Name of the dashbaord
	Name string
	//Description of the dashboard
	Description string
	//UserID of the user who created the dashboard
	UserID uint
	//IsPublic indicates whether the dashboard is public
	IsPublic bool
	//HasPublicWidgets indicates that the dashboard has widgets that do have public access
	HasPublicWidgets bool
	//ShowNavigation indicates whether the navigation for the dashboard has to be made visible
	ShowNavigation bool
	//DashboardPages has the list of pages in the dashboard
	DashboardPages []DashboardPage
}

Dashboard is the dashboard model

func (*Dashboard) AddWidget

func (d *Dashboard) AddWidget(ctx *config.AppContext, w Widget, width, height uint) error

AddWidget will add a widget to the dashboard

func (*Dashboard) CreatePage

func (d *Dashboard) CreatePage(ctx *config.AppContext, pageNumber uint) (*DashboardPage, error)

CreatePage creates a new page for the given dashboard with the given page number

func (*Dashboard) GetLastPage

func (d *Dashboard) GetLastPage(ctx *config.AppContext) (*DashboardPage, error)

GetLastPage returns the last page in the dashboard

type DashboardPage

type DashboardPage struct {
	gorm.Model
	//DashboardID  is the id of the dashboard
	DashboardID uint
	//Name is the name of the dashboard page
	Name string
	//Number is the page number in the dashboard for cronological order
	Number uint
	//GridSize is the size of the each grid uint. grid will be a square of the given size
	GridSize uint
	//Width is the width of the page grid.
	Width uint
	//Height is the height of the page grid.
	Height uint
	//HasWidgetAdded indicates that a widget has been added to the dashboard page
	HasWidgetAdded bool
	//PageGridItems has the list of grid items in the page
	PageGridItems []PageGridItem
}

DashboardPage is the model for representing a dashboard page

func (*DashboardPage) AddWidget

func (dp *DashboardPage) AddWidget(ctx *config.AppContext, w Widget, width, height uint) (bool, error)

AddWidget will try to add a widget to the dashboard page. If succeeds will return true. Else false.

func (*DashboardPage) GetPageLayout

func (dp *DashboardPage) GetPageLayout() [][]bool

GetPageLayout will return the page layout filled with the occupied positions as true

type DashboardUserMappings

type DashboardUserMappings struct {
	gorm.Model
	//DashboardID  is the id of the dashboard
	DashboardID uint
	//UserID is the id of the user
	UserID uint
	//Share indicates whether the user has the permissions for sharing the dashboard
	Share bool
	//Manage indicates whether the user has the permissions for managing the user permissions to the dashboard
	Manage bool
	//Edit indicates whether the user has the permissions for editing the dashboard
	Edit bool
}

DashboardUserMappings has the mappings for the users and the permissions they have with the dashboard

type PageGridItem

type PageGridItem struct {
	gorm.Model
	//DashboardPageID is the id of the page in which the page grid item is present
	DashboardPageID uint
	//WidgetID is id of the underlying widget
	WidgetID uint
	//X is the x position of the grid item in the grid (in grid units)
	X uint
	//Y is the y position of the grid item in the grid (in grid units)
	Y uint
	//Width is the width of the grid item in the grid (in grid units)
	Width uint
	//Height is the height of the grid item in the grid (in grid units)
	Height uint
}

PageGridItem is a grid item in the page layout. It will be linked to the underlying widget. Page Grid items together builds the page layout

type Widget

type Widget struct {
	gorm.Model
}

Widget represents a widget which can be a visualization or something else in a dashboard page

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL