Skip to content

Commit

Permalink
Merge pull request #342 from alerta/multi-column-sort-compat
Browse files Browse the repository at this point in the history
Do not break if sortBy is multi-column
  • Loading branch information
satterly authored Jun 20, 2020
2 parents 942a981 + 8022b29 commit 7103481
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/AlertList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/alerts.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 7103481

Please sign in to comment.