From e21b2fed5f0a5f3a2ad5d6017b859b1389557c9e Mon Sep 17 00:00:00 2001 From: kirankumarb07 Date: Fri, 31 Mar 2023 18:30:24 +0530 Subject: Filter the event log data by severity and status In the event logs page, if the filter options are selected for both severity and status, it displays row that falls into either of the two categories: severity or status. The filter options are in two categories: severity [OK, Warning, Critical], and status [Resolved, Unresolved] If select the filter options "Critical" on severity and "Unresolved" on status, it shows every row whose status is "Unresolved" whether its severity is "Ok" or "Warning", If the row data is "Critical" or "Unresolved", it shows in the table. As per the filter selection, it shouldn't show the row data that has "Ok" or "Warning" but the status is "Unresolved"; it should show only the row data that is in both "Critical" and "Unresolved". This commit will work as follows: if different categories are selected, that will be applied with an "and" logic, and within the same category, it will be applied with an "or" logic. Change-Id: I5ddf6e5ebe35c961306e68885febf6f2324ebaee Signed-off-by: Kirankumar Ballapalli --- src/components/Mixins/TableFilterMixin.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/components/Mixins/TableFilterMixin.js b/src/components/Mixins/TableFilterMixin.js index 7a2cc540..ffc8b444 100644 --- a/src/components/Mixins/TableFilterMixin.js +++ b/src/components/Mixins/TableFilterMixin.js @@ -1,5 +1,3 @@ -import { includes } from 'lodash'; - const TableFilterMixin = { methods: { getFilteredTableData(tableData = [], filters = []) { @@ -9,18 +7,23 @@ const TableFilterMixin = { // If no filters are active, then return all table data if (filterItems.length === 0) return tableData; + const selectedValues = {}; + for (const { key, values } of filters) { + if (values.length > 0) { + selectedValues[key] = values; + } + } + // Check if row property value is included in list of // active filters return tableData.filter((row) => { - let returnRow = false; - for (const { key, values } of filters) { + for (const [key, values] of Object.entries(selectedValues)) { const rowProperty = row[key]; - if (rowProperty && includes(values, rowProperty)) { - returnRow = true; - break; + if (rowProperty && !values.includes(rowProperty)) { + return false; } } - return returnRow; + return true; }); }, getFilteredTableDataByDate( -- cgit v1.2.3