diff --git a/web/app/components/app/workflow-log/filter.tsx b/web/app/components/app/workflow-log/filter.tsx index d25f938719..f5756ee183 100644 --- a/web/app/components/app/workflow-log/filter.tsx +++ b/web/app/components/app/workflow-log/filter.tsx @@ -2,11 +2,29 @@ import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' +import dayjs from 'dayjs' +import { RiCalendarLine } from '@remixicon/react' +import quarterOfYear from 'dayjs/plugin/quarterOfYear' import type { QueryParam } from './index' import Chip from '@/app/components/base/chip' import Input from '@/app/components/base/input' +dayjs.extend(quarterOfYear) -interface IFilterProps { +const today = dayjs() + +export const TIME_PERIOD_MAPPING: { [key: string]: { value: number; name: string } } = { + 1: { value: 0, name: 'today' }, + 2: { value: 7, name: 'last7days' }, + 3: { value: 28, name: 'last4weeks' }, + 4: { value: today.diff(today.subtract(3, 'month'), 'day'), name: 'last3months' }, + 5: { value: today.diff(today.subtract(12, 'month'), 'day'), name: 'last12months' }, + 6: { value: today.diff(today.startOf('month'), 'day'), name: 'monthToDate' }, + 7: { value: today.diff(today.startOf('quarter'), 'day'), name: 'quarterToDate' }, + 8: { value: today.diff(today.startOf('year'), 'day'), name: 'yearToDate' }, + 9: { value: -1, name: 'allTime' }, +} + +type IFilterProps = { queryParams: QueryParam setQueryParams: (v: QueryParam) => void } @@ -27,6 +45,17 @@ const Filter: FC = ({ queryParams, setQueryParams }: IFilterProps) { value: 'stopped', name: 'Stop' }, ]} /> + } + value={queryParams.period} + onSelect={(item) => { + setQueryParams({ ...queryParams, period: item.value }) + }} + onClear={() => setQueryParams({ ...queryParams, period: '9' })} + items={Object.entries(TIME_PERIOD_MAPPING).map(([k, v]) => ({ value: k, name: t(`appLog.filter.period.${v.name}`) }))} + /> = ({ appUrl }) => { const Logs: FC = ({ appDetail }) => { const { t } = useTranslation() - const [queryParams, setQueryParams] = useState({ status: 'all' }) + const [queryParams, setQueryParams] = useState({ status: 'all', period: '2' }) const [currPage, setCurrPage] = React.useState(0) const debouncedQueryParams = useDebounce(queryParams, { wait: 500 }) const [limit, setLimit] = React.useState(APP_PAGE_LIMIT) @@ -58,6 +61,13 @@ const Logs: FC = ({ appDetail }) => { limit, ...(debouncedQueryParams.status !== 'all' ? { status: debouncedQueryParams.status } : {}), ...(debouncedQueryParams.keyword ? { keyword: debouncedQueryParams.keyword } : {}), + ...((debouncedQueryParams.period !== '9') + ? { + start: dayjs().subtract(TIME_PERIOD_MAPPING[debouncedQueryParams.period].value, 'day').startOf('day').format('YYYY-MM-DD HH:mm'), + end: dayjs().endOf('day').format('YYYY-MM-DD HH:mm'), + } + : {}), + ...omit(debouncedQueryParams, ['period', 'status']), } const getWebAppType = (appType: AppMode) => { diff --git a/web/app/components/workflow/nodes/_base/components/output-vars.tsx b/web/app/components/workflow/nodes/_base/components/output-vars.tsx index 4a265a5a5b..cedf63a08a 100644 --- a/web/app/components/workflow/nodes/_base/components/output-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/output-vars.tsx @@ -42,7 +42,7 @@ export const VarItem: FC = ({
{name}
-
{type}
+
{type}
{description}