Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 4.5-7.10]Removes unnecessary requests in config, inventory data or statistics #5508

Merged
merged 1 commit into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions public/components/common/welcome/agents-welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ class AgentsWelcome extends Component {

renderTitle() {

const notNeedStatus = true;

return (
<EuiFlexGroup>
<EuiFlexItem className="wz-module-header-agent-title">
Expand Down Expand Up @@ -321,21 +323,21 @@ class AgentsWelcome extends Component {
<EuiFlexItem grow={false} style={{ marginTop: 7 }}>
<EuiButtonEmpty
iconType="inspect"
onClick={() => this.props.switchTab('syscollector')}>
onClick={() => this.props.switchTab('syscollector', notNeedStatus)}>
Inventory data
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ marginTop: 7 }}>
<EuiButtonEmpty
iconType="stats"
onClick={() => this.props.switchTab('stats')}>
onClick={() => this.props.switchTab('stats', notNeedStatus)}>
Stats
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ marginTop: 7 }}>
<EuiButtonEmpty
iconType="gear"
onClick={() => this.props.switchTab('configuration')}>
onClick={() => this.props.switchTab('configuration', notNeedStatus)}>
Configuration
</EuiButtonEmpty>
</EuiFlexItem>
Expand Down
10 changes: 4 additions & 6 deletions public/controllers/agent/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand Down