filebrowser/backend/settings/structs.go

104 lines
3.3 KiB
Go
Raw Normal View History

2023-08-05 12:32:43 +00:00
package settings
import (
"github.com/gtsteffaniak/filebrowser/rules"
"github.com/gtsteffaniak/filebrowser/users"
)
// Apply applies the default options to a user.
func (d *UserDefaults) Apply(u *users.User) {
u.Scope = d.Scope
u.Locale = d.Locale
u.ViewMode = d.ViewMode
u.SingleClick = d.SingleClick
u.Perm = d.Perm
u.Sorting = d.Sorting
u.Commands = d.Commands
u.HideDotfiles = d.HideDotfiles
u.DateFormat = d.DateFormat
}
type Settings struct {
Key []byte `json:"key"`
Signup bool `json:"signup"`
CreateUserDir bool `json:"createUserDir"`
UserHomeBasePath string `json:"userHomeBasePath"`
Commands map[string][]string `json:"commands"`
Shell []string `json:"shell"`
Rules []rules.Rule `json:"rules"`
Server Server `json:"server"`
2023-09-02 00:51:13 +00:00
Auth Auth `json:"auth"`
2023-09-02 15:52:34 +00:00
Frontend Frontend `json:"frontend"`
UserDefaults UserDefaults `json:"userDefaults"`
2023-08-05 12:32:43 +00:00
}
2023-09-01 14:00:02 +00:00
type Auth struct {
2023-09-02 15:52:34 +00:00
Recaptcha Recaptcha `json:"recaptcha"`
Header string `json:"header"`
Method string `json:"method"`
Command string `json:"command"`
Signup bool `json:"signup"`
Shell string `json:"shell"`
2023-09-01 14:00:02 +00:00
}
type Recaptcha struct {
2023-09-02 15:52:34 +00:00
Host string `json:"host"`
Key string `json:"key"`
Secret string `json:"secret"`
2023-09-01 14:00:02 +00:00
}
2023-08-05 12:32:43 +00:00
type Server struct {
2023-09-02 00:51:13 +00:00
IndexingInterval uint32 `json:"indexingInterval"`
NumImageProcessors int `json:"numImageProcessors"`
2023-08-05 12:32:43 +00:00
Socket string `json:"socket"`
TLSKey string `json:"tlsKey"`
TLSCert string `json:"tlsCert"`
EnableThumbnails bool `json:"enableThumbnails"`
ResizePreview bool `json:"resizePreview"`
EnableExec bool `json:"enableExec"`
TypeDetectionByHeader bool `json:"typeDetectionByHeader"`
AuthHook string `json:"authHook"`
2023-09-02 00:51:13 +00:00
Port int `json:"port"`
2023-08-05 12:32:43 +00:00
BaseURL string `json:"baseURL"`
Address string `json:"address"`
Log string `json:"log"`
Database string `json:"database"`
Root string `json:"root"`
2023-09-02 15:52:34 +00:00
EnablePreviewResize bool `json:"enablePreviewResize"`
2023-08-05 12:32:43 +00:00
}
2023-09-01 14:00:02 +00:00
type Frontend struct {
2023-08-05 12:32:43 +00:00
Name string `json:"name"`
DisableExternal bool `json:"disableExternal"`
DisableUsedPercentage bool `json:"disableUsedPercentage"`
Files string `json:"files"`
Theme string `json:"theme"`
Color string `json:"color"`
}
// UserDefaults is a type that holds the default values
// for some fields on User.
type UserDefaults struct {
2023-09-02 15:52:34 +00:00
Scope string `json:"scope"`
Locale string `json:"locale"`
ViewMode string `json:"viewMode"`
SingleClick bool `json:"singleClick"`
Sorting struct {
By string `json:"by"`
Asc bool `json:"asc"`
} `json:"sorting"`
Perm struct {
Admin bool `json:"admin"`
Execute bool `json:"execute"`
Create bool `json:"create"`
Rename bool `json:"rename"`
Modify bool `json:"modify"`
Delete bool `json:"delete"`
Share bool `json:"share"`
Download bool `json:"download"`
} `json:"perm"`
Commands []string `json:"commands"`
HideDotfiles bool `json:"hideDotfiles"`
DateFormat bool `json:"dateFormat"`
2023-08-05 12:32:43 +00:00
}