Commit 23c3c81f authored by lauraMon's avatar lauraMon

Sets up graphql sorting

parent b4af5106
...@@ -154,7 +154,9 @@ export default { ...@@ -154,7 +154,9 @@ export default {
errored: false, errored: false,
isAlertDismissed: false, isAlertDismissed: false,
isErrorAlertDismissed: false, isErrorAlertDismissed: false,
sort: null,
statusFilter: this.$options.statusTabs[4].filters, statusFilter: this.$options.statusTabs[4].filters,
}; };
}, },
computed: { computed: {
...@@ -180,6 +182,11 @@ export default { ...@@ -180,6 +182,11 @@ export default {
filterAlertsByStatus(tabIndex) { filterAlertsByStatus(tabIndex) {
this.statusFilter = this.$options.statusTabs[tabIndex].filters; this.statusFilter = this.$options.statusTabs[tabIndex].filters;
}, },
fetchSortedData({ sortBy, sortDesc }) {
const sortDirection = sortDesc ? 'DESC' : 'ASC';
const sortColumn = sortBy.replace(/([A-Z])/g, '_$1').toUpperCase();
this.sort = `${sortColumn}_${sortDirection}`;
},
capitalizeFirstCharacter, capitalizeFirstCharacter,
updateAlertStatus(status, iid) { updateAlertStatus(status, iid) {
this.$apollo this.$apollo
...@@ -241,7 +248,9 @@ export default { ...@@ -241,7 +248,9 @@ export default {
:busy="loading" :busy="loading"
stacked="md" stacked="md"
:tbody-tr-class="tbodyTrClass" :tbody-tr-class="tbodyTrClass"
:no-local-sorting="true"
@row-clicked="navigateToAlertDetails" @row-clicked="navigateToAlertDetails"
@sort-changed="fetchSortedData"
> >
<template #cell(severity)="{ item }"> <template #cell(severity)="{ item }">
<div <div
......
#import "../fragments/list_item.fragment.graphql" #import "../fragments/list_item.fragment.graphql"
query getAlerts($projectPath: ID!, $statuses: [AlertManagementStatus!]) { query getAlerts($projectPath: ID!, $statuses: [AlertManagementStatus!], $sort: AlertManagementAlertSort ) {
project(fullPath: $projectPath) { project(fullPath: $projectPath) {
alertManagementAlerts(statuses: $statuses) { alertManagementAlerts(statuses: $statuses, sort: $sort) {
nodes { nodes {
...AlertListItem ...AlertListItem
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment