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
60f44f4e
Commit
60f44f4e
authored
Jul 28, 2023
by
JzoNg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/milvus-support' into deploy/dev
parents
0f00b898
46dcaad1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
31 deletions
+41
-31
InfiniteVirtualList.tsx
...tasets/documents/detail/completed/InfiniteVirtualList.tsx
+30
-28
index.tsx
.../components/datasets/documents/detail/completed/index.tsx
+11
-3
No files found.
web/app/components/datasets/documents/detail/completed/InfiniteVirtualList.tsx
View file @
60f44f4e
import
React
,
{
FC
,
CSSProperties
}
from
"react"
;
import
type
{
CSSProperties
,
FC
}
from
'react'
import
{
FixedSizeList
as
List
}
from
"react-window"
;
import
React
from
'react'
import
InfiniteLoader
from
"react-window-infinite-loader"
;
import
{
FixedSizeList
as
List
}
from
'react-window'
import
type
{
SegmentDetailModel
}
from
"@/models/datasets"
;
import
InfiniteLoader
from
'react-window-infinite-loader'
import
SegmentCard
from
"./SegmentCard"
;
import
SegmentCard
from
'./SegmentCard'
import
s
from
"./style.module.css"
;
import
s
from
'./style.module.css'
import
type
{
SegmentDetailModel
}
from
'@/models/datasets'
type
IInfiniteVirtualListProps
=
{
type
IInfiniteVirtualListProps
=
{
hasNextPage
?:
boolean
;
// Are there more items to load? (This information comes from the most recent API request.)
hasNextPage
?:
boolean
// Are there more items to load? (This information comes from the most recent API request.)
isNextPageLoading
:
boolean
;
// Are we currently loading a page of items? (This may be an in-flight flag in your Redux store for example.)
isNextPageLoading
:
boolean
// Are we currently loading a page of items? (This may be an in-flight flag in your Redux store for example.)
items
:
Array
<
SegmentDetailModel
[]
>
;
// Array of items loaded so far.
items
:
Array
<
SegmentDetailModel
[]
>
// Array of items loaded so far.
loadNextPage
:
()
=>
Promise
<
any
>
;
// Callback function responsible for loading the next page of items.
loadNextPage
:
()
=>
Promise
<
any
>
// Callback function responsible for loading the next page of items.
onClick
:
(
detail
:
SegmentDetailModel
)
=>
void
;
onClick
:
(
detail
:
SegmentDetailModel
)
=>
void
onChangeSwitch
:
(
segId
:
string
,
enabled
:
boolean
)
=>
Promise
<
void
>
;
onChangeSwitch
:
(
segId
:
string
,
enabled
:
boolean
)
=>
Promise
<
void
>
}
;
}
const
InfiniteVirtualList
:
FC
<
IInfiniteVirtualListProps
>
=
({
const
InfiniteVirtualList
:
FC
<
IInfiniteVirtualListProps
>
=
({
hasNextPage
,
hasNextPage
,
...
@@ -23,28 +24,29 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
...
@@ -23,28 +24,29 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
onChangeSwitch
,
onChangeSwitch
,
})
=>
{
})
=>
{
// If there are more items to be loaded then add an extra row to hold a loading indicator.
// If there are more items to be loaded then add an extra row to hold a loading indicator.
const
itemCount
=
hasNextPage
?
items
.
length
+
1
:
items
.
length
;
const
itemCount
=
hasNextPage
?
items
.
length
+
1
:
items
.
length
// Only load 1 page of items at a time.
// Only load 1 page of items at a time.
// Pass an empty callback to InfiniteLoader in case it asks us to load more than once.
// Pass an empty callback to InfiniteLoader in case it asks us to load more than once.
const
loadMoreItems
=
isNextPageLoading
?
()
=>
{
}
:
loadNextPage
;
const
loadMoreItems
=
isNextPageLoading
?
()
=>
{
}
:
loadNextPage
// Every row is loaded except for our loading indicator row.
// Every row is loaded except for our loading indicator row.
const
isItemLoaded
=
(
index
:
number
)
=>
!
hasNextPage
||
index
<
items
.
length
;
const
isItemLoaded
=
(
index
:
number
)
=>
!
hasNextPage
||
index
<
items
.
length
// Render an item or a loading indicator.
// Render an item or a loading indicator.
const
Item
=
({
index
,
style
}:
{
index
:
number
;
style
:
CSSProperties
})
=>
{
const
Item
=
({
index
,
style
}:
{
index
:
number
;
style
:
CSSProperties
})
=>
{
let
content
;
let
content
if
(
!
isItemLoaded
(
index
))
{
if
(
!
isItemLoaded
(
index
))
{
content
=
(
content
=
(
<>
<>
{
[
1
,
2
,
3
].
map
(
(
v
)
=>
(
{
[
1
,
2
,
3
].
map
(
v
=>
(
<
SegmentCard
loading=
{
true
}
detail=
{
{
position
:
v
}
as
any
}
/>
<
SegmentCard
loading=
{
true
}
detail=
{
{
position
:
v
}
as
any
}
/>
))
}
))
}
</>
</>
);
)
}
else
{
}
content
=
items
[
index
].
map
((
segItem
)
=>
(
else
{
content
=
items
[
index
].
map
(
segItem
=>
(
<
SegmentCard
<
SegmentCard
key=
{
segItem
.
id
}
key=
{
segItem
.
id
}
detail=
{
segItem
}
detail=
{
segItem
}
...
@@ -52,15 +54,15 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
...
@@ -52,15 +54,15 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
onChangeSwitch=
{
onChangeSwitch
}
onChangeSwitch=
{
onChangeSwitch
}
loading=
{
false
}
loading=
{
false
}
/>
/>
))
;
))
}
}
return
(
return
(
<
div
style=
{
style
}
className=
{
s
.
cardWrapper
}
>
<
div
style=
{
style
}
className=
{
s
.
cardWrapper
}
>
{
content
}
{
content
}
</
div
>
</
div
>
)
;
)
}
;
}
return
(
return
(
<
InfiniteLoader
<
InfiniteLoader
...
@@ -73,7 +75,7 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
...
@@ -73,7 +75,7 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
ref=
{
ref
}
ref=
{
ref
}
className=
"List"
className=
"List"
height=
{
800
}
height=
{
800
}
width=
{
"100%"
}
width=
{
'100%'
}
itemSize=
{
200
}
itemSize=
{
200
}
itemCount=
{
itemCount
}
itemCount=
{
itemCount
}
onItemsRendered=
{
onItemsRendered
}
onItemsRendered=
{
onItemsRendered
}
...
@@ -82,6 +84,6 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
...
@@ -82,6 +84,6 @@ const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({
</
List
>
</
List
>
)
}
)
}
</
InfiniteLoader
>
</
InfiniteLoader
>
)
;
)
}
;
}
export
default
InfiniteVirtualList
;
export
default
InfiniteVirtualList
web/app/components/datasets/documents/detail/completed/index.tsx
View file @
60f44f4e
...
@@ -219,7 +219,7 @@ const Completed: FC<ICompletedProps> = ({ showNewSegmentModal, onNewSegmentModal
...
@@ -219,7 +219,7 @@ const Completed: FC<ICompletedProps> = ({ showNewSegmentModal, onNewSegmentModal
documentId
,
documentId
,
params
:
omitBy
({
params
:
omitBy
({
last_id
:
!
needLastId
?
undefined
:
finalLastId
,
last_id
:
!
needLastId
?
undefined
:
finalLastId
,
limit
:
9
,
limit
:
12
,
keyword
:
searchValue
,
keyword
:
searchValue
,
enabled
:
selectedStatus
===
'all'
?
'all'
:
!!
selectedStatus
,
enabled
:
selectedStatus
===
'all'
?
'all'
:
!!
selectedStatus
,
},
isNil
)
as
SegmentsQuery
,
},
isNil
)
as
SegmentsQuery
,
...
@@ -227,12 +227,20 @@ const Completed: FC<ICompletedProps> = ({ showNewSegmentModal, onNewSegmentModal
...
@@ -227,12 +227,20 @@ const Completed: FC<ICompletedProps> = ({ showNewSegmentModal, onNewSegmentModal
if
(
!
e
)
{
if
(
!
e
)
{
setAllSegments
([...(
!
needLastId
?
[]
:
allSegments
),
...
splitArray
(
res
.
data
||
[])])
setAllSegments
([...(
!
needLastId
?
[]
:
allSegments
),
...
splitArray
(
res
.
data
||
[])])
setLastSegmentsRes
(
res
)
setLastSegmentsRes
(
res
)
if
(
!
lastSegmentsRes
)
if
(
!
lastSegmentsRes
||
!
needLastId
)
setTotal
(
res
?.
total
||
0
)
setTotal
(
res
?.
total
||
0
)
}
}
setLoading
(
false
)
setLoading
(
false
)
}
}
const
resetList
=
()
=>
{
setLastSegmentsRes
(
undefined
)
setAllSegments
([])
setLoading
(
false
)
setTotal
(
undefined
)
getSegments
(
false
)
}
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
lastSegmentsRes
!==
undefined
)
if
(
lastSegmentsRes
!==
undefined
)
getSegments
(
false
)
getSegments
(
false
)
...
@@ -336,7 +344,7 @@ const Completed: FC<ICompletedProps> = ({ showNewSegmentModal, onNewSegmentModal
...
@@ -336,7 +344,7 @@ const Completed: FC<ICompletedProps> = ({ showNewSegmentModal, onNewSegmentModal
isShow=
{
showNewSegmentModal
}
isShow=
{
showNewSegmentModal
}
docForm=
{
docForm
}
docForm=
{
docForm
}
onCancel=
{
()
=>
onNewSegmentModalChange
(
false
)
}
onCancel=
{
()
=>
onNewSegmentModalChange
(
false
)
}
onSave=
{
()
=>
getSegments
(
false
)
}
onSave=
{
resetList
}
/>
/>
</>
</>
)
)
...
...
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