widget

package
v0.0.0-...-0ad5b3e Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	Create(c *gin.Context)
	Get(c *gin.Context)
	Update(c *gin.Context)
	Delete(c *gin.Context)
	Copy(c *gin.Context)
	UpdateGridPositions(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	enforcer security.Enforcer,
	transformer *RequestTransformer,
) API

type CreateRequest

type CreateRequest struct {
	EditRequest
	Tab string `json:"tab" binding:"required"`
}

type EditGridPositionItemRequest

type EditGridPositionItemRequest struct {
	ID             string                 `json:"_id"`
	GridParameters map[string]interface{} `json:"grid_parameters"`
}

type EditGridPositionRequest

type EditGridPositionRequest struct {
	Items []EditGridPositionItemRequest `json:"items" binding:"required,notblank"`
}

func (EditGridPositionRequest) MarshalJSON

func (r EditGridPositionRequest) MarshalJSON() ([]byte, error)

func (*EditGridPositionRequest) UnmarshalJSON

func (r *EditGridPositionRequest) UnmarshalJSON(b []byte) error

type EditRequest

type EditRequest struct {
	Title          string                 `json:"title" binding:"max=255"`
	Type           string                 `json:"type" binding:"required,max=255"`
	GridParameters map[string]interface{} `json:"grid_parameters"`
	Parameters     view.Parameters        `json:"parameters"`
	Author         string                 `json:"author" swaggerignore:"true"`

	Filters []FilterRequest `json:"filters" binding:"dive"`
}

type FilterRequest

type FilterRequest struct {
	widgetfilter.BaseEditRequest
	ID string `json:"_id"`
}

type RequestTransformer

type RequestTransformer struct {
	// contains filtered or unexported fields
}

func NewRequestTransformer

func NewRequestTransformer(
	patternFieldsTransformer common.PatternFieldsTransformer,
	client mongo.DbClient,
) *RequestTransformer

func (*RequestTransformer) Transform

func (t *RequestTransformer) Transform(ctx context.Context, r *EditRequest) error

type Response

type Response struct {
	ID             string                 `bson:"_id" json:"_id,omitempty"`
	Title          string                 `bson:"title" json:"title"`
	Tab            string                 `bson:"tab" json:"-"`
	Type           string                 `bson:"type" json:"type"`
	GridParameters map[string]interface{} `bson:"grid_parameters" json:"grid_parameters"`
	Parameters     view.Parameters        `bson:"parameters" json:"parameters"`
	Author         *author.Author         `bson:"author" json:"author,omitempty"`
	Created        *datetime.CpsTime      `bson:"created" json:"created,omitempty" swaggertype:"integer"`
	Updated        *datetime.CpsTime      `bson:"updated" json:"updated,omitempty" swaggertype:"integer"`

	Filters []widgetfilter.Response `bson:"filters" json:"filters"`

	IsPrivate bool `bson:"is_private" json:"is_private"`
}

type Store

type Store interface {
	FindTabPrivacySettings(ctx context.Context, ids []string) (map[string]apisecurity.ViewTabPrivacySettings, error)
	FindViewIdByTab(ctx context.Context, tabId string) (string, error)
	GetOneBy(ctx context.Context, id string) (*Response, error)
	Insert(ctx context.Context, r CreateRequest) (*Response, error)
	Update(ctx context.Context, r UpdateRequest) (*Response, error)
	Delete(ctx context.Context, id, userID string) (bool, error)
	Copy(ctx context.Context, widgetID string, r CreateRequest) (*Response, error)
	CopyForTab(ctx context.Context, tabID, newTabID, author string, isPrivate bool) error
	UpdateGridPositions(ctx context.Context, items []EditGridPositionItemRequest) (bool, error)
}

func NewStore

func NewStore(dbClient mongo.DbClient, authorProvider author.Provider, enforcer security.Enforcer) Store

type UpdateRequest

type UpdateRequest struct {
	EditRequest
	ID string `json:"-"`
}

type ValidationError

type ValidationError struct {
	// contains filtered or unexported fields
}

func (ValidationError) Error

func (v ValidationError) Error() string

type Validator

type Validator interface {
	ValidateEditRequest(sl validator.StructLevel)
	ValidateFilterRequest(sl validator.StructLevel)
}

func NewValidator

func NewValidator() Validator

Jump to

Keyboard shortcuts

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