feat: add result column to document list

This commit is contained in:
shiweisong.ssw 2023-06-30 14:45:09 +08:00
parent 492e5559b4
commit 80e93ac6ec

View File

@ -18,7 +18,7 @@ import {
import moment from 'moment' import moment from 'moment'
import { InboxOutlined } from '@ant-design/icons' import { InboxOutlined } from '@ant-design/icons'
import type { UploadProps } from 'antd' import type { UploadProps } from 'antd'
import { Upload, Pagination, message } from 'antd' import { Upload, Pagination, Popover, message } from 'antd'
import { fetchBaseURL } from '@/app/datastores/constants' import { fetchBaseURL } from '@/app/datastores/constants'
const { Dragger } = Upload const { Dragger } = Upload
@ -149,6 +149,7 @@ const Documents = () => {
<th>Size</th> <th>Size</th>
<th>Last Synch</th> <th>Last Synch</th>
<th>Status</th> <th>Status</th>
<th>Result</th>
<th>Operation</th> <th>Operation</th>
</tr> </tr>
</thead> </thead>
@ -157,11 +158,7 @@ const Documents = () => {
<tr key={row.id}> <tr key={row.id}>
<td>{row.doc_name}</td> <td>{row.doc_name}</td>
<td> <td>
<Chip <Chip variant="solid" color="neutral" sx={{ opacity: 0.5 }}>
variant="solid"
color="neutral"
sx={{ opacity: .5 }}
>
{row.doc_type} {row.doc_type}
</Chip> </Chip>
</td> </td>
@ -169,7 +166,7 @@ const Documents = () => {
<td>{moment(row.last_sync).format('YYYY-MM-DD HH:MM:SS')}</td> <td>{moment(row.last_sync).format('YYYY-MM-DD HH:MM:SS')}</td>
<td> <td>
<Chip <Chip
sx={{ opacity: .5 }} sx={{ opacity: 0.5 }}
variant="solid" variant="solid"
color={(function () { color={(function () {
switch (row.status) { switch (row.status) {
@ -187,6 +184,37 @@ const Documents = () => {
{row.status} {row.status}
</Chip> </Chip>
</td> </td>
<td>
{(function () {
if (row.status === 'TODO' || row.status === 'RUNNING') {
return ''
} else if (row.status === 'FINISHED') {
return (
<Popover content={row.result} trigger="hover">
<Chip
variant="solid"
color="success"
sx={{ opacity: 0.5 }}
>
SUCCESS
</Chip>
</Popover>
)
} else {
return (
<Popover content={row.result} trigger="hover">
<Chip
variant="solid"
color="danger"
sx={{ opacity: 0.5 }}
>
FAILED
</Chip>
</Popover>
)
}
})()}
</td>
<td> <td>
{ {
<> <>
@ -301,7 +329,10 @@ const Documents = () => {
{stepsOfAddingDocument.map((item: any, index: number) => ( {stepsOfAddingDocument.map((item: any, index: number) => (
<Item <Item
key={item} key={item}
sx={{ fontWeight: activeStep === index ? 'bold' : '', color: activeStep === index ? '#814DDE' : '' }} sx={{
fontWeight: activeStep === index ? 'bold' : '',
color: activeStep === index ? '#814DDE' : ''
}}
> >
{item} {item}
</Item> </Item>
@ -393,7 +424,7 @@ const Documents = () => {
)} )}
</Box> </Box>
<Button <Button
variant='outlined' variant="outlined"
onClick={async () => { onClick={async () => {
if (documentName === '') { if (documentName === '') {
message.error('Please input the name') message.error('Please input the name')