mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 03:16:51 +08:00
feat: annotation management frontend (#1764)
This commit is contained in:
31
web/app/components/billing/annotation-full/index.tsx
Normal file
31
web/app/components/billing/annotation-full/index.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import cn from 'classnames'
|
||||
import UpgradeBtn from '../upgrade-btn'
|
||||
import Usage from './usage'
|
||||
import s from './style.module.css'
|
||||
import GridMask from '@/app/components/base/grid-mask'
|
||||
|
||||
const AnnotationFull: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<GridMask wrapperClassName='rounded-lg' canvasClassName='rounded-lg' gradientClassName='rounded-lg'>
|
||||
<div className='mt-6 px-3.5 py-4 border-2 border-solid border-transparent rounded-lg shadow-md flex flex-col transition-all duration-200 ease-in-out cursor-pointer'>
|
||||
<div className='flex justify-between items-center'>
|
||||
<div className={cn(s.textGradient, 'leading-[24px] text-base font-semibold')}>
|
||||
<div>{t('billing.annotatedResponse.fullTipLine1')}</div>
|
||||
<div>{t('billing.annotatedResponse.fullTipLine2')}</div>
|
||||
</div>
|
||||
<div className='flex'>
|
||||
<UpgradeBtn loc={'annotation-create'} />
|
||||
</div>
|
||||
</div>
|
||||
<Usage className='mt-4' />
|
||||
</div>
|
||||
</GridMask>
|
||||
)
|
||||
}
|
||||
export default React.memo(AnnotationFull)
|
||||
47
web/app/components/billing/annotation-full/modal.tsx
Normal file
47
web/app/components/billing/annotation-full/modal.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import cn from 'classnames'
|
||||
import UpgradeBtn from '../upgrade-btn'
|
||||
import Modal from '../../base/modal'
|
||||
import Usage from './usage'
|
||||
import s from './style.module.css'
|
||||
import GridMask from '@/app/components/base/grid-mask'
|
||||
|
||||
type Props = {
|
||||
show: boolean
|
||||
onHide: () => void
|
||||
}
|
||||
const AnnotationFullModal: FC<Props> = ({
|
||||
show,
|
||||
onHide,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isShow={show}
|
||||
onClose={onHide}
|
||||
closable
|
||||
className='!p-0'
|
||||
>
|
||||
<GridMask wrapperClassName='rounded-lg' canvasClassName='rounded-lg' gradientClassName='rounded-lg'>
|
||||
<div className='mt-6 px-7 py-6 border-2 border-solid border-transparent rounded-lg shadow-md flex flex-col transition-all duration-200 ease-in-out cursor-pointer'>
|
||||
<div className='flex justify-between items-center'>
|
||||
<div className={cn(s.textGradient, 'leading-[27px] text-[18px] font-semibold')}>
|
||||
<div>{t('billing.annotatedResponse.fullTipLine1')}</div>
|
||||
<div>{t('billing.annotatedResponse.fullTipLine2')}</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<Usage className='mt-4' />
|
||||
<div className='mt-7 flex justify-end'>
|
||||
<UpgradeBtn loc={'annotation-create'} />
|
||||
</div>
|
||||
</div>
|
||||
</GridMask>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default React.memo(AnnotationFullModal)
|
||||
@@ -0,0 +1,7 @@
|
||||
.textGradient {
|
||||
background: linear-gradient(92deg, #2250F2 -29.55%, #0EBCF3 75.22%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
text-fill-color: transparent;
|
||||
}
|
||||
32
web/app/components/billing/annotation-full/usage.tsx
Normal file
32
web/app/components/billing/annotation-full/usage.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { MessageFastPlus } from '../../base/icons/src/vender/line/communication'
|
||||
import UsageInfo from '../usage-info'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
|
||||
type Props = {
|
||||
className?: string
|
||||
}
|
||||
|
||||
const Usage: FC<Props> = ({
|
||||
className,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const { plan } = useProviderContext()
|
||||
const {
|
||||
usage,
|
||||
total,
|
||||
} = plan
|
||||
return (
|
||||
<UsageInfo
|
||||
className={className}
|
||||
Icon={MessageFastPlus}
|
||||
name={t('billing.annotatedResponse.quotaTitle')}
|
||||
usage={usage.annotatedResponse}
|
||||
total={total.annotatedResponse}
|
||||
/>
|
||||
)
|
||||
}
|
||||
export default React.memo(Usage)
|
||||
@@ -63,10 +63,12 @@ export const defaultPlan = {
|
||||
vectorSpace: 1,
|
||||
buildApps: 1,
|
||||
teamMembers: 1,
|
||||
annotatedResponse: 1,
|
||||
},
|
||||
total: {
|
||||
vectorSpace: 10,
|
||||
buildApps: 10,
|
||||
teamMembers: 1,
|
||||
annotatedResponse: 10,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ const ProgressBar = ({
|
||||
color = '#2970FF',
|
||||
}: ProgressBarProps) => {
|
||||
return (
|
||||
<div className='bg-[#F2F4F7] rounded-[4px]'>
|
||||
<div className='bg-[#F2F4F7] rounded-[4px] overflow-hidden'>
|
||||
<div
|
||||
className='h-2 rounded-[4px]'
|
||||
style={{
|
||||
|
||||
@@ -23,7 +23,7 @@ export type PlanInfo = {
|
||||
annotatedResponse: number
|
||||
}
|
||||
|
||||
export type UsagePlanInfo = Pick<PlanInfo, 'vectorSpace' | 'buildApps' | 'teamMembers'>
|
||||
export type UsagePlanInfo = Pick<PlanInfo, 'vectorSpace' | 'buildApps' | 'teamMembers' | 'annotatedResponse'>
|
||||
|
||||
export enum DocumentProcessingPriority {
|
||||
standard = 'standard',
|
||||
@@ -48,6 +48,10 @@ export type CurrentPlanInfoBackend = {
|
||||
size: number
|
||||
limit: number // total. 0 means unlimited
|
||||
}
|
||||
annotation_quota_limit: {
|
||||
size: number
|
||||
limit: number // total. 0 means unlimited
|
||||
}
|
||||
docs_processing: DocumentProcessingPriority
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,13 @@ export const parseCurrentPlan = (data: CurrentPlanInfoBackend) => {
|
||||
vectorSpace: data.vector_space.size,
|
||||
buildApps: data.apps?.size || 0,
|
||||
teamMembers: data.members.size,
|
||||
annotatedResponse: data.annotation_quota_limit.size,
|
||||
},
|
||||
total: {
|
||||
vectorSpace: parseLimit(data.vector_space.limit),
|
||||
buildApps: parseLimit(data.apps?.limit) || 0,
|
||||
teamMembers: parseLimit(data.members.limit),
|
||||
annotatedResponse: parseLimit(data.annotation_quota_limit.limit),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user