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 <kirankumarb@ami.com>
diff --git a/src/components/Mixins/TableFilterMixin.js b/src/components/Mixins/TableFilterMixin.js
index 7a2cc54..ffc8b44 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 @@
// 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(