diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1d9ebe559..23c0ca5d50 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,8 +31,8 @@ All notable changes to the Wazuh app project will be documented in this file.
- Move AngularJS controller for management to ReactJS component [#6555](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6555)
- Moved the registry data to in-memory cache [#6481](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6481)
- Enhance the validation for `enrollment.dns` on App Settings application [#6573](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6573)
-- Remove AngularJS controller for manage groups [#6543](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6543)
- Remove some branding references across the application. [#6155](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6155)
+- Move AngularJS controller for the agent view to ReactJS [#6618](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6618)
- Implement new data source feature on MITRE ATT&CK module [#6482](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6482)
### Fixed
diff --git a/plugins/main/public/components/agents/export-configuration.js b/plugins/main/public/components/agents/export-configuration.js
new file mode 100644
index 0000000000..995a4d23bc
--- /dev/null
+++ b/plugins/main/public/components/agents/export-configuration.js
@@ -0,0 +1,181 @@
+/*
+ * Wazuh app - React component for exporting the configuration of a group.
+ * Copyright (C) 2015-2022 Wazuh, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Find more information about this on the LICENSE file.
+ */
+import React, { Component } from 'react';
+
+import {
+ EuiPopover,
+ EuiButton,
+ EuiCheckboxGroup,
+ EuiSpacer,
+ EuiButtonEmpty,
+} from '@elastic/eui';
+
+import PropTypes from 'prop-types';
+import { UnsupportedComponents } from '../../utils/components-os-support';
+import { WAZUH_AGENTS_OS_TYPE } from '../../../common/constants';
+import { withErrorBoundary } from '../common/hocs';
+
+export const ExportConfiguration = withErrorBoundary(
+ class ExportConfiguration extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ buttonDisabled: false,
+ isPopoverOpen: false,
+ };
+
+ const agentOptions = [
+ 'Global configuration',
+ 'Communication',
+ 'Anti-flooding settings',
+ 'Labels',
+ 'Policy monitoring',
+ { name: 'oscap', desc: 'OpenSCAP' },
+ 'CIS-CAT',
+ 'Osquery',
+ 'Inventory data',
+ 'Active response',
+ 'Commands',
+ { name: 'docker', desc: 'Docker listener' },
+ 'Log collection',
+ 'Integrity monitoring',
+ ];
+ const groupOptions = ['Configurations', 'Agents in group'];
+
+ this.options = [];
+ const list = this.props.type === 'agent' ? agentOptions : groupOptions;
+ list.forEach((x, idx) => {
+ if (
+ typeof x === 'string' ||
+ (x.name &&
+ !(
+ UnsupportedComponents[this.props.agentPlatform] ||
+ UnsupportedComponents[WAZUH_AGENTS_OS_TYPE.OTHERS]
+ ).includes(x.name))
+ ) {
+ this.options.push({ id: `${idx}`, label: x.desc || x });
+ }
+ });
+
+ let initialChecks = {};
+ this.options.forEach(x => {
+ initialChecks[x.id] = true;
+ });
+ this.state.checkboxIdToSelectedMap = initialChecks;
+ }
+
+ selectAll(flag) {
+ let newCheckboxIdToSelectedMap = {};
+ for (let i = 0; i < this.options.length; i++) {
+ newCheckboxIdToSelectedMap[`${this.options[i].id}`] = flag;
+ }
+ this.setState({
+ checkboxIdToSelectedMap: newCheckboxIdToSelectedMap,
+ buttonDisabled: !flag,
+ });
+ }
+
+ exportClick() {
+ this.setState({
+ isPopoverOpen: !this.state.isPopoverOpen,
+ });
+ }
+
+ closePopover() {
+ this.setState({
+ isPopoverOpen: false,
+ });
+ }
+
+ onChange = optionId => {
+ const newCheckboxIdToSelectedMap = {
+ ...this.state.checkboxIdToSelectedMap,
+ ...{
+ [optionId]: !this.state.checkboxIdToSelectedMap[optionId],
+ },
+ };
+ let result = false;
+ for (let i = 0; i < this.options.length; i++) {
+ if (newCheckboxIdToSelectedMap[`${this.options[i].id}`] === true) {
+ result = true;
+ }
+ }
+ this.setState({
+ checkboxIdToSelectedMap: newCheckboxIdToSelectedMap,
+ buttonDisabled: !result,
+ });
+ };
+
+ render() {
+ const button = (
+
+ Export PDF
+
+ );
+ return (
+
+
+
+ {this.options.length > 3 && (
+ <>
+ this.selectAll(true)}>
+ Select all
+
+
+ this.selectAll(false)}>
+ Unselect all
+
+ >
+ )}
+
+ {
+ this.closePopover();
+ this.props.exportConfiguration(
+ this.state.checkboxIdToSelectedMap,
+ );
+ }}
+ fill
+ >
+ Generate PDF report
+
+
+ );
+ }
+ },
+);
+
+ExportConfiguration.propTypes = {
+ exportConfiguration: PropTypes.func,
+ type: PropTypes.string,
+ agentPlatform: PropTypes.string,
+};
diff --git a/plugins/main/public/components/common/charts/visualizations/basic.tsx b/plugins/main/public/components/common/charts/visualizations/basic.tsx
index 2e48e5e734..eaca2e6270 100644
--- a/plugins/main/public/components/common/charts/visualizations/basic.tsx
+++ b/plugins/main/public/components/common/charts/visualizations/basic.tsx
@@ -160,7 +160,11 @@ export const VisualizationBasicWidgetSelector = ({
return (
<>
-
+
{title && (
diff --git a/plugins/main/public/components/common/welcome/agents-welcome.js b/plugins/main/public/components/common/welcome/agents-welcome.js
index cb4b63fb54..43b19f1556 100644
--- a/plugins/main/public/components/common/welcome/agents-welcome.js
+++ b/plugins/main/public/components/common/welcome/agents-welcome.js
@@ -22,7 +22,6 @@ import {
EuiButtonEmpty,
EuiPage,
EuiPopover,
- EuiLoadingChart,
EuiToolTip,
EuiButtonIcon,
EuiPageBody,
@@ -39,20 +38,16 @@ import WzReduxProvider from '../../../redux/wz-redux-provider';
import MenuAgent from './components/menu-agent';
import './welcome.scss';
import { WzDatePicker } from '../../../components/wz-date-picker/wz-date-picker';
-import KibanaVis from '../../../kibana-integrations/kibana-vis';
-import { VisFactoryHandler } from '../../../react-services/vis-factory-handler';
-import { AppState } from '../../../react-services/app-state';
-import { FilterHandler } from '../../../utils/filter-handler';
import { TabVisualizations } from '../../../factories/tab-visualizations';
import {
showExploreAgentModalGlobal,
updateCurrentAgentData,
} from '../../../redux/actions/appStateActions';
import {
- getAngularModule,
getChrome,
getCore,
getDataPlugin,
+ getAngularModule,
} from '../../../kibana-services';
import { hasAgentSupportModule } from '../../../react-services/wz-agents';
import {
@@ -80,6 +75,7 @@ import {
malwareDetection,
} from '../../../utils/applications';
import { RedirectAppLinks } from '../../../../../../src/plugins/opensearch_dashboards_react/public';
+import { EventsCount } from './dashboard/events-count';
const mapStateToProps = state => ({
agent: state.appStateReducers.currentAgentData,
@@ -105,11 +101,11 @@ export const AgentsWelcome = compose(
},
...(agent?.name
? [
- {
- text: `${agent.name}`,
- truncate: true,
- },
- ]
+ {
+ text: `${agent.name}`,
+ truncate: true,
+ },
+ ]
: []),
];
}),
@@ -150,6 +146,9 @@ export const AgentsWelcome = compose(
this.sidebarSizeDefault = 320;
+ const $injector = getAngularModule().$injector;
+ this.location = $injector.get('$location');
+
this.state = {
lastScans: [],
isLoading: true,
@@ -200,8 +199,8 @@ export const AgentsWelcome = compose(
of duplicating it. It was duplicated due to the differences of requirements
in the Explore agent button for the modules and agent welcome
*/
- async removeAgentsFilter() {
- await this.props.setAgent(false);
+ removeAgentsFilter() {
+ this.props.setAgent(false);
const currentAppliedFilters = getDataPlugin().query.filterManager.filters;
const agentFilters = currentAppliedFilters.filter(x => {
return x.meta.key !== 'agent.id';
@@ -226,8 +225,7 @@ export const AgentsWelcome = compose(
tabVisualizations.assign({
welcome: 8,
});
- const filterHandler = new FilterHandler(AppState.getCurrentPattern());
- const $injector = getAngularModule().$injector;
+
this.drawerLokedSubscribtion = getChrome()
.getIsNavDrawerLocked$()
.subscribe(isLocked => {
@@ -235,15 +233,7 @@ export const AgentsWelcome = compose(
this.updateWidth();
});
});
- this.router = $injector.get('$route');
- this.location = $injector.get('$location');
window.addEventListener('resize', this.updateWidth); //eslint-disable-line
- await VisFactoryHandler.buildAgentsVisualizations(
- filterHandler,
- 'welcome',
- null,
- this.props.agent.id,
- );
}
componentDidUpdate(prevProps) {
@@ -268,13 +258,13 @@ export const AgentsWelcome = compose(
)
? JSON.parse(window.localStorage.getItem('wz-menu-agent-apps-pinned'))
: [
- // Default pinned applications
- threatHunting.id,
- fileIntegrityMonitoring.id,
- configurationAssessment.id,
- mitreAttack.id,
- malwareDetection.id,
- ];
+ // Default pinned applications
+ threatHunting.id,
+ fileIntegrityMonitoring.id,
+ configurationAssessment.id,
+ mitreAttack.id,
+ malwareDetection.id,
+ ];
}
// Ensure the pinned applications are supported
@@ -354,7 +344,6 @@ export const AgentsWelcome = compose(
closePopover={() => {
this.setState({ switchModule: false });
}}
- switchTab={module => this.props.switchTab(module)}
>
@@ -366,7 +355,6 @@ export const AgentsWelcome = compose(
}
renderTitle() {
- const notNeedStatus = true;
const thereAreAgentSelected = Boolean(this.props.agent?.id);
// Calculate if the header buttons should display the name or only the icon to be responsive
@@ -411,7 +399,6 @@ export const AgentsWelcome = compose(
closePopover={() => {
this.setState({ switchModule: false });
}}
- switchTab={module => this.props.switchTab(module)}
>
@@ -460,9 +447,7 @@ export const AgentsWelcome = compose(
- this.props.switchTab('syscollector', notNeedStatus)
- }
+ onClick={() => this.props.switchTab('syscollector')}
className='wz-it-hygiene-header-button'
tooltip={
this.state.maxModules === null
@@ -477,7 +462,7 @@ export const AgentsWelcome = compose(
this.props.switchTab('stats', notNeedStatus)}
+ onClick={() => this.props.switchTab('stats')}
className='wz-it-hygiene-header-button'
tooltip={
this.state.maxModules === null
@@ -492,9 +477,7 @@ export const AgentsWelcome = compose(
- this.props.switchTab('configuration', notNeedStatus)
- }
+ onClick={() => this.props.switchTab('configuration')}
className='wz-it-hygiene-header-button'
tooltip={
this.state.maxModules === null
@@ -569,50 +552,13 @@ export const AgentsWelcome = compose(
}
renderEventCountVisualization() {
- return (
-
-
-
-
-
-
- Events count evolution
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
+ return ;
}
renderSCALastScan() {
return (
-
+
);
}
@@ -654,8 +600,8 @@ export const AgentsWelcome = compose(
}}
>
{' '}
- {/* DatePicker */}
- {}} />
+ {/* TODO: Replace with SearchBar and replace implementation to get the time range in AgentView component*/}
+ { }} />
{(this.state.widthWindow < 1150 && (
@@ -688,33 +634,33 @@ export const AgentsWelcome = compose(
)) || (
-
-
-
-
-
- {this.renderMitrePanel()}
-
- {this.renderCompliancePanel()}
-
-
-
-
-
-
-
- {' '}
- {/* Events count evolution */}
- {this.renderEventCountVisualization()}
-
- {this.renderSCALastScan()}
-
-
- )}
+
+
+
+
+
+ {this.renderMitrePanel()}
+
+ {this.renderCompliancePanel()}
+
+
+
+
+
+
+
+ {' '}
+ {/* Events count evolution */}
+ {this.renderEventCountVisualization()}
+
+ {this.renderSCALastScan()}
+
+
+ )}
diff --git a/plugins/main/public/components/common/welcome/dashboard/dashboard_panels.ts b/plugins/main/public/components/common/welcome/dashboard/dashboard_panels.ts
new file mode 100644
index 0000000000..7d250e7d05
--- /dev/null
+++ b/plugins/main/public/components/common/welcome/dashboard/dashboard_panels.ts
@@ -0,0 +1,137 @@
+import { DashboardPanelState } from '../../../../../../../src/plugins/dashboard/public/application';
+import { EmbeddableInput } from '../../../../../../../src/plugins/embeddable/public';
+
+const getVisStateEventsCountEvolution = (indexPatternId: string) => ({
+ id: 'App-Agents-Welcome-Events-Evolution',
+ title: 'Events count evolution',
+ type: 'line',
+ params: {
+ type: 'line',
+ grid: { categoryLines: false },
+ categoryAxes: [
+ {
+ id: 'CategoryAxis-1',
+ type: 'category',
+ position: 'bottom',
+ show: true,
+ style: {},
+ scale: { type: 'linear' },
+ labels: { show: true, filter: true, truncate: 100 },
+ title: {},
+ },
+ ],
+ valueAxes: [
+ {
+ id: 'ValueAxis-1',
+ name: 'LeftAxis-1',
+ type: 'value',
+ position: 'left',
+ show: true,
+ style: {},
+ scale: { type: 'linear', mode: 'normal' },
+ labels: { show: true, rotate: 0, filter: false, truncate: 100 },
+ title: { text: 'Count' },
+ },
+ ],
+ seriesParams: [
+ {
+ show: true,
+ type: 'line',
+ mode: 'normal',
+ data: { label: 'Count', id: '1' },
+ valueAxis: 'ValueAxis-1',
+ drawLinesBetweenPoints: true,
+ lineWidth: 2,
+ interpolate: 'linear',
+ showCircles: true,
+ },
+ ],
+ addTooltip: true,
+ addLegend: false,
+ legendPosition: 'right',
+ times: [],
+ addTimeMarker: false,
+ labels: {},
+ thresholdLine: {
+ show: false,
+ value: 10,
+ width: 1,
+ style: 'full',
+ color: '#E7664C',
+ },
+ dimensions: {
+ x: null,
+ y: [
+ {
+ accessor: 0,
+ format: { id: 'number' },
+ params: {},
+ label: 'Count',
+ aggType: 'count',
+ },
+ ],
+ },
+ },
+ uiState: {
+ vis: { params: { sort: { columnIndex: 2, direction: 'desc' } } },
+ },
+ data: {
+ searchSource: {
+ query: {
+ language: 'kuery',
+ query: '',
+ },
+ index: indexPatternId,
+ },
+ references: [
+ {
+ name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
+ type: 'index-pattern',
+ id: indexPatternId,
+ },
+ ],
+ aggs: [
+ { id: '1', enabled: true, type: 'count', schema: 'metric', params: {} },
+ {
+ id: '2',
+ enabled: true,
+ type: 'date_histogram',
+ schema: 'segment',
+ params: {
+ field: 'timestamp',
+ useNormalizedEsInterval: true,
+ scaleMetricValues: false,
+ interval: 'auto',
+ drop_partials: false,
+ min_doc_count: 1,
+ extended_bounds: {},
+ },
+ },
+ ],
+ },
+});
+
+export const getDashboardPanels = (
+ indexPatternId: string,
+): {
+ [panelId: string]: DashboardPanelState<
+ EmbeddableInput & { [k: string]: unknown }
+ >;
+} => {
+ return {
+ '1': {
+ gridData: {
+ w: 48,
+ h: 12,
+ x: 0,
+ y: 0,
+ i: '1',
+ },
+ type: 'visualization',
+ explicitInput: {
+ id: '1',
+ savedVis: getVisStateEventsCountEvolution(indexPatternId),
+ },
+ },
+ };
+};
diff --git a/plugins/main/public/components/common/welcome/dashboard/events-count.tsx b/plugins/main/public/components/common/welcome/dashboard/events-count.tsx
new file mode 100644
index 0000000000..e41f399a5f
--- /dev/null
+++ b/plugins/main/public/components/common/welcome/dashboard/events-count.tsx
@@ -0,0 +1,75 @@
+import React from 'react';
+import { AlertsDataSource } from '../../data-source/pattern/alerts/alerts-data-source';
+import { AlertsDataSourceRepository } from '../../data-source/pattern/alerts/alerts-data-source-repository';
+import { getPlugins } from '../../../../kibana-services';
+import { getDashboardPanels } from './dashboard_panels';
+import { ViewMode } from '../../../../../../../src/plugins/embeddable/public';
+import { useDataSource } from '../../data-source/hooks';
+import { PatternDataSource, tParsedIndexPattern } from '../../data-source';
+import {
+ EuiPanel,
+ EuiFlexItem,
+ EuiFlexGroup,
+ EuiSpacer,
+ EuiText,
+} from '@elastic/eui';
+import { useTimeFilter } from '../../hooks';
+import { LoadingSpinner } from '../../loading-spinner/loading-spinner';
+
+const plugins = getPlugins();
+const DashboardByRenderer = plugins.dashboard.DashboardContainerByValueRenderer;
+
+export const EventsCount = () => {
+ const {
+ dataSource,
+ fetchFilters,
+ isLoading: isDataSourceLoading,
+ } = useDataSource({
+ DataSource: AlertsDataSource,
+ repository: new AlertsDataSourceRepository(),
+ });
+
+ const { timeFilter } = useTimeFilter();
+
+ return (
+
+
+
+
+
+
+ Events count evolution
+
+
+
+
+
+ {!isDataSourceLoading && dataSource ? (
+
+ ) : (
+
+ )}
+
+
+ );
+};
diff --git a/plugins/main/public/components/endpoints-summary/agent/index.tsx b/plugins/main/public/components/endpoints-summary/agent/index.tsx
new file mode 100644
index 0000000000..c7b88c3ad9
--- /dev/null
+++ b/plugins/main/public/components/endpoints-summary/agent/index.tsx
@@ -0,0 +1,126 @@
+import React, { useState, useEffect } from 'react';
+import { EuiPage, EuiPageBody, EuiProgress } from '@elastic/eui';
+import { useDispatch } from 'react-redux';
+import { getErrorOrchestrator } from '../../../react-services/common-services';
+import { UI_LOGGER_LEVELS } from '../../../../common/constants';
+import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types';
+import { AgentsWelcome } from '../../common/welcome/agents-welcome';
+import { Agent } from '../types';
+import {
+ getAngularModule,
+ getCore,
+ getDataPlugin,
+} from '../../../kibana-services';
+import { MainSyscollector } from '../../agents/syscollector/main';
+import { MainAgentStats } from '../../agents/stats';
+import WzManagementConfiguration from '../../../controllers/management/components/management/configuration/configuration-main.js';
+import { getAgentsService } from '../services';
+import { ShareAgent } from '../../../factories/share-agent';
+import { updateCurrentAgentData } from '../../../redux/actions/appStateActions';
+import { endpointSummary } from '../../../utils/applications';
+import { withErrorBoundary, withReduxProvider } from '../../common/hocs';
+import { compose } from 'redux';
+
+export const AgentView = compose(
+ withErrorBoundary,
+ withReduxProvider,
+)(() => {
+ //TODO: Replace when implement React router
+ const $injector = getAngularModule().$injector;
+ const $router = $injector.get('$route');
+ const $commonData = $injector.get('commonData');
+
+ const shareAgent = new ShareAgent();
+
+ //TODO: Replace with useDatasource and useSearchBar when replace WzDatePicker with SearchBar in AgentsWelcome component
+ const savedTimefilter = $commonData.getTimefilter();
+ if (savedTimefilter) {
+ getDataPlugin().query.timefilter.timefilter.setTime(savedTimefilter);
+ $commonData.removeTimefilter();
+ }
+
+ const { agent: agentId } = $router.current.params;
+
+ const [agent, setAgent] = useState();
+ const [isLoadingAgent, setIsLoadingAgent] = useState(true);
+ const [tab, setTab] = useState($commonData.checkTabLocation());
+ const dispatch = useDispatch();
+
+ const getAgent = async () => {
+ try {
+ setIsLoadingAgent(true);
+
+ const id = $commonData.checkLocationAgentId(
+ agentId,
+ shareAgent.getAgent(),
+ );
+
+ if (!id) {
+ return;
+ }
+
+ const { affected_items } = await getAgentsService({
+ agents: [agentId],
+ });
+ if (!affected_items?.length) {
+ throw 'Not found';
+ }
+
+ const agent = affected_items[0];
+ setAgent(agent);
+ dispatch(updateCurrentAgentData(agent));
+ } catch (error) {
+ const options = {
+ context: `AgentView.getAgent`,
+ level: UI_LOGGER_LEVELS.ERROR,
+ severity: UI_ERROR_SEVERITIES.CRITICAL,
+ store: true,
+ error: {
+ error,
+ message: error.message || error,
+ title: `Error getting the agent: ${error.message || error}`,
+ },
+ };
+ getErrorOrchestrator().handleError(options);
+ } finally {
+ setIsLoadingAgent(false);
+ }
+ };
+
+ useEffect(() => {
+ getAgent();
+ }, [tab]);
+
+ const switchTab = (tab: string) => {
+ setTab(tab);
+ getCore().application.navigateToApp(endpointSummary.id, {
+ path: `#/agents?tab=${tab}&agent=${agent?.id}`,
+ });
+ };
+
+ if (isLoadingAgent) {
+ return (
+
+
+
+
+
+ );
+ }
+
+ if (tab === 'welcome') {
+ return ;
+ }
+
+ if (tab === 'syscollector' && agent) {
+ return ;
+ }
+
+ if (tab === 'stats' && agent) {
+ return ;
+ }
+
+ if (tab === 'configuration' && agent) {
+ return ;
+ }
+});
diff --git a/plugins/main/public/components/endpoints-summary/services/get-agents.tsx b/plugins/main/public/components/endpoints-summary/services/get-agents.tsx
index ebe67f445e..5040a34335 100644
--- a/plugins/main/public/components/endpoints-summary/services/get-agents.tsx
+++ b/plugins/main/public/components/endpoints-summary/services/get-agents.tsx
@@ -4,11 +4,13 @@ import { Agent } from '../types';
export const getAgentsService = async ({
filters,
+ agents,
limit,
offset,
pageSize = 1000,
}: {
- filters: any;
+ filters?: any;
+ agents?: string[];
limit?: number;
offset?: number;
pageSize?: number;
@@ -27,7 +29,8 @@ export const getAgentsService = async ({
params: {
limit: queryLimit,
offset: queryOffset,
- q: filters,
+ ...(agents?.length ? { agents_list: agents?.join(',') } : {}),
+ ...(filters ? { q: filters } : {}),
wait_for_complete: true,
},
})) as IApiResponse;
diff --git a/plugins/main/public/controllers/agent/agents.js b/plugins/main/public/controllers/agent/agents.js
deleted file mode 100644
index db8249dedc..0000000000
--- a/plugins/main/public/controllers/agent/agents.js
+++ /dev/null
@@ -1,784 +0,0 @@
-/*
- * Wazuh app - Agents controller
- * Copyright (C) 2015-2022 Wazuh, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Find more information about this on the LICENSE file.
- */
-import { FilterHandler } from '../../utils/filter-handler';
-import { TabNames } from '../../utils/tab-names';
-import { visualizations } from '../../templates/agents/visualizations';
-
-import { ConfigurationHandler } from '../../utils/config-handler';
-import { AppState } from '../../react-services/app-state';
-import { WazuhConfig } from '../../react-services/wazuh-config';
-import { GenericRequest } from '../../react-services/generic-request';
-import { WzRequest } from '../../react-services/wz-request';
-import {
- getToasts,
- getDataPlugin,
- getWazuhCorePlugin,
-} from '../../kibana-services';
-import { ShareAgent } from '../../factories/share-agent';
-import { TabVisualizations } from '../../factories/tab-visualizations';
-import { formatUIDate } from '../../react-services/time-service';
-import { hasAgentSupportModule } from '../../react-services/wz-agents';
-import { UI_LOGGER_LEVELS } from '../../../common/constants';
-import { UI_ERROR_SEVERITIES } from '../../react-services/error-orchestrator/types';
-import { getErrorOrchestrator } from '../../react-services/common-services';
-import { updateCurrentAgentData } from '../../redux/actions/appStateActions';
-import store from '../../redux/store';
-
-export class AgentsController {
- /**
- * Class constructor
- * @param {Object} $scope
- * @param {Object} $location
- * @param {Object} $rootScope
- * @param {Object} errorHandler
- * @param {Object} commonData
- * @param {Object} reportingService
- * @param {Object} visFactoryService
- * @param {Object} csvReq
- */
- constructor(
- $scope,
- $location,
- $rootScope,
- errorHandler,
- commonData,
- reportingService,
- visFactoryService,
- csvReq,
- ) {
- this.$scope = $scope;
- this.$location = $location;
- this.$rootScope = $rootScope;
- this.errorHandler = errorHandler;
- this.tabVisualizations = new TabVisualizations();
- this.$scope.visualizations = visualizations;
- this.shareAgent = new ShareAgent();
- this.commonData = commonData;
- this.reportingService = reportingService;
- this.visFactoryService = visFactoryService;
- this.csvReq = csvReq;
- this.wazuhConfig = new WazuhConfig();
- this.genericReq = GenericRequest;
-
- // Config on-demand
- this.$scope.isArray = Array.isArray;
- this.configurationHandler = new ConfigurationHandler(errorHandler);
- this.$scope.currentConfig = null;
- this.$scope.configurationTab = '';
- this.$scope.configurationSubTab = '';
- this.$scope.integrations = {};
- this.$scope.selectedItem = 0;
- this.targetLocation = null;
- this.ignoredTabs = ['syscollector', 'welcome', 'configuration', 'stats'];
-
- this.$scope.expandArray = [
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- false,
- ];
-
- this.loadWelcomeCardsProps();
- this.$scope.getWelcomeCardsProps = resultState => {
- return { ...this.$scope.welcomeCardsProps, resultState };
- };
- }
-
- /**
- * On controller loads
- */
- async $onInit() {
- const savedTimefilter = this.commonData.getTimefilter();
- if (savedTimefilter) {
- getDataPlugin().query.timefilter.timefilter.setTime(savedTimefilter);
- this.commonData.removeTimefilter();
- }
-
- this.$rootScope.reportStatus = false;
-
- this.$location.search('_a', null);
- this.filterHandler = new FilterHandler(AppState.getCurrentPattern());
- this.visFactoryService.clearAll();
-
- // Getting possible target location
- this.targetLocation = this.shareAgent.getTargetLocation();
-
- if (this.targetLocation && typeof this.targetLocation === 'object') {
- this.$scope.tabView = this.targetLocation.subTab;
- this.$scope.tab = this.targetLocation.tab;
- } else {
- this.$scope.tabView = this.commonData.checkTabViewLocation();
- this.$scope.tab = this.commonData.checkTabLocation();
- }
- this.tabHistory = [];
- if (!this.ignoredTabs.includes(this.$scope.tab))
- this.tabHistory.push(this.$scope.tab);
-
- // Tab names
- this.$scope.tabNames = TabNames;
-
- this.tabVisualizations.assign('agents');
-
- /**
- * This check if given array of items contais a single given item
- * @param {Object} item
- * @param {Array