feat: Add pending tasks and active status to WikiStats
- Introduced `pending_tasks` and `is_active` fields in the `WikiStats` interface to track the number of tasks waiting for processing and the current activity status of the wiki ingestion. - Updated localization files for English, Korean, Russian, and Chinese to include a new message for displaying the number of pending tasks in the wiki queue. - Enhanced the `WikiBrowser` component to display the queue status, improving user awareness of ongoing tasks. - Implemented polling logic to refresh wiki stats periodically when there are pending tasks or active ingestion, ensuring up-to-date information is presented. These changes enhance the functionality and user experience of the wiki management system by providing real-time insights into task status.
This commit is contained in:
@@ -40,6 +40,8 @@ export interface WikiStats {
|
||||
total_links: number;
|
||||
orphan_count: number;
|
||||
recent_updates: WikiPage[];
|
||||
pending_tasks: number;
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
// Wiki API Functions
|
||||
|
||||
@@ -1636,6 +1636,7 @@ export default {
|
||||
showArrows: 'Show arrows',
|
||||
hideArrows: 'Hide arrows',
|
||||
healthCheck: 'Health Check',
|
||||
queueStatus: '{count} pending tasks in Wiki queue',
|
||||
},
|
||||
buttons: {
|
||||
create: 'Create Knowledge Base',
|
||||
|
||||
@@ -2159,6 +2159,7 @@ export default {
|
||||
showArrows: '화살표 표시',
|
||||
hideArrows: '화살표 숨기기',
|
||||
healthCheck: "상태 점검",
|
||||
queueStatus: "Wiki 대기열에 {count}개의 보류 중인 작업",
|
||||
},
|
||||
buttons: {
|
||||
create: "지식베이스 생성",
|
||||
|
||||
@@ -1838,6 +1838,7 @@ export default {
|
||||
showArrows: 'Показать стрелки',
|
||||
hideArrows: 'Скрыть стрелки',
|
||||
healthCheck: 'Проверка здоровья',
|
||||
queueStatus: '{count} ожидающих задач в очереди Wiki',
|
||||
},
|
||||
buttons: {
|
||||
create: 'Создать базу знаний',
|
||||
|
||||
@@ -2144,6 +2144,7 @@ export default {
|
||||
showArrows: '显示箭头',
|
||||
hideArrows: '隐藏箭头',
|
||||
healthCheck: "健康检查",
|
||||
queueStatus: "Wiki 队列中 {count} 个待处理任务",
|
||||
},
|
||||
buttons: {
|
||||
create: "创建知识库",
|
||||
|
||||
@@ -91,6 +91,10 @@
|
||||
<!-- Left Panel: Page List -->
|
||||
<aside class="wiki-sidebar">
|
||||
<div class="wiki-sidebar-header">
|
||||
<div v-if="stats && (stats.pending_tasks > 0 || stats.is_active)" class="wiki-queue-status">
|
||||
<t-loading size="small" />
|
||||
<span class="queue-text">{{ $t('knowledgeEditor.wikiBrowser.queueStatus', { count: stats.pending_tasks || 0 }) }}</span>
|
||||
</div>
|
||||
<t-input
|
||||
v-model="searchQuery"
|
||||
:placeholder="$t('knowledgeEditor.wikiBrowser.searchPlaceholder')"
|
||||
@@ -255,7 +259,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, watch, nextTick, reactive } from 'vue'
|
||||
import { ref, computed, onMounted, onUnmounted, watch, nextTick, reactive } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { marked } from 'marked'
|
||||
import { hydrateProtectedFileImages } from '@/utils/security'
|
||||
@@ -477,10 +481,26 @@ async function loadPages() {
|
||||
}
|
||||
}
|
||||
|
||||
let statsTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
async function loadStats() {
|
||||
try {
|
||||
const res = await getWikiStats(props.knowledgeBaseId)
|
||||
stats.value = (res as any).data || res as any
|
||||
|
||||
// Poll if there are pending tasks or wiki ingest is active
|
||||
if (stats.value && (stats.value.pending_tasks > 0 || stats.value.is_active)) {
|
||||
if (!statsTimer) {
|
||||
statsTimer = setInterval(() => {
|
||||
loadStats()
|
||||
}, 5000)
|
||||
}
|
||||
} else if (statsTimer) {
|
||||
// If completed, clear timer and reload pages once to get new content
|
||||
clearInterval(statsTimer)
|
||||
statsTimer = null
|
||||
loadPages()
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
@@ -1300,6 +1320,12 @@ onMounted(() => {
|
||||
loadStats()
|
||||
if (props.view === 'graph') loadGraph()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (statsTimer) {
|
||||
clearInterval(statsTimer)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
@@ -1323,6 +1349,24 @@ onMounted(() => {
|
||||
|
||||
.wiki-sidebar-header {
|
||||
padding: 16px 16px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.wiki-queue-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 6px;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: 13px;
|
||||
|
||||
.queue-text {
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
.wiki-page-list {
|
||||
|
||||
Reference in New Issue
Block a user