diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/logs/page.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/logs/page.tsx index 5ee114c6d2..d23e690dc5 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/logs/page.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/logs/page.tsx @@ -1,19 +1,16 @@ import React from 'react' import Main from '@/app/components/app/log-annotation' import { PageType } from '@/app/components/app/configuration/toolbox/annotation/type' -import type { AppMode } from '@/types/app' export type IProps = { params: { appId: string } - appMode: AppMode } const Logs = async ({ params: { appId }, - appMode, }: IProps) => { return ( - + ) } diff --git a/web/app/components/app/log-annotation/index.tsx b/web/app/components/app/log-annotation/index.tsx index 492e63ff81..ea548e2b61 100644 --- a/web/app/components/app/log-annotation/index.tsx +++ b/web/app/components/app/log-annotation/index.tsx @@ -7,32 +7,40 @@ import { useRouter } from 'next/navigation' import Log from '@/app/components/app/log' import WorkflowLog from '@/app/components/app/workflow-log' import Annotation from '@/app/components/app/annotation' +import Loading from '@/app/components/base/loading' import { PageType } from '@/app/components/app/configuration/toolbox/annotation/type' import TabSlider from '@/app/components/base/tab-slider-plain' -import type { AppMode } from '@/types/app' +import { useStore as useAppStore } from '@/app/components/app/store' type Props = { pageType: PageType appId: string - appMode: AppMode } const LogAnnotation: FC = ({ pageType, appId, - appMode, }) => { const { t } = useTranslation() const router = useRouter() + const { appDetail } = useAppStore() const options = [ { value: PageType.log, text: t('appLog.title') }, { value: PageType.annotation, text: t('appAnnotation.title') }, ] + if (!appDetail) { + return ( + + + + ) + } + return ( - {appMode !== 'workflow' && ( + {appDetail.mode !== 'workflow' && ( = ({ options={options} /> )} - - {pageType === PageType.log && appMode !== 'workflow' && ()} + + {pageType === PageType.log && appDetail.mode !== 'workflow' && ()} {pageType === PageType.annotation && ()} - {pageType === PageType.log && appMode === 'workflow' && ()} + {pageType === PageType.log && appDetail.mode === 'workflow' && ()} ) diff --git a/web/app/components/app/workflow-log/detail.tsx b/web/app/components/app/workflow-log/detail.tsx index ee0677e876..40796a1772 100644 --- a/web/app/components/app/workflow-log/detail.tsx +++ b/web/app/components/app/workflow-log/detail.tsx @@ -6,7 +6,7 @@ import Run from '@/app/components/workflow/run' import { XClose } from '@/app/components/base/icons/src/vender/line/general' type ILogDetail = { - appDetail?: App + appDetail: App onClose: () => void } @@ -19,7 +19,7 @@ const DetailPanel: FC = ({ appDetail, onClose }) => { {t('appLog.runDetail.workflowTitle')} - + ) } diff --git a/web/app/components/app/workflow-log/filter.tsx b/web/app/components/app/workflow-log/filter.tsx index 182344afd6..d239c39d2c 100644 --- a/web/app/components/app/workflow-log/filter.tsx +++ b/web/app/components/app/workflow-log/filter.tsx @@ -20,7 +20,7 @@ const Filter: FC = ({ queryParams, setQueryParams }: IFilterProps) { setQueryParams({ ...queryParams, status: item.value as string }) diff --git a/web/app/components/app/workflow-log/index.tsx b/web/app/components/app/workflow-log/index.tsx index 0ebc8d2f9e..5fd345cc3d 100644 --- a/web/app/components/app/workflow-log/index.tsx +++ b/web/app/components/app/workflow-log/index.tsx @@ -13,13 +13,12 @@ import DetailPanel from './detail' import s from './style.module.css' import Loading from '@/app/components/base/loading' import { fetchWorkflowLogs } from '@/service/log' -import { fetchAppDetail } from '@/service/apps' import { APP_PAGE_LIMIT } from '@/config' -import type { AppMode } from '@/types/app' +import type { App, AppMode } from '@/types/app' import Drawer from '@/app/components/base/drawer' export type ILogsProps = { - appId: string + appDetail: App } export type QueryParam = { @@ -32,7 +31,6 @@ const ThreeDotsIcon = ({ className }: SVGProps) => { } - const EmptyElement: FC<{ appUrl: string }> = ({ appUrl }) => { const { t } = useTranslation() const pathname = usePathname() @@ -51,7 +49,8 @@ const EmptyElement: FC<{ appUrl: string }> = ({ appUrl }) => { } -const Logs: FC = ({ appId }) => { +const Logs: FC = ({ appDetail }) => { + // ###TODO### const [showDrawer, setShowDrawer] = useState(true) const onCloseDrawer = () => { setShowDrawer(false) @@ -64,22 +63,18 @@ const Logs: FC = ({ appId }) => { const query = { page: currPage + 1, limit: APP_PAGE_LIMIT, - ...queryParams, + ...(queryParams.status !== 'all' ? { status: queryParams.status } : {}), + ...(queryParams.keyword ? { keyword: queryParams.keyword } : {}), } - // Get the app type first - const { data: appDetail } = useSWR({ url: '/apps', id: appId }, fetchAppDetail) - - const getWebAppType = (appType?: AppMode) => { - if (!appType) - return '' + const getWebAppType = (appType: AppMode) => { if (appType === 'completion' || appType === 'workflow') return 'completion' return 'chat' } const { data: workflowLogs, mutate } = useSWR({ - url: `/apps/${appId}/workflow-app-logs`, + url: `/apps/${appDetail.id}/workflow-app-logs`, params: query, }, fetchWorkflowLogs) const total = workflowLogs?.total @@ -98,7 +93,7 @@ const Logs: FC = ({ appId }) => { ? : total > 0 ? - : + : } {/* Show Pagination only if the total is more than the limit */} {(total && total > APP_PAGE_LIMIT) diff --git a/web/app/components/app/workflow-log/list.tsx b/web/app/components/app/workflow-log/list.tsx index a98a284ce9..373b234c89 100644 --- a/web/app/components/app/workflow-log/list.tsx +++ b/web/app/components/app/workflow-log/list.tsx @@ -50,7 +50,7 @@ const WorkflowAppLogList: FC = ({ logs, appDetail, onRefresh }) => { if (status === 'stopped') { return ( - + Stop ) @@ -71,7 +71,7 @@ const WorkflowAppLogList: FC = ({ logs, appDetail, onRefresh }) => { setCurrentLog(undefined) } - if (!logs) + if (!logs || !appDetail) return return ( @@ -104,7 +104,6 @@ const WorkflowAppLogList: FC = ({ logs, appDetail, onRefresh }) => { 10 && 'text-orange-400', )}>{`${log.workflow_run.elapsed_time}s`} {log.workflow_run.total_tokens}