Skip to content

Modern Docker Management, Designed for Everyone

feat: allow custom profile pictures (#3023)

olzi795c3aad1331
diff --git a/backend/api/api.go b/backend/api/api.go
index 93c4e6d9c..5295e63fe 100644
--- a/backend/api/api.go
+++ b/backend/api/api.go
@@ -277,7 +277,7 @@ func registerHandlersInternal(api huma.API, svc *di.Services, handlerAppCtx hand
svc = &di.Services{}
}
handlers.RegisterHealth(api)
- handlers.RegisterAuth(api, svc.User, svc.Auth, svc.Oidc)
+ handlers.RegisterAuth(api, svc.User, svc.Auth, svc.Oidc, svc.Settings)
handlers.RegisterApiKeys(api, svc.ApiKey)
handlers.RegisterFederatedCredentials(api, svc.Federated)
handlers.RegisterRoles(api, svc.Role)
diff --git a/backend/api/handlers/auth.go b/backend/api/handlers/auth.go
index 3ab37442f..2d34418d6 100644
--- a/backend/api/handlers/auth.go
+++ b/backend/api/handlers/auth.go
@@ -1,9 +1,16 @@
package handlers
import (
+ "bytes"
"context"
"errors"
+ "fmt"
+ stdimage "image"
+ "image/jpeg"
+ "image/png"
+ "io"
"log/slog"
+ "mime/multipart"
"net/http"
"time"
@@ -18,9 +25,10 @@ import (
)
type AuthHandler struct {
- userService *services.UserService
- authService *services.AuthService
- oidcService *services.OidcService
+ userService *services.UserService
+ authService *services.AuthService
+ oidcService *services.OidcService
+ settingsService *services.SettingsService
}
// --- Huma Input/Output Wrappers ---
@@ -80,12 +88,25 @@ type GetCurrentUserOutput struct {
Body base.ApiResponse[user.User]
}
+type UploadMyAvatarInput struct {
+ RawBody multipart.Form `contentType:"multipart/form-data"`
+}
+
+type UploadMyAvatarOutput struct {
+ Body base.ApiResponse[user.User]
+}
+
+type DeleteMyAvatarOutput struct {
+ Body base.ApiResponse[user.User]
+}
+
// RegisterAuth registers authentication routes using Huma.
-func RegisterAuth(api huma.API, userService *services.UserService, authService *services.AuthService, oidcService *services.OidcService) {
+func RegisterAuth(api huma.API, userService *services.UserService, authService *services.AuthService, oidcService *services.OidcService, settingsService *services.SettingsService) {
h := &AuthHandler{
- userService: userService,
- authService: authService,
- oidcService: oidcService,
+ userService: userService,
+ authService: authService,
+ oidcService: oidcService,
+ settingsService: settingsService,
}
huma.Register(api, huma.Operation{
@@ -169,6 +190,45 @@ func RegisterAuth(api huma.API, userService *services.UserService, authService *
{"ApiKeyAuth": {}},
},
}, h.UpdateMyProfile)
+
+ huma.Register(api, huma.Operation{
+ OperationID: "upload-my-avatar",
+ Method: http.MethodPost,
+ Path: "/auth/me/avatar",
+ Summary: "Upload own avatar",
+ Description: "Upload a custom profile picture (PNG, JPEG or WebP). Replaces any existing avatar.",
+ Tags: []string{"Auth"},
+ Security: []map[string][]string{
+ {"BearerAuth": {}},
+ {"ApiKeyAuth": {}},
+ },
+ RequestBody: &huma.RequestBody{
+ Required: true,
+ Content: map[string]*huma.MediaType{
+ "multipart/form-data": {
+ Schema: &huma.Schema{
+ Type: "object",
+ Properties: map[string]*huma.Schema{
+ "file": {Type: "string", Format: "binary"},
+ },
+ },
+ },
+ },
+ },
+ }, h.UploadMyAvatar)
+
+ huma.Register(api, huma.Operation{
+ OperationID: "delete-my-avatar",
+ Method: http.MethodDelete,
+ Path: "/auth/me/avatar",
+ Summary: "Delete own avatar",
+ Description: "Remove the current user's custom profile picture, reverting to the default avatar.",
+ Tags: []string{"Auth"},
+ Security: []map[string][]string{
+ {"BearerAuth": {}},
+ {"ApiKeyAuth": {}},
+ },
+ }, h.DeleteMyAvatar)
}
// Login authenticates a user and returns tokens.
@@ -433,3 +493,176 @@ func (h *AuthHandler) UpdateMyProfile(ctx context.Context, input *UpdateMyProfil
},
}, nil
}
+
+// UploadMyAvatar lets the current user upload a custom profile picture.
+// Accepts PNG, JPEG, or WebP images up to the configured avatar upload limit.
+func (h *AuthHandler) UploadMyAvatar(ctx context.Context, input *UploadMyAvatarInput) (*UploadMyAvatarOutput, error) {
+ if h.userService == nil {
+ return nil, huma.Error500InternalServerError("service not available")
+ }
+
+ currentUser, err := requireUserInternal(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ // Get file from multipart form
+ files := input.RawBody.File["file"]
+ if len(files) == 0 {
+ return nil, huma.Error400BadRequest("no file uploaded; include a 'file' field in the multipart form")
+ }
+
+ fileHeader := files[0]
+
+ f, err := fileHeader.Open()
+ if err != nil {
+ return nil, huma.Error500InternalServerError("failed to read uploaded file: " + err.Error())
+ }
+ defer func() { _ = f.Close() }()
+
+ maxSizeMb := h.avatarMaxUploadSizeMbInternal(ctx)
+ maxSizeBytes := int64(maxSizeMb) * 1024 * 1024
+
+ // Read one byte past the configured ceiling so oversized files are rejected
+ // without buffering the full multipart payload.
+ buf := new(bytes.Buffer)
+ if _, err := buf.ReadFrom(io.LimitReader(f, maxSizeBytes+1)); err != nil {
+ return nil, huma.Error500InternalServerError("failed to read file data: " + err.Error())
+ }
+
+ if int64(buf.Len()) > maxSizeBytes {
+ return nil, huma.NewError(http.StatusRequestEntityTooLarge, fmt.Sprintf("avatar file must be %d MB or smaller", maxSizeMb))
+ }
+ data := buf.Bytes()
+
+ // Detect and validate image format
+ mimeType, err := detectAvatarMimeTypeInternal(data)
+ if err != nil {
+ return nil, huma.Error400BadRequest("unsupported image format: only PNG, JPEG and WebP are accepted")
+ }
+ data, mimeType = normalizeAvatarImageInternal(data, mimeType)
+
+ if err := h.userService.UploadAvatar(ctx, currentUser.ID, data, mimeType); err != nil {
+ slog.ErrorContext(ctx, "Failed to save avatar", "user_id", currentUser.ID, "error", err)
+ return nil, huma.Error500InternalServerError("failed to save avatar")
+ }
+
+ // Reload user so the response reflects the new AvatarURL
+ updatedUser, err := h.userService.GetUser(ctx, currentUser.ID)
+ if err != nil {
+ return nil, huma.Error500InternalServerError((&common.UserRetrievalError{Err: err}).Error())
+ }
+
+ out, err := h.userService.ToUserResponseDto(ctx, *updatedUser)
+ if err != nil {
+ return nil, huma.Error500InternalServerError((&common.UserMappingError{Err: err}).Error())
+ }
+
+ return &UploadMyAvatarOutput{
+ Body: base.ApiResponse[user.User]{
+ Success: true,
+ Data: out,
+ },
+ }, nil
+}
+
+func (h *AuthHandler) avatarMaxUploadSizeMbInternal(ctx context.Context) int {
+ const defaultAvatarMaxUploadSizeMb = 2
+ if h.settingsService == nil {
+ return defaultAvatarMaxUploadSizeMb
+ }
+ maxSizeMb := h.settingsService.GetIntSetting(ctx, "avatarMaxUploadSizeMb", defaultAvatarMaxUploadSizeMb)
+ if maxSizeMb <= 0 {
+ return defaultAvatarMaxUploadSizeMb
+ }
+ return maxSizeMb
+}
+
+// DeleteMyAvatar removes the current user's custom profile picture.
+func (h *AuthHandler) DeleteMyAvatar(ctx context.Context, input *struct{}) (*DeleteMyAvatarOutput, error) {
+ if h.userService == nil {
+ return nil, huma.Error500InternalServerError("service not available")
+ }
+
+ currentUser, err := requireUserInternal(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := h.userService.DeleteAvatar(ctx, currentUser.ID); err != nil {
+ slog.ErrorContext(ctx, "Failed to delete avatar", "user_id", currentUser.ID, "error", err)
+ return nil, huma.Error500InternalServerError("failed to delete avatar")
+ }
+
+ updatedUser, err := h.userService.GetUser(ctx, currentUser.ID)
+ if err != nil {
+ return nil, huma.Error500InternalServerError((&common.UserRetrievalError{Err: err}).Error())
+ }
+
+ out, err := h.userService.ToUserResponseDto(ctx, *updatedUser)
+ if err != nil {
+ return nil, huma.Error500InternalServerError((&common.UserMappingError{Err: err}).Error())
+ }
+
+ return &DeleteMyAvatarOutput{
+ Body: base.ApiResponse[user.User]{
+ Success: true,
+ Data: out,
+ },
+ }, nil
+}
+
+// detectAvatarMimeTypeInternal validates that data is a supported image format and returns its MIME type.
+// Supported formats: PNG, JPEG, WebP.
+func detectAvatarMimeTypeInternal(data []byte) (string, error) {
+ mimeType := http.DetectContentType(data)
+ switch mimeType {
+ case "image/png", "image/jpeg", "image/webp":
+ return mimeType, nil
+ default:
+ return "", errors.New("unsupported image format: only PNG, JPEG and WebP are accepted")
+ }
+}
+
+func normalizeAvatarImageInternal(data []byte, mimeType string) ([]byte, string) {
+ const maxAvatarNormalizePixels = 16 * 1024 * 1024
+ if mimeType != "image/png" {
+ return data, mimeType
+ }
+
+ config, err := png.DecodeConfig(bytes.NewReader(data))
+ if err != nil || config.Width <= 0 || config.Height <= 0 {
+ return data, mimeType
+ }
+ if config.Width > maxAvatarNormalizePixels/config.Height {
+ return data, mimeType
+ }
+
+ img, err := png.Decode(bytes.NewReader(data))
+ if err != nil || imageHasTransparencyInternal(img) {
+ return data, mimeType
+ }
+
+ var out bytes.Buffer
+ if err := jpeg.Encode(&out, img, &jpeg.Options{Quality: 92}); err != nil {
+ return data, mimeType
+ }
+ if out.Len() == 0 || out.Len() >= len(data) {
+ return data, mimeType
+ }
+
+ return out.Bytes(), "image/jpeg"
+}
+
+func imageHasTransparencyInternal(img stdimage.Image) bool {
+ bounds := img.Bounds()
+ for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
+ for x := bounds.Min.X; x < bounds.Max.X; x++ {
+ _, _, _, alpha := img.At(x, y).RGBA()
+ if alpha != 0xffff {
+ return true
+ }
+ }
+ }
+ return false
+}
diff --git a/backend/api/handlers/settings.go b/backend/api/handlers/settings.go
index f9d096579..d378d61e1 100644
--- a/backend/api/handlers/settings.go
+++ b/backend/api/handlers/settings.go
@@ -357,6 +357,13 @@ func (h *SettingsHandler) validateSettingsUpdateInput(input settings.Update) err
}
}
+ if input.AvatarMaxUploadSizeMb != nil && strings.TrimSpace(*input.AvatarMaxUploadSizeMb) != "" {
+ value, err := strconv.Atoi(strings.TrimSpace(*input.AvatarMaxUploadSizeMb))
+ if err != nil || value < 1 || value > 50 {
+ return huma.Error400BadRequest("avatarMaxUploadSizeMb must be between 1 and 50")
+ }
+ }
+
return nil
}
diff --git a/backend/api/handlers/users.go b/backend/api/handlers/users.go
index 8eeed7a32..7037f051d 100644
--- a/backend/api/handlers/users.go
+++ b/backend/api/handlers/users.go
@@ -79,6 +79,17 @@ type DeleteUserOutput struct {
Body base.ApiResponse[base.MessageResponse]
}
+type GetUserAvatarInput struct {
+ UserID string `path:"userId" doc:"User ID"`
+}
+
+type GetUserAvatarOutput struct {
+ ContentType string `header:"Content-Type"`
+ CacheControl string `header:"Cache-Control"`
+ XContentTypeOptions string `header:"X-Content-Type-Options"`
+ Body []byte
+}
+
// ============================================================================
// Registration
// ============================================================================
@@ -156,6 +167,18 @@ func RegisterUsers(api huma.API, userService *services.UserService, authService
},
Middlewares: humamw.RequirePermission(api, authz.PermUsersDelete),
}, h.DeleteUser)
+
+ // Unauthenticated by design: profile pictures are publicly visible
+ // so they can be displayed without requiring a session token.
+ huma.Register(api, huma.Operation{
+ OperationID: "getUserAvatar",
+ Method: "GET",
+ Path: "/users/{userId}/avatar",
+ Summary: "Get user avatar",
+ Description: "Get the custom profile picture for a user",
+ Tags: []string{"Users"},
+ Security: []map[string][]string{},
+ }, h.GetUserAvatar)
}
// ============================================================================
@@ -352,6 +375,32 @@ func (h *UserHandler) DeleteUser(ctx context.Context, input *DeleteUserInput) (*
}, nil
}
+// GetUserAvatar returns the custom profile picture for a user.
+func (h *UserHandler) GetUserAvatar(ctx context.Context, input *GetUserAvatarInput) (*GetUserAvatarOutput, error) {
+ if h.userService == nil {
+ return nil, huma.Error500InternalServerError("service not available")
+ }
+
+ data, mimeType, err := h.userService.GetAvatar(ctx, input.UserID)
+ if err != nil {
+ if errors.Is(err, services.ErrUserNotFound) {
+ return nil, huma.Error404NotFound((&common.UserNotFoundError{}).Error())
+ }
+ return nil, huma.Error500InternalServerError("failed to retrieve avatar")
+ }
+
+ if len(data) == 0 {
+ return nil, huma.Error404NotFound("user has no custom avatar")
+ }
+
+ return &GetUserAvatarOutput{
+ ContentType: mimeType,
+ CacheControl: "public, max-age=3600, stale-while-revalidate=86400",
+ XContentTypeOptions: "nosniff",
+ Body: data,
+ }, nil
+}
+
func normalizeOptionalEmailInternal(email *string) (*string, error) {
if email == nil {
return nil, nil
diff --git a/backend/internal/configschema/schema_test.go b/backend/internal/configschema/schema_test.go
index 7d6dd73f5..d11d610a4 100644
--- a/backend/internal/configschema/schema_test.go
+++ b/backend/internal/configschema/schema_test.go
@@ -279,6 +279,7 @@ var expectedSettingOverrideKeys = []string{
"autoUpdate",
"autoUpdateExcludedContainers",
"autoUpdateInterval",
+ "avatarMaxUploadSizeMb",
"baseServerUrl",
"buildProvider",
"buildTimeout",
diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.go
index 656d95f79..04ced6d61 100644
--- a/backend/internal/models/settings.go
+++ b/backend/internal/models/settings.go
@@ -74,6 +74,7 @@ type Settings struct {
DiskUsagePath SettingVariable `key:"diskUsagePath" meta:"label=Disk Usage Path;type=text;keywords=disk,usage,path,storage,folder,files;category=general;description=Path used for disk usage calculations"`
BaseServerURL SettingVariable `key:"baseServerUrl" meta:"label=Base Server URL;type=text;keywords=base,url,server,domain,host,endpoint,address,link;category=general;description=Set the base URL for the application"`
EnableGravatar SettingVariable `key:"enableGravatar,authrequired" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=general;description=Enable Gravatar profile pictures for users"`
+ AvatarMaxUploadSizeMb SettingVariable `key:"avatarMaxUploadSizeMb,authrequired,local" meta:"label=Avatar Max Upload Size (MB);type=number;keywords=avatar,profile,picture,upload,size,limit,maximum,image,user,photo,mb;category=general;description=Maximum size in MB for profile picture uploads (default: 2)"`
DefaultShell SettingVariable `key:"defaultShell" meta:"label=Default Shell;type=text;keywords=shell,default,shellpath,path,login;category=general;description=Default shell to use for commands"`
EnvironmentHealthInterval SettingVariable `key:"environmentHealthInterval" meta:"label=Environment Health Check Interval;type=cron;keywords=environment,health,check,interval,frequency,heartbeat,status,monitoring,uptime,jobs,schedule;description=How often to check environment connectivity (cron expression)" catmeta:"id=jobschedule;title=Job Schedule;icon=jobs;url=/settings/jobs;description=Configure how often Arcane background jobs run"`
ApplicationTheme SettingVariable `key:"applicationTheme,public,local" meta:"label=Application Theme;type=select;keywords=theme,appearance,style,visual,palette,background,interface,ui;category=appearance;description=Choose the overall visual theme for the application"`
diff --git a/backend/internal/models/settings_test.go b/backend/internal/models/settings_test.go
index 81bdd2ee2..19b5b252a 100644
--- a/backend/internal/models/settings_test.go
+++ b/backend/internal/models/settings_test.go
@@ -53,6 +53,7 @@ func TestSettings_ToSettingVariableSlice_Visibility(t *testing.T) {
require.Contains(t, nonAdminKeys, "mobileNavigationMode")
require.Contains(t, nonAdminKeys, "keyboardShortcutsEnabled")
require.Contains(t, nonAdminKeys, "enableGravatar")
+ require.Contains(t, nonAdminKeys, "avatarMaxUploadSizeMb")
require.NotContains(t, nonAdminKeys, "baseServerUrl")
require.NotContains(t, nonAdminKeys, "defaultShell")
require.NotContains(t, nonAdminKeys, "oidcClientSecret")
diff --git a/backend/internal/models/user.go b/backend/internal/models/user.go
index 36d965cad..ef377a8fc 100644
--- a/backend/internal/models/user.go
+++ b/backend/internal/models/user.go
@@ -18,6 +18,9 @@ type User struct {
RequiresPasswordChange bool `json:"requiresPasswordChange" gorm:"column:requires_password_change"`
IsServiceAccount bool `json:"isServiceAccount" gorm:"column:is_service_account;not null;default:false"`
+ // Avatar metadata
+ HasAvatar bool `json:"hasAvatar" gorm:"column:has_avatar;not null;default:false"`
+
// OIDC provider tokens
OidcAccessToken *string `json:"-" gorm:"type:text"`
OidcRefreshToken *string `json:"-" gorm:"type:text"`
diff --git a/backend/internal/models/user_avatar.go b/backend/internal/models/user_avatar.go
new file mode 100644
index 000000000..b02cdafba
--- /dev/null
+++ b/backend/internal/models/user_avatar.go
@@ -0,0 +1,14 @@
+package models
+
+// UserAvatar represents the raw profile picture data for a user.
+// Stored separately from the main User struct to prevent
+// loading up to 2MB of binary data on every user query.
+type UserAvatar struct {
+ UserID string `json:"userId" gorm:"column:user_id;primaryKey"`
+ Data []byte `json:"-" gorm:"column:data;type:blob;not null"`
+ MimeType string `json:"mimeType" gorm:"column:mime_type;not null"`
+}
+
+func (UserAvatar) TableName() string {
+ return "user_avatars"
+}
diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.go
index 26c4dbb36..ba7df4a97 100644
--- a/backend/internal/services/settings_service.go
+++ b/backend/internal/services/settings_service.go
@@ -143,6 +143,7 @@ func DefaultSettingsConfig() *models.Settings {
VolumeBrowserHelperIdleTimeout: models.SettingVariable{Value: "10"},
BaseServerURL: models.SettingVariable{Value: "http://localhost"},
EnableGravatar: models.SettingVariable{Value: "true"},
+ AvatarMaxUploadSizeMb: models.SettingVariable{Value: "2"},
DefaultShell: models.SettingVariable{Value: "/bin/sh"},
DockerHost: models.SettingVariable{Value: "unix:///var/run/docker.sock"},
BuildsDirectory: models.SettingVariable{Value: "/builds"},
diff --git a/backend/internal/services/settings_service_test.go b/backend/internal/services/settings_service_test.go
index bb9368991..63e41d7e9 100644
--- a/backend/internal/services/settings_service_test.go
+++ b/backend/internal/services/settings_service_test.go
@@ -128,6 +128,27 @@ func TestSettingsService_GetSettings_UsesCachedSnapshotWithoutDatabase(t *testin
require.Equal(t, "http://cached", settings.BaseServerURL.Value)
}
+func TestSettingsService_AvatarMaxUploadSizeDefaultAndUpdate(t *testing.T) {
+ ctx := context.Background()
+ db := setupSettingsTestDB(t)
+ svc, err := NewSettingsService(ctx, db)
+ require.NoError(t, err)
+
+ current, err := svc.GetSettings(ctx)
+ require.NoError(t, err)
+ require.Equal(t, "2", current.AvatarMaxUploadSizeMb.Value)
+
+ updatedValue := "8"
+ _, err = svc.UpdateSettings(ctx, settings.Update{
+ AvatarMaxUploadSizeMb: &updatedValue,
+ })
+ require.NoError(t, err)
+
+ current, err = svc.GetSettings(ctx)
+ require.NoError(t, err)
+ require.Equal(t, "8", current.AvatarMaxUploadSizeMb.Value)
+}
+
func TestSettingsService_PruneUnknownSettings_RemovesStaleKeys(t *testing.T) {
ctx := context.Background()
db := setupSettingsTestDB(t)
diff --git a/backend/internal/services/user_service.go b/backend/internal/services/user_service.go
index 7b9444f9d..16c2d4cd0 100644
--- a/backend/internal/services/user_service.go
+++ b/backend/internal/services/user_service.go
@@ -449,6 +449,11 @@ func (s *UserService) toUserResponseDtoInternal(ctx context.Context, u models.Us
RoleAssignments: []user.RoleAssignmentSummary{},
PermissionsByEnv: map[string][]string{},
}
+ // Populate AvatarURL when the user has a custom avatar stored
+ if u.HasAvatar {
+ avatarURL := fmt.Sprintf("/api/users/%s/avatar", u.ID)
+ dto.AvatarURL = &avatarURL
+ }
if s.roleService == nil {
return dto
}
@@ -518,3 +523,66 @@ func (s *UserService) getUserInternal(ctx context.Context, userID string, tx *go
Error
return &user, err
}
+
+// UploadAvatar stores avatar bytes for a user, replacing any existing avatar.
+func (s *UserService) UploadAvatar(ctx context.Context, userID string, data []byte, mimeType string) error {
+ return dbutil.WithTx(ctx, s.db.DB, func(tx *gorm.DB) error {
+ avatar := models.UserAvatar{
+ UserID: userID,
+ Data: data,
+ MimeType: mimeType,
+ }
+ if err := tx.Save(&avatar).Error; err != nil {
+ return fmt.Errorf("failed to save avatar data: %w", err)
+ }
+
+ err := tx.Model(&models.User{}).
+ Where("id = ?", userID).
+ Updates(map[string]any{
+ "has_avatar": true,
+ }).Error
+ if err != nil {
+ return fmt.Errorf("failed to update user avatar flag: %w", err)
+ }
+ return nil
+ })
+}
+
+// DeleteAvatar removes the avatar for a user.
+func (s *UserService) DeleteAvatar(ctx context.Context, userID string) error {
+ return dbutil.WithTx(ctx, s.db.DB, func(tx *gorm.DB) error {
+ if err := tx.Where("user_id = ?", userID).Delete(&models.UserAvatar{}).Error; err != nil {
+ return fmt.Errorf("failed to delete avatar data: %w", err)
+ }
+
+ err := tx.Model(&models.User{}).
+ Where("id = ?", userID).
+ Updates(map[string]any{
+ "has_avatar": false,
+ }).Error
+ if err != nil {
+ return fmt.Errorf("failed to update user avatar flag: %w", err)
+ }
+ return nil
+ })
+}
+
+// GetAvatar returns the raw avatar data and MIME type for a user.
+// Returns (nil, "", nil) when the user has no custom avatar.
+func (s *UserService) GetAvatar(ctx context.Context, userID string) ([]byte, string, error) {
+ u, err := s.GetUserByID(ctx, userID)
+ if err != nil {
+ return nil, "", err
+ }
+ if !u.HasAvatar {
+ return nil, "", nil
+ }
+ var avatar models.UserAvatar
+ if err := s.db.DB.WithContext(ctx).Where("user_id = ?", userID).First(&avatar).Error; err != nil {
+ if errors.Is(err, gorm.ErrRecordNotFound) {
+ return nil, "", nil
+ }
+ return nil, "", err
+ }
+ return avatar.Data, avatar.MimeType, nil
+}
diff --git a/backend/resources/migrations/postgres/061_add_user_avatar.sql b/backend/resources/migrations/postgres/061_add_user_avatar.sql
new file mode 100644
index 000000000..a884efa4e
--- /dev/null
+++ b/backend/resources/migrations/postgres/061_add_user_avatar.sql
@@ -0,0 +1,13 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN IF NOT EXISTS has_avatar BOOLEAN NOT NULL DEFAULT FALSE;
+
+CREATE TABLE IF NOT EXISTS user_avatars (
+ user_id TEXT PRIMARY KEY,
+ data BYTEA NOT NULL,
+ mime_type TEXT NOT NULL,
+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
+);
+
+-- +goose Down
+DROP TABLE IF EXISTS user_avatars;
+ALTER TABLE users DROP COLUMN IF EXISTS has_avatar;
diff --git a/backend/resources/migrations/sqlite/061_add_user_avatar.sql b/backend/resources/migrations/sqlite/061_add_user_avatar.sql
new file mode 100644
index 000000000..132f65241
--- /dev/null
+++ b/backend/resources/migrations/sqlite/061_add_user_avatar.sql
@@ -0,0 +1,13 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN has_avatar BOOLEAN NOT NULL DEFAULT 0;
+
+CREATE TABLE user_avatars (
+ user_id TEXT PRIMARY KEY,
+ data BLOB NOT NULL,
+ mime_type TEXT NOT NULL,
+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
+);
+
+-- +goose Down
+DROP TABLE IF EXISTS user_avatars;
+ALTER TABLE users DROP COLUMN has_avatar;
diff --git a/frontend/messages/cs.json b/frontend/messages/cs.json
index 1605e6987..a28164bb1 100644
--- a/frontend/messages/cs.json
+++ b/frontend/messages/cs.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Treat symlinked child directories inside the projects directory as Docker Compose projects.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/da.json b/frontend/messages/da.json
index b05648227..43983f991 100644
--- a/frontend/messages/da.json
+++ b/frontend/messages/da.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Treat symlinked child directories inside the projects directory as Docker Compose projects.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/de.json b/frontend/messages/de.json
index 3418096be..d8aeec2ea 100644
--- a/frontend/messages/de.json
+++ b/frontend/messages/de.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Behandelt symlinked Unterverzeichnisse innerhalb des projects Verzeichnisses als Docker Compose Projekte.",
"general_base_url_label": "Basis-Server-URL",
"general_base_url_help": "Die Basis-URL für deinen Docker-Host. Wird verwendet, wenn Container über Service-Links geöffnet werden.",
- "general_user_avatars_heading": "Benutzer-Avatare",
- "general_user_avatars_description": "Gravatar-Nutzung für Profilbilder steuern.",
"general_enable_gravatar_label": "Gravatar aktivieren",
"general_settings_saved": "Einstellungen erfolgreich aktualisiert",
"_comment_settings_security": "=== EINSTELLUNGEN - SICHERHEIT ===",
diff --git a/frontend/messages/el.json b/frontend/messages/el.json
index e07253333..29ef101e2 100644
--- a/frontend/messages/el.json
+++ b/frontend/messages/el.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Αντιμετωπίστε τους υποκαταλόγους με συμβολική σύνδεση μέσα στον κατάλογο projects ως έργα Docker Compose.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index aa2f50c1a..c9dbbd12f 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -435,6 +435,19 @@
"account_subtitle": "Manage your profile, password, and active sessions",
"account_profile_title": "Profile",
"account_profile_description": "Update your display name and email",
+ "account_upload_overlay": "Upload",
+ "account_avatar_size_error": "Avatar file must be {maxSizeMb} MB or smaller",
+ "account_avatar_upload_success": "Profile picture updated",
+ "account_avatar_upload_failed": "Failed to upload profile picture",
+ "account_avatar_remove_success": "Profile picture removed",
+ "account_avatar_remove_failed": "Failed to remove profile picture",
+ "account_avatar_unsupported_file": "Use a PNG, JPEG, or WebP image.",
+ "account_avatar_crop_title": "Crop profile picture",
+ "account_avatar_crop_description": "Choose the part of the image to use for your profile picture.",
+ "account_avatar_crop_failed": "Failed to crop profile picture",
+ "account_crop_photo": "Crop photo",
+ "account_upload_photo": "Upload photo",
+ "account_remove_photo": "Remove",
"account_single_sign_on": "Single sign-on account",
"account_local_account": "Local account",
"account_last_login_prefix": "Last login",
@@ -1523,9 +1536,11 @@
"general_follow_project_symlinks_help": "Treat symlinked child directories inside the projects directory as Docker Compose projects.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
+ "general_enable_gravatar_description": "Use Gravatar as the fallback profile picture source for users without an uploaded photo.",
+ "general_avatar_upload_size_label": "Profile Picture Upload Size (MB)",
+ "general_avatar_upload_size_description": "Maximum cropped profile picture size users can upload.",
+ "general_avatar_upload_size_help": "Allowed range: 1-50 MB.",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
"security_title": "Security",
@@ -3336,8 +3351,6 @@
"common_log_out": "Log out",
"terminal_reconnect": "Reconnect shell",
"sidebar_toggle": "Toggle Sidebar",
- "account_profile": "Profile",
- "account_profile_desc": "Update your display name and email",
"account_password": "Password",
"account_password_desc": "Change your account password",
"account_current_password": "Current password",
@@ -3369,7 +3382,5 @@
"account_global_scope": "Global scope",
"account_via_sso": "· via SSO",
"account_signout_other_desc": "Revokes every active session except this one. Useful if you forgot to log out somewhere.",
- "common_select_all": "Select all",
- "common_clear": "Clear",
"swarm_stacks_not_deployed_files_found": "This stack is not currently deployed, but Arcane still found its saved source files."
}
diff --git a/frontend/messages/eo.json b/frontend/messages/eo.json
index b284d857f..a8aab4a50 100644
--- a/frontend/messages/eo.json
+++ b/frontend/messages/eo.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Traktu simlinkitajn subdosierujojn ene de la projekta dosierujo kiel Docker Compose-projektojn.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "Agordoj - Sekureco",
diff --git a/frontend/messages/es.json b/frontend/messages/es.json
index 2fd91ee68..53932349f 100644
--- a/frontend/messages/es.json
+++ b/frontend/messages/es.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Tratar los directorios hijos con enlaces simbólicos dentro del directorio de proyectos como proyectos Docker Compose.",
"general_base_url_label": "URL del Servidor Base",
"general_base_url_help": "La URL base para su host docker. Utilizado al abrir contenedores desde los enlaces de servicio",
- "general_user_avatars_heading": "Avatares de usuario",
- "general_user_avatars_description": "Controlar el uso de Gravatar para imágenes de perfil.",
"general_enable_gravatar_label": "Activar Gravatar",
"general_settings_saved": "Configuración actualizada correctamente",
"_comment_settings_security": "=== CONFIGURACIÓN - SEGURIDAD ===",
diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json
index fcfbd99f9..cbaca71bf 100644
--- a/frontend/messages/fr.json
+++ b/frontend/messages/fr.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Traiter les répertoires enfants liés par des liens symboliques dans le répertoire projects comme des projets Docker Compose.",
"general_base_url_label": "URL du serveur de base",
"general_base_url_help": "L'URL de base pour votre hôte docker. Utilisé lors de l'ouverture des conteneurs à partir des liens de service",
- "general_user_avatars_heading": "Avatars de l’utilisateur",
- "general_user_avatars_description": "Contrôler l'utilisation de Gravatar pour les images de profil.",
"general_enable_gravatar_label": "Activer Gravatar",
"general_settings_saved": "Paramètres mis à jour avec succès",
"_comment_settings_security": "=== PARAMÈTRES - SÉCURITÉ ===",
diff --git a/frontend/messages/hu.json b/frontend/messages/hu.json
index ba59940d1..11aef655f 100644
--- a/frontend/messages/hu.json
+++ b/frontend/messages/hu.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Treat symlinked child directories inside the projects directory as Docker Compose projects.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/it.json b/frontend/messages/it.json
index abfc19e35..fb9da313e 100644
--- a/frontend/messages/it.json
+++ b/frontend/messages/it.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Tratta le directory figlie con collegamenti simbolici all'interno della directory projects come progetti Docker Compose.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Abilita Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/ja.json b/frontend/messages/ja.json
index 26cffba53..5a497b093 100644
--- a/frontend/messages/ja.json
+++ b/frontend/messages/ja.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "projectsディレクトリ内のシンボリックリンクされた子ディレクトリをDocker Composeプロジェクトとして扱う。",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/ko.json b/frontend/messages/ko.json
index 5d46cabaf..1311c8305 100644
--- a/frontend/messages/ko.json
+++ b/frontend/messages/ko.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "프로젝트 디렉토리 내에서 심볼릭 링크(Symlink)된 하위 디렉토리도 Docker Compose 프로젝트로 처리합니다.",
"general_base_url_label": "기본 서버 URL",
"general_base_url_help": "Docker 호스트의 기본 URL입니다. 서비스 링크에서 컨테이너를 열 때 사용됩니다.",
- "general_user_avatars_heading": "사용자 아바타",
- "general_user_avatars_description": "프로필 이미지에 Gravatar를 사용할지 설정합니다.",
"general_enable_gravatar_label": "Gravatar 활성화",
"general_settings_saved": "설정이 성공적으로 업데이트되었습니다.",
"_comment_settings_security": "=== 설정 - 보안 ===",
diff --git a/frontend/messages/nl.json b/frontend/messages/nl.json
index 7db366fc3..3cd4a15bd 100644
--- a/frontend/messages/nl.json
+++ b/frontend/messages/nl.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Behandel symlinked kind directories binnen de projecten directory als Docker Compose projecten.",
"general_base_url_label": "Basisserver URL",
"general_base_url_help": "De basis-URL voor uw docker host. Wordt gebruikt bij het openen van containers vanuit de service links",
- "general_user_avatars_heading": "Gebruiker Avatars",
- "general_user_avatars_description": "Bedien Gravatar gebruik voor profielafbeeldingen.",
"general_enable_gravatar_label": "Gravatar inschakelen",
"general_settings_saved": "Instellingen bijgewerkt",
"_comment_settings_security": "=== INSTELLINGEN - BEVEILIGING ===",
diff --git a/frontend/messages/pl.json b/frontend/messages/pl.json
index 9d02fb86f..e7b92b0bd 100644
--- a/frontend/messages/pl.json
+++ b/frontend/messages/pl.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Treat symlinked child directories inside the projects directory as Docker Compose projects.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/pt-BR.json b/frontend/messages/pt-BR.json
index e471dd883..e98398e26 100644
--- a/frontend/messages/pt-BR.json
+++ b/frontend/messages/pt-BR.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Trata os subdiretórios com links simbólicos dentro do diretório de projetos como projetos do Docker Compose.",
"general_base_url_label": "URL base do servidor",
"general_base_url_help": "A URL base para seu host docker. Usada ao acessar os containers de links de serviço.",
- "general_user_avatars_heading": "Avatares do usuário",
- "general_user_avatars_description": "Controle o uso do Gravatar para imagens de perfil.",
"general_enable_gravatar_label": "Ativar Gravatar",
"general_settings_saved": "Atualizações de configurações bem-sucedida",
"_comment_settings_security": "=== CONFIGURAÇÕES — SEGURANÇA ===",
diff --git a/frontend/messages/pt.json b/frontend/messages/pt.json
index 314982c65..de26647c4 100644
--- a/frontend/messages/pt.json
+++ b/frontend/messages/pt.json
@@ -807,8 +807,6 @@
"general_base_url_placeholder": "localhost",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
"general_base_url_required": "Base server URL is required",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_enable_gravatar_description": "Whether to use Gravatar-based avatars for user accounts",
"general_settings_saved": "Settings Updated Successfully",
diff --git a/frontend/messages/ru.json b/frontend/messages/ru.json
index df2b9b1c0..6b3d29ea5 100644
--- a/frontend/messages/ru.json
+++ b/frontend/messages/ru.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Рассматривать дочерние каталоги с символическими ссылками внутри каталога проектов как проекты Docker Compose.",
"general_base_url_label": "Базовый URL сервера",
"general_base_url_help": "Базовый URL-адрес для вашего Docker хоста. Используется при открытии контейнеров из ссылок сервиса",
- "general_user_avatars_heading": "Аватар пользователя",
- "general_user_avatars_description": "Используй Gravatar для изображения профиля.",
"general_enable_gravatar_label": "Использовать Gravatar",
"general_settings_saved": "Настройки Успешно Обновлены",
"_comment_settings_security": "=== НАСТРОЙКИ - БЕЗОПАСНОСТИ ===",
diff --git a/frontend/messages/sv.json b/frontend/messages/sv.json
index 619fa3199..a2fc490f5 100644
--- a/frontend/messages/sv.json
+++ b/frontend/messages/sv.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Behandla symlänkade underordnade kataloger i projektkatalogen som Docker Compose-projekt.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/uk.json b/frontend/messages/uk.json
index 38627e674..780e0d681 100644
--- a/frontend/messages/uk.json
+++ b/frontend/messages/uk.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Синхронізовані дочірні каталоги всередині каталогу проектів слід розглядати як проекти Docker Compose.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "The Base URL for your docker host. Used when opening containers from the service links",
- "general_user_avatars_heading": "User Avatars",
- "general_user_avatars_description": "Control Gravatar usage for profile images.",
"general_enable_gravatar_label": "Enable Gravatar",
"general_settings_saved": "Settings Updated Successfully",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/vi.json b/frontend/messages/vi.json
index 6ac873b8d..85902cd08 100644
--- a/frontend/messages/vi.json
+++ b/frontend/messages/vi.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "Xử lý các thư mục con được liên kết tượng trưng bên trong thư mục projects như các dự án Docker Compose.",
"general_base_url_label": "Base Server URL",
"general_base_url_help": "URL cơ sở cho Docker host của bạn. Được dùng khi mở Container từ các liên kết dịch vụ",
- "general_user_avatars_heading": "Ảnh đại diện người dùng",
- "general_user_avatars_description": "Kiểm soát việc sử dụng Gravatar cho ảnh hồ sơ.",
"general_enable_gravatar_label": "Bật Gravatar",
"general_settings_saved": "Cập nhật cài đặt thành công",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/messages/zh-CN.json b/frontend/messages/zh-CN.json
index fcf376c77..09b4e96e2 100644
--- a/frontend/messages/zh-CN.json
+++ b/frontend/messages/zh-CN.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "将项目目录内的符号链接子目录视为 Docker Compose 项目。",
"general_base_url_label": "基础服务器URL",
"general_base_url_help": "您的Docker host的基本URL。用于打开容器的链接",
- "general_user_avatars_heading": "用户头像",
- "general_user_avatars_description": "控制个人资料图像的 Gravatar 使用情况。",
"general_enable_gravatar_label": "启用 Gravatar 头像",
"general_settings_saved": "已成功更新设置",
"_comment_settings_security": "=== 设置 - 安全===",
diff --git a/frontend/messages/zh-TW.json b/frontend/messages/zh-TW.json
index 338c584a9..acf7db23c 100644
--- a/frontend/messages/zh-TW.json
+++ b/frontend/messages/zh-TW.json
@@ -1410,8 +1410,6 @@
"general_follow_project_symlinks_help": "將專案目錄內的子目錄符號連結視為 Docker Compose 專案。",
"general_base_url_label": "基底伺服器網址",
"general_base_url_help": "Docker 主機的基底路徑,用於從服務連結開啟容器時",
- "general_user_avatars_heading": "使用者頭像",
- "general_user_avatars_description": "控制使用者頭像是否使用 Gravatar。",
"general_enable_gravatar_label": "啟用 Gravatar 頭像",
"general_settings_saved": "設定更新成功",
"_comment_settings_security": "=== SETTINGS - SECURITY ===",
diff --git a/frontend/package.json b/frontend/package.json
index c06f4f528..c658d1c1e 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -48,6 +48,7 @@
"prettier-plugin-tailwindcss": "^0.8.0",
"svelte": "^5.56.3",
"svelte-codemirror-editor": "^2.1.0",
+ "svelte-easy-crop": "^5.0.1",
"yaml": "^2.9.0"
},
"devDependencies": {
diff --git a/frontend/src/lib/components/form/text-input-with-label.svelte b/frontend/src/lib/components/form/text-input-with-label.svelte
index 81b12fca1..2ee8da5d0 100644
--- a/frontend/src/lib/components/form/text-input-with-label.svelte
+++ b/frontend/src/lib/components/form/text-input-with-label.svelte
@@ -47,7 +47,7 @@
}
</script>
-<div class="space-y-2">
+<div class="space-y-2.5">
<div>
<Label for={id} class="text-sm font-medium">
{label}{#if required}<span class="text-destructive ml-0.5">*</span>{/if}
diff --git a/frontend/src/lib/components/sidebar/sidebar-user.svelte b/frontend/src/lib/components/sidebar/sidebar-user.svelte
index 965c8c926..e2dec66b5 100644
--- a/frontend/src/lib/components/sidebar/sidebar-user.svelte
+++ b/frontend/src/lib/components/sidebar/sidebar-user.svelte
@@ -6,7 +6,6 @@
import { useSidebar } from '$lib/components/ui/sidebar/index.js';
import type { User } from '$lib/types/auth';
import settingsStore from '$lib/stores/config-store';
- import { getDefaultProfilePicture } from '$lib/utils/docker';
import { goto } from '$app/navigation';
import { LogoutIcon, UserIcon } from '$lib/icons';
@@ -34,7 +33,7 @@
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hash = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
- return `https://www.gravatar.com/avatar/${hash}?s=${size}`;
+ return `https://www.gravatar.com/avatar/${hash}?s=${size}&d=404`;
}
</script>
@@ -49,24 +48,24 @@
{...props}
>
{#if user && user.displayName}
- <Avatar.Root class="size-8 rounded-lg">
- {#if $settingsStore.enableGravatar}
- {#await getGravatarUrl(user?.email)}
- <Avatar.Image src={getDefaultProfilePicture()} alt={user.displayName} />
- {:then url}
- <Avatar.Image src={url} alt={user.displayName} />
- {:catch}
- <Avatar.Image src={getDefaultProfilePicture()} alt={user.displayName} />
- {/await}
- {:else}
- <Avatar.Image src={getDefaultProfilePicture()} alt={user.displayName} />
- {/if}
- <Avatar.Fallback
- class="from-primary/20 to-primary/10 text-primary border-primary/20 rounded-lg border bg-linear-to-br"
- >
- {user.displayName?.charAt(0).toUpperCase()}
- </Avatar.Fallback>
- </Avatar.Root>
+ {#key user?.updatedAt}
+ <Avatar.Root class="size-8 rounded-lg">
+ {#if user?.avatarUrl}
+ <Avatar.Image src={`${user.avatarUrl}?t=${user.updatedAt}`} alt={user.displayName} />
+ {:else if $settingsStore.enableGravatar}
+ {#await getGravatarUrl(user?.email)}
+ <!-- Loading gravatar, show fallback -->
+ {:then url}
+ <Avatar.Image src={url} alt={user.displayName} />
+ {:catch}
+ <!-- Gravatar failed, show fallback -->
+ {/await}
+ {/if}
+ <Avatar.Fallback class="bg-primary text-primary-foreground rounded-lg text-sm font-semibold">
+ {user.displayName?.charAt(0).toUpperCase()}
+ </Avatar.Fallback>
+ </Avatar.Root>
+ {/key}
{#if !isCollapsed}
<div class="grid flex-1 pl-0 text-left text-sm leading-tight">
<span class="truncate font-medium">{user.displayName}</span>
@@ -96,24 +95,24 @@
}}
>
<div class="flex items-center gap-2.5 px-2 py-2">
- <Avatar.Root class="size-8 shrink-0 rounded-lg">
- {#if $settingsStore.enableGravatar}
- {#await getGravatarUrl(user?.email)}
- <Avatar.Image src={getDefaultProfilePicture()} alt={user.displayName} />
- {:then url}
- <Avatar.Image src={url} alt={user.displayName} />
- {:catch}
- <Avatar.Image src={getDefaultProfilePicture()} alt={user.displayName} />
- {/await}
- {:else}
- <Avatar.Image src={getDefaultProfilePicture()} alt={user.displayName} />
- {/if}
- <Avatar.Fallback
- class="from-primary/20 to-primary/10 text-primary border-primary/20 rounded-lg border bg-linear-to-br text-xs font-semibold"
- >
- {user.displayName?.charAt(0).toUpperCase()}
- </Avatar.Fallback>
- </Avatar.Root>
+ {#key user?.updatedAt}
+ <Avatar.Root class="size-8 shrink-0 rounded-lg">
+ {#if user?.avatarUrl}
+ <Avatar.Image src={`${user.avatarUrl}?t=${user.updatedAt}`} alt={user.displayName} />
+ {:else if $settingsStore.enableGravatar}
+ {#await getGravatarUrl(user?.email)}
+ <!-- Loading gravatar, show fallback -->
+ {:then url}
+ <Avatar.Image src={url} alt={user.displayName} />
+ {:catch}
+ <!-- Gravatar failed, show fallback -->
+ {/await}
+ {/if}
+ <Avatar.Fallback class="bg-primary text-primary-foreground rounded-lg text-xs font-semibold">
+ {user.displayName?.charAt(0).toUpperCase()}
+ </Avatar.Fallback>
+ </Avatar.Root>
+ {/key}
<div class="grid min-w-0 flex-1 leading-tight">
<span class="truncate text-sm font-medium">{user.displayName}</span>
<span class="text-muted-foreground truncate text-xs">{user.email}</span>
diff --git a/frontend/src/lib/components/sidebar/sidebar.svelte b/frontend/src/lib/components/sidebar/sidebar.svelte
index b1035edfd..e75f8fb23 100644
--- a/frontend/src/lib/components/sidebar/sidebar.svelte
+++ b/frontend/src/lib/components/sidebar/sidebar.svelte
@@ -54,7 +54,7 @@
const storeUser = fromStore(userStore);
let showVersionDialog = $state(false);
- const effectiveUser = $derived(user ?? storeUser.current);
+ const effectiveUser = $derived(storeUser.current ?? user);
const isCollapsed = $derived(sidebar.state === 'collapsed' && !(sidebar.hoverExpansionEnabled && sidebar.isHovered));
let envSwitcherOpen = $state(false);
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-cancel.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper-cancel.svelte
new file mode 100644
index 000000000..c2e8eec6c
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-cancel.svelte
@@ -0,0 +1,43 @@
+<script lang="ts">
+ import { ArcaneButton, type Action, type ArcaneButtonSize, type ArcaneButtonTone } from '$lib/components/arcane-button';
+ import { m } from '$lib/paraglide/messages';
+ import { useImageCropperCancel } from './image-cropper-state.svelte.js';
+
+ type CancelButtonProps = {
+ ref?: HTMLElement | null;
+ action?: Action;
+ size?: ArcaneButtonSize;
+ tone?: ArcaneButtonTone;
+ customLabel?: string;
+ disabled?: boolean;
+ class?: string;
+ onclick?: (event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) => void;
+ };
+
+ let {
+ ref = $bindable(null),
+ action = 'cancel',
+ size = 'sm',
+ customLabel = m.common_cancel(),
+ disabled = false,
+ tone = undefined,
+ class: className = undefined,
+ onclick
+ }: CancelButtonProps = $props();
+
+ const cancelState = useImageCropperCancel();
+</script>
+
+<ArcaneButton
+ bind:ref
+ {action}
+ {size}
+ {tone}
+ {customLabel}
+ {disabled}
+ class={className}
+ onclick={(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) => {
+ onclick?.(event);
+ cancelState.onclick();
+ }}
+/>
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-controls.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper-controls.svelte
new file mode 100644
index 000000000..e20678b5e
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-controls.svelte
@@ -0,0 +1,10 @@
+<script lang="ts">
+ import { cn } from '$lib/utils';
+ import type { ImageCropperControlsProps } from './types';
+
+ let { ref = $bindable(null), class: className, children, ...rest }: ImageCropperControlsProps = $props();
+</script>
+
+<div {...rest} bind:this={ref} class={cn('flex w-full items-center justify-center gap-2', className)}>
+ {@render children?.()}
+</div>
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-crop.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper-crop.svelte
new file mode 100644
index 000000000..fd5a526ac
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-crop.svelte
@@ -0,0 +1,43 @@
+<script lang="ts">
+ import { ArcaneButton, type Action, type ArcaneButtonSize, type ArcaneButtonTone } from '$lib/components/arcane-button';
+ import { m } from '$lib/paraglide/messages';
+ import { useImageCropperCrop } from './image-cropper-state.svelte.js';
+
+ type CropButtonProps = {
+ ref?: HTMLElement | null;
+ action?: Action;
+ size?: ArcaneButtonSize;
+ tone?: ArcaneButtonTone;
+ customLabel?: string;
+ disabled?: boolean;
+ class?: string;
+ onclick?: (event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) => void;
+ };
+
+ let {
+ ref = $bindable(null),
+ action = 'save',
+ size = 'sm',
+ customLabel = m.account_crop_photo(),
+ disabled = false,
+ tone = undefined,
+ class: className = undefined,
+ onclick
+ }: CropButtonProps = $props();
+
+ const cropState = useImageCropperCrop();
+</script>
+
+<ArcaneButton
+ bind:ref
+ {action}
+ {size}
+ {tone}
+ {customLabel}
+ {disabled}
+ class={className}
+ onclick={(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) => {
+ onclick?.(event);
+ cropState.onclick();
+ }}
+/>
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-cropper.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper-cropper.svelte
new file mode 100644
index 000000000..c5f29d37f
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-cropper.svelte
@@ -0,0 +1,20 @@
+<script lang="ts">
+ import Cropper from 'svelte-easy-crop';
+ import { useImageCropperCropper } from './image-cropper-state.svelte.js';
+ import type { ImageCropperCropperProps } from './types';
+
+ let { cropShape = 'round', aspect = 1, showGrid = false, ...rest }: ImageCropperCropperProps = $props();
+
+ const cropperState = useImageCropperCropper();
+</script>
+
+<div class="relative h-full w-full">
+ <Cropper
+ {...rest}
+ {cropShape}
+ {aspect}
+ {showGrid}
+ image={cropperState.rootState.tempUrl}
+ oncropcomplete={cropperState.onCropComplete}
+ />
+</div>
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-dialog.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper-dialog.svelte
new file mode 100644
index 000000000..819eac98d
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-dialog.svelte
@@ -0,0 +1,22 @@
+<script lang="ts">
+ import * as Dialog from '$lib/components/ui/dialog';
+ import { cn } from '$lib/utils';
+ import { useImageCropperDialog } from './image-cropper-state.svelte.js';
+ import type { ImageCropperDialogProps } from './types';
+
+ let { children, class: className, ...rest }: ImageCropperDialogProps = $props();
+
+ const dialogState = useImageCropperDialog();
+</script>
+
+<Dialog.Root bind:open={dialogState.rootState.open}>
+ <Dialog.Content
+ {...rest}
+ showCloseButton={false}
+ class={cn('min-h-96 max-w-full rounded-none border-x-0 sm:max-w-lg sm:rounded-lg sm:border-x', className)}
+ >
+ <div class="flex flex-col gap-4">
+ {@render children?.()}
+ </div>
+ </Dialog.Content>
+</Dialog.Root>
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-preview.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper-preview.svelte
new file mode 100644
index 000000000..732980818
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-preview.svelte
@@ -0,0 +1,24 @@
+<script lang="ts">
+ import * as Avatar from '$lib/components/ui/avatar';
+ import { UploadIcon } from '$lib/icons';
+ import { m } from '$lib/paraglide/messages';
+ import { cn } from '$lib/utils';
+ import { useImageCropperPreview } from './image-cropper-state.svelte.js';
+ import type { ImageCropperPreviewProps } from './types';
+
+ let { child, class: className }: ImageCropperPreviewProps = $props();
+
+ const previewState = useImageCropperPreview();
+</script>
+
+{#if child}
+ {@render child({ src: previewState.rootState.src })}
+{:else}
+ <Avatar.Root class={cn('ring-accent ring-offset-background size-20 ring-2 ring-offset-2', className)}>
+ <Avatar.Image src={previewState.rootState.src} />
+ <Avatar.Fallback>
+ <UploadIcon class="size-4" />
+ <span class="sr-only">{m.account_upload_photo()}</span>
+ </Avatar.Fallback>
+ </Avatar.Root>
+{/if}
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-state.svelte.ts b/frontend/src/lib/components/ui/image-cropper/image-cropper-state.svelte.ts
new file mode 100644
index 000000000..9787d6b18
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-state.svelte.ts
@@ -0,0 +1,151 @@
+import type { ReadableBoxedValues, WritableBoxedValues } from 'svelte-toolbelt';
+import { Context } from 'runed';
+import type { CropArea, DispatchEvents } from 'svelte-easy-crop';
+import { getCroppedImg } from './utils';
+
+export const VALID_IMAGE_TYPES = ['image/jpeg', 'image/png', 'image/webp'];
+
+export type ImageCropperRootProps = WritableBoxedValues<{
+ src: string;
+}> &
+ ReadableBoxedValues<{
+ id: string;
+ onCropped: (url: string) => void;
+ onError: (error: Error) => void;
+ onUnsupportedFile: (file: File) => void;
+ }>;
+
+class ImageCropperRootState {
+ #createdUrls = $state<string[]>([]);
+ open = $state(false);
+ tempUrl = $state<string>();
+ pixelCrop = $state<CropArea>();
+
+ constructor(readonly opts: ImageCropperRootProps) {
+ this.onUpload = this.onUpload.bind(this);
+ this.onCancel = this.onCancel.bind(this);
+ this.onCrop = this.onCrop.bind(this);
+ this.dispose = this.dispose.bind(this);
+ }
+
+ onUpload(file: File) {
+ if (!VALID_IMAGE_TYPES.includes(file.type)) {
+ this.opts.onUnsupportedFile.current(file);
+ return;
+ }
+
+ this.tempUrl = URL.createObjectURL(file);
+ this.#createdUrls.push(this.tempUrl);
+ this.open = true;
+ }
+
+ onCancel() {
+ this.tempUrl = undefined;
+ this.open = false;
+ this.pixelCrop = undefined;
+ }
+
+ async onCrop() {
+ if (!this.pixelCrop || !this.tempUrl) return;
+
+ try {
+ this.opts.src.current = await getCroppedImg(this.tempUrl, this.pixelCrop);
+ this.open = false;
+ this.opts.onCropped.current(this.opts.src.current);
+ } catch (error) {
+ this.opts.onError.current(error instanceof Error ? error : new Error('failed to crop image'));
+ }
+ }
+
+ get src() {
+ return this.opts.src.current;
+ }
+
+ get id() {
+ return this.opts.id.current;
+ }
+
+ dispose() {
+ for (const url of this.#createdUrls) {
+ URL.revokeObjectURL(url);
+ }
+ }
+}
+
+class ImageCropperTriggerState {
+ constructor(readonly rootState: ImageCropperRootState) {}
+}
+
+class ImageCropperPreviewState {
+ constructor(readonly rootState: ImageCropperRootState) {}
+}
+
+class ImageCropperDialogState {
+ constructor(readonly rootState: ImageCropperRootState) {}
+}
+
+class ImageCropperCropperState {
+ constructor(readonly rootState: ImageCropperRootState) {
+ this.onCropComplete = this.onCropComplete.bind(this);
+ }
+
+ onCropComplete(event: DispatchEvents['cropcomplete']) {
+ this.rootState.pixelCrop = event.pixels;
+ }
+}
+
+class ImageCropperCropState {
+ constructor(readonly rootState: ImageCropperRootState) {
+ this.onclick = this.onclick.bind(this);
+ }
+
+ onclick() {
+ void this.rootState.onCrop();
+ }
+}
+
+class ImageCropperCancelState {
+ constructor(readonly rootState: ImageCropperRootState) {
+ this.onclick = this.onclick.bind(this);
+ }
+
+ onclick() {
+ this.rootState.onCancel();
+ }
+}
+
+const ImageCropperRootContext = new Context<ImageCropperRootState>('ImageCropper.Root');
+
+export const useImageCropperRoot = (props: ImageCropperRootProps) => {
+ return ImageCropperRootContext.set(new ImageCropperRootState(props));
+};
+
+export const useImageCropperTrigger = () => {
+ const rootState = ImageCropperRootContext.get();
+ return new ImageCropperTriggerState(rootState);
+};
+
+export const useImageCropperPreview = () => {
+ const rootState = ImageCropperRootContext.get();
+ return new ImageCropperPreviewState(rootState);
+};
+
+export const useImageCropperDialog = () => {
+ const rootState = ImageCropperRootContext.get();
+ return new ImageCropperDialogState(rootState);
+};
+
+export const useImageCropperCropper = () => {
+ const rootState = ImageCropperRootContext.get();
+ return new ImageCropperCropperState(rootState);
+};
+
+export const useImageCropperCrop = () => {
+ const rootState = ImageCropperRootContext.get();
+ return new ImageCropperCropState(rootState);
+};
+
+export const useImageCropperCancel = () => {
+ const rootState = ImageCropperRootContext.get();
+ return new ImageCropperCancelState(rootState);
+};
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper-upload-trigger.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper-upload-trigger.svelte
new file mode 100644
index 000000000..8a4dca390
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper-upload-trigger.svelte
@@ -0,0 +1,30 @@
+<script lang="ts">
+ import { cn } from '$lib/utils';
+ import { useImageCropperTrigger } from './image-cropper-state.svelte.js';
+ import type { ImageCropperUploadTriggerProps } from './types';
+
+ let {
+ ref = $bindable(null),
+ class: className,
+ children,
+ type = 'button',
+ onclick,
+ ...rest
+ }: ImageCropperUploadTriggerProps = $props();
+
+ const triggerState = useImageCropperTrigger();
+</script>
+
+<button
+ {...rest}
+ bind:this={ref}
+ {type}
+ onclick={(event) => {
+ onclick?.(event);
+ if (event.defaultPrevented) return;
+ document.getElementById(triggerState.rootState.id)?.click();
+ }}
+ class={cn('hover:cursor-pointer', className)}
+>
+ {@render children?.()}
+</button>
diff --git a/frontend/src/lib/components/ui/image-cropper/image-cropper.svelte b/frontend/src/lib/components/ui/image-cropper/image-cropper.svelte
new file mode 100644
index 000000000..e4a2b75d2
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/image-cropper.svelte
@@ -0,0 +1,45 @@
+<script lang="ts">
+ import { onDestroy } from 'svelte';
+ import { useId } from 'bits-ui';
+ import { box } from 'svelte-toolbelt';
+ import { useImageCropperRoot } from './image-cropper-state.svelte.js';
+ import type { ImageCropperRootProps } from './types';
+
+ let {
+ id = useId(),
+ src = $bindable(''),
+ onCropped = () => {},
+ onError = () => {},
+ onUnsupportedFile = () => {},
+ children,
+ ...rest
+ }: ImageCropperRootProps = $props();
+
+ const rootState = useImageCropperRoot({
+ id: box.with(() => id),
+ src: box.with(
+ () => src,
+ (value) => (src = value)
+ ),
+ onCropped: box.with(() => onCropped),
+ onError: box.with(() => onError),
+ onUnsupportedFile: box.with(() => onUnsupportedFile)
+ });
+
+ onDestroy(() => rootState.dispose());
+</script>
+
+{@render children?.()}
+<input
+ {...rest}
+ onchange={(event) => {
+ const file = event.currentTarget.files?.[0];
+ if (!file) return;
+
+ rootState.onUpload(file);
+ event.currentTarget.value = '';
+ }}
+ type="file"
+ {id}
+ style="display: none;"
+/>
diff --git a/frontend/src/lib/components/ui/image-cropper/index.ts b/frontend/src/lib/components/ui/image-cropper/index.ts
new file mode 100644
index 000000000..12d9218e6
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/index.ts
@@ -0,0 +1,24 @@
+import Root from './image-cropper.svelte';
+import UploadTrigger from './image-cropper-upload-trigger.svelte';
+import Preview from './image-cropper-preview.svelte';
+import Dialog from './image-cropper-dialog.svelte';
+import Cropper from './image-cropper-cropper.svelte';
+import Controls from './image-cropper-controls.svelte';
+import Crop from './image-cropper-crop.svelte';
+import Cancel from './image-cropper-cancel.svelte';
+import { getFileFromUrl } from './utils';
+
+export { Root, UploadTrigger, Preview, Dialog, Cropper, Controls, Crop, Cancel, getFileFromUrl };
+
+export type {
+ ImageCropperRootPropsWithoutHTML,
+ ImageCropperRootProps,
+ ImageCropperDialogProps,
+ ImageCropperCropperProps,
+ ImageCropperControlsWithoutHTML,
+ ImageCropperControlsProps,
+ ImageCropperPreviewPropsWithoutHTML,
+ ImageCropperPreviewProps,
+ ImageCropperUploadTriggerPropsWithoutHTML,
+ ImageCropperUploadTriggerProps
+} from './types';
diff --git a/frontend/src/lib/components/ui/image-cropper/types.ts b/frontend/src/lib/components/ui/image-cropper/types.ts
new file mode 100644
index 000000000..463966c7e
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/types.ts
@@ -0,0 +1,36 @@
+import type { AvatarRootProps, DialogContentProps, WithChildren, WithoutChild, WithoutChildren } from 'bits-ui';
+import type { Snippet } from 'svelte';
+import type { CropperProps } from 'svelte-easy-crop';
+import type { HTMLAttributes, HTMLButtonAttributes, HTMLInputAttributes } from 'svelte/elements';
+
+export type ImageCropperRootPropsWithoutHTML = WithChildren<{
+ id?: string;
+ src?: string;
+ onCropped?: (url: string) => void;
+ onError?: (error: Error) => void;
+ onUnsupportedFile?: (file: File) => void;
+}>;
+
+export type ImageCropperRootProps = ImageCropperRootPropsWithoutHTML & HTMLInputAttributes;
+
+export type ImageCropperDialogProps = DialogContentProps;
+
+export type ImageCropperCropperProps = Omit<Partial<CropperProps>, 'oncropcomplete' | 'image'>;
+
+export type ImageCropperControlsWithoutHTML = WithChildren<{
+ ref?: HTMLDivElement | null;
+}>;
+
+export type ImageCropperControlsProps = ImageCropperControlsWithoutHTML & WithoutChildren<HTMLAttributes<HTMLDivElement>>;
+
+export type ImageCropperPreviewPropsWithoutHTML = {
+ child?: Snippet<[{ src: string }]>;
+};
+
+export type ImageCropperPreviewProps = ImageCropperPreviewPropsWithoutHTML & WithoutChild<AvatarRootProps>;
+
+export type ImageCropperUploadTriggerPropsWithoutHTML = WithChildren<{
+ ref?: HTMLButtonElement | null;
+}>;
+
+export type ImageCropperUploadTriggerProps = ImageCropperUploadTriggerPropsWithoutHTML & WithoutChildren<HTMLButtonAttributes>;
diff --git a/frontend/src/lib/components/ui/image-cropper/utils.ts b/frontend/src/lib/components/ui/image-cropper/utils.ts
new file mode 100644
index 000000000..f1298eaac
--- /dev/null
+++ b/frontend/src/lib/components/ui/image-cropper/utils.ts
@@ -0,0 +1,73 @@
+import type { CropArea } from 'svelte-easy-crop';
+
+export const getFileFromUrl = async (url: string, fileName = 'cropped'): Promise<File> => {
+ const response = await fetch(url);
+
+ if (!response.ok) {
+ throw new Error(`failed to fetch cropped image: ${response.status} ${response.statusText}`);
+ }
+
+ const blob = await response.blob();
+ return new File([blob], fileName, { type: blob.type });
+};
+
+const createImage = (url: string): Promise<HTMLImageElement> => {
+ return new Promise<HTMLImageElement>((resolve, reject) => {
+ const image = new Image();
+ image.addEventListener('load', () => resolve(image));
+ image.addEventListener('error', (error) => reject(error));
+ image.setAttribute('crossOrigin', 'anonymous');
+ image.src = url;
+ });
+};
+
+const getRadianAngle = (degreeValue: number) => {
+ return (degreeValue * Math.PI) / 180;
+};
+
+export const getCroppedImg = async (imageSrc: string, pixelCrop: CropArea, rotation = 0): Promise<string> => {
+ const image = await createImage(imageSrc);
+ const canvas = document.createElement('canvas');
+ const ctx = canvas.getContext('2d');
+
+ if (!ctx) {
+ throw new Error('failed to get 2d rendering context');
+ }
+
+ const maxSize = Math.max(image.width, image.height);
+ const safeArea = 2 * ((maxSize / 2) * Math.sqrt(2));
+
+ canvas.width = safeArea;
+ canvas.height = safeArea;
+
+ ctx.translate(safeArea / 2, safeArea / 2);
+ ctx.rotate(getRadianAngle(rotation));
+ ctx.translate(-safeArea / 2, -safeArea / 2);
+ ctx.drawImage(image, safeArea / 2 - image.width * 0.5, safeArea / 2 - image.height * 0.5);
+
+ const data = ctx.getImageData(0, 0, safeArea, safeArea);
+
+ canvas.width = pixelCrop.width;
+ canvas.height = pixelCrop.height;
+
+ ctx.putImageData(
+ data,
+ Math.round(0 - safeArea / 2 + image.width * 0.5 - pixelCrop.x),
+ Math.round(0 - safeArea / 2 + image.height * 0.5 - pixelCrop.y)
+ );
+
+ return new Promise((resolve, reject) => {
+ canvas.toBlob(
+ (file) => {
+ if (!file) {
+ reject(new Error('failed to crop image'));
+ return;
+ }
+
+ resolve(URL.createObjectURL(file));
+ },
+ 'image/jpeg',
+ 0.92
+ );
+ });
+};
diff --git a/frontend/src/lib/services/user-service.ts b/frontend/src/lib/services/user-service.ts
index 1949cb89e..efcde14b1 100644
--- a/frontend/src/lib/services/user-service.ts
+++ b/frontend/src/lib/services/user-service.ts
@@ -41,6 +41,16 @@ class UserAPIService extends BaseAPIService {
async updateMyProfile(data: { displayName?: string; email?: string; locale?: string; fontSize?: number }): Promise<User> {
return this.handleResponse(this.api.put('/auth/me/profile', data)) as Promise<User>;
}
+
+ async uploadMyAvatar(file: File): Promise<User> {
+ const formData = new FormData();
+ formData.append('file', file);
+ return this.handleResponse(this.api.post('/auth/me/avatar', formData)) as Promise<User>;
+ }
+
+ async deleteMyAvatar(): Promise<User> {
+ return this.handleResponse(this.api.delete('/auth/me/avatar')) as Promise<User>;
+ }
}
export const userService = new UserAPIService();
diff --git a/frontend/src/lib/types/auth.ts b/frontend/src/lib/types/auth.ts
index bcd44c4aa..e0390efed 100644
--- a/frontend/src/lib/types/auth.ts
+++ b/frontend/src/lib/types/auth.ts
@@ -134,6 +134,7 @@ export type User = {
passwordHash?: string;
displayName?: string;
email?: string;
+ avatarUrl?: string;
roleAssignments: RoleAssignmentSummary[];
permissionsByEnv: Record<string, string[]>;
isGlobalAdmin?: boolean;
diff --git a/frontend/src/lib/types/settings.ts b/frontend/src/lib/types/settings.ts
index 78497beb1..31c53e3ee 100644
--- a/frontend/src/lib/types/settings.ts
+++ b/frontend/src/lib/types/settings.ts
@@ -50,6 +50,7 @@ export type Settings = {
gitSyncMaxBinarySizeMb: number;
baseServerUrl: string;
enableGravatar: boolean;
+ avatarMaxUploadSizeMb: number;
uiConfigDisabled: boolean;
defaultShell: string;
dockerHost: string;
diff --git a/frontend/src/lib/utils/avatar-upload.ts b/frontend/src/lib/utils/avatar-upload.ts
new file mode 100644
index 000000000..910d61a7e
--- /dev/null
+++ b/frontend/src/lib/utils/avatar-upload.ts
@@ -0,0 +1,34 @@
+export const MAX_AVATAR_FILE_BYTES = 2 * 1024 * 1024;
+
+export type AvatarUploadFileResult =
+ | {
+ ok: true;
+ file: File;
+ }
+ | {
+ ok: false;
+ reason: 'too_large';
+ };
+
+export async function prepareAvatarUploadFile(
+ url: string,
+ maxSizeBytes: number,
+ getFileFromUrl: (url: string, fileName: string) => Promise<File>
+): Promise<AvatarUploadFileResult> {
+ const file = await getFileFromUrl(url, 'avatar');
+
+ if (file.size > maxSizeBytes) {
+ return { ok: false, reason: 'too_large' };
+ }
+
+ return { ok: true, file };
+}
+
+export function avatarUploadLimitBytes(maxSizeMb: unknown): number {
+ const parsed = Number(maxSizeMb);
+ if (!Number.isFinite(parsed) || parsed <= 0) {
+ return MAX_AVATAR_FILE_BYTES;
+ }
+
+ return Math.floor(parsed * 1024 * 1024);
+}
diff --git a/frontend/src/lib/utils/settings.ts b/frontend/src/lib/utils/settings.ts
index caa31dfdc..bb6b66fec 100644
--- a/frontend/src/lib/utils/settings.ts
+++ b/frontend/src/lib/utils/settings.ts
@@ -15,6 +15,7 @@ export type LocalSettings = {
sidebarHoverExpansion: boolean;
keyboardShortcutsEnabled: boolean;
edgeMTLSManagerCAAvailable?: boolean;
+ avatarMaxUploadSizeMb: number;
};
const LOCAL_SETTING_KEYS = new Set([
@@ -26,6 +27,7 @@ const LOCAL_SETTING_KEYS = new Set([
'mobileNavigationShowLabels',
'sidebarHoverExpansion',
'keyboardShortcutsEnabled',
+ 'avatarMaxUploadSizeMb',
'authLocalEnabled',
'authSessionTimeout',
'authPasswordPolicy',
diff --git a/frontend/src/routes/(app)/account/+page.svelte b/frontend/src/routes/(app)/account/+page.svelte
index 41c87511b..f4f51c4f5 100644
--- a/frontend/src/routes/(app)/account/+page.svelte
+++ b/frontend/src/routes/(app)/account/+page.svelte
@@ -7,11 +7,11 @@
import HeaderCard from '$lib/components/header-card.svelte';
import ApiKeyFormSheet from '$lib/components/sheets/api-key-form-sheet.svelte';
import { Card } from '$lib/components/ui/card';
- import { Input } from '$lib/components/ui/input';
- import { Label } from '$lib/components/ui/label';
import { Separator } from '$lib/components/ui/separator';
import * as Avatar from '$lib/components/ui/avatar';
+ import * as ImageCropper from '$lib/components/ui/image-cropper';
import { ArcaneButton } from '$lib/components/arcane-button/index.js';
+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
import LocalePicker from '$lib/components/locale-picker.svelte';
import FontSizePicker from '$lib/components/font-size-picker.svelte';
import { m } from '$lib/paraglide/messages';
@@ -20,6 +20,8 @@
import userStore from '$lib/stores/user-store';
import settingsStore from '$lib/stores/config-store';
import { getDefaultProfilePicture } from '$lib/utils/docker';
+ import { avatarUploadLimitBytes, prepareAvatarUploadFile } from '$lib/utils/avatar-upload';
+ import { cn } from '$lib/utils';
import { GLOBAL_SCOPE } from '$lib/types/auth';
import type { ApiKey, ApiKeyCreated, ApiKeyPermissionGrant, CreateUserApiKey } from '$lib/types/auth';
import { UserIcon, LogoutIcon, ShieldAlertIcon, ApiKeyIcon, AddIcon, CopyIcon, TrashIcon } from '$lib/icons';
@@ -62,6 +64,10 @@
const autoLogin = fromStore(settingsStore.autoLoginEnabled);
const autoLoginEnabled = $derived(autoLogin.current);
const gravatarEnabled = $derived(Boolean(settings.current?.enableGravatar));
+ const avatarMaxUploadSizeMb = $derived(
+ Number(settings.current?.avatarMaxUploadSizeMb) > 0 ? Number(settings.current?.avatarMaxUploadSizeMb) : 2
+ );
+ const avatarMaxUploadSizeBytes = $derived(avatarUploadLimitBytes(avatarMaxUploadSizeMb));
let profileDisplayName = $state('');
let profileEmail = $state('');
@@ -75,6 +81,9 @@
let revokingAll = $state(false);
let avatarUrl = $state<string>(getDefaultProfilePicture());
+ let avatarCacheBuster = $state(Date.now());
+ const avatarSrc = $derived(currentUser?.avatarUrl ? `${currentUser.avatarUrl}?t=${avatarCacheBuster}` : '');
+ let cropperAvatarSrc = $derived(avatarSrc || avatarUrl);
let apiKeys = $state<ApiKey[]>([]);
let apiKeysLoading = $state(false);
@@ -82,6 +91,8 @@
let creatingKey = $state(false);
let createdKey = $state<ApiKeyCreated | null>(null);
+ let avatarUploading = $state(false);
+
$effect(() => {
if (!profileLoaded && currentUser) {
profileDisplayName = currentUser.displayName ?? '';
@@ -112,7 +123,7 @@
const hash = Array.from(new Uint8Array(hashBuffer))
.map((b) => b.toString(16).padStart(2, '0'))
.join('');
- avatarUrl = `https://www.gravatar.com/avatar/${hash}?s=128`;
+ avatarUrl = `https://www.gravatar.com/avatar/${hash}?s=128&d=404`;
} catch {
avatarUrl = getDefaultProfilePicture();
}
@@ -141,6 +152,51 @@
profileEmail = currentUser?.email ?? '';
}
+ async function handleCroppedAvatar(url: string) {
+ avatarUploading = true;
+ try {
+ const preparedFile = await prepareAvatarUploadFile(url, avatarMaxUploadSizeBytes, ImageCropper.getFileFromUrl);
+ if (!preparedFile.ok) {
+ toast.error(m.account_avatar_size_error({ maxSizeMb: avatarMaxUploadSizeMb }));
+ return;
+ }
+
+ const updatedUser = await userService.uploadMyAvatar(preparedFile.file);
+ await userStore.setUser(updatedUser);
+ avatarCacheBuster = Date.now();
+ toast.success(m.account_avatar_upload_success());
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : m.account_avatar_upload_failed());
+ } finally {
+ avatarUploading = false;
+ URL.revokeObjectURL(url);
+ if (cropperAvatarSrc === url) cropperAvatarSrc = avatarSrc || avatarUrl;
+ }
+ }
+
+ function handleUnsupportedAvatarFile() {
+ toast.error(m.account_avatar_unsupported_file());
+ }
+
+ function handleAvatarCropError() {
+ toast.error(m.account_avatar_crop_failed());
+ }
+
+ async function removeAvatar() {
+ if (!currentUser?.avatarUrl) return;
+ avatarUploading = true;
+ try {
+ const updatedUser = await userService.deleteMyAvatar();
+ await userStore.setUser(updatedUser);
+ avatarCacheBuster = Date.now();
+ toast.success(m.account_avatar_remove_success());
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : m.account_avatar_remove_failed());
+ } finally {
+ avatarUploading = false;
+ }
+ }
+
async function changePassword() {
if (!passwordValid || passwordSaving) return;
passwordSaving = true;
@@ -254,52 +310,112 @@
<!-- Profile -->
<Card class="overflow-hidden">
<div class="border-b p-4 sm:p-6">
- <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_profile()}</h2>
- <p class="text-muted-foreground mt-1 text-xs sm:text-sm">{m.account_profile_desc()}</p>
+ <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_profile_title()}</h2>
+ <p class="text-muted-foreground mt-1 text-xs sm:text-sm">{m.account_profile_description()}</p>
</div>
<div class="space-y-5 p-4 sm:p-6">
- <div class="flex items-center justify-between gap-4">
- <div class="flex min-w-0 items-center gap-4">
- <Avatar.Root class="size-16 rounded-xl">
- <Avatar.Image src={avatarUrl} alt={currentUser.displayName ?? currentUser.username} />
- <Avatar.Fallback
- class="from-primary/20 to-primary/10 text-primary border-primary/20 rounded-xl border bg-linear-to-br text-xl font-semibold"
+ <ImageCropper.Root
+ id="account-avatar-cropper"
+ bind:src={cropperAvatarSrc}
+ accept="image/png, image/jpeg, image/webp"
+ onCropped={handleCroppedAvatar}
+ onError={handleAvatarCropError}
+ onUnsupportedFile={handleUnsupportedAvatarFile}
+ >
+ <ImageCropper.Dialog>
+ <div class="space-y-1">
+ <h3 class="text-base font-semibold tracking-tight">{m.account_avatar_crop_title()}</h3>
+ <p class="text-muted-foreground text-sm">{m.account_avatar_crop_description()}</p>
+ </div>
+ <div class="bg-muted/40 h-72 overflow-hidden rounded-lg border">
+ <ImageCropper.Cropper />
+ </div>
+ <ImageCropper.Controls class="justify-end">
+ <ImageCropper.Cancel disabled={avatarUploading} />
+ <ImageCropper.Crop disabled={avatarUploading} />
+ </ImageCropper.Controls>
+ </ImageCropper.Dialog>
+
+ <div class="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
+ <div class="flex min-w-0 items-center gap-4">
+ <ImageCropper.UploadTrigger
+ aria-label={m.account_upload_photo()}
+ class={cn(
+ 'group/avatar relative size-16 overflow-hidden rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2',
+ avatarUploading && 'pointer-events-none opacity-70'
+ )}
+ disabled={avatarUploading}
>
- {(currentUser.displayName ?? currentUser.username).charAt(0).toUpperCase()}
- </Avatar.Fallback>
- </Avatar.Root>
- <div class="min-w-0">
- <div class="text-sm font-medium">@{currentUser.username}</div>
- <div class="text-muted-foreground text-xs">
- {isOidcUser ? m.account_single_sign_on() : m.account_local_account()}
+ {#key avatarCacheBuster}
+ <Avatar.Root class="size-16 rounded-xl transition-all group-hover/avatar:opacity-80">
+ {#if avatarSrc}
+ <Avatar.Image src={avatarSrc} alt={currentUser.displayName ?? currentUser.username} />
+ {:else if avatarUrl}
+ <Avatar.Image src={avatarUrl} alt={currentUser.displayName ?? currentUser.username} />
+ {/if}
+ <Avatar.Fallback class="bg-primary text-primary-foreground rounded-xl text-xl font-semibold">
+ {(currentUser.displayName ?? currentUser.username).charAt(0).toUpperCase()}
+ </Avatar.Fallback>
+ </Avatar.Root>
+ {/key}
+ <div
+ class="absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover/avatar:opacity-100"
+ >
+ <div class="text-white text-xs font-medium">{m.account_upload_overlay()}</div>
+ </div>
+ </ImageCropper.UploadTrigger>
+ <div class="min-w-0 flex flex-col items-start gap-1">
+ <div class="text-sm font-medium">@{currentUser.username}</div>
+ <div class="text-muted-foreground text-xs">
+ {isOidcUser ? m.account_single_sign_on() : m.account_local_account()}
+ </div>
+ {#if currentUser.avatarUrl}
+ <div class="mt-1 flex items-center gap-2">
+ <ArcaneButton
+ action="remove"
+ size="sm"
+ tone="ghost"
+ customLabel={m.account_remove_photo()}
+ showLabel={true}
+ class="text-muted-foreground hover:text-destructive hover:bg-destructive/10"
+ onclick={removeAvatar}
+ disabled={avatarUploading}
+ />
+ </div>
+ {/if}
</div>
</div>
- </div>
- <div class="hidden text-right sm:block">
- {#if safeFormatDate(currentUser.createdAt, 'PP')}
- <div class="text-muted-foreground text-xs">{m.account_member_since()} {safeFormatDate(currentUser.createdAt, 'PP')}</div>
- {/if}
- <div class="text-muted-foreground text-xs" title={currentUser.lastLogin ?? ''}>
- {m.account_last_login_prefix()} {safeFormatRelative(currentUser.lastLogin) ?? m.common_never()}
+ <div class="hidden text-right sm:block">
+ {#if safeFormatDate(currentUser.createdAt, 'PP')}
+ <div class="text-muted-foreground text-xs">
+ {m.account_member_since()}
+ {safeFormatDate(currentUser.createdAt, 'PP')}
+ </div>
+ {/if}
+ <div class="text-muted-foreground text-xs" title={currentUser.lastLogin ?? ''}>
+ {m.account_last_login_prefix()}
+ {safeFormatRelative(currentUser.lastLogin) ?? m.common_never()}
+ </div>
</div>
</div>
- </div>
-
- <div class="grid gap-4 sm:grid-cols-2">
- <div class="space-y-2">
- <Label for="account-display-name">{m.account_display_name_label()}</Label>
- <Input id="account-display-name" bind:value={profileDisplayName} placeholder={m.account_display_name_placeholder()} disabled={isOidcUser} />
- </div>
- <div class="space-y-2">
- <Label for="account-email">{m.account_email_label()}</Label>
- <Input
- id="account-email"
- type="email"
- bind:value={profileEmail}
- placeholder={m.account_email_placeholder()}
- disabled={isOidcUser}
- />
- </div>
+ </ImageCropper.Root>
+
+ <div class="grid gap-5 sm:grid-cols-2">
+ <TextInputWithLabel
+ id="account-display-name"
+ bind:value={profileDisplayName}
+ label={m.account_display_name_label()}
+ placeholder={m.account_display_name_placeholder()}
+ disabled={isOidcUser}
+ />
+ <TextInputWithLabel
+ id="account-email"
+ type="email"
+ bind:value={profileEmail}
+ label={m.account_email_label()}
+ placeholder={m.account_email_placeholder()}
+ disabled={isOidcUser}
+ />
</div>
{#if !isOidcUser}
<div class="flex justify-end gap-2">
@@ -332,28 +448,30 @@
<p class="text-muted-foreground mt-1 text-xs sm:text-sm">{m.account_password_desc()}</p>
</div>
<div class="space-y-5 p-4 sm:p-6">
- <div class="space-y-2">
- <Label for="account-current-password">{m.account_current_password()}</Label>
- <Input
- id="account-current-password"
+ <TextInputWithLabel
+ id="account-current-password"
+ type="password"
+ bind:value={currentPassword}
+ label={m.account_current_password()}
+ autocomplete="current-password"
+ />
+ <div class="grid gap-5 sm:grid-cols-2">
+ <TextInputWithLabel
+ id="account-new-password"
type="password"
- bind:value={currentPassword}
- autocomplete="current-password"
+ bind:value={newPassword}
+ label={m.account_new_password()}
+ helpText={m.account_password_min_length()}
+ autocomplete="new-password"
+ />
+ <TextInputWithLabel
+ id="account-confirm-password"
+ type="password"
+ bind:value={confirmPassword}
+ label={m.account_confirm_password()}
+ error={confirmPassword.length > 0 && confirmPassword !== newPassword ? m.account_passwords_dont_match() : null}
+ autocomplete="new-password"
/>
- </div>
- <div class="grid gap-4 sm:grid-cols-2">
- <div class="space-y-2">
- <Label for="account-new-password">{m.account_new_password()}</Label>
- <Input id="account-new-password" type="password" bind:value={newPassword} autocomplete="new-password" />
- <p class="text-muted-foreground text-xs">{m.account_password_min_length()}</p>
- </div>
- <div class="space-y-2">
- <Label for="account-confirm-password">{m.account_confirm_password()}</Label>
- <Input id="account-confirm-password" type="password" bind:value={confirmPassword} autocomplete="new-password" />
- {#if confirmPassword.length > 0 && confirmPassword !== newPassword}
- <p class="text-destructive text-xs">{m.account_passwords_dont_match()}</p>
- {/if}
- </div>
</div>
<div class="flex justify-end">
<ArcaneButton
diff --git a/frontend/src/routes/(app)/containers/components/ContainerOverview.svelte b/frontend/src/routes/(app)/containers/components/ContainerOverview.svelte
index c7544d869..0be862685 100644
--- a/frontend/src/routes/(app)/containers/components/ContainerOverview.svelte
+++ b/frontend/src/routes/(app)/containers/components/ContainerOverview.svelte
@@ -142,7 +142,10 @@
<div class="flex size-10 shrink-0 items-center justify-center rounded-full bg-blue-500/10">
<VolumesIcon class="size-5 text-blue-500" />
</div>
- <div class="text-foreground cursor-pointer text-base font-semibold break-all select-all" title={m.common_click_to_select()}>
+ <div
+ class="text-foreground cursor-pointer text-base font-semibold break-all select-all"
+ title={m.common_click_to_select()}
+ >
{container.image || m.common_na()}
</div>
</div>
@@ -182,7 +185,10 @@
<div class="flex size-10 shrink-0 items-center justify-center rounded-full bg-purple-500/10">
<NetworksIcon class="size-5 text-purple-500" />
</div>
- <div class="text-foreground cursor-pointer font-mono text-base font-semibold select-all" title={m.common_click_to_select()}>
+ <div
+ class="text-foreground cursor-pointer font-mono text-base font-semibold select-all"
+ title={m.common_click_to_select()}
+ >
{primaryIpAddress}
</div>
</div>
@@ -215,7 +221,10 @@
<div class="text-muted-foreground text-xs font-semibold tracking-wide uppercase">
{m.common_id()}
</div>
- <div class="text-foreground cursor-pointer font-mono text-sm font-medium break-all select-all" title={m.common_click_to_select()}>
+ <div
+ class="text-foreground cursor-pointer font-mono text-sm font-medium break-all select-all"
+ title={m.common_click_to_select()}
+ >
{container.id}
</div>
</Card.Content>
@@ -334,7 +343,10 @@
<Card.Root variant="subtle">
<Card.Content class="flex flex-col gap-2 p-4">
<div class="text-muted-foreground text-xs font-semibold tracking-wide uppercase">{m.common_image_id()}</div>
- <div class="text-foreground cursor-pointer font-mono text-sm font-medium break-all select-all" title={m.common_click_to_select()}>
+ <div
+ class="text-foreground cursor-pointer font-mono text-sm font-medium break-all select-all"
+ title={m.common_click_to_select()}
+ >
{container.imageId}
</div>
</Card.Content>
@@ -360,7 +372,10 @@
<Card.Root variant="subtle">
<Card.Content class="flex flex-col gap-2 p-4">
<div class="text-muted-foreground text-xs font-semibold tracking-wide uppercase">{m.resource_user_cap()}</div>
- <div class="text-foreground cursor-pointer font-mono text-sm font-medium select-all" title={m.common_click_to_select()}>
+ <div
+ class="text-foreground cursor-pointer font-mono text-sm font-medium select-all"
+ title={m.common_click_to_select()}
+ >
{container.config.user}
</div>
</Card.Content>
diff --git a/frontend/src/routes/(app)/networks/[networkId]/+page.svelte b/frontend/src/routes/(app)/networks/[networkId]/+page.svelte
index 30735d7a5..bfba6ece4 100644
--- a/frontend/src/routes/(app)/networks/[networkId]/+page.svelte
+++ b/frontend/src/routes/(app)/networks/[networkId]/+page.svelte
@@ -176,7 +176,10 @@
</div>
<div class="min-w-0 flex-1">
<p class="text-muted-foreground text-sm font-medium">{m.common_name()}</p>
- <p class="mt-1 cursor-pointer text-sm font-semibold break-all select-all sm:text-base" title={m.common_click_to_select()}>
+ <p
+ class="mt-1 cursor-pointer text-sm font-semibold break-all select-all sm:text-base"
+ title={m.common_click_to_select()}
+ >
{network.name}
</p>
</div>
@@ -200,7 +203,10 @@
</div>
<div class="min-w-0 flex-1">
<p class="text-muted-foreground text-sm font-medium">{m.common_scope()}</p>
- <p class="mt-1 cursor-pointer text-sm font-semibold capitalize select-all sm:text-base" title={m.common_click_to_select()}>
+ <p
+ class="mt-1 cursor-pointer text-sm font-semibold capitalize select-all sm:text-base"
+ title={m.common_click_to_select()}
+ >
{network.scope}
</p>
</div>
diff --git a/frontend/src/routes/(app)/settings/appearance/+page.svelte b/frontend/src/routes/(app)/settings/appearance/+page.svelte
index 618281445..641923abc 100644
--- a/frontend/src/routes/(app)/settings/appearance/+page.svelte
+++ b/frontend/src/routes/(app)/settings/appearance/+page.svelte
@@ -7,6 +7,7 @@
import { navigationSettingsOverridesStore, resetNavigationVisibility } from '$lib/utils/navigation';
import { SettingsPageLayout } from '$lib/layouts';
import { Switch } from '$lib/components/ui/switch/index.js';
+ import { Input } from '$lib/components/ui/input/index.js';
import { useSidebar } from '$lib/components/ui/sidebar/context.svelte.js';
import { createSettingsForm } from '$lib/utils/settings-form';
import SettingsRow from '$lib/components/settings/settings-row.svelte';
@@ -34,6 +35,7 @@
keyboardShortcutsEnabled: z.boolean(),
accentColor: z.string(),
enableGravatar: z.boolean(),
+ avatarMaxUploadSizeMb: z.coerce.number().int().min(1).max(50),
oledMode: z.boolean()
});
@@ -172,10 +174,10 @@
/>
</SettingsRow>
- <!-- User Avatars -->
+ <!-- Gravatar -->
<SettingsRow
- label={m.general_user_avatars_heading()}
- description={m.general_user_avatars_description()}
+ label={m.general_enable_gravatar_label()}
+ description={m.general_enable_gravatar_description()}
layout="inline"
>
<Switch
@@ -188,6 +190,29 @@
/>
</SettingsRow>
+ <SettingsRow
+ label={m.general_avatar_upload_size_label()}
+ description={m.general_avatar_upload_size_description()}
+ helpText={m.general_avatar_upload_size_help()}
+ layout="inline"
+ >
+ <div class="flex w-24 flex-col gap-1">
+ <Input
+ id="avatarMaxUploadSizeMb"
+ type="number"
+ min="1"
+ max="50"
+ bind:value={$formInputs.avatarMaxUploadSizeMb.value}
+ placeholder="2"
+ disabled={isReadOnly}
+ aria-invalid={Boolean($formInputs.avatarMaxUploadSizeMb.error)}
+ />
+ {#if $formInputs.avatarMaxUploadSizeMb.error}
+ <p class="text-destructive text-xs font-medium">{$formInputs.avatarMaxUploadSizeMb.error}</p>
+ {/if}
+ </div>
+ </SettingsRow>
+
<!-- Language -->
<SettingsRow label={m.language()} description={m.appearance_language_current_user_description()} layout="inline">
<LocalePicker
diff --git a/frontend/src/routes/(app)/swarm/stacks/[name]/+page.svelte b/frontend/src/routes/(app)/swarm/stacks/[name]/+page.svelte
index 4d444d8b7..af715d66e 100644
--- a/frontend/src/routes/(app)/swarm/stacks/[name]/+page.svelte
+++ b/frontend/src/routes/(app)/swarm/stacks/[name]/+page.svelte
@@ -81,7 +81,9 @@
const totalServices = $derived(services?.pagination?.totalItems ?? services?.data?.length ?? 0);
const totalTasks = $derived(tasks?.pagination?.totalItems ?? tasks?.data?.length ?? 0);
const stackSubtitle = $derived(
- hasLiveStack ? m.swarm_stack_namespace({ namespace: stack?.namespace ?? stackName }) : m.swarm_stack_saved_source({ stackName })
+ hasLiveStack
+ ? m.swarm_stack_namespace({ namespace: stack?.namespace ?? stackName })
+ : m.swarm_stack_saved_source({ stackName })
);
async function fetchStackServices(options: typeof servicesRequestOptions) {
diff --git a/frontend/src/routes/(app)/volumes/[volumeName]/+page.svelte b/frontend/src/routes/(app)/volumes/[volumeName]/+page.svelte
index 59feb5b3b..8c4879a0f 100644
--- a/frontend/src/routes/(app)/volumes/[volumeName]/+page.svelte
+++ b/frontend/src/routes/(app)/volumes/[volumeName]/+page.svelte
@@ -159,7 +159,10 @@
</div>
<div class="min-w-0 flex-1">
<p class="text-muted-foreground text-sm font-medium">{m.common_driver()}</p>
- <p class="mt-1 cursor-pointer text-sm font-semibold select-all sm:text-base" title={m.common_click_to_select()}>
+ <p
+ class="mt-1 cursor-pointer text-sm font-semibold select-all sm:text-base"
+ title={m.common_click_to_select()}
+ >
{volume.driver}
</p>
</div>
@@ -171,7 +174,10 @@
</div>
<div class="min-w-0 flex-1">
<p class="text-muted-foreground text-sm font-medium">{m.common_created()}</p>
- <p class="mt-1 cursor-pointer text-sm font-semibold select-all sm:text-base" title={m.common_click_to_select()}>
+ <p
+ class="mt-1 cursor-pointer text-sm font-semibold select-all sm:text-base"
+ title={m.common_click_to_select()}
+ >
{createdDate}
</p>
</div>
@@ -214,7 +220,10 @@
</div>
<div class="min-w-0 flex-1">
<p class="text-muted-foreground text-sm font-medium">{m.common_mountpoint()}</p>
- <div class="bg-muted/50 mt-2 cursor-pointer rounded-lg border p-3 select-all" title={m.common_click_to_select()}>
+ <div
+ class="bg-muted/50 mt-2 cursor-pointer rounded-lg border p-3 select-all"
+ title={m.common_click_to_select()}
+ >
<code class="font-mono text-sm break-all">{volume.mountpoint}</code>
</div>
</div>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b2619b504..6539864fa 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -176,6 +176,9 @@ importers:
svelte-codemirror-editor:
specifier: ^2.1.0
+ svelte-easy-crop:
+ specifier: ^5.0.1
+ version: 5.0.1([email protected])
yaml:
specifier: ^2.9.0
version: 2.9.0
@@ -2702,6 +2705,11 @@ packages:
codemirror: ^6.0.0
svelte: ^5.0.0
+ resolution: {integrity: sha512-Dq2rgmPsSEo+K8k49TFGXZAJwJa537AR6hW1RqKEdYj7QKlc4Ya7l4VlSYWlOV8/uAiQ10VyGRdSVAUcZiMwjg==}
+ peerDependencies:
+ svelte: ^5.0.0
+
resolution: {integrity: sha512-5cd3p7wa4cq0NsqslMwdlPb7x1JglEZ/GKrLePWNr5bCxR1nagAVrY01FRFrXfUGs41miLt3C327+8XJo5BzZw==}
peerDependencies:
@@ -5215,6 +5223,10 @@ snapshots:
codemirror: 6.0.2
svelte: 5.56.3
+ dependencies:
+ svelte: 5.56.3
+
dependencies:
runed: 0.28.0([email protected])
diff --git a/types/image/image.go b/types/image/image.go
index 0e9406f80..cd80d598b 100644
--- a/types/image/image.go
+++ b/types/image/image.go
@@ -472,6 +472,7 @@ func NewDetailSummary(src *image.InspectResponse) DetailSummary {
}
}
out.Config.WorkingDir = src.Config.WorkingDir
+ //lint:ignore SA1019 Mirror Docker inspect data; deprecated only for new image builders.
out.Config.ArgsEscaped = src.Config.ArgsEscaped
}
diff --git a/types/settings/settings.go b/types/settings/settings.go
index cb6d66fb4..9a8458b40 100644
--- a/types/settings/settings.go
+++ b/types/settings/settings.go
@@ -207,6 +207,11 @@ type Update struct {
// Required: false
EnableGravatar *string `json:"enableGravatar,omitempty"`
+ // AvatarMaxUploadSizeMb is the maximum size in megabytes for profile picture uploads.
+ //
+ // Required: false
+ AvatarMaxUploadSizeMb *string `json:"avatarMaxUploadSizeMb,omitempty"`
+
// DefaultShell is the default shell used for container execution.
//
// Required: false
diff --git a/types/user/user.go b/types/user/user.go
index 8a53f582f..0abc8d157 100644
--- a/types/user/user.go
+++ b/types/user/user.go
@@ -35,6 +35,7 @@ type User struct {
Username string `json:"username" doc:"Username of the user" example:"johndoe"`
DisplayName *string `json:"displayName,omitempty" doc:"Display name of the user" example:"John Doe"`
Email *string `json:"email,omitempty" doc:"Email address of the user" example:"[email protected]"`
+ AvatarURL *string `json:"avatarUrl,omitempty" doc:"URL to the user's custom avatar image; omitted when using the default profile picture"`
RoleAssignments []RoleAssignmentSummary `json:"roleAssignments" doc:"Role assignments held by the user"`
PermissionsByEnv map[string][]string `json:"permissionsByEnv" doc:"Permissions the user effectively holds, keyed by environment ID. The 'global' key holds permissions that apply across every environment (and to org-level endpoints)."`
IsGlobalAdmin bool `json:"isGlobalAdmin" doc:"Whether the user effectively holds global administrator access"`