view

package
v0.0.0-...-8a398ea Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrViewsNotFound  = errors.New("views not found")
	ErrValueIsMissing = errors.New("value is missing")
)

Functions

func ValidateEditPositionRequest

func ValidateEditPositionRequest(sl validator.StructLevel)

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)
	UpdatePositions(c *gin.Context)
	Import(c *gin.Context)
	Export(c *gin.Context)
}

func NewApi

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

type EditPositionItemRequest

type EditPositionItemRequest struct {
	ID    string   `json:"_id" binding:"required"`
	Views []string `json:"views" binding:"required"`
}

type EditPositionRequest

type EditPositionRequest struct {
	Items []EditPositionItemRequest `json:"items" binding:"required,notblank,dive"`
}

func (EditPositionRequest) MarshalJSON

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

func (*EditPositionRequest) UnmarshalJSON

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

type EditRequest

type EditRequest struct {
	ID          string   `json:"-"`
	Enabled     *bool    `json:"enabled" binding:"required"`
	Title       string   `json:"title" binding:"required,max=255"`
	Description string   `json:"description" binding:"max=255"`
	Group       string   `json:"group" binding:"required"`
	Tags        []string `json:"tags"`
	Author      string   `json:"author" swaggerignore:"true"`

	PeriodicRefresh *datetime.DurationWithEnabled `json:"periodic_refresh"`
}

type ExportRequest

type ExportRequest struct {
	Groups []struct {
		ID    string   `json:"_id" binding:"required"`
		Views []string `json:"views"`
	} `json:"groups"`
	Views []string `json:"views"`
}

type ExportResponse

type ExportResponse struct {
	Groups []ExportViewGroupResponse `json:"groups"`
	Views  []Response                `json:"views"`
}

type ExportViewGroupResponse

type ExportViewGroupResponse struct {
	ViewGroup `bson:",inline"`
	Views     []Response `json:"views"`
}

type ImportItemRequest

type ImportItemRequest struct {
	ViewGroup
	Views []Response `json:"views"`
}

type ImportRequest

type ImportRequest struct {
	Items []ImportItemRequest `json:"items" binding:"required,notblank,dive"`
}

func (ImportRequest) MarshalJSON

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

func (*ImportRequest) UnmarshalJSON

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

type Response

type Response struct {
	ID              string                        `bson:"_id" json:"_id,omitempty"`
	Enabled         bool                          `bson:"enabled" json:"enabled"`
	Title           string                        `bson:"title" json:"title"`
	Description     string                        `bson:"description" json:"description"`
	Tabs            *[]viewtab.Response           `bson:"tabs" json:"tabs,omitempty"`
	Tags            []string                      `bson:"tags" json:"tags"`
	PeriodicRefresh *datetime.DurationWithEnabled `bson:"periodic_refresh" json:"periodic_refresh"`
	Group           *ViewGroup                    `bson:"group" json:"group,omitempty"`
	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"`

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

type Store

type Store interface {
	GetOneBy(ctx context.Context, id string) (*Response, error)
	Insert(ctx context.Context, r EditRequest, withDefaultTab bool) (*Response, error)
	Update(ctx context.Context, r EditRequest) (*Response, error)
	// UpdatePositions receives some groups and views with updated positions and updates
	// positions for all groups and views in db and moves views to another groups if necessary.
	UpdatePositions(ctx context.Context, r EditPositionRequest) (bool, error)
	Delete(ctx context.Context, id, userID string) (bool, error)
	Copy(ctx context.Context, id string, r EditRequest) (*Response, error)
	Export(ctx context.Context, r ExportRequest) (ExportResponse, error)
	Import(ctx context.Context, r ImportRequest, userID string) error
}

func NewStore

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

type ValidationError

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

func (ValidationError) Error

func (v ValidationError) Error() string

type ViewGroup

type ViewGroup struct {
	ID      string            `bson:"_id" json:"_id,omitempty"`
	Title   string            `bson:"title" json:"title"`
	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"`
}

Jump to

Keyboard shortcuts

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