From 9a2e9da0b10467d28f9d5c4207b1f543913e1d24 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> Date: Mon, 29 May 2023 18:01:06 +0200 Subject: [PATCH] Removes unnecessary requests in config, inventory data or statistics (#5460) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add dont make the queries in config or inventory * Update changelog * Fix stats request --------- Co-authored-by: Álex Ruiz (cherry picked from commit f5be86d213db79fb42c8af9098660c961a3e1732) --- CHANGELOG.md | 1 + public/components/common/welcome/agents-welcome.js | 8 +++++--- public/controllers/agent/agents.js | 10 ++++------ .../management/configuration/configuration-switch.js | 7 +++++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed8ea90171..8f62b6c2b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Fixed the GitHub and Office 365 modules appear in the main menu when they were not configured [#5376](https://github.com/wazuh/wazuh-kibana-app/pull/5376) - Fixed TypeError in FIM Inventory using new error handler [#5364](https://github.com/wazuh/wazuh-kibana-app/pull/5364) - Fixed error when using invalid group configuration [#5423](https://github.com/wazuh/wazuh-kibana-app/pull/5423) +- Fixed repeated requests in inventory data and configurations of an agent. [#5460](https://github.com/wazuh/wazuh-kibana-app/pull/5460) - Fixed repeated requests in the group table when adding a group or refreshing the table [#5465](https://github.com/wazuh/wazuh-kibana-app/pull/5465) ### Removed diff --git a/public/components/common/welcome/agents-welcome.js b/public/components/common/welcome/agents-welcome.js index a437098ff7..4d0d3386de 100644 --- a/public/components/common/welcome/agents-welcome.js +++ b/public/components/common/welcome/agents-welcome.js @@ -260,6 +260,8 @@ class AgentsWelcome extends Component { renderTitle() { + const notNeedStatus = true; + return ( @@ -321,21 +323,21 @@ class AgentsWelcome extends Component { this.props.switchTab('syscollector')}> + onClick={() => this.props.switchTab('syscollector', notNeedStatus)}> Inventory data this.props.switchTab('stats')}> + onClick={() => this.props.switchTab('stats', notNeedStatus)}> Stats this.props.switchTab('configuration')}> + onClick={() => this.props.switchTab('configuration', notNeedStatus)}> Configuration diff --git a/public/controllers/agent/agents.js b/public/controllers/agent/agents.js index c63b9e93ea..4f0e7114a9 100644 --- a/public/controllers/agent/agents.js +++ b/public/controllers/agent/agents.js @@ -384,9 +384,9 @@ export class AgentsController { } // Update agent status - if (!force && ((this.$scope || {}).agent || false)) { + if (!force && this.$scope.agent) { try { - const agentInfo = await WzRequest.apiReq('GET', `/agents`, { + const agentInfo = await WzRequest.apiReq('GET', '/agents', { params: { agents_list: this.$scope.agent.id, select: 'status', @@ -395,9 +395,8 @@ export class AgentsController { this.$scope.agent.status = agentInfo?.data?.data?.affected_items?.[0]?.status || this.$scope.agent.status; - this.$scope.isSynchronized = this.$scope.agent.status?.synced; - this.$scope.$applyAsync(); + this.$scope.$applyAsync(); } catch (error) { throw new Error(error); } @@ -582,7 +581,6 @@ export class AgentsController { async getAgent(newAgentId) { try { this.$scope.emptyAgent = false; - this.$scope.isSynchronized = false; this.$scope.load = true; this.changeAgent = true; @@ -654,7 +652,7 @@ export class AgentsController { */ loadWelcomeCardsProps() { this.$scope.welcomeCardsProps = { - switchTab: (tab) => this.switchTab(tab), + switchTab: (tab, force) => this.switchTab(tab, force), extensions: this.cleanExtensions(this.$scope.extensions), agent: this.$scope.agent, api: AppState.getCurrentAPI(), diff --git a/public/controllers/management/components/management/configuration/configuration-switch.js b/public/controllers/management/components/management/configuration/configuration-switch.js index b2f1ec51d0..e58016ddc7 100644 --- a/public/controllers/management/components/management/configuration/configuration-switch.js +++ b/public/controllers/management/components/management/configuration/configuration-switch.js @@ -53,7 +53,11 @@ import WzConfigurationPath from './util-components/configuration-path'; import WzRefreshClusterInfoButton from './util-components/refresh-cluster-info-button'; import { withUserAuthorizationPrompt } from '../../../../../components/common/hocs'; -import { clusterNodes, clusterReq } from './utils/wz-fetch'; +import { + clusterNodes, + clusterReq, + agentIsSynchronized, +} from './utils/wz-fetch'; import { updateClusterNodes, updateClusterNodeSelected, @@ -64,7 +68,6 @@ import { compose } from 'redux'; import { EuiPage, EuiPanel, EuiSpacer, EuiButtonEmpty, EuiFlexItem } from '@elastic/eui'; -import { agentIsSynchronized } from './utils/wz-fetch'; import { WzRequest } from '../../../../../react-services/wz-request'; import { API_NAME_AGENT_STATUS, UI_LOGGER_LEVELS } from '../../../../../../common/constants'; import { UI_ERROR_SEVERITIES } from '../../../../../react-services/error-orchestrator/types';