release: bump version to 0.80.1
This commit is contained in:
1 parent
41059ca42a
commit
4b2004b7d8
29 files changed
+1843
-220
No files matched your search
@@ -0,0 +1,92 @@
|
||||
import { Square, ToggleLeft, ToggleRight, X } from 'lucide-react'
|
||||
|
||||
import { Button } from '../ui/button'
|
||||
|
||||
export type DatasourceBatchAction = '' | 'enable' | 'disable' | 'trigger' | 'stop'
|
||||
|
||||
interface DatasourceBatchBarProps {
|
||||
selectedCount: number
|
||||
enableCount: number
|
||||
disableCount: number
|
||||
triggerCount: number
|
||||
stopCount: number
|
||||
busy: DatasourceBatchAction
|
||||
translate: (value: string) => string
|
||||
onEnable: () => void
|
||||
onDisable: () => void
|
||||
onTrigger: () => void
|
||||
onStop: () => void
|
||||
onClear: () => void
|
||||
}
|
||||
|
||||
export function DatasourceBatchBar({
|
||||
selectedCount,
|
||||
enableCount,
|
||||
disableCount,
|
||||
triggerCount,
|
||||
stopCount,
|
||||
busy,
|
||||
translate,
|
||||
onEnable,
|
||||
onDisable,
|
||||
onTrigger,
|
||||
onStop,
|
||||
onClear,
|
||||
}: DatasourceBatchBarProps) {
|
||||
const locked = Boolean(busy)
|
||||
return (
|
||||
<div className="an-batch-bar" role="toolbar" aria-label={translate('批量操作')}>
|
||||
<span className="an-batch-bar__count">
|
||||
<strong>{selectedCount}</strong>
|
||||
{translate('已选择')}
|
||||
</span>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="subtle"
|
||||
onClick={onEnable}
|
||||
disabled={locked || !enableCount}
|
||||
loading={busy === 'enable'}
|
||||
title={translate('启用调度')}
|
||||
>
|
||||
<ToggleRight size={15} aria-hidden="true" />
|
||||
{translate('启用')}
|
||||
<span className="an-batch-bar__num">{enableCount}</span>
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="subtle"
|
||||
onClick={onDisable}
|
||||
disabled={locked || !disableCount}
|
||||
loading={busy === 'disable'}
|
||||
title={translate('停用调度')}
|
||||
>
|
||||
<ToggleLeft size={15} aria-hidden="true" />
|
||||
{translate('停用')}
|
||||
<span className="an-batch-bar__num">{disableCount}</span>
|
||||
</Button>
|
||||
{stopCount ? (
|
||||
<Button size="sm" variant="danger" onClick={onStop} disabled={locked} loading={busy === 'stop'} title={translate('停止采集')}>
|
||||
<Square size={14} aria-hidden="true" />
|
||||
{translate('停止')}
|
||||
<span className="an-batch-bar__num">{stopCount}</span>
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="primary"
|
||||
icon="trigger"
|
||||
onClick={onTrigger}
|
||||
disabled={locked || !triggerCount}
|
||||
loading={busy === 'trigger'}
|
||||
title={translate('立即采集')}
|
||||
>
|
||||
{translate('立即采集')}
|
||||
<span className="an-batch-bar__num">{triggerCount}</span>
|
||||
</Button>
|
||||
)}
|
||||
<Button size="icon" variant="subtle" onClick={onClear} disabled={locked} title={translate('清除选择')} aria-label={translate('清除选择')}>
|
||||
<X size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,15 +3,18 @@ import axios from 'axios'
|
||||
import {
|
||||
AlertTriangle,
|
||||
ArrowLeft,
|
||||
ArrowUpRight,
|
||||
Bot,
|
||||
BrushCleaning,
|
||||
CheckCircle2,
|
||||
ChevronRight,
|
||||
CircleHelp,
|
||||
Copy,
|
||||
Database,
|
||||
DatabaseZap,
|
||||
Eye,
|
||||
FileText,
|
||||
FilterX,
|
||||
Globe2,
|
||||
History,
|
||||
ImageUp,
|
||||
@@ -41,6 +44,7 @@ import { legacyUiTextEnUS } from '../../i18n/legacy-ui'
|
||||
import { useLocale, type SupportedLocale } from '../../i18n/locale'
|
||||
import { AdminLayout } from '../components/layout/AdminLayout'
|
||||
import { DataTable } from '../components/data-table/DataTable'
|
||||
import { DatasourceBatchBar, type DatasourceBatchAction } from '../components/datasources/DatasourceBatchBar'
|
||||
import { Button, type ButtonProps } from '../components/ui/button'
|
||||
import { ConfirmDialog, Dialog } from '../components/ui/dialog'
|
||||
import { Textarea } from '../components/ui/input'
|
||||
@@ -126,12 +130,13 @@ type BrandAssetTargetKey = 'logo_src' | 'title_src'
|
||||
const DEFAULT_DATASOURCE_FILTERS: DatasourceFilters = {
|
||||
product: '',
|
||||
module: '',
|
||||
isActive: 'true',
|
||||
isActive: '',
|
||||
runStatus: '',
|
||||
dataStatus: '',
|
||||
}
|
||||
|
||||
const DATASOURCE_FILTER_STORAGE_KEY = 'planet.admin.datasource.filters'
|
||||
// v2: the default scheduling filter changed from "enabled only" to "all".
|
||||
const DATASOURCE_FILTER_STORAGE_KEY = 'planet.admin.datasource.filters.v2'
|
||||
const DATASOURCE_FILTER_QUERY_KEYS = ['product', 'module', 'is_active', 'run_status', 'data_status']
|
||||
const DATASOURCE_TERMINAL_STATUSES = new Set(['success', 'completed', 'failed', 'cancelled', 'canceled', 'stopped'])
|
||||
const TASK_ACTIVE_STATUSES = new Set(['queued', 'pending', 'running', 'cancelling'])
|
||||
@@ -749,6 +754,7 @@ function ModuleTable({
|
||||
columns,
|
||||
selection,
|
||||
loading,
|
||||
className = '',
|
||||
}: {
|
||||
rows: TableRecord[]
|
||||
selected: TableRecord | null
|
||||
@@ -762,16 +768,20 @@ function ModuleTable({
|
||||
isRowSelectable?: (row: TableRecord) => boolean
|
||||
}
|
||||
loading?: boolean
|
||||
className?: string
|
||||
}) {
|
||||
const { locale } = useLocale()
|
||||
const tableColumns = useMemo(() => columns || defaultColumns(onSelect, locale), [columns, locale, onSelect])
|
||||
return (
|
||||
<DataTable
|
||||
className="an-resource-table"
|
||||
className={`an-resource-table${className ? ` ${className}` : ''}`}
|
||||
columns={tableColumns}
|
||||
data={rows}
|
||||
emptyText={localizeAdminText('当前模块暂无数据', locale)}
|
||||
getRowClassName={(row) => row.__rowId === selected?.__rowId ? 'is-selected' : undefined}
|
||||
getRowClassName={(row) => [
|
||||
row.__rowId === selected?.__rowId ? 'is-selected' : '',
|
||||
row.__filterStale ? 'is-filter-stale' : '',
|
||||
].filter(Boolean).join(' ') || undefined}
|
||||
getRowId={(row) => row.__rowId}
|
||||
loading={loading}
|
||||
onRowClick={onSelect}
|
||||
@@ -2975,6 +2985,7 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [actionLoading, setActionLoading] = useState(false)
|
||||
const [rowActionLoading, setRowActionLoading] = useState<Record<string, boolean>>({})
|
||||
const [datasourceBatchAction, setDatasourceBatchAction] = useState<DatasourceBatchAction>('')
|
||||
const [collectionQueue, setCollectionQueue] = useState<CollectionQueueItem[]>([])
|
||||
const [collectionQueueOpen, setCollectionQueueOpen] = useState(false)
|
||||
const collectionQueueRef = useRef<HTMLDivElement>(null)
|
||||
@@ -3066,10 +3077,14 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
}
|
||||
}, [collectionQueueOpen])
|
||||
|
||||
const loadRef = useRef<((sectionKey?: string) => Promise<void>) | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const changed = !datasourceFiltersEqual(datasourceFiltersRef.current, datasourceFilters)
|
||||
datasourceFiltersRef.current = datasourceFilters
|
||||
if (config === configs.datasources) {
|
||||
setStates((current) => current.filter((state) => state.section.key !== 'builtin'))
|
||||
// Keep the current rows visible while the filtered list reloads.
|
||||
if (config === configs.datasources && changed) {
|
||||
void loadRef.current?.('builtin')
|
||||
}
|
||||
}, [config, datasourceFilters])
|
||||
|
||||
@@ -3190,6 +3205,7 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [activeSectionKey, config.sections, sectionRequestParams])
|
||||
loadRef.current = load
|
||||
|
||||
const datasourceBuiltinSection = useMemo(
|
||||
() => config.sections.find((section) => section.key === 'builtin') || config.sections[0],
|
||||
@@ -3261,7 +3277,8 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
const updateDatasourceRow = useCallback((row: AnyRecord, options: { removeIfFilteredOut?: boolean } = {}) => {
|
||||
if (config !== configs.datasources) return
|
||||
const normalized = normalizeDatasourceTableRecord(row)
|
||||
const shouldKeep = !options.removeIfFilteredOut || datasourceRowMatchesFilters(normalized, datasourceFiltersRef.current)
|
||||
const matchesFilters = datasourceRowMatchesFilters(normalized, datasourceFiltersRef.current)
|
||||
const shouldKeep = !options.removeIfFilteredOut || matchesFilters
|
||||
setStates((currentStates) => currentStates.map((state) => {
|
||||
if (state.section.key !== 'builtin') return state
|
||||
let matched = false
|
||||
@@ -3270,7 +3287,8 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
return [existing]
|
||||
}
|
||||
matched = true
|
||||
return shouldKeep ? [{ ...existing, ...normalized }] : []
|
||||
// Rows that stop matching the filter stay in place (dimmed) until the next reload.
|
||||
return shouldKeep ? [{ ...existing, ...normalized, __filterStale: !matchesFilters }] : []
|
||||
})
|
||||
if (!matched && shouldKeep) rows.push(normalized)
|
||||
return { ...state, rows, raw: isObjectRecord(state.raw) ? { ...state.raw, data: rows, total: rows.length } : state.raw }
|
||||
@@ -3459,12 +3477,6 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
() => isDatasourceBuiltinSection ? rows.filter((row) => datasourceSelectedRowIds.has(row.__rowId)) : [],
|
||||
[datasourceSelectedRowIds, isDatasourceBuiltinSection, rows],
|
||||
)
|
||||
const selectedDatasourceIds = useMemo(
|
||||
() => selectedDatasourceRows
|
||||
.map((row) => Number(row.id))
|
||||
.filter((id) => Number.isFinite(id) && id > 0),
|
||||
[selectedDatasourceRows],
|
||||
)
|
||||
const toggleDatasourceSelection = useCallback((rowId: string) => {
|
||||
setDatasourceSelectedRowIds((current) => {
|
||||
const next = new Set(current)
|
||||
@@ -3756,37 +3768,151 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
}
|
||||
}
|
||||
|
||||
const triggerSelectedDatasources = async () => {
|
||||
const sourceIds = selectedDatasourceIds
|
||||
if (!sourceIds.length) {
|
||||
toast({ title: '请先勾选数据源', description: '勾选内置源后,主触发按钮会只触发所选数据源。', tone: 'error' })
|
||||
const applyDatasourceCounts = (counts: unknown) => {
|
||||
if (!isObjectRecord(counts)) return
|
||||
setStates((current) => current.map((state) => (
|
||||
state.section.key === 'builtin' && isObjectRecord(state.raw)
|
||||
? { ...state, raw: { ...state.raw, counts } }
|
||||
: state
|
||||
)))
|
||||
}
|
||||
|
||||
const postDatasourceActive = async (id: string, nextActive: boolean): Promise<AnyRecord> => {
|
||||
const response = await axios.post(apiPath(`/datasources/${encodeURIComponent(id)}/${nextActive ? 'enable' : 'disable'}`))
|
||||
return isObjectRecord(response.data) ? response.data : {}
|
||||
}
|
||||
|
||||
const toastDatasourceActiveResult = (name: string, nextActive: boolean, result: AnyRecord | null, error?: unknown) => {
|
||||
if (error !== undefined) {
|
||||
toast({
|
||||
title: localizeAdminText(nextActive ? '启用调度失败' : '停用调度失败', locale),
|
||||
description: localizeAdminText(actionErrorMessage(error), locale),
|
||||
tone: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
setActionLoading(true)
|
||||
toast({
|
||||
title: localizeAdminText(nextActive ? '已启用调度' : '已停用调度', locale),
|
||||
description: localizeDisplayValue(name, locale) || undefined,
|
||||
tone: result?.sync_failed ? 'error' : 'success',
|
||||
})
|
||||
}
|
||||
|
||||
const setDatasourceActive = async (record: TableRecord, nextActive: boolean) => {
|
||||
const id = pick(record, ['id', 'source_id', 'key', 'name'], '')
|
||||
if (!id) return
|
||||
setRowActionLoading((current) => ({ ...current, [id]: true }))
|
||||
try {
|
||||
const result = await postDatasourceActive(id, nextActive)
|
||||
const row = objectAt(result, 'data')
|
||||
updateDatasourceRow(Object.keys(row).length ? row : { ...record, is_active: nextActive })
|
||||
applyDatasourceCounts(result.counts)
|
||||
toastDatasourceActiveResult(recordTitle(record), nextActive, result)
|
||||
} catch (error) {
|
||||
toastDatasourceActiveResult(recordTitle(record), nextActive, null, error)
|
||||
} finally {
|
||||
setRowActionLoading((current) => ({ ...current, [id]: false }))
|
||||
}
|
||||
}
|
||||
|
||||
const setCollectorActive = async (record: AnyRecord, nextActive: boolean) => {
|
||||
const id = text(record.id, '')
|
||||
if (!id) return
|
||||
setRowActionLoading((current) => ({ ...current, [id]: true }))
|
||||
try {
|
||||
const result = await postDatasourceActive(id, nextActive)
|
||||
const saved = objectAt(result, 'data').is_active
|
||||
const resolved = typeof saved === 'boolean' ? saved : nextActive
|
||||
setStates((current) => current.map((state) => (
|
||||
state.section.key !== 'collectors'
|
||||
? state
|
||||
: { ...state, rows: state.rows.map((row) => (text(row.id, '') === id ? { ...row, is_active: resolved, __status: String(resolved) } : row)) }
|
||||
)))
|
||||
toastDatasourceActiveResult(recordTitle(record), nextActive, result)
|
||||
} catch (error) {
|
||||
toastDatasourceActiveResult(recordTitle(record), nextActive, null, error)
|
||||
} finally {
|
||||
setRowActionLoading((current) => ({ ...current, [id]: false }))
|
||||
}
|
||||
}
|
||||
|
||||
const setSelectedDatasourcesActive = async (nextActive: boolean) => {
|
||||
const sourceIds = selectedDatasourceRows
|
||||
.filter((row) => (row.is_active !== false) !== nextActive)
|
||||
.map((row) => Number(row.id))
|
||||
.filter((id) => Number.isFinite(id) && id > 0)
|
||||
if (!sourceIds.length) return
|
||||
setDatasourceBatchAction(nextActive ? 'enable' : 'disable')
|
||||
try {
|
||||
const response = await axios.post(apiPath('/datasources/batch-status'), { source_ids: sourceIds, is_active: nextActive })
|
||||
const updated = arrayAt(response.data, 'updated')
|
||||
updated.forEach((row) => updateDatasourceRow(row))
|
||||
applyDatasourceCounts(response.data?.counts)
|
||||
const missing = Array.isArray(response.data?.not_found) ? response.data.not_found.length : 0
|
||||
const syncFailed = Array.isArray(response.data?.sync_failed) ? response.data.sync_failed.length : 0
|
||||
const issues = [
|
||||
missing ? `${localizeAdminText('数据源不存在', locale)} · ${missing}` : '',
|
||||
syncFailed ? `${localizeAdminText('调度同步失败', locale)} · ${syncFailed}` : '',
|
||||
].filter(Boolean).join(' / ')
|
||||
toast({
|
||||
title: `${localizeAdminText(nextActive ? '已启用调度' : '已停用调度', locale)} · ${updated.length}`,
|
||||
description: issues || undefined,
|
||||
tone: issues ? 'error' : 'success',
|
||||
})
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: localizeAdminText(nextActive ? '启用调度失败' : '停用调度失败', locale),
|
||||
description: localizeAdminText(actionErrorMessage(error), locale),
|
||||
tone: 'error',
|
||||
})
|
||||
} finally {
|
||||
setDatasourceBatchAction('')
|
||||
}
|
||||
}
|
||||
|
||||
const confirmDisableSelectedDatasources = () => {
|
||||
const count = selectedDatasourceRows.filter((row) => row.is_active !== false).length
|
||||
if (!count) return
|
||||
setConfirmAction({
|
||||
title: '停用调度',
|
||||
description: `停用 ${count} 个数据源的定时调度,运行中的任务不受影响。`,
|
||||
danger: true,
|
||||
confirmLabel: '停用',
|
||||
run: () => setSelectedDatasourcesActive(false),
|
||||
})
|
||||
}
|
||||
|
||||
const triggerSelectedDatasources = async () => {
|
||||
const sourceIds = selectedDatasourceRows
|
||||
.filter((row) => row.is_active !== false)
|
||||
.map((row) => Number(row.id))
|
||||
.filter((id) => Number.isFinite(id) && id > 0)
|
||||
if (!sourceIds.length) return
|
||||
setDatasourceBatchAction('trigger')
|
||||
try {
|
||||
const response = await axios.post(apiPath('/datasources/trigger-batch'), {
|
||||
source_ids: sourceIds,
|
||||
force: false,
|
||||
})
|
||||
addBatchQueueResult(response.data)
|
||||
arrayAt(response.data, 'triggered').forEach((item) => {
|
||||
const triggered = arrayAt(response.data, 'triggered')
|
||||
triggered.forEach((item) => {
|
||||
const sourceId = text(item.id || item.source_id || item.datasource_id, '')
|
||||
const record = rows.find((row) => text(row.id, '') === sourceId || text(row.source, '') === text(item.source, ''))
|
||||
if (record) scheduleDatasourceTaskPoll(record, item.task_id as number | string | null | undefined)
|
||||
})
|
||||
replaceSelectedWithPayload('trigger-batch', '批量触发结果', [{
|
||||
...response.data,
|
||||
__title: '批量触发结果',
|
||||
__module: '批量任务',
|
||||
__status: '已提交',
|
||||
__metric: `${sourceIds.length} 个数据源`,
|
||||
}])
|
||||
const skipped = arrayAt(response.data, 'skipped').length
|
||||
const failed = arrayAt(response.data, 'failed').length
|
||||
setDatasourceSelectedRowIds(new Set())
|
||||
toast({ title: '已触发所选数据源', description: `${sourceIds.length} 个数据源已提交。`, tone: 'success' })
|
||||
toast({
|
||||
title: `${localizeAdminText('已提交采集', locale)} · ${triggered.length}`,
|
||||
description: [skipped ? `跳过 ${skipped}(未到采集间隔或任务运行中)` : '', failed ? `失败 ${failed}` : ''].filter(Boolean).join(',') || undefined,
|
||||
tone: failed || !triggered.length ? 'error' : 'success',
|
||||
})
|
||||
} catch (error) {
|
||||
toast({ title: '触发已选失败', description: error instanceof Error ? error.message : '接口请求失败', tone: 'error' })
|
||||
toast({ title: localizeAdminText('触发采集失败', locale), description: localizeAdminText(actionErrorMessage(error), locale), tone: 'error' })
|
||||
} finally {
|
||||
setActionLoading(false)
|
||||
setDatasourceBatchAction('')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3826,41 +3952,6 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
}
|
||||
}
|
||||
|
||||
const triggerDatasourcePrimaryAction = async () => {
|
||||
if (selectedDatasourceIds.length && selectedActiveCollectQueueItems.length) {
|
||||
await cancelCollectionQueueItems(selectedActiveCollectQueueItems, '停止已选')
|
||||
return
|
||||
}
|
||||
if (!selectedDatasourceIds.length && activeCollectQueueItems.length) {
|
||||
await cancelCollectionQueueItems(activeCollectQueueItems, '停止采集')
|
||||
return
|
||||
}
|
||||
if (selectedDatasourceIds.length) {
|
||||
await triggerSelectedDatasources()
|
||||
return
|
||||
}
|
||||
await triggerAllDatasources()
|
||||
}
|
||||
|
||||
const triggerAllDatasources = async () => {
|
||||
setActionLoading(true)
|
||||
try {
|
||||
toast({ title: '正在提交采集队列', description: '触发全部会按后端调度规则跳过未到采集间隔的源。' })
|
||||
const response = await axios.post(apiPath('/datasources/trigger-all'))
|
||||
addBatchQueueResult(response.data)
|
||||
arrayAt(response.data, 'triggered').forEach((item) => {
|
||||
const sourceId = text(item.id || item.source_id || item.datasource_id, '')
|
||||
const record = rows.find((row) => text(row.id, '') === sourceId || text(row.source, '') === text(item.source, ''))
|
||||
if (record) scheduleDatasourceTaskPoll(record, item.task_id as number | string | null | undefined)
|
||||
})
|
||||
toast({ title: '采集队列已提交', description: `${arrayAt(response.data, 'triggered').length} 个任务已进入队列。`, tone: 'success' })
|
||||
} catch (error) {
|
||||
toast({ title: '触发全部失败', description: actionErrorMessage(error), tone: 'error' })
|
||||
} finally {
|
||||
setActionLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const scheduleDatasourceTaskPoll = (record: TableRecord, taskId?: number | string | null) => {
|
||||
const id = pick(record, ['id', 'source_id', 'key', 'name'], '')
|
||||
if (!id) return
|
||||
@@ -4096,7 +4187,6 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
source: text(record.source || response.data?.collector_name, ''),
|
||||
taskType: 'collect',
|
||||
}))
|
||||
setCollectionQueueOpen(true)
|
||||
completedDatasourceTasksRef.current.delete(pendingKey)
|
||||
updateDatasourceRow({
|
||||
...record,
|
||||
@@ -4112,14 +4202,11 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
progress: 0,
|
||||
error_message: null,
|
||||
})
|
||||
replaceSelectedWithPayload('task-status', '任务状态', [{
|
||||
...response.data,
|
||||
__title: `${recordTitle(record)} 任务状态`,
|
||||
__module: '任务状态',
|
||||
__status: '已提交',
|
||||
__metric: response.data?.task_id || '-',
|
||||
}])
|
||||
toast({ title: force ? '已强制重新触发' : '任务已触发', tone: 'success' })
|
||||
toast({
|
||||
title: localizeAdminText(force ? '已强制重新触发' : '已提交采集', locale),
|
||||
description: localizeDisplayValue(recordTitle(record), locale) || undefined,
|
||||
tone: 'success',
|
||||
})
|
||||
scheduleDatasourceTaskPoll(record, taskId)
|
||||
} catch (error) {
|
||||
toast({ title: '触发采集失败', description: actionErrorMessage(error), tone: 'error' })
|
||||
@@ -5609,7 +5696,10 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
),
|
||||
}
|
||||
})
|
||||
: fields
|
||||
: config === configs.collection && activeSection.key === 'collectors'
|
||||
// Scheduling is toggled immediately from the panel heading, not saved with the draft.
|
||||
? fields.filter((field) => field.key !== 'is_active')
|
||||
: fields
|
||||
const renderNewsFeedEditor = () => {
|
||||
if (!activeGroup) return null
|
||||
const currentSource = draftRecord(hierarchyDraft, activeGroup.record)
|
||||
@@ -6008,7 +6098,7 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
if (activeSection.key === 'collectors' && id) {
|
||||
const globalSingleLocked = Boolean(collectorStoragePolicy?.global_single_lock || activeGroup.record.snapshot_locked === true)
|
||||
await saveHierarchySettings(`/settings/collectors/${encodeURIComponent(id)}`, {
|
||||
is_active: Boolean(payload.is_active),
|
||||
is_active: activeGroup.record.is_active !== false,
|
||||
priority: text(payload.priority, 'P1'),
|
||||
frequency_minutes: Number(payload.frequency_minutes || 60),
|
||||
snapshot_mode: globalSingleLocked ? 'single' : text(payload.snapshot_mode, 'single'),
|
||||
@@ -6279,6 +6369,17 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
<p>{localizeDisplayValue(activeGroup?.description || '选择左侧父级后编辑它的子配置。', locale)}</p>
|
||||
</div>
|
||||
<div className="an-toolbar">
|
||||
{config === configs.collection && activeSection.key === 'collectors' && activeGroup ? (
|
||||
<span className="an-inline-switch" title={localizeAdminText('定时调度', locale)}>
|
||||
<AdminSwitch
|
||||
checked={activeGroup.record.is_active !== false}
|
||||
disabled={Boolean(rowActionLoading[text(activeGroup.record.id, '')])}
|
||||
label={localizeAdminText(activeGroup.record.is_active !== false ? '停用调度' : '启用调度', locale)}
|
||||
onCheckedChange={(next) => void setCollectorActive(activeGroup.record, next)}
|
||||
/>
|
||||
<span>{localizeAdminText('定时调度', locale)}</span>
|
||||
</span>
|
||||
) : null}
|
||||
{config === configs.earthContent && activeSection.key === 'brand' ? (
|
||||
<>
|
||||
<Button size="icon" variant="subtle" title="重置品牌配置" aria-label="重置品牌配置" onClick={() => setConfirmAction({
|
||||
@@ -6723,53 +6824,39 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
const id = pick(selected, ['config_id', 'id', 'source_id', 'key', 'name'], '')
|
||||
|
||||
if (config === configs.datasources && endpointKey === 'builtin' && id) {
|
||||
const isDatasourceActive = selected.is_active !== false
|
||||
const toggle = isDatasourceActive ? 'disable' : 'enable'
|
||||
const toggleLabel = isDatasourceActive ? '停用数据源调度' : '启用数据源调度'
|
||||
const rowLoading = Boolean(rowActionLoading[id])
|
||||
const sourceId = text(selected.id || selected.source_id, '')
|
||||
const source = text(selected.source || selected.collector_name, '')
|
||||
const queueItem = collectionQueue.find((item) => isSameDatasourceRow(selected, item.sourceId || '', item.source || '') && isActiveQueueStatus(item.status))
|
||||
const activeCollectItem = queueItem?.taskType === 'collect' ? queueItem : null
|
||||
const activeDeleteItem = queueItem?.taskType === 'clear_data' ? queueItem : null
|
||||
const activeTaskId = queueItem?.taskId || selected.task_id
|
||||
const isCollecting = isCollectTaskActive(selected) || Boolean(activeCollectItem)
|
||||
actions.push(
|
||||
<Button key="load-detail" size="icon" variant="subtle" icon="detail" onClick={() => void loadDatasourceDetail(selected)} loading={actionLoading} title="详情/统计" aria-label="详情/统计" />,
|
||||
isCollecting && (activeCollectItem?.taskId || activeTaskId) ? (
|
||||
<Button key="trigger" variant="danger" onClick={() => void cancelQueueItem(queueItemFromDatasourceRow(selected, (activeCollectItem?.taskId || activeTaskId) as number | string, {
|
||||
taskType: 'collect',
|
||||
status: activeCollectItem?.status || 'running',
|
||||
phase: text(selected.phase, queueItem?.phase || 'running'),
|
||||
phaseMessage: text(selected.phase_message, queueItem?.phaseMessage || '后端任务仍在运行'),
|
||||
progress: typeof selected.progress === 'number' ? selected.progress : queueItem?.progress,
|
||||
createdAt: queueItem?.createdAt || Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
}))} loading={rowLoading}>
|
||||
<Square size={14} />
|
||||
停止采集
|
||||
</Button>
|
||||
) : (
|
||||
<Button key="trigger" variant="primary" icon="trigger" onClick={() => void triggerDatasourceWithPrecheck(selected)} loading={rowLoading}>触发采集</Button>
|
||||
),
|
||||
<Button key="toggle" size="icon" variant={toggle === 'enable' ? 'subtle' : 'danger'} icon={toggle === 'enable' ? 'start' : 'stop'} onClick={() => void requestAction(toggleLabel, 'post', `/datasources/${encodeURIComponent(id)}/${toggle}`)} loading={actionLoading} title={toggleLabel} aria-label={toggleLabel} />,
|
||||
<Button key="task-status" size="icon" variant="subtle" icon="status" onClick={() => void loadTaskStatus(selected)} loading={actionLoading} title="任务状态" aria-label="任务状态" />,
|
||||
<Button key="clear-cache" size="icon" variant="subtle" onClick={() => setConfirmAction({
|
||||
title: '清理数据源缓存',
|
||||
description: `确认清理 ${recordTitle(selected)} 的智能星球展示缓存?这不会删除数据库里的采集数据。`,
|
||||
danger: false,
|
||||
confirmLabel: '清理缓存',
|
||||
run: () => clearDatasourceCache(selected),
|
||||
})} loading={actionLoading} title="清理缓存" aria-label="清理缓存"><BrushCleaning size={15} /></Button>,
|
||||
activeDeleteItem ? (
|
||||
<Button key="delete-data" size="icon" variant="subtle" onClick={() => void cancelQueueItem(activeDeleteItem)} loading={actionLoading} title="停止删除" aria-label="停止删除"><X size={15} /></Button>
|
||||
) : (
|
||||
<Button key="delete-data" size="icon" variant="danger" onClick={() => setConfirmAction({
|
||||
title: '清理数据库数据',
|
||||
description: `确认删除 ${recordTitle(selected)} 的已采集数据库记录?这不会清理智能星球展示缓存,此操作不可恢复。`,
|
||||
danger: true,
|
||||
confirmLabel: '删除数据',
|
||||
run: () => clearDatasourceData(selected),
|
||||
})} loading={actionLoading} title="清理数据库数据" aria-label="清理数据库数据"><Trash2 size={15} /></Button>
|
||||
),
|
||||
const taskId = text(queueItem?.taskId || selected.task_id, '')
|
||||
return (
|
||||
<nav className="an-detail-links" aria-label={localizeAdminText('数据源详情', locale)}>
|
||||
<button
|
||||
type="button"
|
||||
className="an-detail-link"
|
||||
disabled={actionLoading}
|
||||
onClick={() => void loadDatasourceDetail(selected)}
|
||||
>
|
||||
<span>{localizeAdminText('详情与统计', locale)}</span>
|
||||
<ChevronRight size={14} aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="an-detail-link"
|
||||
disabled={actionLoading}
|
||||
onClick={() => void loadTaskStatus(selected)}
|
||||
>
|
||||
<span>{localizeAdminText('任务状态', locale)}</span>
|
||||
<ChevronRight size={14} aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="an-detail-link an-detail-link--external"
|
||||
onClick={() => openLogsForTask({ taskId, sourceId, source })}
|
||||
>
|
||||
<span>{localizeAdminText('查看日志', locale)}</span>
|
||||
<ArrowUpRight size={14} aria-hidden="true" />
|
||||
</button>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6962,27 +7049,18 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
|
||||
const renderModuleActions = () => {
|
||||
const actions: ReactNode[] = []
|
||||
if (config === configs.datasources) {
|
||||
const selectedCount = selectedDatasourceIds.length
|
||||
const selectedRunningCount = selectedActiveCollectQueueItems.length
|
||||
const allRunningCount = activeCollectQueueItems.length
|
||||
const isStopAction = selectedCount ? selectedRunningCount > 0 : allRunningCount > 0
|
||||
const label = isStopAction
|
||||
? selectedCount ? `停止已选 ${selectedRunningCount}` : '停止采集'
|
||||
: selectedCount ? `触发已选 ${selectedCount}` : '触发全部'
|
||||
const title = isStopAction
|
||||
? selectedCount ? `停止已选中的 ${selectedRunningCount} 个采集任务` : `停止 ${allRunningCount} 个采集任务`
|
||||
: selectedCount ? `触发已选 ${selectedCount} 个数据源` : '触发全部数据源'
|
||||
if (config === configs.datasources && activeCollectQueueItems.length > 0) {
|
||||
const runningCount = activeCollectQueueItems.length
|
||||
actions.push(
|
||||
<Button
|
||||
key="trigger-primary"
|
||||
variant="primary"
|
||||
onClick={() => void triggerDatasourcePrimaryAction()}
|
||||
key="stop-all-active"
|
||||
variant="danger"
|
||||
onClick={() => void cancelCollectionQueueItems(activeCollectQueueItems, '停止采集')}
|
||||
loading={actionLoading}
|
||||
title={title}
|
||||
title={localizeAdminText('停止采集', locale)}
|
||||
>
|
||||
{isStopAction ? <Square size={15} /> : <Radio size={15} />}
|
||||
{label}
|
||||
<Square size={15} />
|
||||
{`${localizeAdminText('停止采集', locale)} ${runningCount}`}
|
||||
</Button>,
|
||||
)
|
||||
}
|
||||
@@ -7049,8 +7127,30 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
|
||||
const renderDatasourceFilters = () => {
|
||||
if (config !== configs.datasources || activeSection?.key !== 'builtin') return null
|
||||
const counts = objectAt(activeState?.raw, 'counts')
|
||||
const countOf = (key: string) => (typeof counts[key] === 'number' ? counts[key] as number : null)
|
||||
const scheduleOptions = [
|
||||
{ value: '', label: '全部状态', count: countOf('all') },
|
||||
{ value: 'true', label: '已启用', count: countOf('active') },
|
||||
{ value: 'false', label: '已停用', count: countOf('inactive') },
|
||||
]
|
||||
const filtersDirty = !datasourceFiltersEqual(datasourceFilters, DEFAULT_DATASOURCE_FILTERS)
|
||||
return (
|
||||
<div className="an-filter-grid an-filter-grid--datasources">
|
||||
<div className="an-segmented an-segmented--counted" role="group" aria-label={localizeAdminText('定时调度', locale)}>
|
||||
{scheduleOptions.map((option) => (
|
||||
<button
|
||||
key={option.value || 'all'}
|
||||
type="button"
|
||||
className={datasourceFilters.isActive === option.value ? 'is-active' : undefined}
|
||||
aria-pressed={datasourceFilters.isActive === option.value}
|
||||
onClick={() => setDatasourceFilter('isActive', option.value)}
|
||||
>
|
||||
{localizeAdminText(option.label, locale)}
|
||||
{option.count !== null ? <span className="an-segmented__count">{option.count}</span> : null}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<label className="an-field an-field--inline-filter">
|
||||
<select className="an-input" value={datasourceFilters.product} onChange={(event) => setDatasourceFilter('product', event.target.value)}>
|
||||
<option value="">全部产品域</option>
|
||||
@@ -7073,13 +7173,6 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
<option value="L4">L4</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="an-field an-field--inline-filter">
|
||||
<select className="an-input" value={datasourceFilters.isActive} onChange={(event) => setDatasourceFilter('isActive', event.target.value)}>
|
||||
<option value="">全部启用状态</option>
|
||||
<option value="true">已启用</option>
|
||||
<option value="false">已停用</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="an-field an-field--inline-filter">
|
||||
<select className="an-input" value={datasourceFilters.runStatus} onChange={(event) => setDatasourceFilter('runStatus', event.target.value)}>
|
||||
<option value="">全部执行状态</option>
|
||||
@@ -7097,6 +7190,23 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
<option value="uncollected">未采集</option>
|
||||
</select>
|
||||
</label>
|
||||
{filtersDirty ? (
|
||||
<Button
|
||||
size="icon"
|
||||
variant="subtle"
|
||||
onClick={() => {
|
||||
const next = { ...DEFAULT_DATASOURCE_FILTERS }
|
||||
setDatasourceSelectedRowIds(new Set())
|
||||
setDatasourceFilters(next)
|
||||
storeDatasourceFilters(next)
|
||||
navigate({ pathname: location.pathname, search: datasourceFiltersSearch(next) }, { replace: true })
|
||||
}}
|
||||
title={localizeAdminText('重置筛选', locale)}
|
||||
aria-label={localizeAdminText('重置筛选', locale)}
|
||||
>
|
||||
<FilterX size={15} />
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7106,7 +7216,6 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
const sourceId = text(selected.id || selected.source_id, '')
|
||||
const source = text(selected.source || selected.collector_name, '')
|
||||
const queueItem = collectionQueue.find((item) => isSameDatasourceRow(selected, item.sourceId || '', item.source || '') && isActiveQueueStatus(item.status))
|
||||
const status = queueItem?.status || datasourceStatus(selected)
|
||||
const taskId = text(queueItem?.taskId || selected.task_id, '')
|
||||
return (
|
||||
<section className="an-task-summary">
|
||||
@@ -7114,19 +7223,13 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
<strong>采集任务</strong>
|
||||
<p>{queueItem?.phaseMessage || text(selected.last_status || selected.phase_message, '当前没有运行中的任务。')}</p>
|
||||
</div>
|
||||
<StatusText tone={statusTone(status)}>{queueStatusLabel(status, queueItem?.taskType || text(selected.task_type, 'collect'))}</StatusText>
|
||||
{queueItem ? <span className="an-task-summary__progress">{queueProgress(queueItem)}%</span> : null}
|
||||
<dl>
|
||||
<dt>数据源</dt><dd>{source || sourceId || '-'}</dd>
|
||||
<dt>任务</dt><dd>{text(taskId, '-')}</dd>
|
||||
<dt>进度</dt><dd>{queueItem ? `${queueProgress(queueItem)}%` : '-'}</dd>
|
||||
<dt>更新时间</dt><dd>{queueItem?.updatedAt ? new Date(queueItem.updatedAt).toLocaleTimeString() : text(selected.last_run_at, '-')}</dd>
|
||||
</dl>
|
||||
<div className="an-task-summary__actions">
|
||||
<Button size="sm" variant="subtle" onClick={() => openLogsForTask({ taskId, sourceId, source })}>
|
||||
<FileText size={14} />
|
||||
查看日志
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -7207,6 +7310,170 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
await cancelCollectionQueueItems([item], `停止${taskTypeLabel(item.taskType)}`)
|
||||
}
|
||||
|
||||
const activeCollectQueueItemFor = (record: AnyRecord) => activeCollectQueueItems.find((item) => isSameDatasourceRow(record, item.sourceId || '', item.source || ''))
|
||||
|
||||
const stopDatasourceCollection = (record: AnyRecord) => {
|
||||
const queueItem = activeCollectQueueItemFor(record)
|
||||
const taskId = (queueItem?.taskId || record.task_id) as number | string | null | undefined
|
||||
if (!taskId) return
|
||||
void cancelQueueItem(queueItemFromDatasourceRow(record, taskId, {
|
||||
taskType: 'collect',
|
||||
status: queueItem?.status || 'running',
|
||||
phase: text(record.phase, queueItem?.phase || 'running'),
|
||||
phaseMessage: text(record.phase_message, queueItem?.phaseMessage || '后端任务仍在运行'),
|
||||
progress: typeof record.progress === 'number' ? record.progress : queueItem?.progress,
|
||||
createdAt: queueItem?.createdAt || Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
}))
|
||||
}
|
||||
|
||||
const datasourceColumns: Array<ColumnDef<TableRecord>> = [
|
||||
{
|
||||
id: 'name',
|
||||
header: localizeAdminText('名称', locale),
|
||||
size: 148,
|
||||
cell: ({ row }) => (
|
||||
<button type="button" className="an-table-link" onClick={() => openResourceDetail(row.original)}>
|
||||
{localizeDisplayValue(recordTitle(row.original), locale)}
|
||||
</button>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'schedule',
|
||||
header: localizeAdminText('定时调度', locale),
|
||||
size: 64,
|
||||
enableSorting: false,
|
||||
cell: ({ row }) => {
|
||||
const record = row.original
|
||||
const id = pick(record, ['id', 'source_id', 'key', 'name'], '')
|
||||
const active = record.is_active !== false
|
||||
return (
|
||||
<span className="an-table-switch" onClick={(event) => event.stopPropagation()}>
|
||||
<AdminSwitch
|
||||
checked={active}
|
||||
disabled={Boolean(rowActionLoading[id])}
|
||||
label={localizeAdminText(active ? '停用调度' : '启用调度', locale)}
|
||||
onCheckedChange={(next) => void setDatasourceActive(record, next)}
|
||||
/>
|
||||
</span>
|
||||
)
|
||||
},
|
||||
},
|
||||
{ id: 'module', header: localizeAdminText('模块', locale), size: 54, cell: ({ row }) => localizeDisplayValue(row.original.__module, locale) },
|
||||
{
|
||||
id: 'status',
|
||||
header: localizeAdminText('状态', locale),
|
||||
size: 96,
|
||||
cell: ({ row }) => {
|
||||
const status = recordDisplayStatus(row.original)
|
||||
return <StatusText tone={statusTone(status)}>{localizeDisplayValue(status, locale)}</StatusText>
|
||||
},
|
||||
},
|
||||
{ id: 'metric', header: localizeAdminText('指标', locale), size: 72, cell: ({ row }) => <span className="an-muted-text">{localizeDisplayValue(semanticLabel(recordMetric(row.original)), locale)}</span> },
|
||||
{ id: 'updated', header: localizeAdminText('更新时间', locale), size: 152, cell: ({ row }) => localizeDisplayValue(row.original.__time, locale) },
|
||||
{
|
||||
id: 'actions',
|
||||
header: localizeAdminText('操作', locale),
|
||||
size: 104,
|
||||
enableSorting: false,
|
||||
cell: ({ row }) => {
|
||||
const record = row.original
|
||||
const id = pick(record, ['id', 'source_id', 'key', 'name'], '')
|
||||
const active = record.is_active !== false
|
||||
const loadingRow = Boolean(rowActionLoading[id])
|
||||
const collecting = isCollectTaskActive(record) || Boolean(activeCollectQueueItemFor(record))
|
||||
const activeDeleteItem = collectionQueue.find(
|
||||
(item) => isSameDatasourceRow(record, item.sourceId || '', item.source || '') && item.taskType === 'clear_data' && isActiveQueueStatus(item.status),
|
||||
)
|
||||
return (
|
||||
<span className="an-table-actions" onClick={(event) => event.stopPropagation()}>
|
||||
{collecting ? (
|
||||
<Button size="icon" variant="danger" onClick={() => stopDatasourceCollection(record)} loading={loadingRow} title={localizeAdminText('停止采集', locale)} aria-label={localizeAdminText('停止采集', locale)}>
|
||||
<Square size={14} />
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
icon="trigger"
|
||||
onClick={() => void triggerDatasourceWithPrecheck(record)}
|
||||
loading={loadingRow}
|
||||
disabled={!active}
|
||||
title={localizeAdminText(active ? '立即采集' : '调度已停用', locale)}
|
||||
aria-label={localizeAdminText('立即采集', locale)}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
onClick={() => setConfirmAction({
|
||||
title: '清理数据源缓存',
|
||||
description: `确认清理 ${recordTitle(record)} 的智能星球展示缓存?这不会删除数据库里的采集数据。`,
|
||||
danger: false,
|
||||
confirmLabel: '清理缓存',
|
||||
run: () => clearDatasourceCache(record),
|
||||
})}
|
||||
disabled={actionLoading}
|
||||
title={localizeAdminText('清理缓存', locale)}
|
||||
aria-label={localizeAdminText('清理缓存', locale)}
|
||||
>
|
||||
<BrushCleaning size={14} />
|
||||
</Button>
|
||||
{activeDeleteItem ? (
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
onClick={() => void cancelQueueItem(activeDeleteItem)}
|
||||
disabled={actionLoading}
|
||||
title={localizeAdminText('停止删除', locale)}
|
||||
aria-label={localizeAdminText('停止删除', locale)}
|
||||
>
|
||||
<X size={14} />
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="an-table-action--danger"
|
||||
onClick={() => setConfirmAction({
|
||||
title: '清理数据库数据',
|
||||
description: `确认删除 ${recordTitle(record)} 的已采集数据库记录?这不会清理智能星球展示缓存,此操作不可恢复。`,
|
||||
danger: true,
|
||||
confirmLabel: '删除数据',
|
||||
run: () => clearDatasourceData(record),
|
||||
})}
|
||||
disabled={actionLoading}
|
||||
title={localizeAdminText('清理数据库数据', locale)}
|
||||
aria-label={localizeAdminText('清理数据库数据', locale)}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const selectedInactiveCount = selectedDatasourceRows.filter((row) => row.is_active === false).length
|
||||
const selectedActiveCount = selectedDatasourceRows.length - selectedInactiveCount
|
||||
const renderDatasourceBatchBar = () => (
|
||||
<DatasourceBatchBar
|
||||
selectedCount={selectedDatasourceRows.length}
|
||||
enableCount={selectedInactiveCount}
|
||||
disableCount={selectedActiveCount}
|
||||
triggerCount={selectedActiveCount}
|
||||
stopCount={selectedActiveCollectQueueItems.length}
|
||||
busy={datasourceBatchAction}
|
||||
translate={(value) => localizeAdminText(value, locale)}
|
||||
onEnable={() => void setSelectedDatasourcesActive(true)}
|
||||
onDisable={confirmDisableSelectedDatasources}
|
||||
onTrigger={() => void triggerSelectedDatasources()}
|
||||
onStop={() => void cancelCollectionQueueItems(selectedActiveCollectQueueItems, '停止已选')}
|
||||
onClear={() => setDatasourceSelectedRowIds(new Set())}
|
||||
/>
|
||||
)
|
||||
|
||||
const renderCollectionQueuePanel = () => {
|
||||
if (config !== configs.datasources) return null
|
||||
const groups: Array<{ key: string; title: string; items: CollectionQueueItem[] }> = [
|
||||
@@ -7370,23 +7637,29 @@ function ModuleConsole({ config }: { config: ModuleConfig }) {
|
||||
) : isHierarchySection ? (
|
||||
config === configs.ai ? renderAIHierarchy() : renderConfigHierarchy()
|
||||
) : (
|
||||
<div className={`an-resource-layout${mobileResourceDetailOpen ? ' is-mobile-detail-open' : ''}`} style={{ '--an-detail-width': `${detailWidth}px` } as CSSProperties}>
|
||||
<div
|
||||
className={`an-resource-layout${isDatasourceBuiltinSection ? ' an-resource-layout--datasources' : ''}${mobileResourceDetailOpen ? ' is-mobile-detail-open' : ''}`}
|
||||
style={{ '--an-detail-width': `${detailWidth}px` } as CSSProperties}
|
||||
>
|
||||
<Panel className="an-resource-main">
|
||||
<div className="an-panel-heading">
|
||||
<div>
|
||||
<h2>{localizeAdminText(activeSection?.label || config.listTitle, locale)}</h2>
|
||||
<p>{localizeAdminText(config.listDescription, locale)}</p>
|
||||
</div>
|
||||
<StatusText tone={loading ? 'running' : activeState?.ok === false ? 'danger' : 'success'}>{localizeAdminText(loading ? '同步中' : activeState?.ok === false ? '接口失败' : '已就绪', locale)}</StatusText>
|
||||
{isDatasourceBuiltinSection && selectedDatasourceRows.length ? renderDatasourceBatchBar() : (
|
||||
<StatusText tone={loading ? 'running' : activeState?.ok === false ? 'danger' : 'success'}>{localizeAdminText(loading ? '同步中' : activeState?.ok === false ? '接口失败' : '已就绪', locale)}</StatusText>
|
||||
)}
|
||||
</div>
|
||||
<div className="an-panel-body">
|
||||
{loading || rows.length > 0 ? (
|
||||
<ModuleTable
|
||||
className={isDatasourceBuiltinSection ? 'an-data-table--datasources' : undefined}
|
||||
rows={rows}
|
||||
selected={selected}
|
||||
onSelect={openResourceDetail}
|
||||
columns={config.columns}
|
||||
loading={loading}
|
||||
columns={isDatasourceBuiltinSection ? datasourceColumns : config.columns}
|
||||
loading={loading && rows.length === 0}
|
||||
selection={isDatasourceBuiltinSection ? {
|
||||
selectedRowIds: datasourceSelectedRowIds,
|
||||
onToggleAllVisible: toggleAllVisibleDatasourceSelection,
|
||||
|
||||
+312
-16
@@ -754,6 +754,19 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.an-task-summary strong {
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.an-task-summary__progress {
|
||||
align-self: start;
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--an-accent);
|
||||
}
|
||||
|
||||
.an-task-summary p {
|
||||
margin: 3px 0 0;
|
||||
color: var(--an-muted);
|
||||
@@ -793,10 +806,9 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.an-task-summary__actions {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
.an-task-summary dt:nth-last-child(-n+4),
|
||||
.an-task-summary dd:nth-last-child(-n+4) {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.admin__content {
|
||||
@@ -1362,7 +1374,7 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
|
||||
.an-detail-title {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
@@ -1386,6 +1398,62 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.an-detail-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px 16px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid var(--an-border);
|
||||
}
|
||||
|
||||
.an-detail-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--an-accent);
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
cursor: pointer;
|
||||
transition: color 0.14s ease, opacity 0.14s ease;
|
||||
}
|
||||
|
||||
.an-detail-link svg {
|
||||
flex: 0 0 auto;
|
||||
opacity: 0.72;
|
||||
transition: transform 0.14s ease, opacity 0.14s ease;
|
||||
}
|
||||
|
||||
.an-detail-link:hover:not(:disabled) {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
|
||||
.an-detail-link:hover:not(:disabled) svg {
|
||||
opacity: 1;
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
.an-detail-link--external:hover:not(:disabled) svg {
|
||||
transform: translate(1px, -1px);
|
||||
}
|
||||
|
||||
.an-detail-link:focus-visible {
|
||||
outline: 2px solid color-mix(in srgb, var(--an-accent) 78%, white);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.an-detail-link:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.52;
|
||||
}
|
||||
|
||||
.an-detail-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
@@ -3878,8 +3946,151 @@ body[data-admin-theme='dark'] .an-connection-test-input > .tui-button:hover:not(
|
||||
}
|
||||
|
||||
.an-filter-grid--datasources {
|
||||
grid-template-columns: repeat(5, minmax(128px, 1fr));
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.an-filter-grid--datasources > .an-segmented--counted {
|
||||
flex: 0 0 auto;
|
||||
max-width: 100%;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.an-filter-grid--datasources > .an-field--inline-filter {
|
||||
flex: 1 1 116px;
|
||||
min-width: 116px;
|
||||
}
|
||||
|
||||
.an-filter-grid--datasources > .tui-button {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.an-segmented--counted button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.an-segmented__count {
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-size: 11px;
|
||||
color: var(--an-muted);
|
||||
}
|
||||
|
||||
.an-segmented--counted button.is-active .an-segmented__count {
|
||||
color: var(--an-accent);
|
||||
}
|
||||
|
||||
.an-batch-bar {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.an-batch-bar__count {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
padding-right: 4px;
|
||||
color: var(--an-muted);
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.an-batch-bar__count strong {
|
||||
color: var(--an-text);
|
||||
font-size: 14px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.an-batch-bar__num {
|
||||
font-variant-numeric: tabular-nums;
|
||||
opacity: 0.72;
|
||||
}
|
||||
|
||||
.an-table-switch,
|
||||
.an-table-actions,
|
||||
.an-inline-switch {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.an-table-actions {
|
||||
gap: 2px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.an-table-actions .tui-button--icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 6px;
|
||||
color: var(--an-muted);
|
||||
}
|
||||
|
||||
.an-table-actions .tui-button--icon:hover:not(:disabled) {
|
||||
color: var(--an-text);
|
||||
}
|
||||
|
||||
.an-table-actions .tui-button--danger {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.an-table-actions .an-table-action--danger:hover:not(:disabled),
|
||||
.an-table-actions .an-table-action--danger:focus-visible {
|
||||
color: var(--an-danger);
|
||||
background: color-mix(in srgb, var(--an-danger) 12%, transparent);
|
||||
}
|
||||
|
||||
.an-inline-switch {
|
||||
gap: 6px;
|
||||
height: 32px;
|
||||
color: var(--an-muted);
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.an-data-table tr.is-filter-stale td {
|
||||
opacity: 0.48;
|
||||
}
|
||||
|
||||
.an-data-table--datasources .an-data-table__table {
|
||||
min-width: 730px;
|
||||
}
|
||||
|
||||
.an-data-table--datasources th,
|
||||
.an-data-table--datasources td {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.an-data-table--datasources .an-data-table__selection-cell {
|
||||
width: 40px;
|
||||
min-width: 40px;
|
||||
max-width: 40px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.an-data-table--datasources th[data-sticky-end='true'],
|
||||
.an-data-table--datasources td[data-sticky-end='true'] {
|
||||
padding: 0 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.an-data-table--datasources th[data-sticky-end='true'] .an-data-table__sort {
|
||||
justify-content: center;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.an-data-table--datasources .an-table-link {
|
||||
max-width: 148px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.an-field--inline-filter .an-input {
|
||||
@@ -4535,8 +4746,28 @@ body[data-admin-theme='dark'] .an-connection-test-input > .tui-button:hover:not(
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.an-filter-grid--datasources {
|
||||
grid-template-columns: repeat(3, minmax(112px, 1fr));
|
||||
.an-filter-grid--datasources > .an-segmented--counted {
|
||||
flex: 1 0 100%;
|
||||
}
|
||||
|
||||
.an-segmented--counted button {
|
||||
flex: 1 1 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (900px < width <= 1100px) {
|
||||
.an-resource-layout--datasources .an-resource-side,
|
||||
.an-resource-layout--datasources.is-mobile-detail-open .an-resource-main {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.an-resource-layout--datasources.is-mobile-detail-open .an-resource-side {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.an-resource-layout--datasources .an-mobile-detail-bar {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4638,15 +4869,65 @@ body[data-admin-theme='dark'] .an-connection-test-input > .tui-button:hover:not(
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.an-page {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.an-page__header {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.an-page__header h1 {
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
.an-page-grid,
|
||||
.an-resource-page .an-page__body {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.an-toolbar {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.an-summary-strip,
|
||||
.an-summary-strip {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.an-summary-strip .an-stat-cell {
|
||||
padding: 8px 10px;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.an-summary-strip .an-stat-cell strong {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.an-summary-strip .an-stat-cell span,
|
||||
.an-summary-strip .an-stat-cell small {
|
||||
font-size: 11px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.an-panel-heading {
|
||||
min-height: 40px;
|
||||
padding: 8px 12px;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.an-panel-body {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.an-batch-bar {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.an-kpi-grid,
|
||||
.an-summary-kpis,
|
||||
.an-detail-list,
|
||||
@@ -4663,7 +4944,12 @@ body[data-admin-theme='dark'] .an-connection-test-input > .tui-button:hover:not(
|
||||
}
|
||||
|
||||
.an-filter-grid--datasources {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.an-filter-grid--datasources > .an-field--inline-filter {
|
||||
flex: 1 1 calc(50% - 6px);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.an-collection-queue__bar {
|
||||
@@ -4688,6 +4974,22 @@ body[data-admin-theme='dark'] .an-connection-test-input > .tui-button:hover:not(
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.an-task-summary dt:nth-last-child(-n+4),
|
||||
.an-task-summary dd:nth-last-child(-n+4) {
|
||||
border-bottom: 1px solid var(--an-border);
|
||||
}
|
||||
|
||||
.an-task-summary dt:nth-last-child(-n+2),
|
||||
.an-task-summary dd:nth-last-child(-n+2) {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.an-data-table--datasources th[data-sticky-end='true'],
|
||||
.an-data-table--datasources td[data-sticky-end='true'] {
|
||||
position: static;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.an-logs-filters {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
@@ -4743,9 +5045,3 @@ body[data-admin-theme='dark'] .an-connection-test-input > .tui-button:hover:not(
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 420px) {
|
||||
.an-filter-grid--datasources {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -899,4 +899,24 @@ export const legacyUiTextEnUS: Record<string, string> = {
|
||||
'发件邮箱': 'Sender email',
|
||||
'发件人名称': 'Sender name',
|
||||
'个历史快照,选择后查看该版本详情。': 'historical snapshots. Select one to view that version.',
|
||||
'批量操作': 'Bulk actions',
|
||||
'已选择': 'selected',
|
||||
'定时调度': 'Schedule',
|
||||
'启用调度': 'Enable schedule',
|
||||
'停用调度': 'Disable schedule',
|
||||
'已启用调度': 'Schedule enabled',
|
||||
'已停用调度': 'Schedule disabled',
|
||||
'启用调度失败': 'Failed to enable schedule',
|
||||
'停用调度失败': 'Failed to disable schedule',
|
||||
'数据源不存在': 'Data sources not found',
|
||||
'调度同步失败': 'Schedule sync failed',
|
||||
'调度已停用': 'Schedule is disabled',
|
||||
'立即采集': 'Collect now',
|
||||
'已提交采集': 'Collection submitted',
|
||||
'触发采集失败': 'Failed to trigger collection',
|
||||
'已强制重新触发': 'Collection restarted',
|
||||
'清除选择': 'Clear selection',
|
||||
'重置筛选': 'Reset filters',
|
||||
'操作': 'Actions',
|
||||
'详情与统计': 'Details & stats',
|
||||
}
|
||||
Reference in new issue
Block a user