|
|
|
|
|
|
|
|
import { ReactComponent as RefreshIcon } from '@/assets/svg/refresh.svg'; |
|
|
import { ReactComponent as RefreshIcon } from '@/assets/svg/refresh.svg'; |
|
|
import { ReactComponent as RunIcon } from '@/assets/svg/run.svg'; |
|
|
import { ReactComponent as RunIcon } from '@/assets/svg/run.svg'; |
|
|
import { useTranslate } from '@/hooks/commonHooks'; |
|
|
import { useTranslate } from '@/hooks/commonHooks'; |
|
|
import { useRunDocument } from '@/hooks/documentHooks'; |
|
|
|
|
|
import { IKnowledgeFile } from '@/interfaces/database/knowledge'; |
|
|
import { IKnowledgeFile } from '@/interfaces/database/knowledge'; |
|
|
import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd'; |
|
|
import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd'; |
|
|
|
|
|
import classNames from 'classnames'; |
|
|
import { useTranslation } from 'react-i18next'; |
|
|
import { useTranslation } from 'react-i18next'; |
|
|
import reactStringReplace from 'react-string-replace'; |
|
|
import reactStringReplace from 'react-string-replace'; |
|
|
import { RunningStatus, RunningStatusMap } from '../constant'; |
|
|
import { RunningStatus, RunningStatusMap } from '../constant'; |
|
|
|
|
|
import { useHandleRunDocumentByIds } from '../hooks'; |
|
|
import { isParserRunning } from '../utils'; |
|
|
import { isParserRunning } from '../utils'; |
|
|
import styles from './index.less'; |
|
|
import styles from './index.less'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const text = record.run; |
|
|
const text = record.run; |
|
|
const runningStatus = RunningStatusMap[text]; |
|
|
const runningStatus = RunningStatusMap[text]; |
|
|
const { t } = useTranslation(); |
|
|
const { t } = useTranslation(); |
|
|
const runDocumentByIds = useRunDocument(); |
|
|
|
|
|
|
|
|
const { handleRunDocumentByIds, loading } = useHandleRunDocumentByIds( |
|
|
|
|
|
record.id, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
const isRunning = isParserRunning(text); |
|
|
const isRunning = isParserRunning(text); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const label = t(`knowledgeDetails.runningStatus${text}`); |
|
|
const label = t(`knowledgeDetails.runningStatus${text}`); |
|
|
|
|
|
|
|
|
const handleOperationIconClick = () => { |
|
|
const handleOperationIconClick = () => { |
|
|
runDocumentByIds({ |
|
|
|
|
|
doc_ids: [record.id], |
|
|
|
|
|
run: isRunning ? 2 : 1, |
|
|
|
|
|
knowledgeBaseId: record.kb_id, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
handleRunDocumentByIds(record.id, record.kb_id, isRunning); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
|
|
|
|
|
|
)} |
|
|
)} |
|
|
</Tag> |
|
|
</Tag> |
|
|
</Popover> |
|
|
</Popover> |
|
|
<div onClick={handleOperationIconClick} className={styles.operationIcon}> |
|
|
|
|
|
|
|
|
<div |
|
|
|
|
|
onClick={handleOperationIconClick} |
|
|
|
|
|
className={classNames(styles.operationIcon, { |
|
|
|
|
|
[styles.operationIconSpin]: loading, |
|
|
|
|
|
})} |
|
|
|
|
|
> |
|
|
<OperationIcon /> |
|
|
<OperationIcon /> |
|
|
</div> |
|
|
</div> |
|
|
</Flex> |
|
|
</Flex> |