Skip to content

Commit

Permalink
can filter shard recovery stage
Browse files Browse the repository at this point in the history
  • Loading branch information
cars10 committed Jan 21, 2025
1 parent 6bfc136 commit e105aad
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/components/shardrecovery/ShardRecovery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@
const t = useTranslation()
const { requestState, data, load } = useElasticsearchRequest<IndexRecovery>('recovery')
onMounted(() => (load()))
</script>
2 changes: 1 addition & 1 deletion src/components/shardrecovery/ShardRecoveryRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="text-muted">Type: {{ shardRecovery.type }}</span>
</td>
<td>
<span v-if="shardRecovery.stage === 'done'">{{ shardRecovery.stage }}</span>
<span v-if="shardRecovery.stage === 'DONE'">{{ shardRecovery.stage }}</span>
<span v-else class="text-warning">{{ shardRecovery.stage }}</span>
</td>
<td>
Expand Down
10 changes: 9 additions & 1 deletion src/components/shardrecovery/ShardRecoveryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
:filtered-results-count="filterStateProps.filteredResultsCount" />

<div class="flex q-ml-auto">
<q-select v-model="stage"
:options="['INIT', 'INDEX', 'VERIFY_INDEX', 'TRANSLOG', 'FINALIZE', 'DONE']"
:label="t('shard_recovery_table.stage')"
clearable
dense
outlined
class="q-mr-md"
style="min-width: 140px" />
<filter-input v-model="shardRecoveryStore.filter" :columns="['index']" />

<q-btn icon="settings" round flat class="q-ml-sm">
Expand Down Expand Up @@ -59,5 +67,5 @@
const shardRecoveryStore = useShardRecoveryStore()
const resizeStore = useResizeStore()
const { filterStateProps, filteredResults, columns } = useShardRecoveryTable(props)
const { filterStateProps, filteredResults, columns, stage } = useShardRecoveryTable(props)
</script>
18 changes: 13 additions & 5 deletions src/composables/components/shardrecovery/ShardRecoveryTable.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { genColumns } from '../../../helpers/tableColumns.ts'
import { useTranslation } from '../../i18n.ts'
import { computed } from 'vue'
import { computed, ref } from 'vue'
import { useShardRecoveryStore } from '../../../store/shardRecovery.ts'
import { setupFilterState } from '../shared/FilterState.ts'
import { filterItems } from '../../../helpers/filters.ts'

export type ShardRecovery = {
index: string
Expand Down Expand Up @@ -90,12 +91,18 @@ export type ShardRecoveryTableProps = {
export const useShardRecoveryTable = (props: ShardRecoveryTableProps) => {
const t = useTranslation()
const shardRecoveryStore = useShardRecoveryStore()
const stage = ref(null)

const results = computed(() => transformRecoveryResponse(props.shardRecoveries))
const filteredResults = computed(() => {
if (shardRecoveryStore.filter.length === 0) return results.value
if (shardRecoveryStore.filter.length === 0 && !stage.value) return results.value

return results.value.filter(shard => shard.index.includes(shardRecoveryStore.filter))
let items = results.value
if (stage.value) {
items = items.filter(r => r.stage === stage.value)
}

return filterItems(items, shardRecoveryStore.filter, ['index'])
})

function transformRecoveryResponse (input: IndexRecovery): ShardRecovery[] {
Expand All @@ -110,8 +117,8 @@ export const useShardRecoveryTable = (props: ShardRecoveryTableProps) => {
total_time_in_millis: shard.total_time_in_millis,
start_time_in_millis: shard.start_time_in_millis,
stop_time_in_millis: shard.stop_time_in_millis,
type: shard.type.toLowerCase(),
stage: shard.stage.toLowerCase(),
type: shard.type,
stage: shard.stage,
source_host: shard.source.host,
source_node: shard.source.name,
target_host: shard.target.host,
Expand Down Expand Up @@ -147,6 +154,7 @@ export const useShardRecoveryTable = (props: ShardRecoveryTableProps) => {
])

return {
stage,
filterStateProps,
filteredResults,
columns
Expand Down
1 change: 1 addition & 0 deletions src/locales/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
"heading": "分片恢复"
},
"shard_recovery_table": {
"stage": "阶段",
"columns": {
"index": "索引",
"stage": "阶段",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
"heading": "Shard recovery"
},
"shard_recovery_table": {
"stage": "Stage",
"columns": {
"index": "Index",
"stage": "Stage",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
"heading": "Récupération de shard"
},
"shard_recovery_table": {
"stage": "Étape",
"columns": {
"index": "Index",
"stage": "Étape",
Expand Down

0 comments on commit e105aad

Please sign in to comment.