Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
feat(admin): allow managing spaces from the admin section
johaven9822209934c6
diff --git a/backend/src/applications/links/services/links-queries.service.ts b/backend/src/applications/links/services/links-queries.service.tsindex 2a91f683..e3d2cbc6 100644--- a/backend/src/applications/links/services/links-queries.service.ts+++ b/backend/src/applications/links/services/links-queries.service.ts@@ -16,6 +16,7 @@ import { spacesMembers } from '../../spaces/schemas/spaces-members.schema'import { spacesRoots } from '../../spaces/schemas/spaces-roots.schema'import { spaces } from '../../spaces/schemas/spaces.schema'import { USER_ROLE } from '../../users/constants/user'+import { UserModel } from '../../users/models/user.model'import type { User } from '../../users/schemas/user.interface'import { userFullNameSQL, users } from '../../users/schemas/users.schema'import { CACHE_LINK_UUID_PREFIX, CACHE_LINK_UUID_TTL } from '../constants/cache'@@ -32,7 +33,7 @@ export class LinksQueries {private readonly cache: Cache) {}- async linkFromShare(ownerId: number, linkId: number, shareId: number, isAdmin: number = 0): Promise<LinkGuest> {+ async linkFromShare(owner: UserModel, linkId: number, shareId: number): Promise<LinkGuest> {const [r] = await this.db.select({...getTableColumns(links),@@ -41,7 +42,7 @@ export class LinksQueries {isActive: users.isActive}).from(links)- .innerJoin(shares, and(eq(shares.id, shareId), or(eq(shares.ownerId, ownerId), and(eq(sql`${isAdmin}`, 1), isNull(shares.ownerId)))))+ .innerJoin(shares, and(eq(shares.id, shareId), or(eq(shares.ownerId, owner.id), eq(sql`${+owner.isAdmin}`, 1)))).innerJoin(sharesMembers, and(eq(sharesMembers.shareId, shares.id), eq(sharesMembers.userId, links.userId), eq(sharesMembers.linkId, linkId))).innerJoin(users, eq(users.id, links.userId)).where(eq(links.id, linkId))@@ -49,8 +50,9 @@ export class LinksQueries {return r as LinkGuest}- async linkFromSpace(managerId: number, linkId: number, spaceId: number): Promise<LinkGuest> {+ async linkFromSpace(manager: UserModel, linkId: number, spaceId: number): Promise<LinkGuest> {const linkMember: any = alias(spacesMembers, 'linkMember')+ const managerMember: any = alias(spacesMembers, 'managerMember')const [r] = await this.db.select({...getTableColumns(links),@@ -59,13 +61,13 @@ export class LinksQueries {isActive: users.isActive}).from(links)- .innerJoin(- spacesMembers,- and(eq(spacesMembers.spaceId, spaceId), eq(spacesMembers.userId, managerId), eq(spacesMembers.role, SPACE_ROLE.IS_MANAGER))+ .innerJoin(linkMember, and(eq(linkMember.spaceId, spaceId), eq(linkMember.userId, links.userId), eq(linkMember.linkId, linkId)))+ .leftJoin(+ managerMember,+ and(eq(managerMember.spaceId, linkMember.spaceId), eq(managerMember.userId, manager.id), eq(managerMember.role, SPACE_ROLE.IS_MANAGER)))- .innerJoin(linkMember, and(eq(linkMember.spaceId, spacesMembers.spaceId), eq(linkMember.userId, links.userId), eq(linkMember.linkId, linkId))).innerJoin(users, eq(users.id, links.userId))- .where(eq(links.id, linkId))+ .where(and(eq(links.id, linkId), or(eq(sql`${+manager.isAdmin}`, 1), isNotNull(managerMember.userId)))).limit(1)return r as LinkGuest}diff --git a/backend/src/applications/shares/services/shares-manager.service.ts b/backend/src/applications/shares/services/shares-manager.service.tsindex 14bc8cfe..13bb7823 100644--- a/backend/src/applications/shares/services/shares-manager.service.ts+++ b/backend/src/applications/shares/services/shares-manager.service.ts@@ -79,13 +79,16 @@ export class SharesManager {}async setAllowedPermissions(user: UserModel, share: ShareProps | ShareLink, asAdmin = false) {+ // Computes the effective maximum permissions on the shared file target (or on the share owner when `asOwner` is true)+ // to safely restrict delegated member/link permissions.if (share.file?.ownerId === user.id || (share.externalPath && user.isAdmin)) {// current user is the file owner (personal space case)share.file.permissions = SHARE_ALL_OPERATIONS} else if (share.file?.space?.alias) {share.file.ownerId = null// retrieve space permissions (cached query)- const spacePermissions: Partial<SpaceEnv> = await this.spacesQueries.permissions(user.id, share.file.space.alias, share.file.space.root?.alias)+ const userId = asAdmin ? share.ownerId : user.id+ const spacePermissions: Partial<SpaceEnv> = await this.spacesQueries.permissions(userId, share.file.space.alias, share.file.space.root?.alias)if (!spacePermissions) {this.logger.warn({ tag: this.setAllowedPermissions.name, msg: `missing space permissions : ${JSON.stringify(share)}` })throw new HttpException('Space not found', HttpStatus.NOT_FOUND)@@ -111,7 +114,7 @@ export class SharesManager {}async getShareWithMembers(user: UserModel, shareId: number, asAdmin = false): Promise<ShareProps> {- // asAdmin : true if the user is the owner of the parent share or if the share is requested from the administration+ // asAdmin: true if the user is the owner of the parent share or if the share is requested from the administrationconst share: ShareProps = await this.sharesQueries.getShareWithMembers(user, shareId, asAdmin)if (!share) {throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)@@ -538,7 +541,7 @@ export class SharesManager {if (!shareLink) {throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)}- await this.setAllowedPermissions(user, shareLink)+ await this.setAllowedPermissions(user, shareLink, asAdmin)if (shareLink.file?.permissions) {// share link does not have these permissionsshareLink.file.permissions = removePermissions(shareLink.file.permissions, [SPACE_OPERATION.SHARE_INSIDE, SPACE_OPERATION.SHARE_OUTSIDE])@@ -549,9 +552,9 @@ export class SharesManager {async getLinkFromSpaceOrShare(user: UserModel, linkId: number, spaceOrShareId: number, type: LINK_TYPE): Promise<LinkGuest> {let linkGuest: LinkGuestif (type === LINK_TYPE.SPACE) {- linkGuest = await this.linksQueries.linkFromSpace(user.id, linkId, spaceOrShareId)+ linkGuest = await this.linksQueries.linkFromSpace(user, linkId, spaceOrShareId)} else {- linkGuest = await this.linksQueries.linkFromShare(user.id, linkId, spaceOrShareId, +user.isAdmin)+ linkGuest = await this.linksQueries.linkFromShare(user, linkId, spaceOrShareId)}if (!linkGuest) {this.logger.warn({ tag: this.getLinkFromSpaceOrShare.name, msg: `unable to find link (${linkId}) on ${type} (${spaceOrShareId})` })@@ -635,7 +638,7 @@ export class SharesManager {}breakcase 'permissions':- if (fromAPI) {+ if (fromAPI && type === LINK_TYPE.SHARE) {// permissions are only present if the share type is link// intersect permissions to ensure that the user does not attempt to exceed his rightsconst shareLink: ShareLink = await this.getShareLink(user, spaceOrShareId)diff --git a/backend/src/applications/shares/services/shares-queries.service.ts b/backend/src/applications/shares/services/shares-queries.service.tsindex 8c1c8229..df038c19 100644--- a/backend/src/applications/shares/services/shares-queries.service.ts+++ b/backend/src/applications/shares/services/shares-queries.service.ts@@ -155,9 +155,7 @@ export class SharesQueries {}async listShareLinks(user: UserModel, shareId: number, asAdmin?: boolean): Promise<ShareLink>-async listShareLinks(user: UserModel, shareId?: number, asAdmin?: boolean): Promise<ShareLink[]>-async listShareLinks(user: UserModel, shareId?: number, asAdmin: boolean = false): Promise<ShareLink[] | ShareLink> {if (!this.shareLinksListQuery) {const [selectFile, shareRootFile, parentShare, parentShareFile, childShareFromRoot, shareMembers] = this.shareFileSelect()diff --git a/backend/src/applications/spaces/constants/routes.ts b/backend/src/applications/spaces/constants/routes.tsindex 9cb21f7c..5e1435fa 100644--- a/backend/src/applications/spaces/constants/routes.ts+++ b/backend/src/applications/spaces/constants/routes.ts@@ -4,6 +4,7 @@ import { SPACE_REPOSITORY } from './spaces'export const SPACES_BASE_ROUTE = 'spaces'export const SPACES_ROUTE = {BASE: `${APP_BASE_ROUTE}/${SPACES_BASE_ROUTE}`,+ ADMIN: 'admin',BROWSE: 'browse',TREE: 'tree',LIST: 'list',@@ -17,5 +18,6 @@ export const SPACES_ROUTE = {export const API_SPACES_BROWSE = `${SPACES_ROUTE.BASE}/${SPACES_ROUTE.BROWSE}`export const API_SPACES_TREE = `${SPACES_ROUTE.BASE}/${SPACES_ROUTE.TREE}`export const API_SPACES_LIST = `${SPACES_ROUTE.BASE}/${SPACES_ROUTE.LIST}`+export const API_ADMIN_SPACES_LIST = `${SPACES_ROUTE.BASE}/${SPACES_ROUTE.ADMIN}/${SPACES_ROUTE.LIST}`export const API_SPACES_TRASH_BINS_LIST = `${SPACES_ROUTE.BASE}/${SPACES_ROUTE.TRASH}/${SPACES_ROUTE.LIST}`export const API_SPACES_ROOT_CHECK = `${SPACES_ROUTE.BASE}/${SPACES_ROUTE.ROOT_CHECK}`diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.tsindex 779a2519..a8e59b81 100644--- a/backend/src/applications/spaces/services/spaces-manager.service.ts+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts@@ -67,6 +67,10 @@ export class SpacesManager {return this.spacesQueries.spaces(userId)}+ listSpacesAsAdmin(): Promise<SpaceProps[]> {+ return this.spacesQueries.spacesAsAdmin()+ }+spacesWithDetails(userId: number): Promise<SpaceProps[]> {return this.spacesQueries.spacesWithDetails(userId)}@@ -190,7 +194,7 @@ export class SpacesManager {}async getSpace(user: UserModel, spaceId: number): Promise<SpaceProps> {- const space: SpaceProps = await this.userCanAccessSpace(user.id, spaceId, true)+ const space: SpaceProps = await this.userCanAccessSpace(user, spaceId, true)if (space.roots?.length && !user.isAdmin) {// remove external path if the current user is not an administratorfor (const root of space.roots) {@@ -226,12 +230,12 @@ export class SpacesManager {await this.updateMembers(user, space, createOrUpdateSpaceDto.members.concat(createOrUpdateSpaceDto.managers))// create links after members, user must be a space manager to create linksawait this.sharesManager.createOrUpdateLinksAsMembers(user, space, LINK_TYPE.SPACE, createOrUpdateSpaceDto.links)- return this.spacesQueries.getSpaceAsManager(user.id, space.id)+ return this.spacesQueries.getSpaceAsAdminOrManager(user, space.id)}async updateSpace(user: UserModel, spaceId: number, createOrUpdateSpaceDto: CreateOrUpdateSpaceDto): Promise<SpaceProps> {/* only managers of the space can update it */- const space: SpaceProps = await this.userCanAccessSpace(user.id, spaceId, true)+ const space: SpaceProps = await this.userCanAccessSpace(user, spaceId, true)// check and update space infoconst spaceDiffProps: Partial<SpaceProps> = { modifiedAt: new Date() }const props: (keyof CreateOrUpdateSpaceDto)[] = ['name', 'description', 'enabled', 'storageQuota', 'storageIndexing']@@ -279,13 +283,13 @@ export class SpacesManager {// current manager was removedreturn null} else {- return this.spacesQueries.getSpaceAsManager(user.id, spaceId)+ return this.spacesQueries.getSpaceAsAdminOrManager(user, spaceId)}}async deleteSpace(user: UserModel, spaceId: number, deleteSpaceDto?: DeleteSpaceDto) {/* only managers of the space can disable it */- const space: SpaceProps = await this.userCanAccessSpace(user.id, spaceId, true)+ const space: SpaceProps = await this.userCanAccessSpace(user, spaceId, true)// only admin can delete the space data, managers can only disable the space for 30 daysconst deleteNow: boolean = user.isAdmin && !!deleteSpaceDto?.deleteNowtry {@@ -306,7 +310,7 @@ export class SpacesManager {}async updateUserRoots(user: UserModel, spaceId: number, userRoots: SpaceRootProps[], addOnly: boolean = false): Promise<SpaceRootProps[]> {- const space: Partial<SpaceProps> = await this.userCanAccessSpace(user.id, spaceId)+ const space: Partial<SpaceProps> = await this.userCanAccessSpace(user, spaceId)if (space.role !== SPACE_ROLE.IS_MANAGER && !haveSpacePermission(space, SPACE_OPERATION.SHARE_INSIDE)) {this.logger.warn({ tag: this.updateUserRoots.name, msg: `is not allowed to share inside on this space : *${space.alias}* (${space.id})` })throw new HttpException('You are not allowed to do this action', HttpStatus.FORBIDDEN)@@ -452,31 +456,31 @@ export class SpacesManager {}async listSpaceShares(user: UserModel, spaceId: number): Promise<ShareChild[]> {- if (await this.userIsSpaceManager(user, spaceId)) {+ if (await this.userIsAdminOrSpaceManager(user, spaceId)) {return this.sharesManager.listSpaceShares(spaceId)}}async getSpaceShare(user: UserModel, spaceId: number, shareId: number): Promise<ShareProps> {- if (await this.userIsSpaceManager(user, spaceId, shareId)) {+ if (await this.userIsAdminOrSpaceManager(user, spaceId, shareId)) {return this.sharesManager.getShareWithMembers(user, shareId, true)}}async updateSpaceShare(user: UserModel, spaceId: number, shareId: number, createOrUpdateShareDto: CreateOrUpdateShareDto): Promise<ShareProps> {- if (await this.userIsSpaceManager(user, spaceId, shareId)) {+ if (await this.userIsAdminOrSpaceManager(user, spaceId, shareId)) {return this.sharesManager.updateShare(user, shareId, createOrUpdateShareDto, true)}}async deleteSpaceShare(user: UserModel, spaceId: number, shareId: number): Promise<void> {- if (await this.userIsSpaceManager(user, spaceId, shareId)) {+ if (await this.userIsAdminOrSpaceManager(user, spaceId, shareId)) {return this.sharesManager.deleteShare(user, shareId, true)}}async getSpaceShareLink(user: UserModel, spaceId: number, shareId: number): Promise<ShareLink> {- if (await this.userIsSpaceManager(user, spaceId, shareId)) {+ if (await this.userIsAdminOrSpaceManager(user, spaceId, shareId)) {return this.sharesManager.getShareLink(user, shareId, true)}}@@ -796,33 +800,33 @@ export class SpacesManager {return alias}- private async userCanAccessSpace(userId: number, spaceId: number, asManager: true): Promise<SpaceProps>- private async userCanAccessSpace(userId: number, spaceId: number, asManager?: false): Promise<Partial<SpaceProps>>- private async userCanAccessSpace(userId: number, spaceId: number, asManager: boolean = false): Promise<Partial<SpaceProps>> {+ private async userCanAccessSpace(user: UserModel, spaceId: number, asManager: true): Promise<SpaceProps>+ private async userCanAccessSpace(user: UserModel, spaceId: number, asManager?: false): Promise<Partial<SpaceProps>>+ private async userCanAccessSpace(user: UserModel, spaceId: number, asManager: boolean = false): Promise<Partial<SpaceProps>> {if (asManager) {// Get all space details if user is a manager- const space: SpaceProps = await this.spacesQueries.getSpaceAsManager(userId, spaceId)+ const space: SpaceProps = await this.spacesQueries.getSpaceAsAdminOrManager(user, spaceId)if (!space) {- this.logger.warn({ tag: this.userCanAccessSpace.name, msg: `space (${spaceId}) not found or not authorized for user (${userId})` })+ this.logger.warn({ tag: this.userCanAccessSpace.name, msg: `space (${spaceId}) not found or not authorized for user (${user.id})` })throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)}return space} else {- const [space]: SpaceProps[] = await this.spacesQueries.spaces(userId, true, spaceId)+ const [space]: SpaceProps[] = await this.spacesQueries.spaces(user.id, true, spaceId)if (!space) {- this.logger.warn({ tag: this.userCanAccessSpace.name, msg: `space (${spaceId}) not found or not authorized for user (${userId})` })+ this.logger.warn({ tag: this.userCanAccessSpace.name, msg: `space (${spaceId}) not found or not authorized for user (${user.id})` })throw new HttpException('Space not found', HttpStatus.NOT_FOUND)}return space}}- private async userIsSpaceManager(user: UserModel, spaceId: number, shareId?: number): Promise<boolean> {- if (!(await this.spacesQueries.userIsSpaceManager(user.id, spaceId, shareId))) {- this.logger.warn({ tag: this.userIsSpaceManager.name, msg: `space (${spaceId}) not found or not authorized for user (${user.id})` })- throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)+ private async userIsAdminOrSpaceManager(user: UserModel, spaceId: number, shareId?: number): Promise<boolean> {+ if (await this.spacesQueries.userIsAdminOrSpaceManager(user, spaceId, shareId)) {+ return true}- return true+ this.logger.warn({ tag: this.userIsAdminOrSpaceManager.name, msg: `space (${spaceId}) not found or not authorized for user (${user.id})` })+ throw new HttpException('Not authorized', HttpStatus.FORBIDDEN)}private async setQuotaExceeded(user: UserModel, space: SpaceEnv) {diff --git a/backend/src/applications/spaces/services/spaces-queries.service.ts b/backend/src/applications/spaces/services/spaces-queries.service.tsindex ba11a0b8..f905b7fc 100644--- a/backend/src/applications/spaces/services/spaces-queries.service.ts+++ b/backend/src/applications/spaces/services/spaces-queries.service.ts@@ -1,5 +1,5 @@import { Inject, Injectable, Logger } from '@nestjs/common'-import { and, countDistinct, eq, isNotNull, isNull, max, SelectedFields, SQL, sql } from 'drizzle-orm'+import { and, countDistinct, eq, isNotNull, isNull, max, or, SelectedFields, SQL, sql } from 'drizzle-orm'import { alias, union } from 'drizzle-orm/mysql-core'import { MySql2PreparedQuery, MySqlQueryResult } from 'drizzle-orm/mysql2'import { ACTION } from '../../../common/constants'@@ -30,6 +30,7 @@ import { GROUP_TYPE } from '../../users/constants/group'import { MEMBER_TYPE } from '../../users/constants/member'import { USER_ROLE } from '../../users/constants/user'import { Member } from '../../users/interfaces/member.interface'+import { UserModel } from '../../users/models/user.model'import { groups } from '../../users/schemas/groups.schema'import { usersGroups } from '../../users/schemas/users-groups.schema'import { userFullNameSQL, users } from '../../users/schemas/users.schema'@@ -98,27 +99,26 @@ export class SpacesQueries {.groupBy(spaces.id)}- async userIsSpaceManager(userId: number, spaceId: number, shareId?: number): Promise<boolean> {- /* Check if user is a space manager */+ async userIsAdminOrSpaceManager(user: UserModel, spaceId: number, shareId?: number): Promise<boolean> {const q = this.db.select({- userId: spacesMembers.userId,- spaceId: spacesMembers.spaceId,- ...(shareId && { shareId: shares.id })+ managerId: spacesMembers.userId,+ ...(shareId ? { shareId: shares.id } : {})})- .from(spacesMembers)+ .from(spaces)+ .leftJoin(+ spacesMembers,+ and(eq(spacesMembers.spaceId, spaces.id), eq(spacesMembers.userId, user.id), eq(spacesMembers.role, SPACE_ROLE.IS_MANAGER))+ )if (shareId) {- q.innerJoin(shares, and(eq(shares.id, shareId), eq(shares.spaceId, spaceId)))+ q.innerJoin(shares, and(eq(shares.id, shareId), eq(shares.spaceId, spaces.id)))}- const [r] = await q- .where(and(eq(spacesMembers.spaceId, spaceId), eq(spacesMembers.userId, userId), eq(spacesMembers.role, SPACE_ROLE.IS_MANAGER)))- .limit(1)- return r && r.userId === userId && r.spaceId === spaceId && (shareId ? r.shareId === shareId : true)+ const [r] = await q.where(and(eq(spaces.id, spaceId), or(isNotNull(spacesMembers.userId), eq(sql`${+user.isAdmin}`, 1)))).limit(1)+ return !!r}- async getSpaceAsManager(userId: number, spaceId: number): Promise<SpaceProps> {- /* User must be the manager of the space */- // todo: make a condition if current user is an admin+ async getSpaceAsAdminOrManager(user: UserModel, spaceId: number): Promise<SpaceProps> {+ /* User must be an admin or the manager of the space */if (!this.spaceQuery) {const otherMembers: any = alias(spacesMembers, 'otherMembers')const rootOwner: any = alias(users, 'rootOwner')@@ -179,17 +179,16 @@ export class SpacesQueries {createdAt: dateTimeUTC(otherMembers.createdAt)})} satisfies SpaceProps | SelectedFields<any, any>)- .from(spacesMembers)- .innerJoin(- spaces,+ .from(spaces)+ .leftJoin(+ spacesMembers,and(- eq(spaces.id, spacesMembers.spaceId),- eq(spacesMembers.spaceId, sql.placeholder('spaceId')),+ eq(spacesMembers.spaceId, spaces.id),eq(spacesMembers.userId, sql.placeholder('userId')),eq(spacesMembers.role, SPACE_ROLE.IS_MANAGER)))- .innerJoin(otherMembers, eq(otherMembers.spaceId, spaces.id))+ .leftJoin(otherMembers, eq(otherMembers.spaceId, spaces.id)).leftJoin(users, and(isNull(otherMembers.linkId), eq(otherMembers.userId, users.id))).leftJoin(linkUsers, and(isNotNull(otherMembers.linkId), eq(linkUsers.id, otherMembers.userId))).leftJoin(links, and(eq(links.userId, linkUsers.id), eq(links.id, otherMembers.linkId)))@@ -198,17 +197,18 @@ export class SpacesQueries {.leftJoin(files, eq(spacesRoots.fileId, files.id)).leftJoin(rootOwner, eq(rootOwner.id, files.ownerId)).leftJoin(fileOwner, and(eq(fileOwner.id, files.id), eq(fileOwner.ownerId, sql.placeholder('userId'))))+ .where(and(eq(spaces.id, sql.placeholder('spaceId')), or(isNotNull(spacesMembers.userId), eq(sql.placeholder('isAdmin'), 1)))).groupBy(spaces.id).limit(1).prepare()}- const [space] = await this.spaceQuery.execute({ userId, spaceId })+ const [space] = await this.spaceQuery.execute({ userId: user.id, spaceId, isAdmin: +user.isAdmin })if (!space) {return null}// merge membersspace.members = [...popFromObject('users', space), ...popFromObject('groups', space), ...popFromObject('links', space)]- return new SpaceProps(space, userId)+ return new SpaceProps(space, user.id)}async createSpace(space: SpaceProps): Promise<number> {@@ -603,6 +603,49 @@ export class SpacesQueries {return r.length ? r.map((s: Partial<SpaceProps>) => new SpaceProps(s)) : []}+ async spacesAsAdmin(): Promise<SpaceProps[]> {+ const managers: any = alias(users, 'managers')+ const select: SpaceProps | SelectedFields<any, any> = {+ id: spaces.id,+ alias: spaces.alias,+ name: spaces.name,+ description: spaces.description,+ enabled: spaces.enabled,+ storageQuota: spaces.storageQuota,+ storageUsage: spaces.storageUsage,+ modifiedAt: spaces.modifiedAt,+ createdAt: spaces.createdAt,+ disabledAt: spaces.disabledAt,+ members: concatDistinctObjectsInArray(managers.id, {+ id: managers.id,+ login: managers.login,+ name: userFullNameSQL(managers),+ description: managers.email,+ type: sql.raw(`'${MEMBER_TYPE.USER}'`),+ spaceRole: spacesMembers.role,+ permissions: sql<string>`''`,+ createdAt: dateTimeUTC(spacesMembers.createdAt)+ } satisfies Record<keyof Pick<Member, 'id' | 'name' | 'login' | 'description' | 'type' | 'permissions' | 'spaceRole' | 'createdAt'>, any>),+ counts: {+ users: sql`COUNT(DISTINCT(CASE WHEN ${spacesMembers.userId} IS NOT NULL AND ${spacesMembers.linkId} IS NULL THEN ${spacesMembers.userId} END))`,+ groups: countDistinct(spacesMembers.groupId),+ links: sql`COUNT(DISTINCT(CASE WHEN ${spacesMembers.linkId} IS NOT NULL THEN ${spacesMembers.linkId} END))`,+ shares: sql`COUNT(DISTINCT(CASE WHEN ${shares.id} IS NOT NULL THEN ${shares.id} END))`+ }+ }+ const r = await this.db+ .select(select)+ .from(spaces)+ .leftJoin(spacesMembers, eq(spacesMembers.spaceId, spaces.id))+ .leftJoin(users, eq(users.id, spacesMembers.userId))+ .leftJoin(groups, eq(groups.id, spacesMembers.groupId))+ .leftJoin(managers, and(eq(spacesMembers.userId, managers.id), eq(spacesMembers.role, SPACE_ROLE.IS_MANAGER)))+ .leftJoin(spacesRoots, eq(spacesRoots.spaceId, spaces.id))+ .leftJoin(shares, and(eq(shares.spaceId, spaces.id), isNotNull(shares.spaceId)))+ .groupBy(spaces.id)+ return r.length ? r.map((s: Partial<SpaceProps>) => new SpaceProps(s)) : []+ }+@CacheDecorator()async permissions(userId: number, spaceAlias: string, rootAlias: string): Promise<Partial<SpaceEnv>> {if (rootAlias) {diff --git a/backend/src/applications/spaces/spaces.controller.ts b/backend/src/applications/spaces/spaces.controller.tsindex 52a7c7f3..a11c5e05 100644--- a/backend/src/applications/spaces/spaces.controller.ts+++ b/backend/src/applications/spaces/spaces.controller.ts@@ -92,6 +92,12 @@ export class SpacesController {return this.spacesManager.spacesWithDetails(user.id)}+ @Get(`${SPACES_ROUTE.ADMIN}/${SPACES_ROUTE.LIST}`)+ @UserHaveRole(USER_ROLE.ADMINISTRATOR)+ listSpacesAsAdmin(): Promise<SpaceProps[]> {+ return this.spacesManager.listSpacesAsAdmin()+ }+@UserHavePermission([USER_PERMISSION.PERSONAL_SPACE, USER_PERMISSION.SPACES])@Get(`${SPACES_ROUTE.TRASH}/${SPACES_ROUTE.LIST}`)listTrashes(@GetUser() user: UserModel): Promise<SpaceTrash[]> {diff --git a/frontend/src/app/applications/admin/admin.constants.ts b/frontend/src/app/applications/admin/admin.constants.tsindex f92a2371..9002963e 100644--- a/frontend/src/app/applications/admin/admin.constants.ts+++ b/frontend/src/app/applications/admin/admin.constants.ts@@ -1,4 +1,4 @@-import { faGear, faUserGear, faUsersGear } from '@fortawesome/free-solid-svg-icons'+import { faGear, faLayerGroup, faUserGear, faUsersGear } from '@fortawesome/free-solid-svg-icons'import { AppMenu } from '../../layout/layout.interfaces'export const ADMIN_PATH = {@@ -6,7 +6,8 @@ export const ADMIN_PATH = {USERS: 'users',GUESTS: 'guests',GROUPS: 'groups',- PGROUPS: 'personal_groups'+ PGROUPS: 'personal_groups',+ SPACES: 'spaces'} as constexport const ADMIN_TITLE = {@@ -14,13 +15,15 @@ export const ADMIN_TITLE = {USERS: 'Users',GROUPS: 'Groups',GUESTS: 'Guests',- PGROUPS: 'Personal groups'+ PGROUPS: 'Personal groups',+ SPACES: 'Spaces'} as constexport const ADMIN_ICON = {BASE: faGear,USERS: faUserGear,- GROUPS: faUsersGear+ GROUPS: faUsersGear,+ SPACES: faLayerGroup} as constexport const ADMIN_MENU: AppMenu = {@@ -41,6 +44,11 @@ export const ADMIN_MENU: AppMenu = {icon: ADMIN_ICON.GROUPS,link: `${ADMIN_PATH.BASE}/${ADMIN_PATH.GROUPS}`,matchLink: RegExp(`^${ADMIN_PATH.BASE}/${ADMIN_PATH.GROUPS}|^${ADMIN_PATH.BASE}/${ADMIN_PATH.PGROUPS}`)+ },+ {+ title: ADMIN_TITLE.SPACES,+ icon: ADMIN_ICON.SPACES,+ link: `${ADMIN_PATH.BASE}/${ADMIN_PATH.SPACES}`}]} as constdiff --git a/frontend/src/app/applications/admin/admin.routes.ts b/frontend/src/app/applications/admin/admin.routes.tsindex ecf12b14..45236462 100644--- a/frontend/src/app/applications/admin/admin.routes.ts+++ b/frontend/src/app/applications/admin/admin.routes.ts@@ -43,6 +43,16 @@ export const adminRoutes: Routes = [}]},+ {+ path: ADMIN_PATH.SPACES,+ children: [+ {+ path: '**',+ resolve: { routes: routeResolver },+ loadComponent: () => import('./components/admin-spaces.component').then((c) => c.AdminSpacesComponent)+ }+ ]+ },{ path: '**', redirectTo: ADMIN_PATH.USERS }]}diff --git a/frontend/src/app/applications/admin/admin.service.ts b/frontend/src/app/applications/admin/admin.service.tsindex 9c0aacaf..3d121c09 100644--- a/frontend/src/app/applications/admin/admin.service.ts+++ b/frontend/src/app/applications/admin/admin.service.ts@@ -1,6 +1,8 @@import { HttpClient, HttpHeaders } from '@angular/common/http'import { inject, Injectable } from '@angular/core'import { Router } from '@angular/router'+import { API_ADMIN_SPACES_LIST } from '@sync-in-server/backend/src/applications/spaces/constants/routes'+import type { SpaceProps } from '@sync-in-server/backend/src/applications/spaces/models/space-props.model'import {ADMIN_USERS_ROUTE,API_ADMIN_GROUPS,@@ -29,6 +31,7 @@ import type { Member } from '@sync-in-server/backend/src/applications/users/inteimport type { LoginResponseDto } from '@sync-in-server/backend/src/authentication/dto/login-response.dto'import { catchError, map, Observable } from 'rxjs'import { AuthService } from '../../auth/auth.service'+import { SpaceModel } from '../spaces/models/space.model'import { GroupBrowseModel } from '../users/models/group-browse.model'import { GuestUserModel } from '../users/models/guest.model'import { MemberModel } from '../users/models/member.model'@@ -137,4 +140,8 @@ export class AdminService {this.authService.initUserFromResponse(r, true)this.router.navigate([USER_PATH.BASE, USER_PATH.ACCOUNT]).catch(console.error)}++ listSpaces(): Observable<SpaceModel[]> {+ return this.http.get<SpaceProps[]>(API_ADMIN_SPACES_LIST).pipe(map((sps: SpaceProps[]) => sps.map((s: SpaceProps) => new SpaceModel(s))))+ }}diff --git a/frontend/src/app/applications/admin/components/admin-spaces.component.html b/frontend/src/app/applications/admin/components/admin-spaces.component.htmlnew file mode 100644index 00000000..eafef1c4--- /dev/null+++ b/frontend/src/app/applications/admin/components/admin-spaces.component.html@@ -0,0 +1,155 @@+<!--Start Top Menu-->+<div class="app-top-menu">+ <button (click)="loadSpaces()"+ class="d-none d-sm-block btn btn-default me-1"+ [tooltip]="'Refresh' | translate:locale.language"+ type="button">+ <fa-icon [icon]="icons.faArrowRotateRight" [animation]="loading ? 'spin' : null"></fa-icon>+ </button>+ <button (click)="openSpaceDialog(true)"+ class="btn btn-default me-1"+ [tooltip]="'New space' | translate:locale.language"+ type="button">+ <fa-icon [icon]="icons.faPlus"></fa-icon>+ </button>+ <button (click)="openSpaceDialog()"+ [disabled]="!selected"+ class="btn btn-default me-1"+ [tooltip]="'Edit space' | translate:locale.language"+ type="button">+ <fa-icon [icon]="icons.faPen"></fa-icon>+ </button>+ <button (click)="openChildShareDialog()"+ [disabled]="!selected?.counts.shares"+ class="btn btn-default me-1"+ [tooltip]="'Edit children shares' | translate:locale.language"+ type="button">+ <fa-icon [icon]="icons.SHARED"></fa-icon>+ </button>+ <div class="ms-auto">+ <!--Start Filter Button-->+ <div class="btn-group">+ <app-input-filter class="d-none d-sm-block"></app-input-filter>+ </div>+ <!--End Filter Button-->+ </div>+</div>+<!--End Top Menu-->+<table class="app-table">+ <thead>+ <tr>+ @for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {+ @if (th.value.show) {+ <th (click)="sortBy(th.key)"+ [style.width.%]="th.value.width"+ [class.text-align-center]="th.value.textCenter"+ [class.cursor-pointer]="th.value.sortable"+ class="{{th.value.class}}"+ l10nTranslate>+ {{ th.value.label }}+ @if (sortTable.sortParam.column === th.key) {+ <fa-icon [icon]="sortTable.sortParam.asc ? icons.faArrowDown : icons.faArrowUp" [fixedWidth]="false"></fa-icon>+ }+ </th>+ }+ }+ </tr>+ </thead>+</table>+<app-virtual-scroll (contextmenu)="onContextMenu($event)"+ [bufferAmount]="5"+ [items]="spaces | searchFilter:inputFilter.search()">+ <table class="app-table">+ <tbody tabindex="-1">+ @for (s of scrollView?.viewPortItems; track s.id) {+ <tr (click)="onSelect(s)"+ (contextmenu)="onTargetContextMenu($event, s)"+ (appTap)="openSpaceDialog()"+ [class.disabled]="!s.enabled"+ [class.selected]="s.id === selected?.id">+ @for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {+ @if (th.value.show) {+ <td [style.width.%]="th.value.width"+ [class.text-align-center]="th.value.textCenter"+ class="{{th.value.class}}">+ @switch (th.key) {+ @case ('name') {+ <div class="d-flex align-items-center">+ <fa-icon [icon]="icons.SPACES" class="circle-primary-icon" [fixedWidth]="false"></fa-icon>+ <div class="d-flex flex-column text-truncate">+ <span class="no-pointer-events text-file-name-preserve" draggable="false">{{ s.name }}</span>+ <span class="no-pointer-events text-muted fs-xs" draggable="false">{{ s.description }}</span>+ </div>+ </div>+ }+ @case ('managers') {+ <div class="avatar-stack">+ @for (m of s.managers; track m.mid) {+ <app-user-avatar [user]="m" [isMember]="true" [container]="'body'"></app-user-avatar>+ }+ </div>+ }+ @case ('storage') {+ @if (s.storageUsage || s.storageQuota) {+ <app-storage-usage [item]="s"></app-storage-usage>+ }+ }+ @case ('members') {+ <app-badge-members [members]="s.counts"></app-badge-members>+ }+ @case ('info') {+ @if (s.counts.shares) {+ <span (click)="openChildShareDialog(s)" class="badge bg-purple cursor-pointer me-1">+ <fa-icon [icon]="icons.SHARED"></fa-icon>+ {{ s.counts.shares }}+ </span>+ }+ }+ @case ('modified') {+ <span class="{{th.value.newly && s[th.value.newly] ? 'badge prop-newly-' + s[th.value.newly] : ''}}">+ <span>+ {{ s.hTimeAgo }}+ </span>+ </span>+ }+ }+ </td>+ }+ }+ </tr>+ }+ </tbody>+ </table>+</app-virtual-scroll>+<!--End Table Files Content-->+<!--Start Foot Content-->+<div class="app-foot-menu">+ <span class="mx-auto">{{ spaces.length }} {{ 'spaces' | translate:locale.language }}</span>+</div>+<!--End Foot Content-->+<!--Start Context Menu -->+<context-menu #MainContextMenu>+ <ng-template+ (execute)="openSpaceDialog(true)" contextMenuItem>+ <span l10nTranslate><fa-icon [icon]="icons.faPlus"></fa-icon>New space</span>+ </ng-template>+ <ng-template [divider]="true" contextMenuItem></ng-template>+ <ng-template (execute)="loadSpaces()" contextMenuItem>+ <span l10nTranslate><fa-icon [icon]="icons.faArrowRotateRight"></fa-icon>Refresh</span>+ </ng-template>+</context-menu>+<context-menu #TargetContextMenu>+ <ng-template (execute)="openSpaceDialog()" contextMenuItem>+ <span l10nTranslate><fa-icon [icon]="icons.faPen"></fa-icon>Edit space</span>+ </ng-template>+ @if (!!selected?.counts.shares) {+ <ng-template (execute)="openChildShareDialog()" contextMenuItem>+ <span l10nTranslate><fa-icon [icon]="icons.SHARED"></fa-icon>Edit children shares</span>+ </ng-template>+ }+ <ng-template [divider]="true" contextMenuItem></ng-template>+ <ng-template (execute)="layout.showRSideBarTab(TAB_MENU.SELECTION)" contextMenuItem>+ <span l10nTranslate><fa-icon [icon]="icons.faCircleInfo"></fa-icon>Info</span>+ </ng-template>+</context-menu>+<!--End Context Menu-->diff --git a/frontend/src/app/applications/admin/components/admin-spaces.component.ts b/frontend/src/app/applications/admin/components/admin-spaces.component.tsnew file mode 100644index 00000000..64f793f2--- /dev/null+++ b/frontend/src/app/applications/admin/components/admin-spaces.component.ts@@ -0,0 +1,248 @@+import { KeyValuePipe } from '@angular/common'+import { HttpErrorResponse } from '@angular/common/http'+import { Component, ElementRef, inject, ViewChild } from '@angular/core'+import { ActivatedRoute } from '@angular/router'+import { FaIconComponent } from '@fortawesome/angular-fontawesome'+import { faArrowDown, faArrowRotateRight, faArrowUp, faCircleInfo, faPen, faPlus, faRotate, faUpload } from '@fortawesome/free-solid-svg-icons'+import { ContextMenuComponent, ContextMenuModule } from '@perfectmemory/ngx-contextmenu'+import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'+import { BsModalRef } from 'ngx-bootstrap/modal'+import { TooltipModule } from 'ngx-bootstrap/tooltip'+import { take } from 'rxjs/operators'+import { BadgeMembersComponent } from '../../../common/components/badge-members.component'+import { FilterComponent } from '../../../common/components/filter.component'+import { StorageUsageComponent } from '../../../common/components/storage-usage.component'+import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'+import { TapDirective } from '../../../common/directives/tap.directive'+import { TableHeaderConfig } from '../../../common/interfaces/table.interface'+import { SearchFilterPipe } from '../../../common/pipes/search.pipe'+import { originalOrderKeyValue } from '../../../common/utils/functions'+import { SortSettings, SortTable } from '../../../common/utils/sort-table'+import { TAB_MENU } from '../../../layout/layout.interfaces'+import { LayoutService } from '../../../layout/layout.service'+import { SharedChildrenDialogComponent } from '../../shares/components/dialogs/shared-children-dialog.component'+import { SpaceDialogComponent } from '../../spaces/components/dialogs/space-dialog.component'+import type { SpaceModel } from '../../spaces/models/space.model'+import { SpacesService } from '../../spaces/services/spaces.service'+import { SPACES_ICON } from '../../spaces/spaces.constants'+import { UserAvatarComponent } from '../../users/components/utils/user-avatar.component'+import { ADMIN_ICON, ADMIN_PATH, ADMIN_TITLE } from '../admin.constants'+import { AdminService } from '../admin.service'++@Component({+ selector: 'app-admin-spaces',+ imports: [+ KeyValuePipe,+ L10nTranslateDirective,+ FaIconComponent,+ UserAvatarComponent,+ VirtualScrollComponent,+ TooltipModule,+ L10nTranslatePipe,+ ContextMenuModule,+ FilterComponent,+ SearchFilterPipe,+ TapDirective,+ BadgeMembersComponent,+ StorageUsageComponent+ ],+ templateUrl: 'admin-spaces.component.html'+})+export class AdminSpacesComponent {+ @ViewChild(VirtualScrollComponent) scrollView: { element: ElementRef; viewPortItems: SpaceModel[]; scrollInto: (arg: SpaceModel | number) => void }+ @ViewChild(FilterComponent, { static: true }) inputFilter: FilterComponent+ @ViewChild('MainContextMenu', { static: true }) mainContextMenu: ContextMenuComponent<any>+ @ViewChild('TargetContextMenu', { static: true }) targetContextMenu: ContextMenuComponent<any>+ protected readonly locale = inject<L10nLocale>(L10N_LOCALE)+ protected readonly layout = inject(LayoutService)+ protected readonly originalOrderKeyValue = originalOrderKeyValue+ protected readonly TAB_MENU = TAB_MENU+ protected readonly icons = {+ SPACES: ADMIN_ICON.SPACES,+ SHARED: SPACES_ICON.SHARED_WITH_OTHERS,+ faArrowDown,+ faArrowUp,+ faRotate,+ faArrowRotateRight,+ faUpload,+ faPlus,+ faPen,+ faCircleInfo+ }+ // Sort+ protected tableHeaders: Record<'name' | 'managers' | 'storage' | 'members' | 'info' | 'modified', TableHeaderConfig> = {+ name: {+ label: 'Name',+ width: 30,+ textCenter: false,+ class: '',+ show: true,+ sortable: true+ },+ managers: {+ label: 'Managers',+ width: 12,+ class: 'd-none d-md-table-cell',+ textCenter: true,+ show: true,+ sortable: true+ },+ storage: {+ label: 'Storage Space',+ width: 15,+ class: 'd-none d-md-table-cell',+ textCenter: true,+ show: true,+ sortable: true+ },+ members: {+ label: 'Members',+ width: 15,+ class: 'd-none d-lg-table-cell',+ textCenter: true,+ show: true+ },+ info: { label: 'Info', width: 8, textCenter: true, class: 'd-none d-md-table-cell', show: true },+ modified: {+ label: 'Modified',+ width: 8,+ textCenter: true,+ class: 'd-none d-lg-table-cell',+ newly: 'newly',+ show: true,+ sortable: true+ }+ }+ protected loading = false+ protected spaces: SpaceModel[] = []+ protected selected: SpaceModel = null+ private readonly activatedRoute = inject(ActivatedRoute)+ private readonly spacesService = inject(SpacesService)+ private readonly adminService = inject(AdminService)+ private readonly sortSettings: SortSettings = {+ default: [{ prop: 'name', type: 'string' }],+ name: [{ prop: 'name', type: 'string' }],+ managers: [{ prop: 'managers', type: 'length' }],+ storage: [{ prop: 'storageUsage', type: 'number' }],+ modified: [{ prop: 'modifiedAt', type: 'date' }]+ }+ protected sortTable = new SortTable(this.constructor.name, this.sortSettings)+ // States+ private focusOnSelect: string++ constructor() {+ this.loadSpaces()+ this.layout.setBreadcrumbIcon(ADMIN_ICON.SPACES)+ this.layout.setBreadcrumbNav({+ url: `/${ADMIN_PATH.BASE}/${ADMIN_PATH.SPACES}/${ADMIN_TITLE.SPACES}`,+ splicing: 2,+ translating: true,+ sameLink: true+ })+ this.activatedRoute.queryParams.subscribe((params) => (this.focusOnSelect = params.select))+ }++ loadSpaces() {+ this.loading = true+ this.onSelect()+ this.adminService.listSpaces().subscribe({+ next: (spaces: SpaceModel[]) => {+ this.sortBy(this.sortTable.sortParam.column, false, spaces)+ this.loading = false+ if (this.focusOnSelect) {+ this.focusOn(this.focusOnSelect)+ } else {+ this.scrollView.scrollInto(-1)+ }+ },+ error: (e: HttpErrorResponse) => {+ this.spaces = []+ this.loading = false+ this.layout.sendNotification('error', 'Spaces', e.error.message)+ }+ })+ }++ onSelect(space: SpaceModel = null) {+ this.selected = space ?? null+ }++ sortBy(column: string, toUpdate = true, collection?: SpaceModel[]) {+ this.spaces = this.sortTable.sortBy(column, toUpdate, collection || this.spaces)+ }++ onContextMenu(ev: any) {+ ev.preventDefault()+ ev.stopPropagation()+ this.layout.openContextMenu(ev, this.mainContextMenu)+ }++ onTargetContextMenu(ev: any, space: SpaceModel) {+ ev.preventDefault()+ if (ev.type === 'contextmenu') {+ ev.stopPropagation()+ }+ this.onSelect(space)+ this.layout.openContextMenu(ev, this.targetContextMenu)+ }++ openSpaceDialog(add = false) {+ if (add) {+ const modalRef: BsModalRef<SpaceDialogComponent> = this.layout.openDialog(SpaceDialogComponent, 'xl')+ modalRef.content.spaceChange.pipe(take(1)).subscribe((r: ['add' | string, SpaceModel]) => {+ const [action, s] = r+ if (action === 'add') {+ this.sortBy(this.sortTable.sortParam.column, false, this.spaces.concat(s))+ this.onSelect(s)+ }+ })+ } else if (this.selected) {+ this.spacesService.getSpace(this.selected.id).subscribe({+ next: (space: SpaceModel) => {+ const modalRef: BsModalRef<SpaceDialogComponent> = this.layout.openDialog(SpaceDialogComponent, 'xl', {+ initialState: { space: space } as SpaceDialogComponent+ })+ modalRef.content.spaceChange.pipe(take(1)).subscribe((r: ['update' | 'delete' | string, SpaceModel]) => {+ const [action, s] = r+ if (action === 'update') {+ this.selected.name = s.name+ this.selected.alias = s.alias+ this.selected.description = s.description+ this.selected.storageUsage = s.storageUsage+ this.selected.storageQuota = s.storageQuota+ // hook to keep the shares count+ this.selected.counts = { ...s.counts, shares: this.selected.counts.shares }+ this.selected.modifiedAt = s.modifiedAt+ this.selected.enabled = s.enabled+ this.selected.managers = [...s.managers]+ } else if (action === 'delete') {+ this.onSelect()+ this.sortBy(+ this.sortTable.sortParam.column,+ false,+ this.spaces.filter((sp: SpaceModel) => sp.id !== s.id)+ )+ }+ })+ },+ error: (e: HttpErrorResponse) => this.layout.sendNotification('error', 'Edit space', this.selected.name, e)+ })+ }+ }++ openChildShareDialog(space?: SpaceModel) {+ if (space) this.onSelect(space)+ const modalRef: BsModalRef<SharedChildrenDialogComponent> = this.layout.openDialog(SharedChildrenDialogComponent, null, {+ initialState: { space: this.selected } as SharedChildrenDialogComponent+ })+ modalRef.content.sharesCountEvent.subscribe((sharesCount: number) => (this.selected.counts.shares = sharesCount))+ }++ private focusOn(select: string) {+ const s = this.spaces.find((space) => space.name === select)+ if (s) {+ setTimeout(() => this.scrollView.scrollInto(s), 100)+ this.onSelect(s)+ }+ }+}diff --git a/frontend/src/app/applications/admin/components/admin-users.component.html b/frontend/src/app/applications/admin/components/admin-users.component.htmlindex c5ba1e97..0a1c31a4 100644--- a/frontend/src/app/applications/admin/components/admin-users.component.html+++ b/frontend/src/app/applications/admin/components/admin-users.component.html@@ -114,7 +114,7 @@</div>}@case ('storage') {- @if (u.storageUsage) {+ @if (u.storageUsage || u.storageQuota) {<app-storage-usage [item]="u"></app-storage-usage>}}diff --git a/frontend/src/app/applications/admin/components/dialogs/admin-user-dialog.component.html b/frontend/src/app/applications/admin/components/dialogs/admin-user-dialog.component.htmlindex 4f6b46db..634bf0c7 100644--- a/frontend/src/app/applications/admin/components/dialogs/admin-user-dialog.component.html+++ b/frontend/src/app/applications/admin/components/dialogs/admin-user-dialog.component.html@@ -148,7 +148,7 @@<div><app-storage-quota [quota]="userForm.value.storageQuota" (quotaChange)="updateQuota($event)" [fullWidth]="true"></app-storage-quota></div>- @if (user && user.storageUsage) {+ @if (user && (user.storageUsage || user.storageQuota)) {<div><label class="form-label" for="storage" l10nTranslate>Storage Usage</label><app-storage-usage id="storage" [item]="user"></app-storage-usage>diff --git a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.html b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.htmlindex f8dec5c2..6a963dd0 100644--- a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.html+++ b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.html@@ -60,7 +60,7 @@<div class="d-flex flex-column align-items-start"><app-storage-quota [(quota)]="share.storageQuota" [fullWidth]="true" class="w-100 mb-3"></app-storage-quota></div>- @if (share.storageUsage) {+ @if (share.storageUsage || share.storageQuota) {<div class="d-flex flex-column mb-3"><label class="form-label" for="storage" l10nTranslate>Storage Usage</label><app-storage-usage id="storage" [item]="share"></app-storage-usage>diff --git a/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.html b/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.htmlindex 94ef5a3c..7b65af17 100644--- a/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.html+++ b/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.html@@ -59,7 +59,7 @@<div class="d-flex flex-column align-items-start"><app-storage-quota [(quota)]="space.storageQuota" [fullWidth]="true" class="w-100 mb-3"></app-storage-quota></div>- @if (space.storageUsage) {+ @if (space.storageUsage || space.storageQuota) {<div class="d-flex flex-column mb-3"><label class="form-label" for="storage" l10nTranslate>Storage Usage</label><app-storage-usage id="storage" [item]="space"></app-storage-usage>@@ -120,7 +120,7 @@[rowBackgroundClass]="''"[customPlaceholder]="'Type to search for managers to add'"></app-user-search>- @if (!space.managers.length) {+ @if (!space.managers.length && !confirmDeletion) {<small class="text-danger" l10nTranslate>At least one manager is required</small>}</div>diff --git a/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts b/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.tsindex 3719a1b8..153d0862 100644--- a/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts+++ b/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts@@ -218,7 +218,8 @@ export class SpaceDialogComponent implements OnInit {}cantSubmit() {- return this.submitted || !this.space.name || !this.space.managers.length+ const canDeleteWithoutManagers = this.confirmDeletion && this.space.id !== 0 && this.user.isAdmin+ return this.submitted || !this.space.name || (!this.space.managers.length && !canDeleteWithoutManagers)}private onError() {diff --git a/frontend/src/app/common/components/storage-usage.component.ts b/frontend/src/app/common/components/storage-usage.component.tsindex 2c34ca9d..2bc6f8f5 100644--- a/frontend/src/app/common/components/storage-usage.component.ts+++ b/frontend/src/app/common/components/storage-usage.component.ts@@ -46,9 +46,7 @@ export class StorageUsageComponent {this.cdr.detectChanges()}}-measure()-const ro = new ResizeObserver(() => measure())ro.observe(host)// cleanup