diff --git a/public/components/Flyout/flyouts/components/AlertsDashboardFlyoutComponent.js b/public/components/Flyout/flyouts/components/AlertsDashboardFlyoutComponent.js
index 9d72546d8..730e2b535 100644
--- a/public/components/Flyout/flyouts/components/AlertsDashboardFlyoutComponent.js
+++ b/public/components/Flyout/flyouts/components/AlertsDashboardFlyoutComponent.js
@@ -14,6 +14,8 @@ import {
EuiIcon,
EuiLink,
EuiSpacer,
+ EuiTab,
+ EuiTabs,
EuiText,
} from '@elastic/eui';
import { getTime } from '../../../../pages/MonitorDetails/components/MonitorOverview/utils/getOverviewStats';
@@ -27,7 +29,6 @@ import {
SEARCH_TYPE,
} from '../../../../utils/constants';
import { TRIGGER_TYPE } from '../../../../pages/CreateTrigger/containers/CreateTrigger/utils/constants';
-import { SEVERITY_OPTIONS } from '../../../../pages/CreateTrigger/containers/DefineTrigger/DefineTrigger';
import { UNITS_OF_TIME } from '../../../../pages/CreateMonitor/components/MonitorExpressions/expressions/utils/constants';
import { DEFAULT_WHERE_EXPRESSION_TEXT } from '../../../../pages/CreateMonitor/components/MonitorExpressions/expressions/utils/whereHelpers';
import { backendErrorNotification } from '../../../../utils/helpers';
@@ -45,14 +46,18 @@ import { queryColumns } from '../../../../pages/Dashboard/utils/tableUtils';
import { DEFAULT_PAGE_SIZE_OPTIONS } from '../../../../pages/Monitors/containers/Monitors/utils/constants';
import queryString from 'query-string';
import { MAX_ALERT_COUNT } from '../../../../pages/Dashboard/utils/constants';
+import { SEVERITY_OPTIONS } from '../../../../pages/CreateTrigger/utils/constants';
+import { TABLE_TAB_IDS } from '../../../../pages/Dashboard/components/FindingsDashboard/utils';
+import FindingsDashboard from '../../../../pages/Dashboard/containers/FindingsDashboard';
export const DEFAULT_NUM_FLYOUT_ROWS = 10;
export default class AlertsDashboardFlyoutComponent extends Component {
constructor(props) {
super(props);
- const { location, monitor_id } = this.props;
-
+ const { location, monitors, monitor_id } = this.props;
+ const monitor = _.get(_.find(monitors, { _id: monitor_id }), '_source');
+ const monitorType = _.get(monitor, 'monitor_type', MONITOR_TYPE.QUERY_LEVEL);
const {
alertState,
from,
@@ -67,8 +72,9 @@ export default class AlertsDashboardFlyoutComponent extends Component {
alerts: [],
alertState: alertState,
loading: true,
- monitors: [],
+ monitor: monitor,
monitorIds: [monitor_id],
+ monitorType: monitorType,
page: Math.floor(from / size),
search: search,
selectable: true,
@@ -77,6 +83,8 @@ export default class AlertsDashboardFlyoutComponent extends Component {
size: DEFAULT_NUM_FLYOUT_ROWS,
sortDirection: sortDirection,
sortField: sortField,
+ tabContent: undefined,
+ tabId: TABLE_TAB_IDS.ALERTS.id,
totalAlerts: 0,
};
}
@@ -129,6 +137,12 @@ export default class AlertsDashboardFlyoutComponent extends Component {
monitorIds
);
}
+ const { monitorType } = this.state;
+ if (
+ monitorType === MONITOR_TYPE.DOC_LEVEL &&
+ !_.isEqual(prevState.selectedItems, this.state.selectedItems)
+ )
+ this.setState({ tabContent: this.renderAlertsTable() });
}
getBucketLevelGraphConditions = (trigger) => {
@@ -153,7 +167,7 @@ export default class AlertsDashboardFlyoutComponent extends Component {
};
getAlerts = async () => {
- this.setState({ ...this.state, loading: true });
+ this.setState({ loading: true });
const {
from,
search,
@@ -193,9 +207,9 @@ export default class AlertsDashboardFlyoutComponent extends Component {
console.log('error getting alerts:', resp);
backendErrorNotification(notifications, 'get', 'alerts', resp.err);
}
+ this.setState({ tabContent: this.renderAlertsTable() });
});
-
- this.setState({ ...this.state, loading: false });
+ this.setState({ loading: false });
};
acknowledgeAlerts = async () => {
@@ -249,7 +263,8 @@ export default class AlertsDashboardFlyoutComponent extends Component {
alertState,
monitorIds
);
- this.setState({ ...this.state, selectedItems: [] });
+ this.setState({ selectedItems: [], tabContent: undefined });
+ this.setState({ tabContent: this.renderAlertsTable() });
this.props.refreshDashboard();
};
@@ -284,89 +299,24 @@ export default class AlertsDashboardFlyoutComponent extends Component {
this.setState({ alerts });
};
- render() {
- const {
- last_notification_time,
- loadingMonitors,
- monitors,
- monitor_id,
- monitor_name,
- start_time,
- triggerID,
- trigger_name,
- } = this.props;
- const monitor = _.get(_.find(monitors, { _id: monitor_id }), '_source');
- const monitorType = _.get(monitor, 'monitor_type', MONITOR_TYPE.QUERY_LEVEL);
- const searchType = _.get(monitor, 'ui_metadata.search.searchType', SEARCH_TYPE.GRAPH);
- const detectorId = _.get(monitor, MONITOR_INPUT_DETECTOR_ID);
-
- const triggerType =
- monitorType === MONITOR_TYPE.BUCKET_LEVEL
- ? TRIGGER_TYPE.BUCKET_LEVEL
- : TRIGGER_TYPE.QUERY_LEVEL;
-
- let trigger = _.get(monitor, 'triggers', []).find(
- (trigger) => trigger[triggerType].id === triggerID
- );
- trigger = _.get(trigger, triggerType);
+ getTriggerType() {
+ const { monitorType } = this.state;
+ switch (monitorType) {
+ case MONITOR_TYPE.BUCKET_LEVEL:
+ return TRIGGER_TYPE.BUCKET_LEVEL;
+ case MONITOR_TYPE.DOC_LEVEL:
+ return TRIGGER_TYPE.DOC_LEVEL;
+ default:
+ return TRIGGER_TYPE.QUERY_LEVEL;
+ }
+ }
- const severity = _.get(trigger, 'severity');
+ renderAlertsTable() {
+ const { trigger_name } = this.props;
+ const { monitor, monitorType } = this.state;
+ const detectorId = _.get(monitor, MONITOR_INPUT_DETECTOR_ID);
const groupBy = _.get(monitor, MONITOR_GROUP_BY);
- const condition =
- monitorType === MONITOR_TYPE.BUCKET_LEVEL && searchType === SEARCH_TYPE.GRAPH
- ? this.getBucketLevelGraphConditions(trigger)
- : _.get(trigger, 'condition.script.source', '-');
-
- const filters =
- monitorType === MONITOR_TYPE.BUCKET_LEVEL && searchType === SEARCH_TYPE.GRAPH
- ? this.getBucketLevelGraphFilter(trigger)
- : '-';
-
- const bucketValue = _.get(monitor, 'ui_metadata.search.bucketValue');
- let bucketUnitOfTime = _.get(monitor, 'ui_metadata.search.bucketUnitOfTime');
- UNITS_OF_TIME.map((entry) => {
- if (entry.value === bucketUnitOfTime) bucketUnitOfTime = entry.text;
- });
- const timeRangeForLast =
- bucketValue !== undefined && !_.isEmpty(bucketUnitOfTime)
- ? `${bucketValue} ${bucketUnitOfTime}`
- : '-';
-
- const actions = () => {
- const { selectedItems } = this.state;
- const actions = [
-
{timeRangeForLast}
-{loadingMonitors || loading ? 'Loading filters...' : filters}
-- {loadingMonitors || loading - ? 'Loading groups...' - : !_.isEmpty(groupBy) - ? _.join(_.orderBy(groupBy), ', ') - : '-'} -
-{timeRangeForLast}
+{loadingMonitors || loading ? 'Loading filters...' : filters}
++ {loadingMonitors || loading + ? 'Loading groups...' + : !_.isEmpty(groupBy) + ? _.join(_.orderBy(groupBy), ', ') + : '-'} +
++ Loading filters... +
++ Loading groups... +
+- Loading filters... -
-- Loading groups... -
-0 ? '10px' : undefined }}> + {`${query.name} (${query.query})`} +
+ ); + }); + + return ( +{docId}
+{findingId}
+{index}
+{query.query}
+