assets

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: BSD-3-Clause Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAssetNotFound = errors.New("asset not found")

Functions

func NewDecoder

func NewDecoder(decimalSeparator string) *form.Decoder

Types

type APIRouter

type APIRouter struct {
	Control *Control
}

func (*APIRouter) RegisterRoutes

func (rt *APIRouter) RegisterRoutes(mux *chi.Mux)

type Asset

type Asset struct {
	ID int64 `form:"-"`

	ParentAssetID int64    `form:"parent_asset_id"`
	Parent        *Asset   `form:"-"`
	Children      []*Asset `form:"-"`

	Status Status `form:"status"`

	Tag           string         `form:"tag"`
	Name          string         `form:"name"`
	Category      string         `form:"category"`
	Model         string         `form:"model"`
	ModelNo       string         `form:"model_no"`
	SerialNo      string         `form:"serial_no"`
	Manufacturer  string         `form:"manufacturer"`
	Notes         string         `form:"notes"`
	ImageURL      string         `form:"-"`
	ThumbnailURL  string         `form:"-"`
	WarrantyUntil time.Time      `form:"warranty_until,omitempty"`
	CustomAttrs   map[string]any `form:"custom_attrs"`

	CheckedOutTo int64  `form:"checked_out_to"`
	Location     string `form:"location"`
	PositionCode string `form:"position_code"`

	PurchaseInfo PurchaseInfo `form:"purchase"`

	PartsTotalCounter int     `form:"parts_total_counter"`
	Parts             []*Part `form:"parts"`

	MetaInfo MetaInfo `form:"-"`
}

func (*Asset) Labels

func (a *Asset) Labels(baseURL *url.URL, barcodeSize int) ([]Label, error)

type AssetListPage

type AssetListPage struct {
	Assets   []*Asset
	Total    int
	NumPages int
	Page     int
	PageSize int
}

type AssetRepo

type AssetRepo interface {
	Get(ctx context.Context, exec bob.Executor, idOrTag string) (*Asset, error)
	List(ctx context.Context, exec bob.Executor, query ListAssetsQuery) (*AssetListPage, error)
	ListForExport(ctx context.Context, exec bob.Executor, query ListAssetsQuery) (*AssetListPage, error)
	Create(ctx context.Context, exec bob.Executor, asset *Asset) (*Asset, error)
	Update(ctx context.Context, exec bob.Executor, asset *Asset) (*Asset, error)
	Delete(ctx context.Context, exec bob.Executor, id int64) error

	CreateParts(ctx context.Context, exec bob.Executor, parts []*Part) error
	DeleteParts(ctx context.Context, exec bob.Executor, assetID int64) error

	ListCategories(ctx context.Context, exec bob.Executor, query ListCategoriesQuery) ([]Category, error)
}

type Barcode

type Barcode struct {
	Size  int
	Value string
	Image image.Image
}

type Category

type Category struct {
	Name string
}

type Control

type Control struct {
	DB        *database.Database
	AssetRepo AssetRepo
	TagCtrl   *tags.Control

	FileDir string
	TmpDir  string
}

type DeleteAssetsPageViewModel

type DeleteAssetsPageViewModel struct {
	Asset   *Asset
	Message string
}

type EditAssetsPageViewModel

type EditAssetsPageViewModel struct {
	IsNew            bool
	Asset            *Asset
	ValidationErrs   map[string]string
	DecimalSeparator string
}

type File

type File struct {
	ID      int64
	AssetID int64

	Name      string
	Sha256    []byte
	SizeBytes int64

	CreatedBy int64
	CreatedAt time.Time
	UpdatedAt time.Time
	// contains filtered or unexported fields
}

type Label

type Label struct {
	Tag          string
	Name         string
	LocationCode string
	URL          string
	Barcode      Barcode
}

func (*Label) Image

func (l *Label) Image() ([]byte, error)

type LabelSheetCreatorPageViewModel

type LabelSheetCreatorPageViewModel struct {
	Template string `form:"template"`

	SelectedAssetIDs []int64 `form:"-"`

	PageSize   string `form:"page_size"`
	SkipLabels int    `form:"skip_labels"`

	NumColumns   int     `form:"page_cols"`
	NumRows      int     `form:"page_rows"`
	MarginLeft   float64 `form:"page_margin_left"`
	MarginTop    float64 `form:"page_margin_top"`
	MarginRight  float64 `form:"page_margin_right"`
	MarginBottom float64 `form:"page_margin_bottom"`

	ShowBorders       bool    `form:"label_show_borders"`
	FontSize          float64 `form:"label_font_size"`
	Width             float64 `form:"label_width"`
	Height            float64 `form:"label_height"`
	VerticalPadding   float64 `form:"label_vertical_padding"`
	HorizontalPadding float64 `form:"label_horizontal_padding"`
	VerticalSpacing   float64 `form:"label_vertical_spacing"`
	HorizontalSpacing float64 `form:"label_horizontal_spacing"`

	Assets []*Asset `form:"-"`

	ValidationErrs map[string]string `form:"-"`
}

type LabelSize

type LabelSize struct {
	FontSize float64

	// Height of a single label in mm including padding.
	Height float64
	// Width of a single label in mm including padding.
	Width float64

	// VerticalPadding applied to the inside of the label in mm.
	VerticalPadding float64
	// HorizontalPadding applied to the inside of the label in mm.
	HorizontalPadding float64

	// VerticalSpacing between each label in mm.
	VerticalSpacing float64
	// HorizontalSpacing between each label in mm.
	HorizontalSpacing float64
}

type ListAssetsPageViewModel

type ListAssetsPageViewModel struct {
	Page    *AssetListPage
	Query   ListAssetsQuery
	Columns map[string]bool
	Compact bool
}

type ListAssetsQuery

type ListAssetsQuery struct {
	Search *ListAssetsQuerySearch

	IDs []int64

	Page     int
	PageSize int

	OrderBy  string
	OrderDir string
}

type ListAssetsQuerySearch

type ListAssetsQuerySearch struct {
	Raw string

	Fields map[string]string
}

type ListCategoriesQuery

type ListCategoriesQuery struct {
	Search   string
	Page     int
	PageSize int
}

type MetaInfo

type MetaInfo struct {
	CreatedBy int64
	CreatedAt time.Time
	UpdatedAt time.Time
}

type MonetaryAmount

type MonetaryAmount int

func (MonetaryAmount) Format

func (c MonetaryAmount) Format(decimalSeparator string) string

type PageLayout

type PageLayout struct {
	// Cols per page.
	Cols int
	// Rows per page.
	Rows int

	// MarginLeft of the page in mm.
	MarginLeft float64
	// MarginTop of the page in mm.
	MarginTop float64
	// MarginRight of the page in mm.
	MarginRight float64
	// MarginBottom of the page in mm.
	MarginBottom float64
}

type PageSize

type PageSize string
const (
	PageSizeA4 PageSize = "A4"
)

type Part

type Part struct {
	ID      int64 `from:"id"`
	AssetID int64 `form:"asset_id"`

	Tag          string `form:"tag"`
	Name         string `form:"name"`
	Location     string `form:"location"`
	PositionCode string `form:"position_code"`
	Notes        string `form:"notes"`

	CreatedBy int64     `form:"-"`
	CreatedAt time.Time `form:"-"`
	UpdatedAt time.Time `form:"-"`
}

type PurchaseInfo

type PurchaseInfo struct {
	Supplier string         `form:"supplier"`
	OrderNo  string         `form:"order_no"`
	Date     time.Time      `form:"date,omitempty"`
	Amount   MonetaryAmount `form:"amount"`
	Currency string         `form:"currency"`
}

type RepoSQLite

type RepoSQLite struct{}

func (*RepoSQLite) Create

func (ar *RepoSQLite) Create(ctx context.Context, exec bob.Executor, asset *Asset) (*Asset, error)

func (*RepoSQLite) CreateParts

func (ar *RepoSQLite) CreateParts(ctx context.Context, exec bob.Executor, parts []*Part) error

func (*RepoSQLite) Delete

func (ar *RepoSQLite) Delete(ctx context.Context, exec bob.Executor, id int64) error

func (*RepoSQLite) DeleteParts

func (ar *RepoSQLite) DeleteParts(ctx context.Context, exec bob.Executor, assetID int64) error

func (*RepoSQLite) Get

func (ar *RepoSQLite) Get(ctx context.Context, exec bob.Executor, idOrTag string) (*Asset, error)

func (*RepoSQLite) List

func (ar *RepoSQLite) List(ctx context.Context, exec bob.Executor, query ListAssetsQuery) (*AssetListPage, error)

func (*RepoSQLite) ListCategories

func (ar *RepoSQLite) ListCategories(ctx context.Context, exec bob.Executor, query ListCategoriesQuery) ([]Category, error)

func (*RepoSQLite) ListForExport

func (ar *RepoSQLite) ListForExport(ctx context.Context, exec bob.Executor, query ListAssetsQuery) (*AssetListPage, error)

func (*RepoSQLite) Update

func (ar *RepoSQLite) Update(ctx context.Context, exec bob.Executor, asset *Asset) (*Asset, error)

type Sheet

type Sheet struct {
	PageSize      PageSize
	Labels        []Label
	LabelSize     LabelSize
	PageLayout    PageLayout
	SkipNumLabels int
	PrintBorders  bool
}

func (*Sheet) Generate

func (s *Sheet) Generate() ([]byte, error)

type Status

type Status string
const (
	StatusInStorage Status = "IN_STORAGE"
	StatusInUse     Status = "IN_USE"
	StatusArchived  Status = "ARCHIVED"
)

type UIRouter

type UIRouter struct {
	BaseURL          *url.URL
	Control          *Control
	Decoder          *form.Decoder
	DefaultCurrency  string
	DecimalSeparator string
	FileDir          string
}

func (*UIRouter) RegisterRoutes

func (rt *UIRouter) RegisterRoutes(mux *chi.Mux)

type ViewAssetsPageViewModel

type ViewAssetsPageViewModel struct {
	Asset            *Asset
	DecimalSeparator string
	ValidationErrs   map[string]string
}

Jump to

Keyboard shortcuts

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