Config: Refactor client data types

This commit is contained in:
Michael Mayer 2021-09-02 14:45:26 +02:00
parent 9acd4a25b9
commit 5f07b8bb10
7 changed files with 30 additions and 11 deletions

View file

@ -36,11 +36,12 @@ type ClientConfig struct {
Public bool `json:"public"`
Experimental bool `json:"experimental"`
AlbumCategories []string `json:"albumCategories"`
Albums []entity.Album `json:"albums"`
Cameras []entity.Camera `json:"cameras"`
Lenses []entity.Lens `json:"lenses"`
Countries []entity.Country `json:"countries"`
Thumbs []Thumb `json:"thumbs"`
Albums entity.Albums `json:"albums"`
Cameras entity.Cameras `json:"cameras"`
Lenses entity.Lenses `json:"lenses"`
Countries entity.Countries `json:"countries"`
Subjects entity.Subjects `json:"subjects"`
Thumbs ThumbTypes `json:"thumbs"`
Status string `json:"status"`
MapKey string `json:"mapKey"`
DownloadToken string `json:"downloadToken"`
@ -52,13 +53,16 @@ type ClientConfig struct {
Disable ClientDisable `json:"disable"`
Count ClientCounts `json:"count"`
Pos ClientPosition `json:"pos"`
Years []int `json:"years"`
Years Years `json:"years"`
Colors []map[string]string `json:"colors"`
Categories []CategoryLabel `json:"categories"`
Categories CategoryLabels `json:"categories"`
Clip int `json:"clip"`
Server RuntimeInfo `json:"server"`
}
// Years represents a list of years.
type Years []int
// ClientDisable represents disabled client features a user can't turn back on.
type ClientDisable struct {
Backups bool `json:"backups"`
@ -99,6 +103,8 @@ type ClientCounts struct {
LabelMaxPhotos int `json:"labelMaxPhotos"`
}
type CategoryLabels []CategoryLabel
type CategoryLabel struct {
LabelUID string `json:"UID"`
CustomSlug string `json:"Slug"`

View file

@ -77,7 +77,7 @@ func init() {
t := thumb.Types[size]
if t.Public {
Thumbs = append(Thumbs, Thumb{Size: size, Use: t.Use, Width: t.Width, Height: t.Height})
Thumbs = append(Thumbs, ThumbType{Size: size, Use: t.Use, Width: t.Width, Height: t.Height})
}
}
}

View file

@ -1,12 +1,15 @@
package config
// Thumb represents thumbnail info for use in client apps.
type Thumb struct {
// ThumbType represents thumbnail info for use in client apps.
type ThumbType struct {
Size string `json:"size"`
Use string `json:"use"`
Width int `json:"w"`
Height int `json:"h"`
}
// ThumbTypes represents a list of thumbnail types.
type ThumbTypes []ThumbType
// Thumbs is a list of thumbnails for use in client apps.
var Thumbs []Thumb
var Thumbs ThumbTypes

View file

@ -12,6 +12,9 @@ import (
var cameraMutex = sync.Mutex{}
// Cameras represents a list of cameras.
type Cameras []Camera
// Camera model and make (as extracted from UpdateExif metadata)
type Camera struct {
ID uint `gorm:"primary_key" json:"ID" yaml:"ID"`

View file

@ -14,6 +14,9 @@ var altCountryNames = map[string]string{
"": "Unknown",
}
// Countries represents a list of countries.
type Countries []Country
// Country represents a country location, used for labeling photos.
type Country struct {
ID string `gorm:"type:VARBINARY(2);primary_key" json:"ID" yaml:"ID"`

View file

@ -12,6 +12,9 @@ import (
var lensMutex = sync.Mutex{}
// Lenses represents a list of lenses.
type Lenses []Lens
// Lens represents camera lens (as extracted from UpdateExif metadata)
type Lens struct {
ID uint `gorm:"primary_key" json:"ID" yaml:"ID"`

View file

@ -19,6 +19,7 @@ const (
var subjectMutex = sync.Mutex{}
// Subjects represents a list of subjects.
type Subjects []Subject
// Subject represents a named photo subject, typically a person.