From 2be2bc5877d4e5987a8a8d2487de33d99036b24b Mon Sep 17 00:00:00 2001 From: JzoNg Date: Sat, 2 Mar 2024 09:59:31 +0800 Subject: [PATCH] add run log status --- web/app/components/workflow/run/index.tsx | 4 +- web/app/components/workflow/run/result.tsx | 24 +++++- web/app/components/workflow/run/status.tsx | 90 ++++++++++++++++++++++ web/i18n/en-US/app-log.ts | 2 - web/i18n/en-US/run-log.ts | 11 +++ web/i18n/i18next-config.ts | 1 + web/i18n/pt-BR/run-log.ts | 11 +++ web/i18n/uk-UA/run-log.ts | 11 +++ web/i18n/zh-Hans/app-log.ts | 4 - web/i18n/zh-Hans/run-log.ts | 11 +++ 10 files changed, 159 insertions(+), 10 deletions(-) create mode 100644 web/app/components/workflow/run/status.tsx create mode 100644 web/i18n/en-US/run-log.ts create mode 100644 web/i18n/pt-BR/run-log.ts create mode 100644 web/i18n/uk-UA/run-log.ts create mode 100644 web/i18n/zh-Hans/run-log.ts diff --git a/web/app/components/workflow/run/index.tsx b/web/app/components/workflow/run/index.tsx index 77fb5ec0b0..f2c72c7948 100644 --- a/web/app/components/workflow/run/index.tsx +++ b/web/app/components/workflow/run/index.tsx @@ -25,14 +25,14 @@ const RunPanel: FC = ({ activeTab, appId }) => { currentTab === 'RESULT' && '!border-[rgb(21,94,239)] text-gray-700', )} onClick={() => setCurrentTab('RESULT')} - >{t('appLog.runDetail.result')} + >{t('runLog.result')}
setCurrentTab('TRACING')} - >{t('appLog.runDetail.tracing')}
+ >{t('runLog.tracing')} {/* panel detal */}
diff --git a/web/app/components/workflow/run/result.tsx b/web/app/components/workflow/run/result.tsx index 4e71213541..141b977a4d 100644 --- a/web/app/components/workflow/run/result.tsx +++ b/web/app/components/workflow/run/result.tsx @@ -3,6 +3,7 @@ import type { FC } from 'react' // import React, { useState } from 'react' import { useTranslation } from 'react-i18next' // import cn from 'classnames' +import StatusPanel from './status' // import Loading from '@/app/components/base/loading' // import Indicator from '@/app/components/header/indicator' @@ -15,8 +16,27 @@ const Result: FC = ({ appId }) => { // const [currentTab, setCurrentTab] = useState(activeTab) return ( -
- Result panel = TODO +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
INPUT TODO
+
OUPUT TODO
+
+
+
+
+
META DATA TODO
) } diff --git a/web/app/components/workflow/run/status.tsx b/web/app/components/workflow/run/status.tsx new file mode 100644 index 0000000000..0ef0dd36a2 --- /dev/null +++ b/web/app/components/workflow/run/status.tsx @@ -0,0 +1,90 @@ +'use client' +import type { FC } from 'react' +import { useTranslation } from 'react-i18next' +import cn from 'classnames' +import Indicator from '@/app/components/header/indicator' + +type ResultProps = { + status: 'running' | 'succeeded' | 'failed' | 'stopped' + time?: number + tokens?: number +} + +const StatusPanel: FC = ({ + status, + time, + tokens, +}) => { + const { t } = useTranslation() + + return ( +
+
+
{t('runLog.resultPanel.status')}
+
+ {status === 'running' && ( + Running + )} + {status === 'succeeded' && ( + <> + + SUCCESS + + )} + {status === 'failed' && ( + <> + + FAIL + + )} + {status === 'stopped' && ( + <> + + STOP + + )} +
+
+
+
{t('runLog.resultPanel.time')}
+
+ {status === 'running' && ( +
+ )} + {status !== 'running' && ( + {`${time}s`} + )} +
+
+
+
{t('runLog.resultPanel.tokens')}
+
+ {status === 'running' && ( +
+ )} + {status !== 'running' && ( + {`${tokens} Tokens`} + )} +
+
+
+ ) +} + +export default StatusPanel diff --git a/web/i18n/en-US/app-log.ts b/web/i18n/en-US/app-log.ts index e4849cc935..59151b2c1f 100644 --- a/web/i18n/en-US/app-log.ts +++ b/web/i18n/en-US/app-log.ts @@ -75,8 +75,6 @@ const translation = { runDetail: { title: 'Conversation Log', workflowTitle: 'Log Detail', - result: 'RESULT', - tracing: 'TRACING', }, } diff --git a/web/i18n/en-US/run-log.ts b/web/i18n/en-US/run-log.ts new file mode 100644 index 0000000000..14684413cf --- /dev/null +++ b/web/i18n/en-US/run-log.ts @@ -0,0 +1,11 @@ +const translation = { + result: 'RESULT', + tracing: 'TRACING', + resultPanel: { + status: 'STATUS', + time: 'ELAPSED TIME', + tokens: 'TOTAL TOKENS', + }, +} + +export default translation diff --git a/web/i18n/i18next-config.ts b/web/i18n/i18next-config.ts index e12c6a52fa..661475ea21 100644 --- a/web/i18n/i18next-config.ts +++ b/web/i18n/i18next-config.ts @@ -27,6 +27,7 @@ const loadLangResources = (lang: string) => ({ custom: require(`./${lang}/custom`).default, tools: require(`./${lang}/tools`).default, workflow: require(`./${lang}/workflow`).default, + runLog: require(`./${lang}/run-log`).default, }, }) diff --git a/web/i18n/pt-BR/run-log.ts b/web/i18n/pt-BR/run-log.ts new file mode 100644 index 0000000000..14684413cf --- /dev/null +++ b/web/i18n/pt-BR/run-log.ts @@ -0,0 +1,11 @@ +const translation = { + result: 'RESULT', + tracing: 'TRACING', + resultPanel: { + status: 'STATUS', + time: 'ELAPSED TIME', + tokens: 'TOTAL TOKENS', + }, +} + +export default translation diff --git a/web/i18n/uk-UA/run-log.ts b/web/i18n/uk-UA/run-log.ts new file mode 100644 index 0000000000..14684413cf --- /dev/null +++ b/web/i18n/uk-UA/run-log.ts @@ -0,0 +1,11 @@ +const translation = { + result: 'RESULT', + tracing: 'TRACING', + resultPanel: { + status: 'STATUS', + time: 'ELAPSED TIME', + tokens: 'TOTAL TOKENS', + }, +} + +export default translation diff --git a/web/i18n/zh-Hans/app-log.ts b/web/i18n/zh-Hans/app-log.ts index c5eae35836..7233be9ae3 100644 --- a/web/i18n/zh-Hans/app-log.ts +++ b/web/i18n/zh-Hans/app-log.ts @@ -72,10 +72,6 @@ const translation = { }, workflowTitle: '日志', workflowSubtitle: '日志记录了应用的执行情况', - runDetail: { - title: '对话日志', - workflowTitle: '日志详情', - }, } export default translation diff --git a/web/i18n/zh-Hans/run-log.ts b/web/i18n/zh-Hans/run-log.ts new file mode 100644 index 0000000000..d7079b9fb0 --- /dev/null +++ b/web/i18n/zh-Hans/run-log.ts @@ -0,0 +1,11 @@ +const translation = { + result: '结果', + tracing: '追踪', + resultPanel: { + status: '状态', + time: '运行时间', + tokens: '总 token 数', + }, +} + +export default translation