From 8022b29ca629118ce56bc54d2b00698081f1ca59 Mon Sep 17 00:00:00 2001 From: Nick Satterly Date: Sun, 21 Jun 2020 00:01:08 +0200 Subject: [PATCH] Do not break if sortBy is multi-column --- src/components/AlertList.vue | 8 ++++++-- src/store/modules/alerts.store.ts | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/AlertList.vue b/src/components/AlertList.vue index 27103284..f08fb049 100644 --- a/src/components/AlertList.vue +++ b/src/components/AlertList.vue @@ -553,8 +553,12 @@ export default { if (index == 'default') { return items.sort((a, b) => { if (a.severity == b.severity) { - const sortBy = this.$config.sort_by.replace(/^\-/,'') - const reverseTime = this.$config.sort_by.startsWith('-') ? -1 : 1 + let sortBy = this.$config.sort_by + if (typeof sortBy === 'object') { + sortBy = sortBy[0] + } + const reverseTime = sortBy.startsWith('-') ? -1 : 1 + sortBy = sortBy.replace(/^\-/,'') return (b[sortBy] - a[sortBy]) * reverseTime } const severityCodeA = this.$config.severity[a.severity] diff --git a/src/store/modules/alerts.store.ts b/src/store/modules/alerts.store.ts index cd13faa6..d3231e2a 100644 --- a/src/store/modules/alerts.store.ts +++ b/src/store/modules/alerts.store.ts @@ -120,6 +120,9 @@ const actions = { // get "lucene" query params and sort order let params = new URLSearchParams(state.query) let sortBy = rootGetters['getConfig']('sort_by') + if (typeof sortBy === 'object') { + sortBy = sortBy[0] + } params.append('sort-by', sortBy.replace(/^\-/,'')) if (sortBy.startsWith('-')) { params.append('reverse', '1')