Skip to content

Commit

Permalink
fix #136 - keep pagination when searching new index
Browse files Browse the repository at this point in the history
  • Loading branch information
cars10 committed Jul 10, 2023
1 parent 490745c commit 0d44271
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/composables/components/indices/IndexRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useElasticsearchAdapter } from '../../CallElasticsearch'
import { QMenu } from 'quasar'
import { useRouter } from 'vue-router'
import { useSearchStore } from '../../../store/search'
import { DEFAULT_PAGINATION, DEFAULT_SEARCH_QUERY } from '../../../consts'
import { DEFAULT_PAGINATION, DEFAULT_SEARCH_QUERY, DEFAULT_SEARCH_QUERY_OBJ } from '../../../consts'
import ElasticsearchIndex from '../../../models/ElasticsearchIndex.ts'
import { handleError } from '../../../helpers/error.ts'

Expand Down Expand Up @@ -65,7 +65,14 @@ export const useIndexRow = (props: IndexRowProps, emit: any) => {
searchStore.indices = index
searchStore.searchQueryCollapsed = false
searchStore.searchQuery = DEFAULT_SEARCH_QUERY

const rowsPerPage = searchStore.pagination.rowsPerPage
searchStore.pagination = DEFAULT_PAGINATION
if (rowsPerPage && rowsPerPage > 0 && rowsPerPage <= 10000) {
searchStore.searchQuery = JSON.stringify(Object.assign({}, DEFAULT_SEARCH_QUERY_OBJ, { size: rowsPerPage }))
searchStore.pagination.rowsPerPage = rowsPerPage
}

router.push({ name: 'search' })
}

Expand Down
3 changes: 2 additions & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const buildDefaultRequest = () => ({
body: ''
})

export const DEFAULT_SEARCH_QUERY = '{"query": {"query_string": {"query": "*"}},"size": 10,"from": 0,"sort": []}'
export const DEFAULT_SEARCH_QUERY_OBJ = { query: { query_string: { query: '*' } }, size: 10, from: 0, sort: [] }
export const DEFAULT_SEARCH_QUERY = JSON.stringify(DEFAULT_SEARCH_QUERY_OBJ)
export const DEFAULT_SEARCH_RESULT_COLUMNS = ['_index', '_type', '_id', '_score']
export const DEFAULT_SORTABLE_COLUMNS = ['_index', '_type', '_id', '_score']
export const DEFAULT_PAGINATION = {
Expand Down

0 comments on commit 0d44271

Please sign in to comment.