summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkirankumarb07 <kirankumarb@ami.com>2023-03-31 16:00:24 +0300
committerKiran Kumar Ballapalli <kirankumarb@ami.com>2023-04-10 06:19:04 +0300
commite21b2fed5f0a5f3a2ad5d6017b859b1389557c9e (patch)
treecebe91bdf411705731dfa263439b1c8f8d9829d3
parent5905f96bac2e8386f8b56b97c11f8e7655c8424a (diff)
downloadwebui-vue-e21b2fed5f0a5f3a2ad5d6017b859b1389557c9e.tar.xz
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>
-rw-r--r--src/components/Mixins/TableFilterMixin.js19
1 files changed, 11 insertions, 8 deletions
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(