From 56d6e758fc45ae2463001b78cdfc5d66842cef0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20K=C3=B6nig?= Date: Sun, 7 Jan 2024 16:19:39 +0100 Subject: [PATCH] fix #181 --- CHANGELOG.md | 2 ++ src/components/indices/IndicesTable.vue | 3 +-- src/components/shared/FilterInput.vue | 4 ++-- src/composables/components/indices/IndicesTable.ts | 6 ++---- src/composables/components/search/EditDocument.ts | 2 +- src/store/indices.ts | 2 ++ 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 936e370a..bfd374dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,12 @@ * fixes issue with old versions of elasticsearch that do not provide a uuid, fixes [#182][i182] * adds document meta information when editing documents, fixes [#187][i187] * remap hotkey for sending rest request to `Ctrl+Enter`, fixes [#183][i183] +* cache index table filter, fixes [#181][i181] [i182]: https://github.com/cars10/elasticvue/issues/182 [i187]: https://github.com/cars10/elasticvue/issues/187 [i183]: https://github.com/cars10/elasticvue/issues/183 +[i181]: https://github.com/cars10/elasticvue/issues/181 ## 1.0.1 diff --git a/src/components/indices/IndicesTable.vue b/src/components/indices/IndicesTable.vue index d3528478..08837bbb 100644 --- a/src/components/indices/IndicesTable.vue +++ b/src/components/indices/IndicesTable.vue @@ -9,7 +9,7 @@
- + @@ -95,7 +95,6 @@ const { indicesStore, resizeStore, - filter, items, tableKey, rowsPerPage, diff --git a/src/components/shared/FilterInput.vue b/src/components/shared/FilterInput.vue index 7599d412..42efa2a9 100644 --- a/src/components/shared/FilterInput.vue +++ b/src/components/shared/FilterInput.vue @@ -12,9 +12,9 @@ const t = useTranslation() - defineProps<{ modelValue: string }>() + const props = defineProps<{ modelValue: string }>() const emit = defineEmits(['update:modelValue']) - const filter = ref('') + const filter = ref(props.modelValue) watch(filter, newValue => (emit('update:modelValue', newValue))) diff --git a/src/composables/components/indices/IndicesTable.ts b/src/composables/components/indices/IndicesTable.ts index 6f24f6c3..c4f3d61e 100644 --- a/src/composables/components/indices/IndicesTable.ts +++ b/src/composables/components/indices/IndicesTable.ts @@ -31,7 +31,6 @@ export const useIndicesTable = (props: EsTableProps, emit: any) => { const indicesStore = useIndicesStore() const resizeStore = useResizeStore() - const filter = ref('') const items: Ref = ref([]) const tableKey = ref(0) @@ -50,12 +49,12 @@ export const useIndicesTable = (props: EsTableProps, emit: any) => { results = results.filter((item: any) => !item.index.match(new RegExp(indicesStore.hideIndicesRegex))) } - results = filterItems(results, filter.value, ['index', 'uuid']) + results = filterItems(results, indicesStore.filter, ['index', 'uuid']) items.value = results.map((index: any) => new ElasticsearchIndex(index)) } const debouncedFilterTable = debounce(filterTable, 150) - watch(() => filter.value, debouncedFilterTable) + watch(() => indicesStore.filter, debouncedFilterTable) watch(() => indicesStore.showHiddenIndices, filterTable) watch(() => props.indices, filterTable) watch(() => indicesStore.stickyTableHeader, () => (tableKey.value += 1)) @@ -84,7 +83,6 @@ export const useIndicesTable = (props: EsTableProps, emit: any) => { return { indicesStore, resizeStore, - filter, items, tableKey, rowsPerPage, diff --git a/src/composables/components/search/EditDocument.ts b/src/composables/components/search/EditDocument.ts index 728a0c39..1f93989d 100644 --- a/src/composables/components/search/EditDocument.ts +++ b/src/composables/components/search/EditDocument.ts @@ -66,7 +66,7 @@ export const useEditDocument = (props: EditDocumentProps, emit: any) => { } const validDocumentMeta = computed(() => { - return Object.fromEntries(Object.entries(documentMeta.value).filter(([_, v]) => v != null)) + return Object.fromEntries(Object.entries(documentMeta.value).filter((keyval) => keyval[1] != null)) }) const { run, loading } = defineElasticsearchRequest({ emit, method: 'index' }) diff --git a/src/store/indices.ts b/src/store/indices.ts index 0a10325c..07c12190 100644 --- a/src/store/indices.ts +++ b/src/store/indices.ts @@ -2,6 +2,7 @@ import { defineStore } from 'pinia' import { DEFAULT_HIDE_INDICES_REGEX } from '../consts' type IndicesState = { + filter: string, showHiddenIndices: boolean, stickyTableHeader: boolean, hideIndicesRegex: string @@ -9,6 +10,7 @@ type IndicesState = { export const useIndicesStore = defineStore('indices', { state: (): IndicesState => ({ + filter: '', showHiddenIndices: false, stickyTableHeader: false, hideIndicesRegex: DEFAULT_HIDE_INDICES_REGEX