Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(users): persist theme and editor preferences

johavenac0045d39e7b
diff --git a/backend/migrations/0005_spotty_firebird.sql b/backend/migrations/0005_spotty_firebird.sql
new file mode 100644
index 00000000..097ed4f7
--- /dev/null
+++ b/backend/migrations/0005_spotty_firebird.sql
@@ -0,0 +1 @@
+ALTER TABLE `users` ADD `preferences` json;
\ No newline at end of file
diff --git a/backend/migrations/meta/0005_snapshot.json b/backend/migrations/meta/0005_snapshot.json
new file mode 100644
index 00000000..1c2ab382
--- /dev/null
+++ b/backend/migrations/meta/0005_snapshot.json
@@ -0,0 +1,2567 @@
+{
+ "version": "5",
+ "dialect": "mysql",
+ "id": "5c455ee5-18c5-484a-b7e4-32eef83589e9",
+ "prevId": "0e329e81-02d6-4c0d-8c44-641efb30b285",
+ "tables": {
+ "cache": {
+ "name": "cache",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "varchar(768)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expiration": {
+ "name": "expiration",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": -1
+ }
+ },
+ "indexes": {
+ "expiration_idx": {
+ "name": "expiration_idx",
+ "columns": [
+ "expiration"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "cache_key": {
+ "name": "cache_key",
+ "columns": [
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users": {
+ "name": "users",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "email": {
+ "name": "email",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "login": {
+ "name": "login",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "externalId": {
+ "name": "externalId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastName": {
+ "name": "lastName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "passwordAttempts": {
+ "name": "passwordAttempts",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "isActive": {
+ "name": "isActive",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "secrets": {
+ "name": "secrets",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "preferences": {
+ "name": "preferences",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "language": {
+ "name": "language",
+ "type": "varchar(10)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "notification": {
+ "name": "notification",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "onlineStatus": {
+ "name": "onlineStatus",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "currentIp": {
+ "name": "currentIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastIp": {
+ "name": "lastIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "currentAccess": {
+ "name": "currentAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastAccess": {
+ "name": "lastAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "email_idx": {
+ "name": "email_idx",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ },
+ "login_idx": {
+ "name": "login_idx",
+ "columns": [
+ "login"
+ ],
+ "isUnique": true
+ },
+ "external_id_idx": {
+ "name": "external_id_idx",
+ "columns": [
+ "externalId"
+ ],
+ "isUnique": true
+ },
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ "role"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "users_id": {
+ "name": "users_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "groups": {
+ "name": "groups",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "name_idx": {
+ "name": "name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": true
+ },
+ "parent_idx": {
+ "name": "parent_idx",
+ "columns": [
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "type_idx": {
+ "name": "type_idx",
+ "columns": [
+ "type"
+ ],
+ "isUnique": false
+ },
+ "visibility_idx": {
+ "name": "visibility_idx",
+ "columns": [
+ "visibility"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "groups_parentId_groups_id_fk": {
+ "name": "groups_parentId_groups_id_fk",
+ "tableFrom": "groups",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "parentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "groups_id": {
+ "name": "groups_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users_groups": {
+ "name": "users_groups",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "users_groups_userId_users_id_fk": {
+ "name": "users_groups_userId_users_id_fk",
+ "tableFrom": "users_groups",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "users_groups_groupId_groups_id_fk": {
+ "name": "users_groups_groupId_groups_id_fk",
+ "tableFrom": "users_groups",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_groups_userId_groupId_pk": {
+ "name": "users_groups_userId_groupId_pk",
+ "columns": [
+ "userId",
+ "groupId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users_guests": {
+ "name": "users_guests",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "guestId": {
+ "name": "guestId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "guest_id": {
+ "name": "guest_id",
+ "columns": [
+ "guestId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "users_guests_userId_users_id_fk": {
+ "name": "users_guests_userId_users_id_fk",
+ "tableFrom": "users_guests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "users_guests_guestId_users_id_fk": {
+ "name": "users_guests_guestId_users_id_fk",
+ "tableFrom": "users_guests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "guestId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_guests_userId_guestId_pk": {
+ "name": "users_guests_userId_guestId_pk",
+ "columns": [
+ "userId",
+ "guestId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {
+ "user_guest_check": {
+ "name": "user_guest_check",
+ "value": "`users_guests`.`userId` <> `users_guests`.`guestId`"
+ }
+ }
+ },
+ "spaces": {
+ "name": "spaces",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "disabledAt": {
+ "name": "disabledAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "spaces_id": {
+ "name": "spaces_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "spaces_members": {
+ "name": "spaces_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "linkId": {
+ "name": "linkId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ },
+ "link_idx": {
+ "name": "link_idx",
+ "columns": [
+ "linkId"
+ ],
+ "isUnique": false
+ },
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ "role"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "spaces_members_spaceId_spaces_id_fk": {
+ "name": "spaces_members_spaceId_spaces_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_userId_users_id_fk": {
+ "name": "spaces_members_userId_users_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_groupId_groups_id_fk": {
+ "name": "spaces_members_groupId_groups_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_linkId_links_id_fk": {
+ "name": "spaces_members_linkId_links_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "links",
+ "columnsFrom": [
+ "linkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "spaces_members_id": {
+ "name": "spaces_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "space_user_uniq": {
+ "name": "space_user_uniq",
+ "columns": [
+ "spaceId",
+ "userId"
+ ]
+ },
+ "space_group_uniq": {
+ "name": "space_group_uniq",
+ "columns": [
+ "spaceId",
+ "groupId"
+ ]
+ },
+ "space_link_uniq": {
+ "name": "space_link_uniq",
+ "columns": [
+ "spaceId",
+ "linkId"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "spaces_roots": {
+ "name": "spaces_roots",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "externalPath": {
+ "name": "externalPath",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "spaces_roots_spaceId_spaces_id_fk": {
+ "name": "spaces_roots_spaceId_spaces_id_fk",
+ "tableFrom": "spaces_roots",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_roots_fileId_files_id_fk": {
+ "name": "spaces_roots_fileId_files_id_fk",
+ "tableFrom": "spaces_roots",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "spaces_roots_id": {
+ "name": "spaces_roots_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "space_root_alias_uniq": {
+ "name": "space_root_alias_uniq",
+ "columns": [
+ "id",
+ "alias"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "shares": {
+ "name": "shares",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceRootId": {
+ "name": "spaceRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "externalPath": {
+ "name": "externalPath",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "disabledAt": {
+ "name": "disabledAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": true
+ },
+ "parent_idx": {
+ "name": "parent_idx",
+ "columns": [
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_root_idx": {
+ "name": "space_root_idx",
+ "columns": [
+ "spaceRootId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ },
+ "type_idx": {
+ "name": "type_idx",
+ "columns": [
+ "type"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "shares_ownerId_users_id_fk": {
+ "name": "shares_ownerId_users_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_parentId_shares_id_fk": {
+ "name": "shares_parentId_shares_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "parentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_spaceId_spaces_id_fk": {
+ "name": "shares_spaceId_spaces_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_spaceRootId_spaces_roots_id_fk": {
+ "name": "shares_spaceRootId_spaces_roots_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_fileId_files_id_fk": {
+ "name": "shares_fileId_files_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shares_id": {
+ "name": "shares_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "shares_members": {
+ "name": "shares_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "linkId": {
+ "name": "linkId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ },
+ "link_idx": {
+ "name": "link_idx",
+ "columns": [
+ "linkId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "shares_members_shareId_shares_id_fk": {
+ "name": "shares_members_shareId_shares_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_userId_users_id_fk": {
+ "name": "shares_members_userId_users_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_groupId_groups_id_fk": {
+ "name": "shares_members_groupId_groups_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_linkId_links_id_fk": {
+ "name": "shares_members_linkId_links_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "links",
+ "columnsFrom": [
+ "linkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shares_members_id": {
+ "name": "shares_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "share_user_uniq": {
+ "name": "share_user_uniq",
+ "columns": [
+ "shareId",
+ "userId"
+ ]
+ },
+ "share_group_uniq": {
+ "name": "share_group_uniq",
+ "columns": [
+ "shareId",
+ "groupId"
+ ]
+ },
+ "share_link_uniq": {
+ "name": "share_link_uniq",
+ "columns": [
+ "shareId",
+ "linkId"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "files": {
+ "name": "files",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceExternalRootId": {
+ "name": "spaceExternalRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareExternalId": {
+ "name": "shareExternalId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "isDir": {
+ "name": "isDir",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "inTrash": {
+ "name": "inTrash",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "mime": {
+ "name": "mime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "size": {
+ "name": "size",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "mtime": {
+ "name": "mtime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "ctime": {
+ "name": "ctime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_external_root_idx": {
+ "name": "space_external_root_idx",
+ "columns": [
+ "spaceExternalRootId"
+ ],
+ "isUnique": false
+ },
+ "share_external_idx": {
+ "name": "share_external_idx",
+ "columns": [
+ "shareExternalId"
+ ],
+ "isUnique": false
+ },
+ "name_idx": {
+ "name": "name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": false
+ },
+ "path_idx": {
+ "name": "path_idx",
+ "columns": [
+ "path"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_ownerId_users_id_fk": {
+ "name": "files_ownerId_users_id_fk",
+ "tableFrom": "files",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_spaceId_spaces_id_fk": {
+ "name": "files_spaceId_spaces_id_fk",
+ "tableFrom": "files",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_spaceExternalRootId_spaces_roots_id_fk": {
+ "name": "files_spaceExternalRootId_spaces_roots_id_fk",
+ "tableFrom": "files",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceExternalRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_shareExternalId_shares_id_fk": {
+ "name": "files_shareExternalId_shares_id_fk",
+ "tableFrom": "files",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareExternalId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "files_id": {
+ "name": "files_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "files_favorites": {
+ "name": "files_favorites",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ },
+ "user_created_idx": {
+ "name": "user_created_idx",
+ "columns": [
+ "userId",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_favorites_userId_users_id_fk": {
+ "name": "files_favorites_userId_users_id_fk",
+ "tableFrom": "files_favorites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_favorites_fileId_files_id_fk": {
+ "name": "files_favorites_fileId_files_id_fk",
+ "tableFrom": "files_favorites",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "files_favorites_userId_fileId_pk": {
+ "name": "files_favorites_userId_fileId_pk",
+ "columns": [
+ "userId",
+ "fileId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "files_recents": {
+ "name": "files_recents",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "mime": {
+ "name": "mime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mtime": {
+ "name": "mtime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "mtime_idx": {
+ "name": "mtime_idx",
+ "columns": [
+ "mtime"
+ ],
+ "isUnique": false
+ },
+ "path_idx": {
+ "name": "path_idx",
+ "columns": [
+ "path"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_recents_ownerId_users_id_fk": {
+ "name": "files_recents_ownerId_users_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_recents_spaceId_spaces_id_fk": {
+ "name": "files_recents_spaceId_spaces_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_recents_shareId_shares_id_fk": {
+ "name": "files_recents_shareId_shares_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "links": {
+ "name": "links",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "uuid": {
+ "name": "uuid",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "requireAuth": {
+ "name": "requireAuth",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "nbAccess": {
+ "name": "nbAccess",
+ "type": "int unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "limitAccess": {
+ "name": "limitAccess",
+ "type": "int unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "expiresAt": {
+ "name": "expiresAt",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "uuid_idx": {
+ "name": "uuid_idx",
+ "columns": [
+ "uuid"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "links_userId_users_id_fk": {
+ "name": "links_userId_users_id_fk",
+ "tableFrom": "links",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "links_id": {
+ "name": "links_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "comments": {
+ "name": "comments",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "comments_userId_users_id_fk": {
+ "name": "comments_userId_users_id_fk",
+ "tableFrom": "comments",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "comments_fileId_files_id_fk": {
+ "name": "comments_fileId_files_id_fk",
+ "tableFrom": "comments",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "comments_id": {
+ "name": "comments_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "notifications": {
+ "name": "notifications",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "fromUserId": {
+ "name": "fromUserId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "toUserId": {
+ "name": "toUserId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "wasRead": {
+ "name": "wasRead",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "from_user_idx": {
+ "name": "from_user_idx",
+ "columns": [
+ "fromUserId"
+ ],
+ "isUnique": false
+ },
+ "to_user_idx": {
+ "name": "to_user_idx",
+ "columns": [
+ "toUserId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "notifications_fromUserId_users_id_fk": {
+ "name": "notifications_fromUserId_users_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "users",
+ "columnsFrom": [
+ "fromUserId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notifications_toUserId_users_id_fk": {
+ "name": "notifications_toUserId_users_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "users",
+ "columnsFrom": [
+ "toUserId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "notifications_id": {
+ "name": "notifications_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "sync_clients": {
+ "name": "sync_clients",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tokenExpiration": {
+ "name": "tokenExpiration",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "info": {
+ "name": "info",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "currentIp": {
+ "name": "currentIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastIp": {
+ "name": "lastIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "currentAccess": {
+ "name": "currentAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastAccess": {
+ "name": "lastAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "token_idx": {
+ "name": "token_idx",
+ "columns": [
+ "token"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sync_clients_ownerId_users_id_fk": {
+ "name": "sync_clients_ownerId_users_id_fk",
+ "tableFrom": "sync_clients",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "sync_clients_id": {
+ "name": "sync_clients_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "sync_paths": {
+ "name": "sync_paths",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "clientId": {
+ "name": "clientId",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceRootId": {
+ "name": "spaceRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "client_idx": {
+ "name": "client_idx",
+ "columns": [
+ "clientId"
+ ],
+ "isUnique": false
+ },
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_root_idx": {
+ "name": "space_root_idx",
+ "columns": [
+ "spaceRootId"
+ ],
+ "isUnique": false
+ },
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sync_paths_clientId_sync_clients_id_fk": {
+ "name": "sync_paths_clientId_sync_clients_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "sync_clients",
+ "columnsFrom": [
+ "clientId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_ownerId_users_id_fk": {
+ "name": "sync_paths_ownerId_users_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_spaceId_spaces_id_fk": {
+ "name": "sync_paths_spaceId_spaces_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_spaceRootId_spaces_roots_id_fk": {
+ "name": "sync_paths_spaceRootId_spaces_roots_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_shareId_shares_id_fk": {
+ "name": "sync_paths_shareId_shares_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_fileId_files_id_fk": {
+ "name": "sync_paths_fileId_files_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "sync_paths_id": {
+ "name": "sync_paths_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ }
+ },
+ "views": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "tables": {},
+ "indexes": {}
+ }
+}
\ No newline at end of file
diff --git a/backend/migrations/meta/_journal.json b/backend/migrations/meta/_journal.json
index 1e39e006..4b02ff23 100644
--- a/backend/migrations/meta/_journal.json
+++ b/backend/migrations/meta/_journal.json
@@ -36,6 +36,13 @@
"when": 1787432793784,
"tag": "0004_light_venom",
"breakpoints": true
+ },
+ {
+ "idx": 5,
+ "version": "5",
+ "when": 1790603209539,
+ "tag": "0005_spotty_firebird",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/backend/src/applications/files/editors/collabora-online/collabora-online.constants.ts b/backend/src/applications/files/editors/collabora-online/collabora-online.constants.ts
index 3a4abedd..90c52c8c 100644
--- a/backend/src/applications/files/editors/collabora-online/collabora-online.constants.ts
+++ b/backend/src/applications/files/editors/collabora-online/collabora-online.constants.ts
@@ -2,6 +2,7 @@ export const COLLABORA_URI = 'browser/dist/cool.html'
export const COLLABORA_CONTEXT = 'CollaboraOnlineEnvironment' as const
export const COLLABORA_WOPI_SRC_QUERY_PARAM_NAME = 'WOPISrc' as const
export const COLLABORA_TOKEN_QUERY_PARAM_NAME = 'access_token' as const
+export const COLLABORA_EDITOR = 'collabora' as const
export const COLLABORA_APP_LOCK = 'Collabora' as const
export const COLLABORA_HEADERS = {
diff --git a/backend/src/applications/files/editors/only-office/only-office-manager.service.ts b/backend/src/applications/files/editors/only-office/only-office-manager.service.ts
index f3cdc988..8208bd0a 100644
--- a/backend/src/applications/files/editors/only-office/only-office-manager.service.ts
+++ b/backend/src/applications/files/editors/only-office/only-office-manager.service.ts
@@ -17,6 +17,8 @@ import { HTTP_METHOD } from '../../../applications.constants'
import { FastifySpaceRequest } from '../../../spaces/interfaces/space-request.interface'
import type { SpaceEnv } from '../../../spaces/models/space-env.model'
import { canModifySpaceEnv } from '../../../spaces/utils/permissions'
+import { USER_THEME } from '../../../users/constants/user-preferences'
+import type { UserTheme } from '../../../users/interfaces/user-preferences.interface'
import type { UserModel } from '../../../users/models/user.model'
import { getAvatarBase64 } from '../../../users/utils/avatar'
import { DEPTH, LOCK_SCOPE } from '../../../webdav/constants/webdav'
@@ -75,7 +77,7 @@ export class OnlyOfficeManager {
private readonly filesLockManager: FilesLockManager
) {}
- async getSettings(user: UserModel, space: SpaceEnv, req: FastifySpaceRequest, theme?: 'dark' | 'light'): Promise<OnlyOfficeReqDto> {
+ async getSettings(user: UserModel, space: SpaceEnv, req: FastifySpaceRequest, theme?: UserTheme): Promise<OnlyOfficeReqDto> {
if (!(await isPathExists(space.realPath))) {
throw new HttpException('Document not found', HttpStatus.BAD_REQUEST)
}
@@ -111,7 +113,7 @@ export class OnlyOfficeManager {
const fileUrl = this.buildUrl(API_ONLY_OFFICE_DOCUMENT, encodeUrl(space.url), authToken)
const callBackUrl = this.buildUrl(API_ONLY_OFFICE_CALLBACK, encodeUrl(space.url), authToken)
const config: OnlyOfficeReqDto = await this.genConfiguration(user, space, mode, fileUrl, fileExtension, callBackUrl, isMobile, hasLock)
- config.config.editorConfig.customization.uiTheme = `theme-${theme ?? 'light'}`
+ config.config.editorConfig.customization.uiTheme = `theme-${theme ?? USER_THEME.LIGHT}`
config.config.token = await this.genPayloadToken(config.config)
return config
}
diff --git a/backend/src/applications/files/editors/only-office/only-office.constants.ts b/backend/src/applications/files/editors/only-office/only-office.constants.ts
index 29d59117..201ada57 100644
--- a/backend/src/applications/files/editors/only-office/only-office.constants.ts
+++ b/backend/src/applications/files/editors/only-office/only-office.constants.ts
@@ -1,6 +1,8 @@
export const ONLY_OFFICE_INTERNAL_URI = '/onlyoffice' // used by nginx as a proxy
export const ONLY_OFFICE_CONTEXT = 'OnlyOfficeEnvironment' as const
export const ONLY_OFFICE_TOKEN_QUERY_PARAM_NAME = 'token' as const
+export const ONLY_OFFICE_EDITOR = 'onlyoffice' as const
+export const EURO_OFFICE_EDITOR = 'eurooffice' as const
export const ONLY_OFFICE_APP_LOCK = 'OnlyOffice' as const
export const EURO_OFFICE_APP_LOCK = 'Euro-Office' as const
// cache only office = `office|${fileId}` => docKey
diff --git a/backend/src/applications/files/editors/only-office/only-office.controller.ts b/backend/src/applications/files/editors/only-office/only-office.controller.ts
index 07c485e8..71efeedd 100644
--- a/backend/src/applications/files/editors/only-office/only-office.controller.ts
+++ b/backend/src/applications/files/editors/only-office/only-office.controller.ts
@@ -1,4 +1,18 @@
-import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query, Request, Res, StreamableFile, UseGuards, UseInterceptors } from '@nestjs/common'
+import {
+ Body,
+ Controller,
+ Get,
+ HttpCode,
+ HttpStatus,
+ ParseEnumPipe,
+ Post,
+ Query,
+ Request,
+ Res,
+ StreamableFile,
+ UseGuards,
+ UseInterceptors
+} from '@nestjs/common'
import { FastifyReply } from 'fastify'
import { ContextInterceptor } from '../../../../infrastructure/context/interceptors/context.interceptor'
import { SPACE_OPERATION } from '../../../spaces/constants/spaces'
@@ -7,7 +21,9 @@ import { GetSpace } from '../../../spaces/decorators/space.decorator'
import { SpaceGuard } from '../../../spaces/guards/space.guard'
import { FastifySpaceRequest } from '../../../spaces/interfaces/space-request.interface'
import { SpaceEnv } from '../../../spaces/models/space-env.model'
+import { USER_THEME } from '../../../users/constants/user-preferences'
import { GetUser } from '../../../users/decorators/user.decorator'
+import type { UserTheme } from '../../../users/interfaces/user-preferences.interface'
import { UserModel } from '../../../users/models/user.model'
import { FilesMethods } from '../../services/files-methods.service'
import { OnlyOfficeEnvironment } from './only-office-environment.decorator'
@@ -25,7 +41,10 @@ export class OnlyOfficeController {
@Get(`${ONLY_OFFICE_ROUTE.SETTINGS}/*`)
@UseGuards(SpaceGuard)
@UseInterceptors(ContextInterceptor)
- onlyOfficeSettings(@Request() req: FastifySpaceRequest, @Query('theme') theme?: 'light' | 'dark'): Promise<OnlyOfficeReqDto> {
+ onlyOfficeSettings(
+ @Request() req: FastifySpaceRequest,
+ @Query('theme', new ParseEnumPipe({ DARK: USER_THEME.DARK, LIGHT: USER_THEME.LIGHT }, { optional: true })) theme?: UserTheme
+ ): Promise<OnlyOfficeReqDto> {
return this.filesOnlyOfficeManager.getSettings(req.user, req.space, req, theme)
}
diff --git a/backend/src/applications/users/constants/routes.ts b/backend/src/applications/users/constants/routes.ts
index c78e156b..858caf85 100644
--- a/backend/src/applications/users/constants/routes.ts
+++ b/backend/src/applications/users/constants/routes.ts
@@ -7,6 +7,7 @@ export const USERS_ROUTE = {
PASSWORD: 'password',
APP_PASSWORDS: 'app_passwords',
NOTIFICATION: 'notification',
+ PREFERENCES: 'preferences',
STORAGE_INDEXING: 'storage_indexing',
AVATAR: 'avatar',
GROUPS: 'groups',
@@ -21,6 +22,7 @@ export const API_USERS_MY_LANGUAGE = `${API_USERS_ME}/${USERS_ROUTE.LANGUAGE}`
export const API_USERS_MY_PASSWORD = `${API_USERS_ME}/${USERS_ROUTE.PASSWORD}`
export const API_USERS_MY_APP_PASSWORDS = `${API_USERS_ME}/${USERS_ROUTE.APP_PASSWORDS}`
export const API_USERS_MY_NOTIFICATION = `${API_USERS_ME}/${USERS_ROUTE.NOTIFICATION}`
+export const API_USERS_MY_PREFERENCES = `${API_USERS_ME}/${USERS_ROUTE.PREFERENCES}`
export const API_USERS_MY_STORAGE_INDEXING = `${API_USERS_ME}/${USERS_ROUTE.STORAGE_INDEXING}`
export const API_USERS_MY_AVATAR = `${API_USERS_ME}/${USERS_ROUTE.AVATAR}`
export const API_USERS_MY_GROUPS = `${API_USERS_ME}/${USERS_ROUTE.GROUPS}`
diff --git a/backend/src/applications/users/constants/user-preferences.ts b/backend/src/applications/users/constants/user-preferences.ts
new file mode 100644
index 00000000..70117f3f
--- /dev/null
+++ b/backend/src/applications/users/constants/user-preferences.ts
@@ -0,0 +1,5 @@
+export enum USER_THEME {
+ DARK = 'dark',
+ LIGHT = 'light',
+ AUTO = 'auto'
+}
diff --git a/backend/src/applications/users/dto/user-properties.dto.ts b/backend/src/applications/users/dto/user-properties.dto.ts
index 9627c4f5..7baaa1bb 100644
--- a/backend/src/applications/users/dto/user-properties.dto.ts
+++ b/backend/src/applications/users/dto/user-properties.dto.ts
@@ -1,8 +1,12 @@
import { Transform } from 'class-transformer'
-import { IsBoolean, IsDate, IsDefined, IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, MinLength, ValidateIf } from 'class-validator'
+import { IsBoolean, IsDate, IsDefined, IsEnum, IsIn, IsInt, IsNotEmpty, IsOptional, IsString, MinLength, ValidateIf } from 'class-validator'
import { AUTH_SCOPE } from '../../../authentication/constants/scope'
import { currentDate } from '../../../common/shared'
+import { COLLABORA_EDITOR } from '../../files/editors/collabora-online/collabora-online.constants'
+import { EURO_OFFICE_EDITOR, ONLY_OFFICE_EDITOR } from '../../files/editors/only-office/only-office.constants'
import { USER_PASSWORD_MIN_LENGTH } from '../constants/user'
+import { USER_THEME } from '../constants/user-preferences'
+import type { UserPreferences } from '../interfaces/user-preferences.interface'
export class UserLanguageDto {
@ValidateIf((_, language) => language === null || typeof language === 'string')
@@ -21,6 +25,16 @@ export class UserStorageIndexingDto {
storageIndexing: boolean
}
+export class UserPreferencesDto implements Partial<UserPreferences> {
+ @ValidateIf((_, value) => value !== undefined)
+ @IsEnum(USER_THEME)
+ theme?: UserPreferences['theme']
+
+ @ValidateIf((_, value) => value !== undefined)
+ @IsIn([COLLABORA_EDITOR, ONLY_OFFICE_EDITOR, EURO_OFFICE_EDITOR, null])
+ editor?: UserPreferences['editor']
+}
+
export class UserUpdatePasswordDto {
@IsNotEmpty()
@IsString()
diff --git a/backend/src/applications/users/interfaces/user-preferences.interface.ts b/backend/src/applications/users/interfaces/user-preferences.interface.ts
new file mode 100644
index 00000000..e44496fc
--- /dev/null
+++ b/backend/src/applications/users/interfaces/user-preferences.interface.ts
@@ -0,0 +1,9 @@
+import type { FileEditorProviders } from '../../files/editors/file-editor-providers.interface'
+import { USER_THEME } from '../constants/user-preferences'
+
+export type UserTheme = Exclude<USER_THEME, USER_THEME.AUTO>
+
+export interface UserPreferences {
+ theme: USER_THEME
+ editor: Exclude<keyof FileEditorProviders, 'drawio'> | null
+}
diff --git a/backend/src/applications/users/models/user.model.ts b/backend/src/applications/users/models/user.model.ts
index 79cdf1e9..3fd76cfa 100644
--- a/backend/src/applications/users/models/user.model.ts
+++ b/backend/src/applications/users/models/user.model.ts
@@ -8,9 +8,11 @@ import { isPathInside } from '../../files/utils/files'
import { SPACE_REPOSITORY } from '../../spaces/constants/spaces'
import { GUEST_PERMISSION, USER_PERMISSION, USER_PERMS_SEP, USER_ROLE, USER_TMP_DIRECTORY } from '../constants/user'
import type { Owner } from '../interfaces/owner.interface'
+import type { UserPreferences } from '../interfaces/user-preferences.interface'
import type { UserSecrets } from '../interfaces/user-secrets.interface'
import type { User } from '../schemas/user.interface'
import { isSafePathSegment, validateUserId } from '../utils/login'
+import { normalizeUserPreferences } from '../utils/user'
export class UserModel implements User {
id: number
@@ -21,6 +23,7 @@ export class UserModel implements User {
role: number
language: string
isActive: boolean
+ preferences: UserPreferences
notification: number
onlineStatus: number
permissions: string
@@ -61,6 +64,7 @@ export class UserModel implements User {
// User model can be instantiated with data from the database or from a token payload
this.initSecrets(props)
Object.assign(this, props)
+ this.preferences = normalizeUserPreferences(this.isLink ? null : this.preferences)
if (removePassword) {
// always remove the password field from model for obvious security reasons
// do not remove it from `props` to not mutate the object
diff --git a/backend/src/applications/users/schemas/user.interface.ts b/backend/src/applications/users/schemas/user.interface.ts
index 5f214553..c4402129 100644
--- a/backend/src/applications/users/schemas/user.interface.ts
+++ b/backend/src/applications/users/schemas/user.interface.ts
@@ -1,3 +1,4 @@
+import type { UserPreferences } from '../interfaces/user-preferences.interface'
import type { UserSecrets } from '../interfaces/user-secrets.interface'
import type { users } from './users.schema'
@@ -14,6 +15,7 @@ export class User implements UserSchema {
role: number
isActive: boolean
secrets: UserSecrets
+ preferences: UserPreferences
language: string
permissions: string
storageUsage: number
diff --git a/backend/src/applications/users/schemas/users.schema.ts b/backend/src/applications/users/schemas/users.schema.ts
index f65485dc..b0b6c737 100644
--- a/backend/src/applications/users/schemas/users.schema.ts
+++ b/backend/src/applications/users/schemas/users.schema.ts
@@ -1,6 +1,7 @@
import { SQL, sql } from 'drizzle-orm'
import { bigint, boolean, datetime, index, mysqlTable, tinyint, uniqueIndex, varchar } from 'drizzle-orm/mysql-core'
import { jsonColumn } from '../../../infrastructure/database/columns'
+import type { UserPreferences } from '../interfaces/user-preferences.interface'
import { UserSecrets } from '../interfaces/user-secrets.interface'
/*
@@ -37,6 +38,7 @@ export const users = mysqlTable(
role: tinyint('role', { unsigned: true }).default(1).notNull(),
isActive: boolean('isActive').default(true).notNull(),
secrets: jsonColumn<UserSecrets>()('secrets'),
+ preferences: jsonColumn<UserPreferences>()('preferences'),
language: varchar('language', { length: 10 }),
permissions: varchar('permissions', { length: 255 }).default('').notNull(),
storageUsage: bigint('storageUsage', { mode: 'number', unsigned: true }).default(0),
diff --git a/backend/src/applications/users/services/users-manager.service.ts b/backend/src/applications/users/services/users-manager.service.ts
index ec1aa85b..fff5f446 100755
--- a/backend/src/applications/users/services/users-manager.service.ts
+++ b/backend/src/applications/users/services/users-manager.service.ts
@@ -36,6 +36,7 @@ import type {
UserAppPasswordDto,
UserLanguageDto,
UserNotificationDto,
+ UserPreferencesDto,
UserStorageIndexingDto,
UserUpdatePasswordDto
} from '../dto/user-properties.dto'
@@ -43,6 +44,7 @@ import type { GroupBrowse } from '../interfaces/group-browse.interface'
import type { GroupMember, GroupWithMembers } from '../interfaces/group-member'
import type { GuestUser } from '../interfaces/guest-user.interface'
import type { Member } from '../interfaces/member.interface'
+import type { UserPreferences } from '../interfaces/user-preferences.interface'
import type { UserAppPassword, UserSecrets } from '../interfaces/user-secrets.interface'
import type { UserOnline } from '../interfaces/websocket.interface'
import { UserModel } from '../models/user.model'
@@ -232,6 +234,18 @@ export class UsersManager {
}
}
+ async updatePreferences(user: UserModel, dto: UserPreferencesDto): Promise<UserPreferences> {
+ const patch: Partial<UserPreferences> = {}
+ if (dto.theme !== undefined) patch.theme = dto.theme
+ if (dto.editor !== undefined) patch.editor = dto.editor
+ try {
+ return await this.usersQueries.updateUserPreferences(user.id, patch)
+ } catch (e) {
+ this.logger.error({ tag: this.updatePreferences.name, msg: `Unable to update preferences for user (${user.id}) : ${e}` })
+ throw new HttpException('Unable to update preferences', HttpStatus.INTERNAL_SERVER_ERROR)
+ }
+ }
+
async updateStorageIndexing(user: UserModel, userStorageIndexingDto: UserStorageIndexingDto) {
if (!(await this.usersQueries.updateUserOrGuest(user.id, userStorageIndexingDto))) {
throw new HttpException('Unable to update full-text search preference', HttpStatus.INTERNAL_SERVER_ERROR)
diff --git a/backend/src/applications/users/services/users-queries.service.ts b/backend/src/applications/users/services/users-queries.service.ts
index 656347d8..05974b60 100644
--- a/backend/src/applications/users/services/users-queries.service.ts
+++ b/backend/src/applications/users/services/users-queries.service.ts
@@ -26,6 +26,7 @@ import { GroupMember, GroupWithMembers } from '../interfaces/group-member'
import { GuestUser } from '../interfaces/guest-user.interface'
import { Member } from '../interfaces/member.interface'
import type { UserAccessUpdateResult } from '../interfaces/user-access-update-result.interface'
+import type { UserPreferences } from '../interfaces/user-preferences.interface'
import { UserSecrets } from '../interfaces/user-secrets.interface'
import { UserOnline } from '../interfaces/websocket.interface'
import { UserModel } from '../models/user.model'
@@ -36,6 +37,7 @@ import { User } from '../schemas/user.interface'
import { usersGroups } from '../schemas/users-groups.schema'
import { usersGuests } from '../schemas/users-guests.schema'
import { userFullNameSQL, users } from '../schemas/users.schema'
+import { normalizeUserPreferences } from '../utils/user'
@Injectable()
export class UsersQueries {
@@ -183,6 +185,22 @@ export class UsersQueries {
})
}
+ async updateUserPreferences(userId: number, patch: Partial<UserPreferences>): Promise<UserPreferences> {
+ return this.db.transaction(async (tx) => {
+ const [user] = await tx.select({ preferences: users.preferences }).from(users).where(eq(users.id, userId)).limit(1).for('update')
+ if (!user) {
+ throw new Error(`User (${userId}) not found`)
+ }
+ const currentPreferences = normalizeUserPreferences(user.preferences)
+ const preferences = { ...currentPreferences, ...patch }
+ if (preferences.theme === currentPreferences.theme && preferences.editor === currentPreferences.editor) {
+ return currentPreferences
+ }
+ dbCheckAffectedRows(await tx.update(users).set({ preferences }).where(eq(users.id, userId)), 1)
+ return preferences
+ })
+ }
+
selectUsers(fields: Partial<keyof User>[] = ['id', 'login', 'email'], where: SQL[]): Promise<Partial<User>[]> {
const select: Record<keyof User, any> = convertToSelect(users, fields)
return this.db
diff --git a/backend/src/applications/users/users.controller.ts b/backend/src/applications/users/users.controller.ts
index 32d907b3..a42d7fd3 100755
--- a/backend/src/applications/users/users.controller.ts
+++ b/backend/src/applications/users/users.controller.ts
@@ -15,13 +15,21 @@ import { GetUser } from './decorators/user.decorator'
import { UserCreateOrUpdateGroupDto } from './dto/create-or-update-group.dto'
import { CreateUserDto, UpdateUserDto, UpdateUserFromGroupDto } from './dto/create-or-update-user.dto'
import { SearchMembersDto } from './dto/search-members.dto'
-import { UserAppPasswordDto, UserLanguageDto, UserNotificationDto, UserStorageIndexingDto, UserUpdatePasswordDto } from './dto/user-properties.dto'
+import {
+ UserAppPasswordDto,
+ UserLanguageDto,
+ UserNotificationDto,
+ UserPreferencesDto,
+ UserStorageIndexingDto,
+ UserUpdatePasswordDto
+} from './dto/user-properties.dto'
import { UserPermissionsGuard } from './guards/permissions.guard'
import { UserRolesGuard } from './guards/roles.guard'
import { GroupBrowse } from './interfaces/group-browse.interface'
import { GroupMember } from './interfaces/group-member'
import { GuestUser } from './interfaces/guest-user.interface'
import { Member } from './interfaces/member.interface'
+import type { UserPreferences } from './interfaces/user-preferences.interface'
import { UserAppPassword } from './interfaces/user-secrets.interface'
import { UserModel } from './models/user.model'
import { UsersManager } from './services/users-manager.service'
@@ -77,6 +85,12 @@ export class UsersController {
return this.usersManager.updateNotification(user, userNotificationDto)
}
+ @Patch(`${USERS_ROUTE.ME}/${USERS_ROUTE.PREFERENCES}`)
+ @UserHaveRole(USER_ROLE.GUEST)
+ updatePreferences(@GetUser() user: UserModel, @Body() dto: UserPreferencesDto): Promise<UserPreferences> {
+ return this.usersManager.updatePreferences(user, dto)
+ }
+
@Put(`${USERS_ROUTE.ME}/${USERS_ROUTE.STORAGE_INDEXING}`)
@UserHaveRole(USER_ROLE.USER)
updateStorageIndexing(@GetUser() user: UserModel, @Body() userStorageIndexingDto: UserStorageIndexingDto) {
diff --git a/backend/src/applications/users/utils/user.ts b/backend/src/applications/users/utils/user.ts
new file mode 100644
index 00000000..6d1bd601
--- /dev/null
+++ b/backend/src/applications/users/utils/user.ts
@@ -0,0 +1,9 @@
+import { USER_THEME } from '../constants/user-preferences'
+import type { UserPreferences } from '../interfaces/user-preferences.interface'
+
+export function normalizeUserPreferences(preferences?: Partial<UserPreferences> | null): UserPreferences {
+ return {
+ theme: preferences?.theme ?? USER_THEME.AUTO,
+ editor: preferences?.editor ?? null
+ }
+}
diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.html b/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.html
index 3e291290..562af4dd 100755
--- a/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.html
+++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.html
@@ -20,7 +20,7 @@
<button
type="button"
class="editor-choice is-collabora w-100 btn p-0 border-0 text-start"
- (click)="selectEditor('collabora')">
+ (click)="selectEditor(collaboraEditor)">
<div class="card h-100 shadow-sm editor-card editor-collabora">
<div class="card-body d-flex align-items-center gap-3 p-3">
<div class="editor-badge collabora">
@@ -58,15 +58,17 @@
</button>
</div>
</div>
- <div class="form-check ms-auto mt-3">
- <input
- class="form-check-input"
- type="checkbox"
- id="rememberEditor"
- [(ngModel)]="rememberChoice"
- />
- <label class="form-check-label fs-sm" for="rememberEditor" l10nTranslate>
- Remember my choice for next time
- </label>
- </div>
+ @if (canRememberChoice) {
+ <div class="form-check ms-auto mt-3">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ id="rememberEditor"
+ [(ngModel)]="rememberChoice"
+ />
+ <label class="form-check-label fs-sm" for="rememberEditor" l10nTranslate>
+ Remember my choice for next time
+ </label>
+ </div>
+ }
</div>
diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.ts b/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.ts
index 07889ad7..416872c5 100644
--- a/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.ts
+++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-select-dialog.component.ts
@@ -1,7 +1,15 @@
import { Component, inject, Input } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { LucideArrowRight, LucideDynamicIcon, LucideFile, LucideFileText, LucideFileTypeCorner } from '@lucide/angular'
+import { COLLABORA_EDITOR } from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.constants'
import type { FileEditorProviders } from '@sync-in-server/backend/src/applications/files/editors/file-editor-providers.interface'
+import {
+ EURO_OFFICE_APP_LOCK,
+ EURO_OFFICE_EDITOR,
+ ONLY_OFFICE_APP_LOCK,
+ ONLY_OFFICE_EDITOR
+} from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.constants'
+import type { UserPreferences } from '@sync-in-server/backend/src/applications/users/interfaces/user-preferences.interface'
import { L10N_LOCALE, L10nLocale, L10nTranslateDirective } from 'angular-l10n'
import { LayoutService } from '../../../../layout/layout.service'
import { StoreService } from '../../../../store/store.service'
@@ -18,22 +26,20 @@ export class FilesViewerSelectDialog {
@Input({ required: true }) file: FileModel = null
@Input({ required: true }) editorProvider: FileEditorProviders
protected rememberChoice = false
+ protected readonly collaboraEditor = COLLABORA_EDITOR
protected readonly icons = { LucideFile, LucideFileTypeCorner, LucideArrowRight, LucideFileText }
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
protected layout = inject(LayoutService)
private readonly store = inject(StoreService)
private readonly userService = inject(UserService)
+ protected readonly canRememberChoice = this.userService.user?.isLink === false
+ protected readonly officeEditorProvider: NonNullable<UserPreferences['editor']> = this.store.server().files.editors.onlyoffice
+ ? ONLY_OFFICE_EDITOR
+ : EURO_OFFICE_EDITOR
+ protected readonly officeEditorName = this.officeEditorProvider === EURO_OFFICE_EDITOR ? EURO_OFFICE_APP_LOCK : ONLY_OFFICE_APP_LOCK
- protected get officeEditorProvider(): keyof FileEditorProviders {
- return this.store.server().files.editors.onlyoffice ? 'onlyoffice' : 'eurooffice'
- }
-
- protected get officeEditorName(): string {
- return this.officeEditorProvider === 'eurooffice' ? 'Euro-Office' : 'OnlyOffice'
- }
-
- selectEditor(editor: keyof FileEditorProviders) {
- if (this.rememberChoice) {
+ selectEditor(editor: NonNullable<UserPreferences['editor']>) {
+ if (this.rememberChoice && this.canRememberChoice) {
this.userService.setEditorProviderPreference(editor)
}
this.editorProvider[editor] = true
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-collabora-online.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-collabora-online.component.ts
index 41c1bc03..1e77b4ab 100644
--- a/frontend/src/app/applications/files/components/viewers/files-viewer-collabora-online.component.ts
+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-collabora-online.component.ts
@@ -4,7 +4,6 @@ import { FILE_MODE } from '@sync-in-server/backend/src/applications/files/consta
import { COLLABORA_APP_LOCK } from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.constants'
import type { CollaboraOnlineReqDto } from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.dtos'
import { API_COLLABORA_ONLINE_SETTINGS } from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.routes'
-import { themeDark } from '../../../../layout/layout.interfaces'
import { LayoutService } from '../../../../layout/layout.service'
import { StoreService } from '../../../../store/store.service'
import { FileModel } from '../../models/file.model'
@@ -85,7 +84,8 @@ export class FilesViewerCollaboraOnlineComponent implements OnInit, OnDestroy {
}
const documentServerUrl = new URL(data.documentServerUrl)
documentServerUrl.searchParams.set('lang', this.layout.getCurrentLanguage())
- this.collaboraUiDefaults = `UITheme=${this.layout.switchTheme.getValue() === themeDark ? 'dark' : 'light'};`
+ const theme = this.layout.getCurrentTheme()
+ this.collaboraUiDefaults = `UITheme=${theme};`
this.documentServerUrl = documentServerUrl.toString()
},
error: (e: HttpErrorResponse) => {
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.ts
index f87b283d..aa675cd2 100644
--- a/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.ts
+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.ts
@@ -4,6 +4,7 @@ import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
import type { DrawioSettingsDto } from '@sync-in-server/backend/src/applications/files/editors/drawio/drawio.dtos'
import { DRAWIO_IMPORT_EXTENSIONS, EMPTY_DRAWIO_XML } from '@sync-in-server/backend/src/applications/files/editors/drawio/drawio.constants'
import { API_DRAWIO_SETTINGS } from '@sync-in-server/backend/src/applications/files/editors/drawio/drawio.routes'
+import { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
import { forbiddenChars, isValidFileName } from '@sync-in-server/backend/src/common/shared'
import { L10nTranslateDirective } from 'angular-l10n'
import type { BsModalRef } from 'ngx-bootstrap/modal'
@@ -230,7 +231,7 @@ export class FilesViewerDrawioComponent extends FilesViewerEditableBase implemen
private configureIframe() {
const editorUrl = new URL(this.editorServerUrl)
- editorUrl.searchParams.set('dark', this.currentTheme === 'dark' ? '1' : '0')
+ editorUrl.searchParams.set('dark', this.currentTheme === USER_THEME.DARK ? '1' : '0')
editorUrl.searchParams.set('lang', this.locale.language)
if (this.isReadonlyView() && this.initializationMode !== 'import') {
editorUrl.searchParams.set('chrome', '0')
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.ts
index 47b50151..4deba3da 100644
--- a/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.ts
+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.ts
@@ -15,10 +15,12 @@ import {
} from '@angular/core'
import { CACHE_LOCK_FILE_TTL } from '@sync-in-server/backend/src/applications/files/constants/cache'
import type { FileLockProps } from '@sync-in-server/backend/src/applications/files/interfaces/file-props.interface'
+import { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
+import type { UserTheme } from '@sync-in-server/backend/src/applications/users/interfaces/user-preferences.interface'
import { L10N_LOCALE, L10nLocale } from 'angular-l10n'
import { TooltipDirective } from 'ngx-bootstrap/tooltip'
import { catchError, EMPTY, exhaustMap, filter, firstValueFrom, Subscription, tap, timer } from 'rxjs'
-import { type AppWindow, themeDark } from '../../../../layout/layout.interfaces'
+import type { AppWindow } from '../../../../layout/layout.interfaces'
import { LayoutService } from '../../../../layout/layout.service'
import { MAX_CLIENT_EDITOR_FILE_SIZE } from '../../files.constants'
import { FileModel } from '../../models/file.model'
@@ -41,16 +43,14 @@ export abstract class FilesViewerEditableBase implements AfterViewInit, OnDestro
protected isModified = signal(false)
protected isSaving = signal(false)
protected warnOnUnsavedChanges = signal(false)
- protected currentTheme: 'dark' | 'light' = 'light'
+ protected currentTheme: UserTheme = USER_THEME.LIGHT
protected readonly layout = inject(LayoutService)
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
private readonly tooltips = viewChildren(TooltipDirective)
private readonly http = inject(HttpClient)
private readonly filesServices = inject(FilesService)
private readonly filesUpload = inject(FilesUploadService)
- private readonly themeSubscription = this.layout.switchTheme.subscribe(
- (layout: string) => (this.currentTheme = layout === themeDark ? 'dark' : 'light')
- )
+ private readonly themeSubscription = this.layout.switchTheme.subscribe(() => (this.currentTheme = this.layout.getCurrentTheme()))
private lockRefreshSubscription: Subscription | null = null
private lockRefreshWarningSent = false
private isDestroyed = false
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-only-office.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-only-office.component.ts
index 1bfa34b8..8e202bc5 100644
--- a/frontend/src/app/applications/files/components/viewers/files-viewer-only-office.component.ts
+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-only-office.component.ts
@@ -4,7 +4,6 @@ import { FILE_MODE } from '@sync-in-server/backend/src/applications/files/consta
import { EURO_OFFICE_APP_LOCK, ONLY_OFFICE_APP_LOCK } from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.constants'
import type { OnlyOfficeReqDto } from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.dtos'
import { API_ONLY_OFFICE_SETTINGS } from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.routes'
-import { themeDark } from '../../../../layout/layout.interfaces'
import { LayoutService } from '../../../../layout/layout.service'
import { StoreService } from '../../../../store/store.service'
import { FileModel } from '../../models/file.model'
@@ -52,7 +51,7 @@ export class FilesViewerOnlyOfficeComponent implements OnInit, OnDestroy {
ngOnInit() {
this.docId = `viewer-doc-${this.file().id}`
- const theme = this.layout.switchTheme.getValue() === themeDark ? 'dark' : 'light'
+ const theme = this.layout.getCurrentTheme()
this.http.get<OnlyOfficeReqDto>(`${API_ONLY_OFFICE_SETTINGS}/${this.file().path}`, { params: { theme } }).subscribe({
next: (data) => {
if (!data) {
diff --git a/frontend/src/app/applications/files/services/files.service.ts b/frontend/src/app/applications/files/services/files.service.ts
index fccc7a9b..95fcc519 100644
--- a/frontend/src/app/applications/files/services/files.service.ts
+++ b/frontend/src/app/applications/files/services/files.service.ts
@@ -32,9 +32,16 @@ import type { CopyMoveFileResponse } from '@sync-in-server/backend/src/applicati
import type { FileLockProps } from '@sync-in-server/backend/src/applications/files/interfaces/file-props.interface'
import type { FileTree } from '@sync-in-server/backend/src/applications/files/interfaces/file-tree.interface'
import type { FileTask } from '@sync-in-server/backend/src/applications/files/models/file-task'
-import { COLLABORA_ONLINE_EXTENSIONS } from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.constants'
+import {
+ COLLABORA_EDITOR,
+ COLLABORA_ONLINE_EXTENSIONS
+} from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.constants'
import type { FileEditorProviders } from '@sync-in-server/backend/src/applications/files/editors/file-editor-providers.interface'
-import { ONLY_OFFICE_EXTENSIONS } from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.constants'
+import {
+ EURO_OFFICE_EDITOR,
+ ONLY_OFFICE_EDITOR,
+ ONLY_OFFICE_EXTENSIONS
+} from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.constants'
import type { FileContent } from '@sync-in-server/backend/src/applications/files/schemas/file-content.interface'
import type { FileFavorite, FileFavoriteIdentity } from '@sync-in-server/backend/src/applications/files/schemas/file-favorite.interface'
import type { FileRecent } from '@sync-in-server/backend/src/applications/files/schemas/file-recent.interface'
@@ -415,7 +422,7 @@ export class FilesService {
const editorProvider: FileEditorProviders = { collabora: false, drawio: false, eurooffice: false, onlyoffice: false }
if (hookedShortMime === SHORT_MIME.DOCUMENT) {
- const officeEditorProvider: keyof FileEditorProviders = this.store.server().files.editors.onlyoffice ? 'onlyoffice' : 'eurooffice'
+ const officeEditorProvider = this.store.server().files.editors.onlyoffice ? ONLY_OFFICE_EDITOR : EURO_OFFICE_EDITOR
const officeEditorEnabled = this.store.server().files.editors[officeEditorProvider]
if (this.store.server().files.editors.collabora && officeEditorEnabled) {
// Case with multiple editors
@@ -424,7 +431,7 @@ export class FilesService {
if (collaboraHasExtension && officeEditorHasExtension) {
// Get user's saved preference
const userEditorPreference = this.userService.getEditorProviderPreference()
- if (userEditorPreference === 'collabora' || userEditorPreference === officeEditorProvider) {
+ if (userEditorPreference === COLLABORA_EDITOR || userEditorPreference === officeEditorProvider) {
editorProvider[userEditorPreference] = true
} else {
// Both editors support this file extension, let the user choose
diff --git a/frontend/src/app/applications/links/components/public/public-link-header.component.html b/frontend/src/app/applications/links/components/public/public-link-header.component.html
index c0da3d14..5af8820a 100644
--- a/frontend/src/app/applications/links/components/public/public-link-header.component.html
+++ b/frontend/src/app/applications/links/components/public/public-link-header.component.html
@@ -2,11 +2,8 @@
<a routerLink="">
<span aria-hidden="true" class="sync-in-logo sync-in-logo--themed"></span>
</a>
- <button (click)="toggleTheme()"
- [attr.aria-label]="'Switch theme' | translate:locale.language"
- [title]="'Switch theme' | translate:locale.language"
- class="public-link-theme-toggle position-absolute top-50 end-0 translate-middle-y me-3"
- type="button">
- <svg [lucideIcon]="icons.LucideContrast"></svg>
- </button>
+ <app-theme-switch
+ buttonClass="public-link-theme-toggle position-absolute top-50 end-0 translate-middle-y me-3"
+ (themeChange)="toggleTheme($event)">
+ </app-theme-switch>
</div>
diff --git a/frontend/src/app/applications/links/components/public/public-link-header.component.ts b/frontend/src/app/applications/links/components/public/public-link-header.component.ts
index 98d03b48..d10b6fe6 100644
--- a/frontend/src/app/applications/links/components/public/public-link-header.component.ts
+++ b/frontend/src/app/applications/links/components/public/public-link-header.component.ts
@@ -1,19 +1,17 @@
import { Component, DOCUMENT, inject, OnDestroy, Renderer2 } from '@angular/core'
import { RouterLink } from '@angular/router'
-import { LucideContrast, LucideDynamicIcon } from '@lucide/angular'
-import { L10N_LOCALE, L10nLocale, L10nTranslatePipe } from 'angular-l10n'
+import type { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
import { Subscription } from 'rxjs'
import { themeDark, themeLight } from '../../../../layout/layout.interfaces'
import { LayoutService } from '../../../../layout/layout.service'
+import { ThemeSwitchComponent } from '../../../../layout/theme-switch.component'
@Component({
selector: 'app-public-link-header',
- imports: [RouterLink, LucideDynamicIcon, L10nTranslatePipe],
+ imports: [RouterLink, ThemeSwitchComponent],
templateUrl: 'public-link-header.component.html'
})
export class PublicLinkHeaderComponent implements OnDestroy {
- protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
- protected readonly icons = { LucideContrast }
private readonly document = inject<Document>(DOCUMENT)
private readonly layout = inject(LayoutService)
private readonly renderer = inject(Renderer2)
@@ -30,7 +28,7 @@ export class PublicLinkHeaderComponent implements OnDestroy {
this.themeSubscription.unsubscribe()
}
- protected toggleTheme() {
- this.layout.toggleTheme()
+ protected toggleTheme(theme: USER_THEME) {
+ this.layout.setThemePreference(theme)
}
}
diff --git a/frontend/src/app/applications/users/components/sidebar/user-profile.component.html b/frontend/src/app/applications/users/components/sidebar/user-profile.component.html
index 20f45c03..582f0180 100755
--- a/frontend/src/app/applications/users/components/sidebar/user-profile.component.html
+++ b/frontend/src/app/applications/users/components/sidebar/user-profile.component.html
@@ -6,19 +6,19 @@
<button class="btn btn-default"
(click)="collapseRSideBar()"
type="button"
+ [attr.aria-label]="'Account' | translate:locale.language"
+ [title]="'Account' | translate:locale.language"
[routerLink]=USER_PATH.BASE>
<svg [lucideIcon]="icons.LucideUserRound"></svg>
</button>
}
- <button class="btn btn-default"
- (click)="toggleTheme()"
- type="button">
- <svg [lucideIcon]="icons.LucideContrast"></svg>
- </button>
+ <app-theme-switch (themeChange)="toggleTheme($event)"></app-theme-switch>
@if (user?.isAdmin) {
<button class="btn btn-default"
(click)="collapseRSideBar()"
type="button"
+ [attr.aria-label]="'Administration' | translate:locale.language"
+ [title]="'Administration' | translate:locale.language"
routerLink="/admin">
<svg [lucideIcon]="icons.LucideSettings"></svg>
</button>
@@ -26,6 +26,8 @@
@if (!store.isElectronApp() || store.isElectronApp() && store.userImpersonate()) {
<button (click)="logOut()"
class="btn btn-default"
+ [attr.aria-label]="'logout' | translate:locale.language"
+ [title]="'logout' | translate:locale.language"
type="button">
<svg [lucideIcon]="store.userImpersonate() ? icons.LucideVenetianMask : icons.LucideLogOut"></svg>
</button>
@@ -70,11 +72,13 @@
<a class="text-primary cursor-pointer" (click)="openLink('versions')" l10nTranslate>Versions</a>
<span>&nbsp;|&nbsp;</span>
<a class="cursor-pointer" (click)="openLink('support')"> 💛</a>
- <svg class="ms-auto fs-xs cursor-pointer"
- (click)="layout.setAutoCollapseRSideBarPreference(!layout.collapseRSideBarPreference())"
- [title]="(layout.collapseRSideBarPreference() ? 'Sidebar auto-hide enabled' : 'Sidebar pinned') | translate:locale.language"
- [lucideIcon]="layout.collapseRSideBarPreference() ? icons.LucidePinOff : icons.LucidePin">
- </svg>
+ <button class="ms-auto fs-xs cursor-pointer border-0 bg-transparent p-0 text-reset"
+ type="button"
+ (click)="layout.setAutoCollapseRSideBarPreference(!layout.collapseRSideBarPreference())"
+ [attr.aria-label]="(layout.collapseRSideBarPreference() ? 'Sidebar auto-hide enabled' : 'Sidebar pinned') | translate:locale.language"
+ [title]="(layout.collapseRSideBarPreference() ? 'Sidebar auto-hide enabled' : 'Sidebar pinned') | translate:locale.language">
+ <svg [lucideIcon]="layout.collapseRSideBarPreference() ? icons.LucidePinOff : icons.LucidePin"></svg>
+ </button>
</div>
</div>
</div>
diff --git a/frontend/src/app/applications/users/components/sidebar/user-profile.component.ts b/frontend/src/app/applications/users/components/sidebar/user-profile.component.ts
index 877e3f5f..70826b8d 100644
--- a/frontend/src/app/applications/users/components/sidebar/user-profile.component.ts
+++ b/frontend/src/app/applications/users/components/sidebar/user-profile.component.ts
@@ -1,16 +1,8 @@
import { Component, inject, OnDestroy } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { RouterLink } from '@angular/router'
-import {
- LucideContrast,
- LucideDynamicIcon,
- LucideLogOut,
- LucidePin,
- LucidePinOff,
- LucideSettings,
- LucideUserRound,
- LucideVenetianMask
-} from '@lucide/angular'
+import { LucideDynamicIcon, LucideLogOut, LucidePin, LucidePinOff, LucideSettings, LucideUserRound, LucideVenetianMask } from '@lucide/angular'
+import type { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
import { APP_URL } from '@sync-in-server/backend/src/common/shared'
import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'
import { Subscription } from 'rxjs'
@@ -19,6 +11,7 @@ import { AuthService } from '../../../../auth/auth.service'
import { AutoResizeDirective } from '../../../../common/directives/auto-resize.directive'
import { CapitalizePipe } from '../../../../common/pipes/capitalize.pipe'
import { LayoutService } from '../../../../layout/layout.service'
+import { ThemeSwitchComponent } from '../../../../layout/theme-switch.component'
import { StoreService } from '../../../../store/store.service'
import { UserType } from '../../interfaces/user.interface'
import { USER_ONLINE_STATUS_LIST, USER_PATH } from '../../user.constants'
@@ -27,7 +20,16 @@ import { UserService } from '../../user.service'
@Component({
selector: 'app-user-profile',
templateUrl: 'user-profile.component.html',
- imports: [FormsModule, RouterLink, CapitalizePipe, LucideDynamicIcon, L10nTranslateDirective, L10nTranslatePipe, AutoResizeDirective]
+ imports: [
+ FormsModule,
+ RouterLink,
+ CapitalizePipe,
+ LucideDynamicIcon,
+ L10nTranslateDirective,
+ L10nTranslatePipe,
+ AutoResizeDirective,
+ ThemeSwitchComponent
+ ]
})
export class UserProfileComponent implements OnDestroy {
protected readonly store = inject(StoreService)
@@ -36,7 +38,7 @@ export class UserProfileComponent implements OnDestroy {
protected readonly allOnlineStatus = USER_ONLINE_STATUS_LIST
protected readonly appVersion = APP_VERSION
protected appBaseUrl = `${APP_URL.WEBSITE}`
- protected readonly icons = { LucideUserRound, LucideContrast, LucideSettings, LucideLogOut, LucideVenetianMask, LucidePin, LucidePinOff }
+ protected readonly icons = { LucideUserRound, LucideSettings, LucideLogOut, LucideVenetianMask, LucidePin, LucidePinOff }
protected user: UserType
protected userAvatar: string = null
protected readonly layout = inject(LayoutService)
@@ -62,8 +64,12 @@ export class UserProfileComponent implements OnDestroy {
this.userService.changeOnlineStatus(status)
}
- toggleTheme() {
- this.layout.toggleTheme()
+ toggleTheme(theme: USER_THEME) {
+ if (this.user?.isLink) {
+ this.layout.setThemePreference(theme)
+ return
+ }
+ this.userService.changePreferences({ theme }).subscribe()
}
logOut() {
diff --git a/frontend/src/app/applications/users/components/user-account.component.html b/frontend/src/app/applications/users/components/user-account.component.html
index 65a8266c..183beff0 100755
--- a/frontend/src/app/applications/users/components/user-account.component.html
+++ b/frontend/src/app/applications/users/components/user-account.component.html
@@ -101,6 +101,20 @@
<div class="card-body">
<div class="text-muted text-uppercase fs-sm text-bold mb-2" l10nTranslate>Preferences</div>
+ <div class="row g-2 align-items-center mb-2">
+ <label class="col-12 col-sm-6" for="userTheme" l10nTranslate>Theme</label>
+ <div class="col-12 col-sm-6">
+ <select id="userTheme"
+ class="form-select"
+ [ngModel]="user.preferences.theme"
+ (ngModelChange)="updateTheme($event)">
+ <option [value]="USER_THEME.AUTO" l10nTranslate>Auto</option>
+ <option [value]="USER_THEME.LIGHT" l10nTranslate>Light</option>
+ <option [value]="USER_THEME.DARK" l10nTranslate>Dark</option>
+ </select>
+ </div>
+ </div>
+
@if (showEditorPreference) {
<div class="row g-2 align-items-center mb-2">
<label class="col-12 col-sm-6" for="documentEditor" l10nTranslate>Document editor</label>
diff --git a/frontend/src/app/applications/users/components/user-account.component.ts b/frontend/src/app/applications/users/components/user-account.component.ts
index 52f131db..46507792 100644
--- a/frontend/src/app/applications/users/components/user-account.component.ts
+++ b/frontend/src/app/applications/users/components/user-account.component.ts
@@ -3,10 +3,19 @@ import { HttpErrorResponse, HttpHeaders } from '@angular/common/http'
import { Component, inject, OnDestroy, OnInit } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { LucideCopy, LucideDynamicIcon, LucideKeyRound } from '@lucide/angular'
-import { COLLABORA_APP_LOCK } from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.constants'
-import type { FileEditorProviders } from '@sync-in-server/backend/src/applications/files/editors/file-editor-providers.interface'
-import { ONLY_OFFICE_APP_LOCK } from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.constants'
+import {
+ COLLABORA_APP_LOCK,
+ COLLABORA_EDITOR
+} from '@sync-in-server/backend/src/applications/files/editors/collabora-online/collabora-online.constants'
+import {
+ EURO_OFFICE_APP_LOCK,
+ EURO_OFFICE_EDITOR,
+ ONLY_OFFICE_APP_LOCK,
+ ONLY_OFFICE_EDITOR
+} from '@sync-in-server/backend/src/applications/files/editors/only-office/only-office.constants'
import { USER_PASSWORD_MIN_LENGTH } from '@sync-in-server/backend/src/applications/users/constants/user'
+import { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
+import type { UserPreferences } from '@sync-in-server/backend/src/applications/users/interfaces/user-preferences.interface'
import { UserAppPassword } from '@sync-in-server/backend/src/applications/users/interfaces/user-secrets.interface'
import { WEBDAV_BASE_PATH } from '@sync-in-server/backend/src/applications/webdav/constants/routes'
import { TWO_FA_HEADER_CODE, TWO_FA_HEADER_PASSWORD } from '@sync-in-server/backend/src/authentication/constants/auth'
@@ -58,6 +67,7 @@ export class UserAccountComponent implements OnInit, OnDestroy {
protected readonly allNotifications = Object.values(USER_NOTIFICATION_TEXT)
protected readonly allOnlineStatus = USER_ONLINE_STATUS_LIST
protected readonly passwordMinLength = USER_PASSWORD_MIN_LENGTH
+ protected readonly USER_THEME = USER_THEME
protected readonly icons = { LucideCopy, LucideKeyRound }
protected user: UserType
protected userAvatar: string = null
@@ -67,7 +77,14 @@ export class UserAccountComponent implements OnInit, OnDestroy {
protected newPassword: string
protected readonly store = inject(StoreService)
protected showEditorPreference = false
- protected userEditorPreference: keyof FileEditorProviders
+ private readonly onlyOfficeEditorEnabled = this.store.server().files.editors.onlyoffice
+ protected readonly editors: Record<string, NonNullable<UserPreferences['editor']>> = {
+ [COLLABORA_APP_LOCK]: COLLABORA_EDITOR,
+ [this.onlyOfficeEditorEnabled ? ONLY_OFFICE_APP_LOCK : EURO_OFFICE_APP_LOCK]: this.onlyOfficeEditorEnabled
+ ? ONLY_OFFICE_EDITOR
+ : EURO_OFFICE_EDITOR
+ }
+ protected userEditorPreference: UserPreferences['editor'] = null
protected readonly originalOrderKeyValue = originalOrderKeyValue
private readonly layout = inject(LayoutService)
protected languages = this.layout.getLanguages(true)
@@ -76,7 +93,13 @@ export class UserAccountComponent implements OnInit, OnDestroy {
private subscriptions: Subscription[] = []
constructor() {
- this.subscriptions.push(this.store.user.subscribe((user: UserType) => (this.user = user)))
+ this.subscriptions.push(
+ this.store.user.subscribe((user: UserType) => {
+ this.user = user
+ const preference = user?.preferences?.editor
+ this.userEditorPreference = preference && Object.values(this.editors).includes(preference) ? preference : null
+ })
+ )
this.subscriptions.push(this.store.userAvatarUrl.subscribe((avatarUrl) => (this.userAvatar = avatarUrl)))
this.layout.setBreadcrumbIcon(USER_ICON.ACCOUNT)
this.layout.setBreadcrumbNav({
@@ -87,19 +110,6 @@ export class UserAccountComponent implements OnInit, OnDestroy {
})
this.showEditorPreference =
this.store.server().files.editors.collabora && (this.store.server().files.editors.onlyoffice || this.store.server().files.editors.eurooffice)
- if (this.showEditorPreference) {
- const preference = this.userService.getEditorProviderPreference()
- this.userEditorPreference = Object.values(this.editors).includes(preference) ? preference : null
- }
- }
-
- protected get editors(): Record<string, keyof FileEditorProviders> {
- return {
- [COLLABORA_APP_LOCK]: 'collabora',
- [this.store.server().files.editors.onlyoffice ? ONLY_OFFICE_APP_LOCK : 'Euro-Office']: this.store.server().files.editors.onlyoffice
- ? 'onlyoffice'
- : 'eurooffice'
- }
}
get language() {
@@ -198,8 +208,12 @@ export class UserAccountComponent implements OnInit, OnDestroy {
this.layout.sendNotification('info', 'Link copied', this.webdavUrl)
}
- updateEditorPreference(preference: keyof FileEditorProviders | null) {
- this.userService.setEditorProviderPreference(preference)
+ updateTheme(theme: UserPreferences['theme']) {
+ this.userService.changePreferences({ theme }).subscribe()
+ }
+
+ updateEditorPreference(editor: UserPreferences['editor']) {
+ this.userService.changePreferences({ editor }).subscribe()
}
async enable2Fa() {
diff --git a/frontend/src/app/applications/users/user.service.ts b/frontend/src/app/applications/users/user.service.ts
index ac844f0f..e67484b0 100644
--- a/frontend/src/app/applications/users/user.service.ts
+++ b/frontend/src/app/applications/users/user.service.ts
@@ -1,6 +1,5 @@
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http'
import { inject, Injectable } from '@angular/core'
-import type { FileEditorProviders } from '@sync-in-server/backend/src/applications/files/editors/file-editor-providers.interface'
import { NOTIFICATIONS_WS } from '@sync-in-server/backend/src/applications/notifications/constants/websocket'
import { SPACE_OPERATION } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
import { SYNC_ROUTE } from '@sync-in-server/backend/src/applications/sync/constants/routes'
@@ -16,6 +15,7 @@ import {
API_USERS_MY_LANGUAGE,
API_USERS_MY_NOTIFICATION,
API_USERS_MY_PASSWORD,
+ API_USERS_MY_PREFERENCES,
API_USERS_MY_STORAGE_INDEXING,
USERS_ROUTE
} from '@sync-in-server/backend/src/applications/users/constants/routes'
@@ -32,6 +32,7 @@ import {
UserAppPasswordDto,
UserLanguageDto,
UserNotificationDto,
+ UserPreferencesDto,
UserStorageIndexingDto,
UserUpdatePasswordDto
} from '@sync-in-server/backend/src/applications/users/dto/user-properties.dto'
@@ -39,6 +40,7 @@ import type { GroupBrowse } from '@sync-in-server/backend/src/applications/users
import type { GroupMember } from '@sync-in-server/backend/src/applications/users/interfaces/group-member'
import type { GuestUser } from '@sync-in-server/backend/src/applications/users/interfaces/guest-user.interface'
import type { Member } from '@sync-in-server/backend/src/applications/users/interfaces/member.interface'
+import type { UserPreferences } from '@sync-in-server/backend/src/applications/users/interfaces/user-preferences.interface'
import type { UserAppPassword } from '@sync-in-server/backend/src/applications/users/interfaces/user-secrets.interface'
import type {
EventChangeOnlineStatus,
@@ -55,7 +57,7 @@ import type {
} from '@sync-in-server/backend/src/authentication/providers/two-fa/auth-two-fa.interfaces'
import { BsModalRef } from 'ngx-bootstrap/modal'
import { Socket } from 'ngx-socket-io'
-import { catchError, map, Observable, of } from 'rxjs'
+import { catchError, EMPTY, map, Observable, of, tap } from 'rxjs'
import { AppMenu, AppMenuEntry, isAppMenu, isAppMenuSeparator } from '../../layout/layout.interfaces'
import { LayoutService } from '../../layout/layout.service'
import { StoreService } from '../../store/store.service'
@@ -100,6 +102,7 @@ export class UserService {
initUser(user: UserType, impersonate = false) {
this.refreshAvatar()
this.layout.setLanguage(user.language).catch(console.error)
+ if (!user.isLink) this.layout.setThemePreference(user.preferences.theme)
this.store.userImpersonate.set(impersonate || user.impersonated)
this.store.user.next(user)
this.checkQuota(this.user)
@@ -115,7 +118,10 @@ export class UserService {
refreshUser() {
this.loadUser().subscribe({
- next: (r: Omit<LoginResponseDto, 'token'>) => this.store.user.next(r.user),
+ next: (r: Omit<LoginResponseDto, 'token'>) => {
+ if (!r.user.isLink) this.layout.setThemePreference(r.user.preferences.theme)
+ this.store.user.next(r.user)
+ },
error: (e: HttpErrorResponse) => console.error(e)
})
}
@@ -239,6 +245,24 @@ export class UserService {
return this.http.put(API_USERS_MY_NOTIFICATION, userNotificationDto)
}
+ changePreferences(patch: UserPreferencesDto): Observable<UserPreferences> {
+ const userId = this.user.id
+ return this.http.patch<UserPreferences>(API_USERS_MY_PREFERENCES, patch).pipe(
+ catchError((e: HttpErrorResponse) => {
+ const message = patch.theme !== undefined ? 'Unable to update theme preference' : 'Unable to update editor preference'
+ this.layout.sendNotification('error', 'Configuration', message, e)
+ return EMPTY
+ }),
+ tap(() => {
+ const user = this.user
+ if (user?.id !== userId) return
+ const preferences = { ...user.preferences, ...patch }
+ this.store.user.next({ ...user, preferences })
+ if (patch.theme !== undefined) this.layout.setThemePreference(preferences.theme)
+ })
+ )
+ }
+
changeStorageIndexing(userStorageIndexingDto: UserStorageIndexingDto): Observable<any> {
return this.http.put(API_USERS_MY_STORAGE_INDEXING, userStorageIndexingDto)
}
@@ -317,16 +341,12 @@ export class UserService {
})
}
- getEditorProviderPreference(): keyof FileEditorProviders {
- return localStorage.getItem('editorPreference') as keyof FileEditorProviders
+ getEditorProviderPreference(): UserPreferences['editor'] {
+ return this.user?.preferences?.editor ?? null
}
- setEditorProviderPreference(editorProvider: keyof FileEditorProviders) {
- if (editorProvider === null) {
- localStorage.removeItem('editorPreference')
- } else {
- localStorage.setItem('editorPreference', editorProvider)
- }
+ setEditorProviderPreference(editorProvider: UserPreferences['editor']) {
+ this.changePreferences({ editor: editorProvider }).subscribe()
}
listAppPasswords(): Observable<Omit<UserAppPassword, 'password'>[]> {
diff --git a/frontend/src/app/layout/layout.constants.ts b/frontend/src/app/layout/layout.constants.ts
index 3f81626d..75397b1a 100644
--- a/frontend/src/app/layout/layout.constants.ts
+++ b/frontend/src/app/layout/layout.constants.ts
@@ -1,4 +1,13 @@
+import { LucideContrast, LucideMoon, LucideSun } from '@lucide/angular'
+import { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
+
export const tableTrSelectedClass = '.selected'
export const dragClass = 'drag-over'
export const defaultCardImageSize = 80
export const defaultResizeOffset = 85
+
+export const THEME_OPTIONS = [
+ { value: USER_THEME.AUTO, label: 'Auto', icon: LucideContrast },
+ { value: USER_THEME.DARK, label: 'Dark', icon: LucideMoon },
+ { value: USER_THEME.LIGHT, label: 'Light', icon: LucideSun }
+] as const
diff --git a/frontend/src/app/layout/layout.service.ts b/frontend/src/app/layout/layout.service.ts
index b9b9c56c..136a9fa0 100644
--- a/frontend/src/app/layout/layout.service.ts
+++ b/frontend/src/app/layout/layout.service.ts
@@ -3,6 +3,8 @@ import { inject, Injectable, NgZone, signal, WritableSignal } from '@angular/cor
import { Title } from '@angular/platform-browser'
import type { LucideIcon } from '@lucide/angular'
import { ContextMenuComponent, ContextMenuService } from '@perfectmemory/ngx-contextmenu'
+import { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
+import type { UserTheme } from '@sync-in-server/backend/src/applications/users/interfaces/user-preferences.interface'
import { L10nTranslationService } from 'angular-l10n'
import { BsModalRef, BsModalService, ModalContainerComponent, ModalOptions } from 'ngx-bootstrap/modal'
import { setTheme } from 'ngx-bootstrap/utils'
@@ -29,7 +31,7 @@ export class LayoutService {
public currentRightSideBarTab: string | null = null
// Resize event
public resizeEvent = new BehaviorSubject<void | null>(null)
- public switchTheme = new BehaviorSubject<string>(sessionStorage.getItem('themeMode') || getTheme())
+ public switchTheme = new BehaviorSubject<string>(getTheme())
// Toggle Left sidebar tabs (1: open / 2: collapse / 3: toggle)
public toggleLeftSideBar = new BehaviorSubject<number>(this.isSmallerMediumScreen() ? 2 : 1)
// Left sidebar: save user action
@@ -53,6 +55,7 @@ export class LayoutService {
public windows = new BehaviorSubject<AppWindow[]>([]) // minimized modals
public modalRefs = new Map<number | string, BsModalRef>()
public collapseRSideBarPreference: WritableSignal<boolean> = signal(this.getAutoCollapseRSideBarPreference())
+ public readonly themePreference = signal<USER_THEME>(USER_THEME.AUTO)
// Services
private readonly title = inject(Title)
private readonly ngZone = inject(NgZone)
@@ -86,7 +89,9 @@ export class LayoutService {
constructor() {
setTheme('bs5')
this.title.setTitle(APP_NAME)
- this.preferTheme.subscribe((theme) => this.setTheme(theme))
+ this.preferTheme.subscribe((theme) => {
+ if (this.themePreference() === USER_THEME.AUTO) this.setTheme(theme)
+ })
}
showRSideBarTab(tabName: TAB_MENU = null, tabVisible = false, delay: number = 0) {
@@ -140,8 +145,8 @@ export class LayoutService {
return window.innerWidth !== 0 && window.innerWidth < this.screenMediumSize
}
- toggleTheme() {
- this.setTheme(this.switchTheme.getValue() === themeLight ? themeDark : themeLight)
+ getCurrentTheme(): UserTheme {
+ return this.switchTheme.getValue() === themeDark ? USER_THEME.DARK : USER_THEME.LIGHT
}
openDialog(dialog: any, size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full', componentState: any = {}, override: ModalOptions = {}): BsModalRef {
@@ -296,6 +301,7 @@ export class LayoutService {
clean() {
this.toggleRSideBar(false)
this.closeDialog(null, null, true)
+ this.setThemePreference(USER_THEME.AUTO)
}
setAutoCollapseRSideBarPreference(preference: boolean) {
@@ -306,6 +312,11 @@ export class LayoutService {
}
}
+ setThemePreference(theme: USER_THEME) {
+ this.themePreference.set(theme)
+ this.setTheme(theme === USER_THEME.AUTO ? getTheme() : theme === USER_THEME.DARK ? themeDark : themeLight)
+ }
+
private openModalWithEffect(modal: ModalComponent) {
this.bsModal['_renderer'].setAttribute(modal['instance']._element.nativeElement, 'aria-hidden', 'false')
this.bsModal['_renderer'].setStyle(modal['instance']._element.nativeElement, 'display', 'block')
@@ -376,7 +387,6 @@ export class LayoutService {
private setTheme(theme: string) {
this.electron.send(EVENT.MISC.SWITCH_THEME, theme)
this.ngZone.run(() => this.switchTheme.next(theme))
- sessionStorage.setItem('themeMode', theme)
}
private getAutoCollapseRSideBarPreference(): boolean {
diff --git a/frontend/src/app/layout/theme-switch.component.ts b/frontend/src/app/layout/theme-switch.component.ts
new file mode 100644
index 00000000..2e48d5e4
--- /dev/null
+++ b/frontend/src/app/layout/theme-switch.component.ts
@@ -0,0 +1,35 @@
+import { Component, computed, inject, input, output } from '@angular/core'
+import { LucideDynamicIcon } from '@lucide/angular'
+import type { USER_THEME } from '@sync-in-server/backend/src/applications/users/constants/user-preferences'
+import { L10N_LOCALE, L10nLocale, L10nTranslatePipe } from 'angular-l10n'
+import { THEME_OPTIONS } from './layout.constants'
+import { LayoutService } from './layout.service'
+
+@Component({
+ selector: 'app-theme-switch',
+ imports: [LucideDynamicIcon, L10nTranslatePipe],
+ template: `
+ <button
+ type="button"
+ [class]="buttonClass()"
+ [attr.aria-label]="('Theme' | translate: locale.language) + ': ' + (currentOption().label | translate: locale.language)"
+ [title]="('Theme' | translate: locale.language) + ': ' + (currentOption().label | translate: locale.language)"
+ (click)="switchTheme()"
+ >
+ <svg [lucideIcon]="currentOption().icon"></svg>
+ </button>
+ `
+})
+export class ThemeSwitchComponent {
+ buttonClass = input('btn btn-default')
+ themeChange = output<USER_THEME>()
+ protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
+ private readonly layout = inject(LayoutService)
+ protected readonly currentOption = computed(
+ () => THEME_OPTIONS.find((option) => option.value === this.layout.themePreference()) ?? THEME_OPTIONS[0]
+ )
+ protected switchTheme() {
+ const index = THEME_OPTIONS.indexOf(this.currentOption())
+ this.themeChange.emit(THEME_OPTIONS[(index + 1) % THEME_OPTIONS.length].value)
+ }
+}
diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json
index f5e7e5c6..20a83f8f 100644
--- a/frontend/src/i18n/de.json
+++ b/frontend/src/i18n/de.json
@@ -740,6 +740,12 @@
"stopping": "wird gestoppt",
"idle": "leerlauf",
"Preferences": "Einstellungen",
+ "Theme": "Design",
+ "Auto": "Automatisch",
+ "Light": "Hell",
+ "Dark": "Dunkel",
+ "Unable to update theme preference": "Die Designeinstellung konnte nicht aktualisiert werden",
+ "Unable to update editor preference": "Die Editoreinstellung konnte nicht aktualisiert werden",
"of": "von",
"Sidebar auto-hide enabled": "Automatisches Ausblenden der Seitenleiste aktiviert",
"Sidebar pinned": "Seitenleiste angeheftet",
diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.json
index 3686746a..448b67fb 100644
--- a/frontend/src/i18n/es.json
+++ b/frontend/src/i18n/es.json
@@ -740,6 +740,12 @@
"stopping": "deteniendo",
"idle": "inactivo",
"Preferences": "Preferencias",
+ "Theme": "Tema",
+ "Auto": "Automático",
+ "Light": "Claro",
+ "Dark": "Oscuro",
+ "Unable to update theme preference": "No se pudo actualizar la preferencia de tema",
+ "Unable to update editor preference": "No se pudo actualizar la preferencia de editor",
"of": "de",
"Sidebar auto-hide enabled": "Ocultación automática de la barra lateral activada",
"Sidebar pinned": "Barra lateral fijada",
diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json
index 07e46d4d..0d68b3fa 100644
--- a/frontend/src/i18n/fr.json
+++ b/frontend/src/i18n/fr.json
@@ -740,6 +740,12 @@
"stopping": "arrêt en cours",
"idle": "inactif",
"Preferences": "Préférences",
+ "Theme": "Thème",
+ "Auto": "Automatique",
+ "Light": "Clair",
+ "Dark": "Sombre",
+ "Unable to update theme preference": "Impossible de mettre à jour la préférence de thème",
+ "Unable to update editor preference": "Impossible de mettre à jour la préférence d’éditeur",
"of": "de",
"Sidebar auto-hide enabled": "Masquage automatique de la barre latérale activé",
"Sidebar pinned": "Barre latérale épinglée",
diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.json
index 22ea1d94..80fa0c9e 100644
--- a/frontend/src/i18n/hi.json
+++ b/frontend/src/i18n/hi.json
@@ -740,6 +740,12 @@
"stopping": "रोका जा रहा है",
"idle": "निष्क्रिय",
"Preferences": "वरीयताएँ",
+ "Theme": "थीम",
+ "Auto": "स्वचालित",
+ "Light": "लाइट",
+ "Dark": "डार्क",
+ "Unable to update theme preference": "थीम की प्राथमिकता अपडेट नहीं की जा सकी",
+ "Unable to update editor preference": "संपादक की प्राथमिकता अपडेट नहीं की जा सकी",
"of": "का",
"Sidebar auto-hide enabled": "साइडबार स्वतः छिपाना सक्षम",
"Sidebar pinned": "साइडबार पिन किया गया",
diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.json
index e43bdf66..d1157e98 100644
--- a/frontend/src/i18n/it.json
+++ b/frontend/src/i18n/it.json
@@ -740,6 +740,12 @@
"stopping": "in arresto",
"idle": "inattivo",
"Preferences": "Preferenze",
+ "Theme": "Tema",
+ "Auto": "Automatico",
+ "Light": "Chiaro",
+ "Dark": "Scuro",
+ "Unable to update theme preference": "Impossibile aggiornare la preferenza del tema",
+ "Unable to update editor preference": "Impossibile aggiornare la preferenza dell'editor",
"of": "di",
"Sidebar auto-hide enabled": "Nascondimento automatico della barra laterale attivato",
"Sidebar pinned": "Barra laterale bloccata",
diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.json
index 9fe71f90..05416d5e 100644
--- a/frontend/src/i18n/ja.json
+++ b/frontend/src/i18n/ja.json
@@ -740,6 +740,12 @@
"stopping": "停止中",
"idle": "待機中",
"Preferences": "環境設定",
+ "Theme": "テーマ",
+ "Auto": "自動",
+ "Light": "ライト",
+ "Dark": "ダーク",
+ "Unable to update theme preference": "テーマ設定を更新できませんでした",
+ "Unable to update editor preference": "エディタ設定を更新できませんでした",
"of": "の",
"Sidebar auto-hide enabled": "サイドバー自動非表示が有効",
"Sidebar pinned": "サイドバー固定",
diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.json
index 0a794889..f2ada728 100644
--- a/frontend/src/i18n/ko.json
+++ b/frontend/src/i18n/ko.json
@@ -740,6 +740,12 @@
"stopping": "중지 중",
"idle": "유휴",
"Preferences": "환경 설정",
+ "Theme": "테마",
+ "Auto": "자동",
+ "Light": "라이트",
+ "Dark": "다크",
+ "Unable to update theme preference": "테마 설정을 업데이트할 수 없습니다",
+ "Unable to update editor preference": "편집기 설정을 업데이트할 수 없습니다",
"of": "의",
"Sidebar auto-hide enabled": "사이드바 자동 숨김 활성화",
"Sidebar pinned": "사이드바 고정됨",
diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.json
index 0d05bce2..a2473ec3 100644
--- a/frontend/src/i18n/nl.json
+++ b/frontend/src/i18n/nl.json
@@ -740,6 +740,12 @@
"stopping": "bezig met stoppen",
"idle": "inactief",
"Preferences": "Voorkeuren",
+ "Theme": "Thema",
+ "Auto": "Automatisch",
+ "Light": "Licht",
+ "Dark": "Donker",
+ "Unable to update theme preference": "Kan de themavoorkeur niet bijwerken",
+ "Unable to update editor preference": "Kan de editorvoorkeur niet bijwerken",
"of": "van",
"Sidebar auto-hide enabled": "Zijbalk automatisch verbergen ingeschakeld",
"Sidebar pinned": "Zijbalk vastgemaakt",
diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.json
index 2dcbf522..3b184dc0 100644
--- a/frontend/src/i18n/pl.json
+++ b/frontend/src/i18n/pl.json
@@ -740,6 +740,12 @@
"stopping": "zatrzymywanie",
"idle": "bezczynny",
"Preferences": "Preferencje",
+ "Theme": "Motyw",
+ "Auto": "Automatyczny",
+ "Light": "Jasny",
+ "Dark": "Ciemny",
+ "Unable to update theme preference": "Nie można zaktualizować preferencji motywu",
+ "Unable to update editor preference": "Nie można zaktualizować preferencji edytora",
"of": "z",
"Sidebar auto-hide enabled": "Włączono automatyczne ukrywanie panelu bocznego",
"Sidebar pinned": "Panel boczny przypięty",
diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.json
index 53df4bd0..c3d75b57 100644
--- a/frontend/src/i18n/pt-BR.json
+++ b/frontend/src/i18n/pt-BR.json
@@ -740,6 +740,12 @@
"stopping": "parando",
"idle": "inativo",
"Preferences": "Preferências",
+ "Theme": "Tema",
+ "Auto": "Automático",
+ "Light": "Claro",
+ "Dark": "Escuro",
+ "Unable to update theme preference": "Não foi possível atualizar a preferência de tema",
+ "Unable to update editor preference": "Não foi possível atualizar a preferência de editor",
"of": "de",
"Sidebar auto-hide enabled": "Ocultação automática da barra lateral ativada",
"Sidebar pinned": "Barra lateral fixada",
diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.json
index 41da7d2a..c2c54c05 100644
--- a/frontend/src/i18n/pt.json
+++ b/frontend/src/i18n/pt.json
@@ -740,6 +740,12 @@
"stopping": "a parar",
"idle": "inativo",
"Preferences": "Preferências",
+ "Theme": "Tema",
+ "Auto": "Automático",
+ "Light": "Claro",
+ "Dark": "Escuro",
+ "Unable to update theme preference": "Não foi possível atualizar a preferência do tema",
+ "Unable to update editor preference": "Não foi possível atualizar a preferência do editor",
"of": "de",
"Sidebar auto-hide enabled": "Ocultação automática da barra lateral ativada",
"Sidebar pinned": "Barra lateral fixa",
diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json
index f9faf3a8..2f7f9e7d 100644
--- a/frontend/src/i18n/ru.json
+++ b/frontend/src/i18n/ru.json
@@ -740,6 +740,12 @@
"stopping": "останавливается",
"idle": "ожидание",
"Preferences": "Настройки",
+ "Theme": "Тема",
+ "Auto": "Автоматически",
+ "Light": "Светлая",
+ "Dark": "Тёмная",
+ "Unable to update theme preference": "Не удалось обновить настройку темы",
+ "Unable to update editor preference": "Не удалось обновить настройку редактора",
"of": "из",
"Sidebar auto-hide enabled": "Автоскрытие боковой панели включено",
"Sidebar pinned": "Боковая панель закреплена",
diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.json
index ee11bf5c..4f77438c 100644
--- a/frontend/src/i18n/tr.json
+++ b/frontend/src/i18n/tr.json
@@ -740,6 +740,12 @@
"stopping": "durduruluyor",
"idle": "boşta",
"Preferences": "Tercihler",
+ "Theme": "Tema",
+ "Auto": "Otomatik",
+ "Light": "Açık",
+ "Dark": "Koyu",
+ "Unable to update theme preference": "Tema tercihi güncellenemedi",
+ "Unable to update editor preference": "Düzenleyici tercihi güncellenemedi",
"of": "/",
"Sidebar auto-hide enabled": "Kenar çubuğu otomatik gizleme etkin",
"Sidebar pinned": "Kenar çubuğu sabitlendi",
diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.json
index 50a538b7..04b616e1 100644
--- a/frontend/src/i18n/zh.json
+++ b/frontend/src/i18n/zh.json
@@ -740,6 +740,12 @@
"stopping": "停止中",
"idle": "空闲",
"Preferences": "偏好设置",
+ "Theme": "主题",
+ "Auto": "自动",
+ "Light": "浅色",
+ "Dark": "深色",
+ "Unable to update theme preference": "无法更新主题偏好设置",
+ "Unable to update editor preference": "无法更新编辑器偏好设置",
"of": "的",
"Sidebar auto-hide enabled": "侧边栏自动隐藏已启用",
"Sidebar pinned": "侧边栏已固定",