From ad74b8016c372811b713fe21e275c5e3e4c2a184 Mon Sep 17 00:00:00 2001 From: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:53:05 -0800 Subject: [PATCH] Adds filtering support by signal definition to signal instance table (#4074) --- .../dispatch/src/signal/TableFilterDialog.vue | 62 +++++++++++++++++++ .../dispatch/src/signal/TableInstance.vue | 20 ++++-- .../static/dispatch/src/signal/store.js | 11 +--- 3 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 src/dispatch/static/dispatch/src/signal/TableFilterDialog.vue diff --git a/src/dispatch/static/dispatch/src/signal/TableFilterDialog.vue b/src/dispatch/static/dispatch/src/signal/TableFilterDialog.vue new file mode 100644 index 000000000000..37c257d8dfc8 --- /dev/null +++ b/src/dispatch/static/dispatch/src/signal/TableFilterDialog.vue @@ -0,0 +1,62 @@ + + + diff --git a/src/dispatch/static/dispatch/src/signal/TableInstance.vue b/src/dispatch/static/dispatch/src/signal/TableInstance.vue index f66ad0ae1742..a9362786fa14 100644 --- a/src/dispatch/static/dispatch/src/signal/TableInstance.vue +++ b/src/dispatch/static/dispatch/src/signal/TableInstance.vue @@ -4,6 +4,9 @@
Signals
+ + + @@ -32,9 +35,6 @@ :loading="loading" loading-text="Loading... Please wait" > - @@ -91,6 +91,7 @@ import CasePopover from "@/case/CasePopover.vue" import RawSignalViewer from "@/signal/RawSignalViewer.vue" import RouterUtils from "@/router/utils" import SignalPopover from "@/signal/SignalPopover.vue" +import TableFilterDialog from "@/signal/TableFilterDialog.vue" export default { name: "SignalInstanceTable", @@ -99,12 +100,12 @@ export default { CasePopover, RawSignalViewer, SignalPopover, + TableFilterDialog, }, data() { return { headers: [ - { title: "Create Case", value: "signal.create_case", sortable: false }, { title: "Case", value: "case", sortable: false }, { title: "Signal Definition", value: "signal", sortable: false }, { title: "Filter Action", value: "filter_action", sortable: true }, @@ -124,6 +125,7 @@ export default { "instanceTable.loading", "instanceTable.options.descending", "instanceTable.options.filters", + "instanceTable.options.filters.signal", "instanceTable.options.itemsPerPage", "instanceTable.options.page", "instanceTable.options.q", @@ -166,7 +168,15 @@ export default { ) this.$watch( - (vm) => [vm.q, vm.sortBy, vm.itemsPerPage, vm.descending, vm.created_at, vm.project], + (vm) => [ + vm.q, + vm.sortBy, + vm.itemsPerPage, + vm.descending, + vm.created_at, + vm.project, + vm.signal, + ], () => { this.page = 1 RouterUtils.updateURLFilters(this.filters) diff --git a/src/dispatch/static/dispatch/src/signal/store.js b/src/dispatch/static/dispatch/src/signal/store.js index 558eb5fb7b62..524894e64261 100644 --- a/src/dispatch/static/dispatch/src/signal/store.js +++ b/src/dispatch/static/dispatch/src/signal/store.js @@ -1,5 +1,5 @@ import { getField, updateField } from "vuex-map-fields" -import { debounce, filter } from "lodash" +import { debounce } from "lodash" import SearchUtils from "@/search/utils" import SignalApi from "@/signal/api" @@ -76,6 +76,7 @@ const state = { start: null, end: null, }, + signal: [], }, q: "", page: 1, @@ -117,14 +118,6 @@ const actions = { return SignalApi.getAllInstances(params) .then((response) => { commit("SET_INSTANCE_TABLE_LOADING", false) - - // We filter out instances based on the given query parameter provided - if (params.q) { - response.data.items = filter(response.data.items, function (item) { - return item.signal.name.includes(params.q) || item.signal.description.includes(params.q) - }) - } - commit("SET_INSTANCE_TABLE_ROWS", response.data) }) .catch(() => {