From 27d0989b91442be814db8e206d7d557ba15632db Mon Sep 17 00:00:00 2001 From: balibabu Date: Fri, 19 Apr 2024 19:05:30 +0800 Subject: [PATCH] feat: #345 even if the backend data returns empty, the skeleton of the chart will be displayed. (#461) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … chart will be displayed. ### What problem does this PR solve? feat: #345 even if the backend data returns empty, the skeleton of the chart will be displayed. ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/components/line-chart/index.tsx | 5 ++- web/src/locales/en.ts | 5 +-- web/src/locales/zh-traditional.ts | 11 +++-- web/src/locales/zh.ts | 9 ++-- .../pages/chat/chat-api-key-modal/index.tsx | 2 + .../pages/chat/chat-overview-modal/index.less | 2 +- .../pages/chat/chat-overview-modal/index.tsx | 41 ++++++++++++------- web/src/pages/chat/model.ts | 1 + 8 files changed, 45 insertions(+), 31 deletions(-) diff --git a/web/src/components/line-chart/index.tsx b/web/src/components/line-chart/index.tsx index 6c032206f01..81ae954b782 100644 --- a/web/src/components/line-chart/index.tsx +++ b/web/src/components/line-chart/index.tsx @@ -50,9 +50,10 @@ const data = [ interface IProps extends CategoricalChartProps { data?: Array<{ xAxis: string; yAxis: number }>; + showLegend?: boolean; } -const RagLineChart = ({ data }: IProps) => { +const RagLineChart = ({ data, showLegend = false }: IProps) => { return ( { - + {showLegend && } { + const { t } = useTranslate('chat'); + const chartList = useSelectChartStatsList(); + const list = + chartList[statsType]?.map((x) => ({ + ...x, + xAxis: formatDate(x.xAxis), + })) ?? []; + + return ( +
+ {t(camelCase(statsType))} + +
+ ); +}; + const ChatOverviewModal = ({ visible, hideModal, dialog, }: IModalProps & { dialog: IDialog }) => { const { t } = useTranslate('chat'); - const chartList = useSelectChartStatsList(); const { visible: apiKeyVisible, hideModal: hideApiKeyModal, @@ -53,6 +70,8 @@ const ChatOverviewModal = ({ title={t('overview')} open={visible} onCancel={hideModal} + cancelButtonProps={{ style: { display: 'none' } }} + onOk={hideModal} width={'100vw'} > @@ -76,14 +95,8 @@ const ChatOverviewModal = ({ - + - {t('publicUrl')} - {/* - {urlWithToken} - - - */} @@ -101,12 +114,12 @@ const ChatOverviewModal = ({ />
- {Object.keys(chartList).map((x) => ( -
- {t(camelCase(x))} - -
- ))} + + + + + +
= { omit(payload, ['dialogId']), ); if (data.retcode === 0) { + message.success(i18n.t('message.deleted')); yield put({ type: 'listToken', payload: { dialog_id: payload.dialogId },