Avoid the blanc page in the agent detail view

This commit is contained in:
Jose Sanchez 2020-07-24 16:51:10 +02:00
parent c38375efa5
commit 650e4c2c61
2 changed files with 17 additions and 3 deletions

View File

@ -191,7 +191,11 @@ export class AgentsWelcome extends Component {
}
showModuleByPlatform(menu) {
return !this.platform ? false : !UnsupportedComponents[this.platform].includes(menu.id);
try {
return !this.platform ? false : !UnsupportedComponents[this.platform].includes(menu.id);
} catch (error) {
return !UnsupportedComponents['other'].includes(menu.id);
}
}
renderModules() {

View File

@ -15,6 +15,7 @@
import { IFilterParams, getElasticAlerts, getIndexPattern } from '../../../../../../../overview/mitre/lib';
import { getWazuhFilter } from '../../../../fim_events_table';
import { buildPhraseFilter, buildExistsFilter } from '../../../../../../../../../../../src/plugins/data/common';
import { toastNotifications } from 'ui/notify';
export async function getRequirementAlerts(agentId, time, requirement) {
const indexPattern = await getIndexPattern();
@ -37,8 +38,17 @@ export async function getRequirementAlerts(agentId, time, requirement) {
}
const response = await getElasticAlerts(indexPattern, filterParams, aggs);
const alerts_count = ((((response || {}).data || {}).aggregations || {}).alerts_count || {}).buckets;
if (typeof alerts_count === 'undefined') {
toastNotifications.add({
color: 'warning',
title: 'Error getting alerts from compliances',
text: "Your environment may not have any index with Wazuh's alerts."
})
}
return {
alerts_count: ((((response || {}).data || {}).aggregations || {}).alerts_count || {}).buckets,
alerts_count: !!alerts_count ? alerts_count : [],
total_alerts: (((response || {}).data || {}).hits || {}).total
};
}
@ -62,4 +72,4 @@ function createFilters(agentId, indexPattern) {
function createExistsFilter(requirement, indexPattern) {
return buildExistsFilter({ name: `rule.${requirement}`, type: 'nested' }, indexPattern)
}
}