mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-30 00:29:46 +08:00
feat(workspace): add blob and storage limit (#5535)
close TOV-343 AFF-508 TOV-461 TOV-460 TOV-419 Add `isOverCapacity ` status to detect if blob usage exceeds limits. Add `onCapacityChange` and `onBlobSet` to monitor if the storage or blob exceeds the capacity limit. Global modals `LocalQuotaModal` and `CloudQuotaModal` have been added, with the upload size of the blob being limited within the modal components. The notification component has been adjusted, now you can pass in `action` click events and `actionLabel` .
This commit is contained in:
@@ -25,6 +25,7 @@ export class QuotaManagementService {
|
||||
storageQuota: quota.feature.storageQuota,
|
||||
historyPeriod: quota.feature.historyPeriod,
|
||||
memberLimit: quota.feature.memberLimit,
|
||||
humanReadableName: quota.feature.humanReadable.name,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,11 +46,12 @@ export class QuotaManagementService {
|
||||
const { user: owner } =
|
||||
await this.permissions.getWorkspaceOwner(workspaceId);
|
||||
if (!owner) throw new NotFoundException('Workspace owner not found');
|
||||
const { storageQuota, blobLimit } = await this.getUserQuota(owner.id);
|
||||
const { humanReadableName, storageQuota, blobLimit } =
|
||||
await this.getUserQuota(owner.id);
|
||||
// get all workspaces size of owner used
|
||||
const usedSize = await this.getUserUsage(owner.id);
|
||||
|
||||
return { storageQuota, usedSize, blobLimit };
|
||||
return { humanReadableName, storageQuota, usedSize, blobLimit };
|
||||
}
|
||||
|
||||
async checkBlobQuota(workspaceId: string, size: number) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Field, Int, ObjectType } from '@nestjs/graphql';
|
||||
import { Field, ObjectType } from '@nestjs/graphql';
|
||||
import { SafeIntResolver } from 'graphql-scalars';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { commonFeatureSchema, FeatureKind } from '../features';
|
||||
@@ -42,13 +43,16 @@ export type Quota = z.infer<typeof QuotaSchema>;
|
||||
|
||||
@ObjectType()
|
||||
export class QuotaQueryType {
|
||||
@Field(() => Int)
|
||||
@Field(() => String)
|
||||
humanReadableName!: string;
|
||||
|
||||
@Field(() => SafeIntResolver)
|
||||
storageQuota!: number;
|
||||
|
||||
@Field(() => Int)
|
||||
@Field(() => SafeIntResolver)
|
||||
usedSize!: number;
|
||||
|
||||
@Field(() => Int)
|
||||
@Field(() => SafeIntResolver)
|
||||
blobLimit!: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user