Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

Remove hardcoded backend settings, accept any JSON input for storage.

Matthew Kilgore782aa6ae0c8d
diff --git a/backend/app/api/handlers/v1/v1_ctrl_user.go b/backend/app/api/handlers/v1/v1_ctrl_user.go
index 8a7df415..6a5f70ef 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_user.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_user.go
@@ -9,20 +9,19 @@ import (
"github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
"github.com/sysadminsmedia/homebox/backend/internal/core/services"
- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
"github.com/sysadminsmedia/homebox/backend/internal/sys/validate"
)
// HandleUserRegistration godoc
//
-// @Summary Register New User
-// @Tags User
-// @Produce json
-// @Param payload body services.UserRegistration true "User Data"
-// @Success 204
-// @Failure 403 {string} string "Local login is not enabled"
-// @Router /v1/users/register [Post]
+// @Summary Register New User
+// @Tags User
+// @Produce json
+// @Param payload body services.UserRegistration true "User Data"
+// @Success 204
+// @Failure 403 {string} string "Local login is not enabled"
+// @Router /v1/users/register [Post]
func (ctrl *V1Controller) HandleUserRegistration() errchain.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
// Forbidden if local login is not enabled
@@ -127,7 +126,7 @@ func (ctrl *V1Controller) HandleUserSelfDelete() errchain.HandlerFunc {
// @Summary Get user settings
// @Tags User
// @Produce json
-// @Success 200 {object} Wrapped{item=schema.UserSettings}
+// @Success 200 {object} Wrapped{item=map[string]interface{}}
// @Router /v1/users/self/settings [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleUserSelfSettingsGet() errchain.HandlerFunc {
@@ -148,15 +147,15 @@ func (ctrl *V1Controller) HandleUserSelfSettingsGet() errchain.HandlerFunc {
// @Summary Update user settings
// @Tags User
// @Produce json
-// @Success 200 {object} Wrapped{item=schema.UserSettings}
+// @Success 200 {object} Wrapped{item=map[string]interface{}}
// @Router /v1/users/self/settings [PUT]
-// @Param payload body schema.UserSettings true "Settings Data"
+// @Param payload body map[string]interface{} true "Settings Data"
// @Security Bearer
func (ctrl *V1Controller) HandleUserSelfSettingsUpdate() errchain.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
// Cap body to prevent DOS via large payloads.
r.Body = http.MaxBytesReader(w, r.Body, 64*1024)
- var settings schema.UserSettings
+ var settings map[string]interface{}
if err := server.Decode(r, &settings); err != nil {
log.Err(err).Msg("failed to decode user settings data")
return validate.NewRequestError(err, http.StatusBadRequest)
@@ -176,6 +175,7 @@ func (ctrl *V1Controller) HandleUserSelfSettingsUpdate() errchain.HandlerFunc {
return server.JSON(w, http.StatusOK, Wrap(newSettings))
}
}
+
type (
ChangePassword struct {
Current string `json:"current,omitempty"`
diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go
index 6c0a560e..dd29038d 100644
--- a/backend/app/api/static/docs/docs.go
+++ b/backend/app/api/static/docs/docs.go
@@ -2511,7 +2511,8 @@ const docTemplate = `{
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -2540,7 +2541,8 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
],
@@ -2556,7 +2558,8 @@ const docTemplate = `{
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -3652,11 +3655,8 @@ const docTemplate = `{
},
"settings": {
"description": "Settings holds the value of the \"settings\" field.",
- "allOf": [
- {
- "$ref": "#/definitions/schema.UserSettings"
- }
- ]
+ "type": "object",
+ "additionalProperties": true
},
"superuser": {
"description": "Superuser holds the value of the \"superuser\" field.",
@@ -5072,64 +5072,6 @@ const docTemplate = `{
}
}
},
- "schema.DuplicateSettings": {
- "type": "object",
- "properties": {
- "copyAttachments": {
- "type": "boolean"
- },
- "copyCustomFields": {
- "type": "boolean"
- },
- "copyMaintenance": {
- "type": "boolean"
- },
- "copyPrefixOverride": {
- "type": "string"
- }
- }
- },
- "schema.UserSettings": {
- "type": "object",
- "properties": {
- "displayLegacyHeader": {
- "type": "boolean"
- },
- "duplicateSettings": {
- "$ref": "#/definitions/schema.DuplicateSettings"
- },
- "editorAdvancedView": {
- "type": "boolean"
- },
- "itemDisplayView": {
- "type": "string"
- },
- "itemsPerPage": {
- "type": "integer"
- },
- "itemsPerTablePage": {
- "type": "integer"
- },
- "language": {
- "type": "string"
- },
- "locale": {
- "type": "string"
- },
- "overrideFormatLocale": {
- "type": "string"
- },
- "showDetails": {
- "type": "boolean"
- },
- "showEmpty": {
- "type": "boolean"
- },
- "theme": {
- "type": "string"
- }
- }
- },
"services.Latest": {
"type": "object",
"properties": {
diff --git a/backend/app/api/static/docs/openapi-3.json b/backend/app/api/static/docs/openapi-3.json
index 07f57dd1..0cf10aa8 100644
--- a/backend/app/api/static/docs/openapi-3.json
+++ b/backend/app/api/static/docs/openapi-3.json
@@ -2691,7 +2691,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/components/schemas/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -2716,7 +2717,8 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
},
@@ -2737,7 +2739,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/components/schemas/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -3852,11 +3855,8 @@
},
"settings": {
"description": "Settings holds the value of the \"settings\" field.",
- "allOf": [
- {
- "$ref": "#/components/schemas/schema.UserSettings"
- }
- ]
+ "type": "object",
+ "additionalProperties": true
},
"superuser": {
"description": "Superuser holds the value of the \"superuser\" field.",
@@ -5272,64 +5272,6 @@
}
}
},
- "schema.DuplicateSettings": {
- "type": "object",
- "properties": {
- "copyAttachments": {
- "type": "boolean"
- },
- "copyCustomFields": {
- "type": "boolean"
- },
- "copyMaintenance": {
- "type": "boolean"
- },
- "copyPrefixOverride": {
- "type": "string"
- }
- }
- },
- "schema.UserSettings": {
- "type": "object",
- "properties": {
- "displayLegacyHeader": {
- "type": "boolean"
- },
- "duplicateSettings": {
- "$ref": "#/components/schemas/schema.DuplicateSettings"
- },
- "editorAdvancedView": {
- "type": "boolean"
- },
- "itemDisplayView": {
- "type": "string"
- },
- "itemsPerPage": {
- "type": "integer"
- },
- "itemsPerTablePage": {
- "type": "integer"
- },
- "language": {
- "type": "string"
- },
- "locale": {
- "type": "string"
- },
- "overrideFormatLocale": {
- "type": "string"
- },
- "showDetails": {
- "type": "boolean"
- },
- "showEmpty": {
- "type": "boolean"
- },
- "theme": {
- "type": "string"
- }
- }
- },
"services.Latest": {
"type": "object",
"properties": {
diff --git a/backend/app/api/static/docs/openapi-3.yaml b/backend/app/api/static/docs/openapi-3.yaml
index 40658d6c..4b5c3be6 100644
--- a/backend/app/api/static/docs/openapi-3.yaml
+++ b/backend/app/api/static/docs/openapi-3.yaml
@@ -1597,7 +1597,8 @@ paths:
- type: object
properties:
item:
- $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
put:
security:
- Bearer: []
@@ -1608,7 +1609,8 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
description: Settings Data
required: true
responses:
@@ -1622,7 +1624,8 @@ paths:
- type: object
properties:
item:
- $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
servers:
- url: https://demo.homebox.software/api
- url: http://demo.homebox.software/api
@@ -2397,8 +2400,8 @@ components:
- $ref: "#/components/schemas/user.Role"
settings:
description: Settings holds the value of the "settings" field.
- allOf:
- - $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
superuser:
description: Superuser holds the value of the "superuser" field.
type: boolean
@@ -3361,44 +3364,6 @@ components:
type: string
value:
type: number
- schema.DuplicateSettings:
- type: object
- properties:
- copyAttachments:
- type: boolean
- copyCustomFields:
- type: boolean
- copyMaintenance:
- type: boolean
- copyPrefixOverride:
- type: string
- schema.UserSettings:
- type: object
- properties:
- displayLegacyHeader:
- type: boolean
- duplicateSettings:
- $ref: "#/components/schemas/schema.DuplicateSettings"
- editorAdvancedView:
- type: boolean
- itemDisplayView:
- type: string
- itemsPerPage:
- type: integer
- itemsPerTablePage:
- type: integer
- language:
- type: string
- locale:
- type: string
- overrideFormatLocale:
- type: string
- showDetails:
- type: boolean
- showEmpty:
- type: boolean
- theme:
- type: string
services.Latest:
type: object
properties:
diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json
index 5705a7a5..c68a4de1 100644
--- a/backend/app/api/static/docs/swagger.json
+++ b/backend/app/api/static/docs/swagger.json
@@ -2509,7 +2509,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -2538,7 +2539,8 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
],
@@ -2554,7 +2556,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -3650,11 +3653,8 @@
},
"settings": {
"description": "Settings holds the value of the \"settings\" field.",
- "allOf": [
- {
- "$ref": "#/definitions/schema.UserSettings"
- }
- ]
+ "type": "object",
+ "additionalProperties": true
},
"superuser": {
"description": "Superuser holds the value of the \"superuser\" field.",
@@ -5070,64 +5070,6 @@
}
}
},
- "schema.DuplicateSettings": {
- "type": "object",
- "properties": {
- "copyAttachments": {
- "type": "boolean"
- },
- "copyCustomFields": {
- "type": "boolean"
- },
- "copyMaintenance": {
- "type": "boolean"
- },
- "copyPrefixOverride": {
- "type": "string"
- }
- }
- },
- "schema.UserSettings": {
- "type": "object",
- "properties": {
- "displayLegacyHeader": {
- "type": "boolean"
- },
- "duplicateSettings": {
- "$ref": "#/definitions/schema.DuplicateSettings"
- },
- "editorAdvancedView": {
- "type": "boolean"
- },
- "itemDisplayView": {
- "type": "string"
- },
- "itemsPerPage": {
- "type": "integer"
- },
- "itemsPerTablePage": {
- "type": "integer"
- },
- "language": {
- "type": "string"
- },
- "locale": {
- "type": "string"
- },
- "overrideFormatLocale": {
- "type": "string"
- },
- "showDetails": {
- "type": "boolean"
- },
- "showEmpty": {
- "type": "boolean"
- },
- "theme": {
- "type": "string"
- }
- }
- },
"services.Latest": {
"type": "object",
"properties": {
diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml
index b9b956fa..31f1d15f 100644
--- a/backend/app/api/static/docs/swagger.yaml
+++ b/backend/app/api/static/docs/swagger.yaml
@@ -748,9 +748,9 @@ definitions:
- $ref: '#/definitions/user.Role'
description: Role holds the value of the "role" field.
settings:
- allOf:
- - $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
description: Settings holds the value of the "settings" field.
+ type: object
superuser:
description: Superuser holds the value of the "superuser" field.
type: boolean
@@ -1714,44 +1714,6 @@ definitions:
value:
type: number
type: object
- schema.DuplicateSettings:
- properties:
- copyAttachments:
- type: boolean
- copyCustomFields:
- type: boolean
- copyMaintenance:
- type: boolean
- copyPrefixOverride:
- type: string
- type: object
- schema.UserSettings:
- properties:
- displayLegacyHeader:
- type: boolean
- duplicateSettings:
- $ref: '#/definitions/schema.DuplicateSettings'
- editorAdvancedView:
- type: boolean
- itemDisplayView:
- type: string
- itemsPerPage:
- type: integer
- itemsPerTablePage:
- type: integer
- language:
- type: string
- locale:
- type: string
- overrideFormatLocale:
- type: string
- showDetails:
- type: boolean
- showEmpty:
- type: boolean
- theme:
- type: string
- type: object
services.Latest:
properties:
date:
@@ -3457,7 +3419,8 @@ paths:
- $ref: '#/definitions/v1.Wrapped'
- properties:
item:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
type: object
security:
- Bearer: []
@@ -3471,7 +3434,8 @@ paths:
name: payload
required: true
schema:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
produces:
- application/json
responses:
@@ -3482,7 +3446,8 @@ paths:
- $ref: '#/definitions/v1.Wrapped'
- properties:
item:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
type: object
security:
- Bearer: []
diff --git a/backend/internal/core/services/service_user.go b/backend/internal/core/services/service_user.go
index c3235a27..ae168e9e 100644
--- a/backend/internal/core/services/service_user.go
+++ b/backend/internal/core/services/service_user.go
@@ -10,7 +10,6 @@ import (
"github.com/rs/zerolog/log"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles"
- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
"github.com/sysadminsmedia/homebox/backend/pkgs/hasher"
)
@@ -371,10 +370,10 @@ func (svc *UserService) ChangePassword(ctx Context, current string, new string)
return true
}
-func (svc *UserService) GetSettings(ctx context.Context, uid uuid.UUID) (schema.UserSettings, error) {
+func (svc *UserService) GetSettings(ctx context.Context, uid uuid.UUID) (map[string]interface{}, error) {
return svc.repos.Users.GetSettings(ctx, uid)
}
-func (svc *UserService) SetSettings(ctx context.Context, uid uuid.UUID, settings schema.UserSettings) error {
+func (svc *UserService) SetSettings(ctx context.Context, uid uuid.UUID, settings map[string]interface{}) error {
return svc.repos.Users.SetSettings(ctx, uid, settings)
}
diff --git a/backend/internal/data/ent/mutation.go b/backend/internal/data/ent/mutation.go
index 95c842e6..7498e8f2 100644
--- a/backend/internal/data/ent/mutation.go
+++ b/backend/internal/data/ent/mutation.go
@@ -25,7 +25,6 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -12584,7 +12583,7 @@ type UserMutation struct {
activated_on *time.Time
oidc_issuer *string
oidc_subject *string
- settings *schema.UserSettings
+ settings *map[string]interface{}
clearedFields map[string]struct{}
group *uuid.UUID
clearedgroup bool
@@ -13152,12 +13151,12 @@ func (m *UserMutation) ResetOidcSubject() {
}
// SetSettings sets the "settings" field.
-func (m *UserMutation) SetSettings(ss schema.UserSettings) {
- m.settings = &ss
+func (m *UserMutation) SetSettings(value map[string]interface{}) {
+ m.settings = &value
}
// Settings returns the value of the "settings" field in the mutation.
-func (m *UserMutation) Settings() (r schema.UserSettings, exists bool) {
+func (m *UserMutation) Settings() (r map[string]interface{}, exists bool) {
v := m.settings
if v == nil {
return
@@ -13168,7 +13167,7 @@ func (m *UserMutation) Settings() (r schema.UserSettings, exists bool) {
// OldSettings returns the old "settings" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *UserMutation) OldSettings(ctx context.Context) (v schema.UserSettings, err error) {
+func (m *UserMutation) OldSettings(ctx context.Context) (v map[string]interface{}, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSettings is only allowed on UpdateOne operations")
}
@@ -13570,7 +13569,7 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
m.SetOidcSubject(v)
return nil
case user.FieldSettings:
- v, ok := value.(schema.UserSettings)
+ v, ok := value.(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
diff --git a/backend/internal/data/ent/schema/user.go b/backend/internal/data/ent/schema/user.go
index 382a11f4..72cbf178 100644
--- a/backend/internal/data/ent/schema/user.go
+++ b/backend/internal/data/ent/schema/user.go
@@ -54,7 +54,7 @@ func (User) Fields() []ent.Field {
field.String("oidc_subject").
Optional().
Nillable(),
- field.JSON("settings", UserSettings{}).
+ field.JSON("settings", map[string]interface{}{}).
Optional(),
}
}
@@ -79,28 +79,6 @@ func (User) Edges() []ent.Edge {
}
}
-type UserSettings struct {
- Theme string `json:"theme"`
- ItemsPerPage int `json:"itemsPerPage"`
- Locale string `json:"locale"`
- ShowDetails bool `json:"showDetails"`
- ShowEmpty bool `json:"showEmpty"`
- EditorAdvancedView bool `json:"editorAdvancedView"`
- ItemDisplayView string `json:"itemDisplayView"`
- ItemsPerTablePage int `json:"itemsPerTablePage"`
- DisplayLegacyHeader bool `json:"displayLegacyHeader"`
- Language string `json:"language"`
- OverrideFormatLocale string `json:"overrideFormatLocale"`
- DuplicateSettings DuplicateSettings `json:"duplicateSettings"`
-}
-
-type DuplicateSettings struct {
- CopyMaintenance bool `json:"copyMaintenance"`
- CopyAttachments bool `json:"copyAttachments"`
- CopyCustomFields bool `json:"copyCustomFields"`
- CopyPrefixOverride string `json:"copyPrefixOverride"`
-}
-
// UserMixin when embedded in an ent.Schema, adds a reference to
// the Group entity.
type UserMixin struct {
diff --git a/backend/internal/data/ent/user.go b/backend/internal/data/ent/user.go
index e1578f74..82883496 100644
--- a/backend/internal/data/ent/user.go
+++ b/backend/internal/data/ent/user.go
@@ -12,7 +12,6 @@ import (
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -44,7 +43,7 @@ type User struct {
// OidcSubject holds the value of the "oidc_subject" field.
OidcSubject *string `json:"oidc_subject,omitempty"`
// Settings holds the value of the "settings" field.
- Settings schema.UserSettings `json:"settings,omitempty"`
+ Settings map[string]interface{} `json:"settings,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges UserEdges `json:"edges"`
diff --git a/backend/internal/data/ent/user_create.go b/backend/internal/data/ent/user_create.go
index eae9cc3f..e9912751 100644
--- a/backend/internal/data/ent/user_create.go
+++ b/backend/internal/data/ent/user_create.go
@@ -14,7 +14,6 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -164,19 +163,11 @@ func (_c *UserCreate) SetNillableOidcSubject(v *string) *UserCreate {
}
// SetSettings sets the "settings" field.
-func (_c *UserCreate) SetSettings(v schema.UserSettings) *UserCreate {
+func (_c *UserCreate) SetSettings(v map[string]interface{}) *UserCreate {
_c.mutation.SetSettings(v)
return _c
}
-// SetNillableSettings sets the "settings" field if the given value is not nil.
-func (_c *UserCreate) SetNillableSettings(v *schema.UserSettings) *UserCreate {
- if v != nil {
- _c.SetSettings(*v)
- }
- return _c
-}
-
// SetID sets the "id" field.
func (_c *UserCreate) SetID(v uuid.UUID) *UserCreate {
_c.mutation.SetID(v)
diff --git a/backend/internal/data/ent/user_update.go b/backend/internal/data/ent/user_update.go
index a27d49c4..a209b761 100644
--- a/backend/internal/data/ent/user_update.go
+++ b/backend/internal/data/ent/user_update.go
@@ -16,7 +16,6 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -190,19 +189,11 @@ func (_u *UserUpdate) ClearOidcSubject() *UserUpdate {
}
// SetSettings sets the "settings" field.
-func (_u *UserUpdate) SetSettings(v schema.UserSettings) *UserUpdate {
+func (_u *UserUpdate) SetSettings(v map[string]interface{}) *UserUpdate {
_u.mutation.SetSettings(v)
return _u
}
-// SetNillableSettings sets the "settings" field if the given value is not nil.
-func (_u *UserUpdate) SetNillableSettings(v *schema.UserSettings) *UserUpdate {
- if v != nil {
- _u.SetSettings(*v)
- }
- return _u
-}
-
// ClearSettings clears the value of the "settings" field.
func (_u *UserUpdate) ClearSettings() *UserUpdate {
_u.mutation.ClearSettings()
@@ -723,19 +714,11 @@ func (_u *UserUpdateOne) ClearOidcSubject() *UserUpdateOne {
}
// SetSettings sets the "settings" field.
-func (_u *UserUpdateOne) SetSettings(v schema.UserSettings) *UserUpdateOne {
+func (_u *UserUpdateOne) SetSettings(v map[string]interface{}) *UserUpdateOne {
_u.mutation.SetSettings(v)
return _u
}
-// SetNillableSettings sets the "settings" field if the given value is not nil.
-func (_u *UserUpdateOne) SetNillableSettings(v *schema.UserSettings) *UserUpdateOne {
- if v != nil {
- _u.SetSettings(*v)
- }
- return _u
-}
-
// ClearSettings clears the value of the "settings" field.
func (_u *UserUpdateOne) ClearSettings() *UserUpdateOne {
_u.mutation.ClearSettings()
diff --git a/backend/internal/data/repo/repo_users.go b/backend/internal/data/repo/repo_users.go
index ef920f0d..12d5b24d 100644
--- a/backend/internal/data/repo/repo_users.go
+++ b/backend/internal/data/repo/repo_users.go
@@ -5,7 +5,6 @@ import (
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
- "github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -177,14 +176,14 @@ func (r *UserRepository) ChangePassword(ctx context.Context, uid uuid.UUID, pw s
return r.db.User.UpdateOneID(uid).SetPassword(pw).Exec(ctx)
}
-func (r *UserRepository) SetSettings(ctx context.Context, uid uuid.UUID, settings schema.UserSettings) error {
+func (r *UserRepository) SetSettings(ctx context.Context, uid uuid.UUID, settings map[string]interface{}) error {
return r.db.User.UpdateOneID(uid).SetSettings(settings).Exec(ctx)
}
-func (r *UserRepository) GetSettings(ctx context.Context, uid uuid.UUID) (schema.UserSettings, error) {
+func (r *UserRepository) GetSettings(ctx context.Context, uid uuid.UUID) (map[string]interface{}, error) {
usr, err := r.db.User.Get(ctx, uid)
if err != nil {
- return schema.UserSettings{}, err
+ return nil, err
}
return usr.Settings, nil
}
diff --git a/docs/en/api/openapi-2.0.json b/docs/en/api/openapi-2.0.json
index 5705a7a5..c68a4de1 100644
--- a/docs/en/api/openapi-2.0.json
+++ b/docs/en/api/openapi-2.0.json
@@ -2509,7 +2509,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -2538,7 +2539,8 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
],
@@ -2554,7 +2556,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -3650,11 +3653,8 @@
},
"settings": {
"description": "Settings holds the value of the \"settings\" field.",
- "allOf": [
- {
- "$ref": "#/definitions/schema.UserSettings"
- }
- ]
+ "type": "object",
+ "additionalProperties": true
},
"superuser": {
"description": "Superuser holds the value of the \"superuser\" field.",
@@ -5070,64 +5070,6 @@
}
}
},
- "schema.DuplicateSettings": {
- "type": "object",
- "properties": {
- "copyAttachments": {
- "type": "boolean"
- },
- "copyCustomFields": {
- "type": "boolean"
- },
- "copyMaintenance": {
- "type": "boolean"
- },
- "copyPrefixOverride": {
- "type": "string"
- }
- }
- },
- "schema.UserSettings": {
- "type": "object",
- "properties": {
- "displayLegacyHeader": {
- "type": "boolean"
- },
- "duplicateSettings": {
- "$ref": "#/definitions/schema.DuplicateSettings"
- },
- "editorAdvancedView": {
- "type": "boolean"
- },
- "itemDisplayView": {
- "type": "string"
- },
- "itemsPerPage": {
- "type": "integer"
- },
- "itemsPerTablePage": {
- "type": "integer"
- },
- "language": {
- "type": "string"
- },
- "locale": {
- "type": "string"
- },
- "overrideFormatLocale": {
- "type": "string"
- },
- "showDetails": {
- "type": "boolean"
- },
- "showEmpty": {
- "type": "boolean"
- },
- "theme": {
- "type": "string"
- }
- }
- },
"services.Latest": {
"type": "object",
"properties": {
diff --git a/docs/en/api/openapi-2.0.yaml b/docs/en/api/openapi-2.0.yaml
index b9b956fa..31f1d15f 100644
--- a/docs/en/api/openapi-2.0.yaml
+++ b/docs/en/api/openapi-2.0.yaml
@@ -748,9 +748,9 @@ definitions:
- $ref: '#/definitions/user.Role'
description: Role holds the value of the "role" field.
settings:
- allOf:
- - $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
description: Settings holds the value of the "settings" field.
+ type: object
superuser:
description: Superuser holds the value of the "superuser" field.
type: boolean
@@ -1714,44 +1714,6 @@ definitions:
value:
type: number
type: object
- schema.DuplicateSettings:
- properties:
- copyAttachments:
- type: boolean
- copyCustomFields:
- type: boolean
- copyMaintenance:
- type: boolean
- copyPrefixOverride:
- type: string
- type: object
- schema.UserSettings:
- properties:
- displayLegacyHeader:
- type: boolean
- duplicateSettings:
- $ref: '#/definitions/schema.DuplicateSettings'
- editorAdvancedView:
- type: boolean
- itemDisplayView:
- type: string
- itemsPerPage:
- type: integer
- itemsPerTablePage:
- type: integer
- language:
- type: string
- locale:
- type: string
- overrideFormatLocale:
- type: string
- showDetails:
- type: boolean
- showEmpty:
- type: boolean
- theme:
- type: string
- type: object
services.Latest:
properties:
date:
@@ -3457,7 +3419,8 @@ paths:
- $ref: '#/definitions/v1.Wrapped'
- properties:
item:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
type: object
security:
- Bearer: []
@@ -3471,7 +3434,8 @@ paths:
name: payload
required: true
schema:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
produces:
- application/json
responses:
@@ -3482,7 +3446,8 @@ paths:
- $ref: '#/definitions/v1.Wrapped'
- properties:
item:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
type: object
security:
- Bearer: []
diff --git a/docs/en/api/openapi-3.0.json b/docs/en/api/openapi-3.0.json
index 07f57dd1..0cf10aa8 100644
--- a/docs/en/api/openapi-3.0.json
+++ b/docs/en/api/openapi-3.0.json
@@ -2691,7 +2691,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/components/schemas/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -2716,7 +2717,8 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
},
@@ -2737,7 +2739,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/components/schemas/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -3852,11 +3855,8 @@
},
"settings": {
"description": "Settings holds the value of the \"settings\" field.",
- "allOf": [
- {
- "$ref": "#/components/schemas/schema.UserSettings"
- }
- ]
+ "type": "object",
+ "additionalProperties": true
},
"superuser": {
"description": "Superuser holds the value of the \"superuser\" field.",
@@ -5272,64 +5272,6 @@
}
}
},
- "schema.DuplicateSettings": {
- "type": "object",
- "properties": {
- "copyAttachments": {
- "type": "boolean"
- },
- "copyCustomFields": {
- "type": "boolean"
- },
- "copyMaintenance": {
- "type": "boolean"
- },
- "copyPrefixOverride": {
- "type": "string"
- }
- }
- },
- "schema.UserSettings": {
- "type": "object",
- "properties": {
- "displayLegacyHeader": {
- "type": "boolean"
- },
- "duplicateSettings": {
- "$ref": "#/components/schemas/schema.DuplicateSettings"
- },
- "editorAdvancedView": {
- "type": "boolean"
- },
- "itemDisplayView": {
- "type": "string"
- },
- "itemsPerPage": {
- "type": "integer"
- },
- "itemsPerTablePage": {
- "type": "integer"
- },
- "language": {
- "type": "string"
- },
- "locale": {
- "type": "string"
- },
- "overrideFormatLocale": {
- "type": "string"
- },
- "showDetails": {
- "type": "boolean"
- },
- "showEmpty": {
- "type": "boolean"
- },
- "theme": {
- "type": "string"
- }
- }
- },
"services.Latest": {
"type": "object",
"properties": {
diff --git a/docs/en/api/openapi-3.0.yaml b/docs/en/api/openapi-3.0.yaml
index 40658d6c..4b5c3be6 100644
--- a/docs/en/api/openapi-3.0.yaml
+++ b/docs/en/api/openapi-3.0.yaml
@@ -1597,7 +1597,8 @@ paths:
- type: object
properties:
item:
- $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
put:
security:
- Bearer: []
@@ -1608,7 +1609,8 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
description: Settings Data
required: true
responses:
@@ -1622,7 +1624,8 @@ paths:
- type: object
properties:
item:
- $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
servers:
- url: https://demo.homebox.software/api
- url: http://demo.homebox.software/api
@@ -2397,8 +2400,8 @@ components:
- $ref: "#/components/schemas/user.Role"
settings:
description: Settings holds the value of the "settings" field.
- allOf:
- - $ref: "#/components/schemas/schema.UserSettings"
+ type: object
+ additionalProperties: true
superuser:
description: Superuser holds the value of the "superuser" field.
type: boolean
@@ -3361,44 +3364,6 @@ components:
type: string
value:
type: number
- schema.DuplicateSettings:
- type: object
- properties:
- copyAttachments:
- type: boolean
- copyCustomFields:
- type: boolean
- copyMaintenance:
- type: boolean
- copyPrefixOverride:
- type: string
- schema.UserSettings:
- type: object
- properties:
- displayLegacyHeader:
- type: boolean
- duplicateSettings:
- $ref: "#/components/schemas/schema.DuplicateSettings"
- editorAdvancedView:
- type: boolean
- itemDisplayView:
- type: string
- itemsPerPage:
- type: integer
- itemsPerTablePage:
- type: integer
- language:
- type: string
- locale:
- type: string
- overrideFormatLocale:
- type: string
- showDetails:
- type: boolean
- showEmpty:
- type: boolean
- theme:
- type: string
services.Latest:
type: object
properties:
diff --git a/docs/en/api/swagger-2.0.json b/docs/en/api/swagger-2.0.json
index 5705a7a5..c68a4de1 100644
--- a/docs/en/api/swagger-2.0.json
+++ b/docs/en/api/swagger-2.0.json
@@ -2509,7 +2509,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -2538,7 +2539,8 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
],
@@ -2554,7 +2556,8 @@
"type": "object",
"properties": {
"item": {
- "$ref": "#/definitions/schema.UserSettings"
+ "type": "object",
+ "additionalProperties": true
}
}
}
@@ -3650,11 +3653,8 @@
},
"settings": {
"description": "Settings holds the value of the \"settings\" field.",
- "allOf": [
- {
- "$ref": "#/definitions/schema.UserSettings"
- }
- ]
+ "type": "object",
+ "additionalProperties": true
},
"superuser": {
"description": "Superuser holds the value of the \"superuser\" field.",
@@ -5070,64 +5070,6 @@
}
}
},
- "schema.DuplicateSettings": {
- "type": "object",
- "properties": {
- "copyAttachments": {
- "type": "boolean"
- },
- "copyCustomFields": {
- "type": "boolean"
- },
- "copyMaintenance": {
- "type": "boolean"
- },
- "copyPrefixOverride": {
- "type": "string"
- }
- }
- },
- "schema.UserSettings": {
- "type": "object",
- "properties": {
- "displayLegacyHeader": {
- "type": "boolean"
- },
- "duplicateSettings": {
- "$ref": "#/definitions/schema.DuplicateSettings"
- },
- "editorAdvancedView": {
- "type": "boolean"
- },
- "itemDisplayView": {
- "type": "string"
- },
- "itemsPerPage": {
- "type": "integer"
- },
- "itemsPerTablePage": {
- "type": "integer"
- },
- "language": {
- "type": "string"
- },
- "locale": {
- "type": "string"
- },
- "overrideFormatLocale": {
- "type": "string"
- },
- "showDetails": {
- "type": "boolean"
- },
- "showEmpty": {
- "type": "boolean"
- },
- "theme": {
- "type": "string"
- }
- }
- },
"services.Latest": {
"type": "object",
"properties": {
diff --git a/docs/en/api/swagger-2.0.yaml b/docs/en/api/swagger-2.0.yaml
index b9b956fa..31f1d15f 100644
--- a/docs/en/api/swagger-2.0.yaml
+++ b/docs/en/api/swagger-2.0.yaml
@@ -748,9 +748,9 @@ definitions:
- $ref: '#/definitions/user.Role'
description: Role holds the value of the "role" field.
settings:
- allOf:
- - $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
description: Settings holds the value of the "settings" field.
+ type: object
superuser:
description: Superuser holds the value of the "superuser" field.
type: boolean
@@ -1714,44 +1714,6 @@ definitions:
value:
type: number
type: object
- schema.DuplicateSettings:
- properties:
- copyAttachments:
- type: boolean
- copyCustomFields:
- type: boolean
- copyMaintenance:
- type: boolean
- copyPrefixOverride:
- type: string
- type: object
- schema.UserSettings:
- properties:
- displayLegacyHeader:
- type: boolean
- duplicateSettings:
- $ref: '#/definitions/schema.DuplicateSettings'
- editorAdvancedView:
- type: boolean
- itemDisplayView:
- type: string
- itemsPerPage:
- type: integer
- itemsPerTablePage:
- type: integer
- language:
- type: string
- locale:
- type: string
- overrideFormatLocale:
- type: string
- showDetails:
- type: boolean
- showEmpty:
- type: boolean
- theme:
- type: string
- type: object
services.Latest:
properties:
date:
@@ -3457,7 +3419,8 @@ paths:
- $ref: '#/definitions/v1.Wrapped'
- properties:
item:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
type: object
security:
- Bearer: []
@@ -3471,7 +3434,8 @@ paths:
name: payload
required: true
schema:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
produces:
- application/json
responses:
@@ -3482,7 +3446,8 @@ paths:
- $ref: '#/definitions/v1.Wrapped'
- properties:
item:
- $ref: '#/definitions/schema.UserSettings'
+ additionalProperties: true
+ type: object
type: object
security:
- Bearer: []
diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts
index 00732e83..339f6c02 100644
--- a/frontend/lib/api/types/data-contracts.ts
+++ b/frontend/lib/api/types/data-contracts.ts
@@ -528,7 +528,7 @@ export interface EntUser {
/** Role holds the value of the "role" field. */
role: UserRole;
/** Settings holds the value of the "settings" field. */
- settings: SchemaUserSettings;
+ settings: Record<string, any>;
/** Superuser holds the value of the "superuser" field. */
superuser: boolean;
/** UpdatedAt holds the value of the "updated_at" field. */
@@ -1059,28 +1059,6 @@ export interface ValueOverTimeEntry {
value: number;
}
-export interface SchemaDuplicateSettings {
- copyAttachments: boolean;
- copyCustomFields: boolean;
- copyMaintenance: boolean;
- copyPrefixOverride: string;
-}
-
-export interface SchemaUserSettings {
- displayLegacyHeader: boolean;
- duplicateSettings: SchemaDuplicateSettings;
- editorAdvancedView: boolean;
- itemDisplayView: string;
- itemsPerPage: number;
- itemsPerTablePage: number;
- language: string;
- locale: string;
- overrideFormatLocale: string;
- showDetails: boolean;
- showEmpty: boolean;
- theme: string;
-}
-
export interface Latest {
date: Date | string;
version: string;