Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
04ad1eef
Commit
04ad1eef
authored
Mar 08, 2024
by
JzoNg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
workflow logs
parent
2b475b79
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
31 deletions
+30
-31
page.tsx
...commonLayout)/app/(appDetailLayout)/[appId]/logs/page.tsx
+1
-4
index.tsx
web/app/components/app/log-annotation/index.tsx
+15
-7
detail.tsx
web/app/components/app/workflow-log/detail.tsx
+2
-2
filter.tsx
web/app/components/app/workflow-log/filter.tsx
+1
-1
index.tsx
web/app/components/app/workflow-log/index.tsx
+9
-14
list.tsx
web/app/components/app/workflow-log/list.tsx
+2
-3
No files found.
web/app/(commonLayout)/app/(appDetailLayout)/[appId]/logs/page.tsx
View file @
04ad1eef
import
React
from
'react'
import
React
from
'react'
import
Main
from
'@/app/components/app/log-annotation'
import
Main
from
'@/app/components/app/log-annotation'
import
{
PageType
}
from
'@/app/components/app/configuration/toolbox/annotation/type'
import
{
PageType
}
from
'@/app/components/app/configuration/toolbox/annotation/type'
import
type
{
AppMode
}
from
'@/types/app'
export
type
IProps
=
{
export
type
IProps
=
{
params
:
{
appId
:
string
}
params
:
{
appId
:
string
}
appMode
:
AppMode
}
}
const
Logs
=
async
({
const
Logs
=
async
({
params
:
{
appId
},
params
:
{
appId
},
appMode
,
}:
IProps
)
=>
{
}:
IProps
)
=>
{
return
(
return
(
<
Main
appMode=
{
appMode
}
pageType=
{
PageType
.
log
}
appId=
{
appId
}
/>
<
Main
pageType=
{
PageType
.
log
}
appId=
{
appId
}
/>
)
)
}
}
...
...
web/app/components/app/log-annotation/index.tsx
View file @
04ad1eef
...
@@ -7,32 +7,40 @@ import { useRouter } from 'next/navigation'
...
@@ -7,32 +7,40 @@ import { useRouter } from 'next/navigation'
import
Log
from
'@/app/components/app/log'
import
Log
from
'@/app/components/app/log'
import
WorkflowLog
from
'@/app/components/app/workflow-log'
import
WorkflowLog
from
'@/app/components/app/workflow-log'
import
Annotation
from
'@/app/components/app/annotation'
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
{
PageType
}
from
'@/app/components/app/configuration/toolbox/annotation/type'
import
TabSlider
from
'@/app/components/base/tab-slider-plain'
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
=
{
type
Props
=
{
pageType
:
PageType
pageType
:
PageType
appId
:
string
appId
:
string
appMode
:
AppMode
}
}
const
LogAnnotation
:
FC
<
Props
>
=
({
const
LogAnnotation
:
FC
<
Props
>
=
({
pageType
,
pageType
,
appId
,
appId
,
appMode
,
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
router
=
useRouter
()
const
router
=
useRouter
()
const
{
appDetail
}
=
useAppStore
()
const
options
=
[
const
options
=
[
{
value
:
PageType
.
log
,
text
:
t
(
'appLog.title'
)
},
{
value
:
PageType
.
log
,
text
:
t
(
'appLog.title'
)
},
{
value
:
PageType
.
annotation
,
text
:
t
(
'appAnnotation.title'
)
},
{
value
:
PageType
.
annotation
,
text
:
t
(
'appAnnotation.title'
)
},
]
]
if
(
!
appDetail
)
{
return
(
<
div
className=
'flex h-full items-center justify-center bg-white'
>
<
Loading
/>
</
div
>
)
}
return
(
return
(
<
div
className=
'pt-4 px-6 h-full flex flex-col'
>
<
div
className=
'pt-4 px-6 h-full flex flex-col'
>
{
app
M
ode
!==
'workflow'
&&
(
{
app
Detail
.
m
ode
!==
'workflow'
&&
(
<
TabSlider
<
TabSlider
className=
'shrink-0'
className=
'shrink-0'
value=
{
pageType
}
value=
{
pageType
}
...
@@ -42,10 +50,10 @@ const LogAnnotation: FC<Props> = ({
...
@@ -42,10 +50,10 @@ const LogAnnotation: FC<Props> = ({
options=
{
options
}
options=
{
options
}
/>
/>
)
}
)
}
<
div
className=
{
cn
(
'grow'
,
app
M
ode
!==
'workflow'
&&
'mt-3'
)
}
>
<
div
className=
{
cn
(
'grow'
,
app
Detail
.
m
ode
!==
'workflow'
&&
'mt-3'
)
}
>
{
pageType
===
PageType
.
log
&&
app
M
ode
!==
'workflow'
&&
(<
Log
appId=
{
appId
}
/>)
}
{
pageType
===
PageType
.
log
&&
app
Detail
.
m
ode
!==
'workflow'
&&
(<
Log
appId=
{
appId
}
/>)
}
{
pageType
===
PageType
.
annotation
&&
(<
Annotation
appId=
{
appId
}
/>)
}
{
pageType
===
PageType
.
annotation
&&
(<
Annotation
appId=
{
appId
}
/>)
}
{
pageType
===
PageType
.
log
&&
app
Mode
===
'workflow'
&&
(<
WorkflowLog
appId=
{
appId
}
/>)
}
{
pageType
===
PageType
.
log
&&
app
Detail
.
mode
===
'workflow'
&&
(<
WorkflowLog
appDetail=
{
appDetail
}
/>)
}
</
div
>
</
div
>
</
div
>
</
div
>
)
)
...
...
web/app/components/app/workflow-log/detail.tsx
View file @
04ad1eef
...
@@ -6,7 +6,7 @@ import Run from '@/app/components/workflow/run'
...
@@ -6,7 +6,7 @@ import Run from '@/app/components/workflow/run'
import
{
XClose
}
from
'@/app/components/base/icons/src/vender/line/general'
import
{
XClose
}
from
'@/app/components/base/icons/src/vender/line/general'
type
ILogDetail
=
{
type
ILogDetail
=
{
appDetail
?
:
App
appDetail
:
App
onClose
:
()
=>
void
onClose
:
()
=>
void
}
}
...
@@ -19,7 +19,7 @@ const DetailPanel: FC<ILogDetail> = ({ appDetail, onClose }) => {
...
@@ -19,7 +19,7 @@ const DetailPanel: FC<ILogDetail> = ({ appDetail, onClose }) => {
<
XClose
className=
'w-4 h-4 text-gray-500'
/>
<
XClose
className=
'w-4 h-4 text-gray-500'
/>
</
span
>
</
span
>
<
h1
className=
'shrink-0 px-4 py-1 text-md font-semibold text-gray-900'
>
{
t
(
'appLog.runDetail.workflowTitle'
)
}
</
h1
>
<
h1
className=
'shrink-0 px-4 py-1 text-md font-semibold text-gray-900'
>
{
t
(
'appLog.runDetail.workflowTitle'
)
}
</
h1
>
<
Run
activeTab=
'TRACING'
appId=
{
appDetail
?.
id
||
''
}
></
Run
>
<
Run
activeTab=
'TRACING'
appId=
{
appDetail
.
id
}
></
Run
>
</
div
>
</
div
>
)
)
}
}
...
...
web/app/components/app/workflow-log/filter.tsx
View file @
04ad1eef
...
@@ -20,7 +20,7 @@ const Filter: FC<IFilterProps> = ({ queryParams, setQueryParams }: IFilterProps)
...
@@ -20,7 +20,7 @@ const Filter: FC<IFilterProps> = ({ queryParams, setQueryParams }: IFilterProps)
<
div
className=
"relative rounded-md"
>
<
div
className=
"relative rounded-md"
>
<
SimpleSelect
<
SimpleSelect
defaultValue=
{
'all'
}
defaultValue=
{
'all'
}
className=
'!w-[100px]'
className=
'!
min-
w-[100px]'
onSelect=
{
onSelect=
{
(
item
)
=>
{
(
item
)
=>
{
setQueryParams
({
...
queryParams
,
status
:
item
.
value
as
string
})
setQueryParams
({
...
queryParams
,
status
:
item
.
value
as
string
})
...
...
web/app/components/app/workflow-log/index.tsx
View file @
04ad1eef
...
@@ -13,13 +13,12 @@ import DetailPanel from './detail'
...
@@ -13,13 +13,12 @@ import DetailPanel from './detail'
import
s
from
'./style.module.css'
import
s
from
'./style.module.css'
import
Loading
from
'@/app/components/base/loading'
import
Loading
from
'@/app/components/base/loading'
import
{
fetchWorkflowLogs
}
from
'@/service/log'
import
{
fetchWorkflowLogs
}
from
'@/service/log'
import
{
fetchAppDetail
}
from
'@/service/apps'
import
{
APP_PAGE_LIMIT
}
from
'@/config'
import
{
APP_PAGE_LIMIT
}
from
'@/config'
import
type
{
AppMode
}
from
'@/types/app'
import
type
{
App
,
App
Mode
}
from
'@/types/app'
import
Drawer
from
'@/app/components/base/drawer'
import
Drawer
from
'@/app/components/base/drawer'
export
type
ILogsProps
=
{
export
type
ILogsProps
=
{
app
Id
:
string
app
Detail
:
App
}
}
export
type
QueryParam
=
{
export
type
QueryParam
=
{
...
@@ -32,7 +31,6 @@ const ThreeDotsIcon = ({ className }: SVGProps<SVGElement>) => {
...
@@ -32,7 +31,6 @@ const ThreeDotsIcon = ({ className }: SVGProps<SVGElement>) => {
<
path
d=
"M5 6.5V5M8.93934 7.56066L10 6.5M10.0103 11.5H11.5103"
stroke=
"#374151"
strokeWidth=
"2"
strokeLinecap=
"round"
strokeLinejoin=
"round"
/>
<
path
d=
"M5 6.5V5M8.93934 7.56066L10 6.5M10.0103 11.5H11.5103"
stroke=
"#374151"
strokeWidth=
"2"
strokeLinecap=
"round"
strokeLinejoin=
"round"
/>
</
svg
>
</
svg
>
}
}
const
EmptyElement
:
FC
<
{
appUrl
:
string
}
>
=
({
appUrl
})
=>
{
const
EmptyElement
:
FC
<
{
appUrl
:
string
}
>
=
({
appUrl
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
pathname
=
usePathname
()
const
pathname
=
usePathname
()
...
@@ -51,7 +49,8 @@ const EmptyElement: FC<{ appUrl: string }> = ({ appUrl }) => {
...
@@ -51,7 +49,8 @@ const EmptyElement: FC<{ appUrl: string }> = ({ appUrl }) => {
</
div
>
</
div
>
}
}
const
Logs
:
FC
<
ILogsProps
>
=
({
appId
})
=>
{
const
Logs
:
FC
<
ILogsProps
>
=
({
appDetail
})
=>
{
// ###TODO###
const
[
showDrawer
,
setShowDrawer
]
=
useState
<
boolean
>
(
true
)
const
[
showDrawer
,
setShowDrawer
]
=
useState
<
boolean
>
(
true
)
const
onCloseDrawer
=
()
=>
{
const
onCloseDrawer
=
()
=>
{
setShowDrawer
(
false
)
setShowDrawer
(
false
)
...
@@ -64,22 +63,18 @@ const Logs: FC<ILogsProps> = ({ appId }) => {
...
@@ -64,22 +63,18 @@ const Logs: FC<ILogsProps> = ({ appId }) => {
const
query
=
{
const
query
=
{
page
:
currPage
+
1
,
page
:
currPage
+
1
,
limit
:
APP_PAGE_LIMIT
,
limit
:
APP_PAGE_LIMIT
,
...
queryParams
,
...(
queryParams
.
status
!==
'all'
?
{
status
:
queryParams
.
status
}
:
{}),
...(
queryParams
.
keyword
?
{
keyword
:
queryParams
.
keyword
}
:
{}),
}
}
// Get the app type first
const
getWebAppType
=
(
appType
:
AppMode
)
=>
{
const
{
data
:
appDetail
}
=
useSWR
({
url
:
'/apps'
,
id
:
appId
},
fetchAppDetail
)
const
getWebAppType
=
(
appType
?:
AppMode
)
=>
{
if
(
!
appType
)
return
''
if
(
appType
===
'completion'
||
appType
===
'workflow'
)
if
(
appType
===
'completion'
||
appType
===
'workflow'
)
return
'completion'
return
'completion'
return
'chat'
return
'chat'
}
}
const
{
data
:
workflowLogs
,
mutate
}
=
useSWR
({
const
{
data
:
workflowLogs
,
mutate
}
=
useSWR
({
url
:
`/apps/
${
app
I
d
}
/workflow-app-logs`
,
url
:
`/apps/
${
app
Detail
.
i
d
}
/workflow-app-logs`
,
params
:
query
,
params
:
query
,
},
fetchWorkflowLogs
)
},
fetchWorkflowLogs
)
const
total
=
workflowLogs
?.
total
const
total
=
workflowLogs
?.
total
...
@@ -98,7 +93,7 @@ const Logs: FC<ILogsProps> = ({ appId }) => {
...
@@ -98,7 +93,7 @@ const Logs: FC<ILogsProps> = ({ appId }) => {
?
<
Loading
type=
'app'
/>
?
<
Loading
type=
'app'
/>
:
total
>
0
:
total
>
0
?
<
List
logs=
{
workflowLogs
}
appDetail=
{
appDetail
}
onRefresh=
{
mutate
}
/>
?
<
List
logs=
{
workflowLogs
}
appDetail=
{
appDetail
}
onRefresh=
{
mutate
}
/>
:
<
EmptyElement
appUrl=
{
`${appDetail
?.site.app_base_url}/${getWebAppType(appDetail?.mode)}/${appDetail?
.site.access_token}`
}
/>
:
<
EmptyElement
appUrl=
{
`${appDetail
.site.app_base_url}/${getWebAppType(appDetail.mode)}/${appDetail
.site.access_token}`
}
/>
}
}
{
/* Show Pagination only if the total is more than the limit */
}
{
/* Show Pagination only if the total is more than the limit */
}
{
(
total
&&
total
>
APP_PAGE_LIMIT
)
{
(
total
&&
total
>
APP_PAGE_LIMIT
)
...
...
web/app/components/app/workflow-log/list.tsx
View file @
04ad1eef
...
@@ -50,7 +50,7 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => {
...
@@ -50,7 +50,7 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => {
if
(
status
===
'stopped'
)
{
if
(
status
===
'stopped'
)
{
return
(
return
(
<
div
className=
'inline-flex items-center gap-1'
>
<
div
className=
'inline-flex items-center gap-1'
>
<
Indicator
color=
{
'
gray
'
}
/>
<
Indicator
color=
{
'
yellow
'
}
/>
<
span
>
Stop
</
span
>
<
span
>
Stop
</
span
>
</
div
>
</
div
>
)
)
...
@@ -71,7 +71,7 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => {
...
@@ -71,7 +71,7 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => {
setCurrentLog
(
undefined
)
setCurrentLog
(
undefined
)
}
}
if
(
!
logs
)
if
(
!
logs
||
!
appDetail
)
return
<
Loading
/>
return
<
Loading
/>
return
(
return
(
...
@@ -104,7 +104,6 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => {
...
@@ -104,7 +104,6 @@ const WorkflowAppLogList: FC<ILogs> = ({ logs, appDetail, onRefresh }) => {
<
td
>
<
td
>
<
div
className=
{
cn
(
<
div
className=
{
cn
(
log
.
workflow_run
.
elapsed_time
===
0
&&
'text-gray-400'
,
log
.
workflow_run
.
elapsed_time
===
0
&&
'text-gray-400'
,
log
.
workflow_run
.
elapsed_time
>
10
&&
'text-orange-400'
,
)
}
>
{
`${log.workflow_run.elapsed_time}s`
}
</
div
>
)
}
>
{
`${log.workflow_run.elapsed_time}s`
}
</
div
>
</
td
>
</
td
>
<
td
>
{
log
.
workflow_run
.
total_tokens
}
</
td
>
<
td
>
{
log
.
workflow_run
.
total_tokens
}
</
td
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment