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

4.0-7.10 - Update agents' info in Management Status after changing cluster node selected #2828

Merged
merged 1 commit into from
Jan 27, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import {
updateLoadingStatus,
updateListDaemons,
updateNodeInfo,
updateSelectedNode
updateSelectedNode,
updateStats,
updateAgentInfo,
} from '../../../../../redux/actions/statusActions';

import StatusHandler from './utils/status-handler';
Expand Down Expand Up @@ -106,13 +108,31 @@ class WzStatusActionButtons extends Component {
this.props.updateLoadingStatus(true);
this.props.updateSelectedNode(node);

const agentSummaryResponse = await this.statusHandler.agentsSummary();
const agentsCountResponse = await this.statusHandler.clusterAgentsCount();

const { active, disconnected, never_connected, total } = agentSummaryResponse.data.data;
this.props.updateStats({
agentsCount: agentsCountResponse.data.data.nodes,
agentsCountActive: active,
agentsCountDisconnected: disconnected,
agentsCountNeverConnected: never_connected,
agentsCountTotal: total,
agentsCoverity: total ? (active / total) * 100 : 0
});

const daemons = await this.statusHandler.clusterNodeStatus(node);
const listDaemons = this.objToArr(daemons.data.data.affected_items[0]);
this.props.updateListDaemons(listDaemons);

const nodeInfo = await this.statusHandler.clusterNodeInfo(node);
this.props.updateNodeInfo(nodeInfo.data.data.affected_items[0]);

const lastAgentRaw = await this.statusHandler.lastAgentRaw();
const [lastAgent] = lastAgentRaw.data.data.affected_items;

this.props.updateAgentInfo(lastAgent);

this.props.updateLoadingStatus(false);
} catch (error) {
this.props.updateLoadingStatus(false);
Expand Down Expand Up @@ -246,8 +266,9 @@ const mapDispatchToProps = dispatch => {
updateLoadingStatus: status => dispatch(updateLoadingStatus(status)),
updateListDaemons: listDaemons => dispatch(updateListDaemons(listDaemons)),
updateNodeInfo: nodeInfo => dispatch(updateNodeInfo(nodeInfo)),
updateSelectedNode: selectedNode =>
dispatch(updateSelectedNode(selectedNode))
updateSelectedNode: selectedNode => dispatch(updateSelectedNode(selectedNode)),
updateStats: stats => dispatch(updateStats(stats)),
updateAgentInfo: agentInfo => dispatch(updateAgentInfo(agentInfo))
};
};

Expand Down