From bc245a25bf97dea1b7209b96b618c6dae7adb327 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Wed, 21 Aug 2024 17:06:55 +0800 Subject: [PATCH] new style of tables --- .../app/annotation/empty-element.tsx | 6 +- web/app/components/app/annotation/filter.tsx | 32 ++++---- web/app/components/app/annotation/index.tsx | 4 +- web/app/components/app/annotation/list.tsx | 31 ++++---- .../app/annotation/style.module.css | 6 -- web/app/components/app/log/filter.tsx | 78 +++++++++---------- web/app/components/app/log/index.tsx | 10 +-- web/app/components/app/log/list.tsx | 51 ++++++------ web/app/components/app/log/style.module.css | 6 -- .../components/app/workflow-log/filter.tsx | 28 ++++--- web/app/components/base/chip/index.tsx | 25 +++--- web/app/components/base/sort/index.tsx | 4 +- 12 files changed, 136 insertions(+), 145 deletions(-) diff --git a/web/app/components/app/annotation/empty-element.tsx b/web/app/components/app/annotation/empty-element.tsx index 2498e38534..9ba31ce11e 100644 --- a/web/app/components/app/annotation/empty-element.tsx +++ b/web/app/components/app/annotation/empty-element.tsx @@ -14,9 +14,9 @@ const EmptyElement: FC = () => { return (
-
- {t('appAnnotation.noData.title')} -
+
+ {t('appAnnotation.noData.title')} +
{t('appAnnotation.noData.description')}
diff --git a/web/app/components/app/annotation/filter.tsx b/web/app/components/app/annotation/filter.tsx index 9a2a750582..d741f6de12 100644 --- a/web/app/components/app/annotation/filter.tsx +++ b/web/app/components/app/annotation/filter.tsx @@ -2,10 +2,8 @@ import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' -import { - MagnifyingGlassIcon, -} from '@heroicons/react/24/solid' import useSWR from 'swr' +import Input from '@/app/components/base/input' import { fetchAnnotationsCount } from '@/service/log' export type QueryParam = { @@ -31,22 +29,18 @@ const Filter: FC = ({ if (!data) return null return ( -
-
-
-
- { - setQueryParams({ ...queryParams, keyword: e.target.value }) - }} - /> -
+
+ { + setQueryParams({ ...queryParams, keyword: e.target.value }) + }} + onClear={() => setQueryParams({ ...queryParams, keyword: '' })} + /> {children}
) diff --git a/web/app/components/app/annotation/index.tsx b/web/app/components/app/annotation/index.tsx index 1e65d7a94f..7025ba9a37 100644 --- a/web/app/components/app/annotation/index.tsx +++ b/web/app/components/app/annotation/index.tsx @@ -150,8 +150,8 @@ const Annotation: FC = ({ return (
-

{t('appLog.description')}

-
+

{t('appLog.description')}

+
{isChatApp && ( diff --git a/web/app/components/app/annotation/list.tsx b/web/app/components/app/annotation/list.tsx index bc3a35158f..49de5a2e7f 100644 --- a/web/app/components/app/annotation/list.tsx +++ b/web/app/components/app/annotation/list.tsx @@ -4,7 +4,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { RiDeleteBinLine } from '@remixicon/react' import { Edit02 } from '../../base/icons/src/vender/line/general' -import s from './style.module.css' import type { AnnotationItem } from './type' import RemoveAnnotationConfirmModal from './remove-annotation-confirm-modal' import cn from '@/utils/classnames' @@ -27,21 +26,21 @@ const List: FC = ({ const [showConfirmDelete, setShowConfirmDelete] = React.useState(false) return (
- - - - - - - - +
{t('appAnnotation.table.header.question')}{t('appAnnotation.table.header.answer')}{t('appAnnotation.table.header.createdAt')}{t('appAnnotation.table.header.hits')}{t('appAnnotation.table.header.actions')}
+ + + + + + + - + {list.map(item => ( { onView(item) @@ -49,16 +48,16 @@ const List: FC = ({ } > - - - + +
{t('appAnnotation.table.header.question')}{t('appAnnotation.table.header.answer')}{t('appAnnotation.table.header.createdAt')}{t('appAnnotation.table.header.hits')}{t('appAnnotation.table.header.actions')}
{item.question} {item.answer}{formatTime(item.created_at, t('appLog.dateTimeFormat') as string)}{item.hit_count} e.stopPropagation()}> + {formatTime(item.created_at, t('appLog.dateTimeFormat') as string)}{item.hit_count} e.stopPropagation()}> {/* Actions */}
= ({ isChatMode, appId, queryParams, setQueryPara if (!data) return null return ( -
- ({ value: item.value, name: t(`appLog.filter.period.${item.name}`) }))} - className='mt-0 !w-40' +
+ } + value={queryParams.period || 7} onSelect={(item) => { - setQueryParams({ ...queryParams, period: item.value }) + setQueryParams({ ...queryParams, period: item.value as string }) }} - defaultValue={queryParams.period} /> -
- { - setQueryParams({ ...queryParams, annotation_status: item.value as string }) - } - } - items={[{ value: 'all', name: t('appLog.filter.annotation.all') }, - { value: 'annotated', name: t('appLog.filter.annotation.annotated', { count: data?.count }) }, - { value: 'not_annotated', name: t('appLog.filter.annotation.not_annotated') }]} - /> -
-
-
-
- { - setQueryParams({ ...queryParams, keyword: e.target.value }) - }} - /> -
+ onClear={() => setQueryParams({ ...queryParams, period: 7 })} + items={TIME_PERIOD_LIST.map(item => ({ value: item.value, name: t(`appLog.filter.period.${item.name}`) }))} + /> + { + setQueryParams({ ...queryParams, annotation_status: item.value as string }) + }} + onClear={() => setQueryParams({ ...queryParams, annotation_status: 'all' })} + items={[ + { value: 'all', name: t('appLog.filter.annotation.all') }, + { value: 'annotated', name: t('appLog.filter.annotation.annotated', { count: data?.count }) }, + { value: 'not_annotated', name: t('appLog.filter.annotation.not_annotated') }, + ]} + /> + { + setQueryParams({ ...queryParams, keyword: e.target.value }) + }} + onClear={() => setQueryParams({ ...queryParams, keyword: '' })} + /> {isChatMode && ( <>
diff --git a/web/app/components/app/log/index.tsx b/web/app/components/app/log/index.tsx index dd6ebd08f0..a9a11aa493 100644 --- a/web/app/components/app/log/index.tsx +++ b/web/app/components/app/log/index.tsx @@ -39,12 +39,12 @@ const EmptyElement: FC<{ appUrl: string }> = ({ appUrl }) => { const pathSegments = pathname.split('/') pathSegments.pop() return
-
- {t('appLog.table.empty.element.title')} -
+
+ {t('appLog.table.empty.element.title')} +
, testLink: }} + components={{ shareLink: , testLink: }} />
@@ -101,7 +101,7 @@ const Logs: FC = ({ appDetail }) => { return (
-

{t('appLog.description')}

+

{t('appLog.description')}

{total === undefined diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx index 40d171761b..f156721abf 100644 --- a/web/app/components/app/log/list.tsx +++ b/web/app/components/app/log/list.tsx @@ -17,7 +17,6 @@ import timezone from 'dayjs/plugin/timezone' import { createContext, useContext } from 'use-context-selector' import { useShallow } from 'zustand/react/shallow' import { useTranslation } from 'react-i18next' -import s from './style.module.css' import VarPanel from './var-panel' import cn from '@/utils/classnames' import { randomString } from '@/utils' @@ -642,14 +641,14 @@ const ConversationList: FC = ({ logs, appDetail, onRefresh }) return ( + {`${t('appLog.detail.annotationTip', { user: annotation?.account?.name })} ${formatTime(annotation?.created_at || dayjs().unix(), 'MM-DD hh:mm A')}`} } className={(isHighlight && !isChatMode) ? '' : '!hidden'} selector={`highlight-${randomString(16)}`} > -
+
{value || '-'}
@@ -667,40 +666,46 @@ const ConversationList: FC = ({ logs, appDetail, onRefresh }) return (
- - +
+ - - - - - - - - + + + + + + + + - + {logs.data.map((log: any) => { const endUser = log.from_end_user_session_id const leftValue = get(log, isChatMode ? 'name' : 'message.inputs.query') || (!isChatMode ? (get(log, 'message.query') || get(log, 'message.inputs.default_input')) : '') || '' const rightValue = get(log, isChatMode ? 'message_count' : 'message.answer') return { setShowDrawer(true) setCurrentConversation(log) }}> - - + - - + - - - - + + })} diff --git a/web/app/components/app/log/style.module.css b/web/app/components/app/log/style.module.css index 67a9fe3bf5..adb32a39db 100644 --- a/web/app/components/app/log/style.module.css +++ b/web/app/components/app/log/style.module.css @@ -1,9 +1,3 @@ -.logTable td { - padding: 7px 8px; - box-sizing: border-box; - max-width: 200px; -} - .pagination li { list-style: none; } diff --git a/web/app/components/app/workflow-log/filter.tsx b/web/app/components/app/workflow-log/filter.tsx index 9f03c4dc3d..466e9b8fda 100644 --- a/web/app/components/app/workflow-log/filter.tsx +++ b/web/app/components/app/workflow-log/filter.tsx @@ -14,21 +14,19 @@ type IFilterProps = { const Filter: FC = ({ queryParams, setQueryParams }: IFilterProps) => { const { t } = useTranslation() return ( -
-
- { - setQueryParams({ ...queryParams, status: item.value as string }) - }} - onClear={() => setQueryParams({ ...queryParams, status: 'all' })} - items={[{ value: 'all', name: 'All' }, - { value: 'succeeded', name: 'Success' }, - { value: 'failed', name: 'Fail' }, - { value: 'stopped', name: 'Stop' }, - ]} - /> -
+
+ { + setQueryParams({ ...queryParams, status: item.value as string }) + }} + onClear={() => setQueryParams({ ...queryParams, status: 'all' })} + items={[{ value: 'all', name: 'All' }, + { value: 'succeeded', name: 'Success' }, + { value: 'failed', name: 'Fail' }, + { value: 'stopped', name: 'Stop' }, + ]} + /> void @@ -22,6 +25,9 @@ type Props = { } const Chip: FC = ({ className, + panelClassName, + showLeftIcon = true, + leftIcon, value, items, onSelect, @@ -46,22 +52,23 @@ const Chip: FC = ({ className='block' >
-
- -
-
+ {showLeftIcon && ( +
+ {leftIcon || ( + + )} +
+ )} +
{triggerContent}
- {/* {value.length > 1 && ( -
{`+${value.length - 1}`}
- )} */}
{!value && } {!!value && ( @@ -75,7 +82,7 @@ const Chip: FC = ({
-
+
{items.map(item => (
= ({ className='block' >
@@ -80,7 +80,7 @@ const Sort: FC = ({
-
onSelect(`${order ? '' : '-'}${value}`)}> +
onSelect(`${order ? '' : '-'}${value}`)}> {!order && } {order && }
{isChatMode ? t('appLog.table.header.summary') : t('appLog.table.header.input')}{t('appLog.table.header.endUser')}{isChatMode ? t('appLog.table.header.messageCount') : t('appLog.table.header.output')}{t('appLog.table.header.userRate')}{t('appLog.table.header.adminRate')}{t('appLog.table.header.updatedTime')}{t('appLog.table.header.time')}{isChatMode ? t('appLog.table.header.summary') : t('appLog.table.header.input')}{t('appLog.table.header.endUser')}{isChatMode ? t('appLog.table.header.messageCount') : t('appLog.table.header.output')}{t('appLog.table.header.userRate')}{t('appLog.table.header.adminRate')}{t('appLog.table.header.updatedTime')}{t('appLog.table.header.time')}
{!log.read_at && } + + {!log.read_at && ( +
+ +
+ )} +
{renderTdValue(leftValue || t('appLog.table.empty.noChat'), !leftValue, isChatMode && log.annotated)} {renderTdValue(endUser || defaultValue, !endUser)} + {renderTdValue(endUser || defaultValue, !endUser)} {renderTdValue(rightValue === 0 ? 0 : (rightValue || t('appLog.table.empty.noOutput')), !rightValue, !isChatMode && !!log.annotation?.content, log.annotation)} + {(!log.user_feedback_stats.like && !log.user_feedback_stats.dislike) ? renderTdValue(defaultValue, true) : <> @@ -709,7 +714,7 @@ const ConversationList: FC = ({ logs, appDetail, onRefresh }) } + {(!log.admin_feedback_stats.like && !log.admin_feedback_stats.dislike) ? renderTdValue(defaultValue, true) : <> @@ -718,8 +723,8 @@ const ConversationList: FC = ({ logs, appDetail, onRefresh }) } {formatTime(log.updated_at, t('appLog.dateTimeFormat') as string)}{formatTime(log.created_at, t('appLog.dateTimeFormat') as string)}{formatTime(log.updated_at, t('appLog.dateTimeFormat') as string)}{formatTime(log.created_at, t('appLog.dateTimeFormat') as string)}