/
management-main.js
101 lines (95 loc) · 2.95 KB
/
management-main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Wazuh app - React component for all management section.
* 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, Fragment } from 'react';
// Redux
import store from '../../../../redux/store';
import WzRuleset from './ruleset/main-ruleset';
import WzCDBLists from './cdblists/main-cdblists';
import WzDecoders from './decoders/main-decoders';
import WzGroups from './groups/groups-main';
import WzStatus from './status/status-main';
import WzLogs from './mg-logs/logs';
import WzReporting from './reporting/reporting-main';
import WzConfiguration from './configuration/configuration-main';
import WzStatistics from './statistics/statistics-main';
import {
SECTION_CDBLIST_SECTION,
SECTION_DECODERS_SECTION,
SECTION_RULES_SECTION,
} from './common/constants';
import { getAngularModule } from '../../../../kibana-services';
import {
withGuardAsync,
withReduxProvider,
} from '../../../../components/common/hocs';
import { compose } from 'redux';
import { ClusterOverview } from './cluster/cluster-overview';
class WzManagementMain extends Component {
constructor(props) {
super(props);
}
render() {
const { section } = this.props;
return (
<Fragment>
{(section === 'groups' && <WzGroups {...this.props} />) ||
(section === 'status' && <WzStatus />) ||
(section === 'monitoring' && <ClusterOverview />) ||
(section === 'reporting' && <WzReporting />) ||
(section === 'statistics' && <WzStatistics />) ||
(section === 'logs' && <WzLogs />) ||
(section === 'configuration' && (
<WzConfiguration
agent={{
id: '000',
}}
/>
)) ||
(section === SECTION_DECODERS_SECTION && <WzDecoders />) ||
(section === SECTION_CDBLIST_SECTION && <WzCDBLists />) ||
(['ruleset', SECTION_RULES_SECTION].includes(section) && (
<WzRuleset />
))}
</Fragment>
);
}
}
const availableViews = [
'groups',
'status',
'reporting',
'statistics',
'logs',
'configuration',
'decoders',
'lists',
'ruleset',
'rules',
'monitoring',
];
export const ManagementRouter = compose(
withReduxProvider,
withGuardAsync(
() => {
// This uses AngularJS to get the tab query parameter
const section = getAngularModule()
.$injector.get('$location')
.search().tab;
if (availableViews.includes(section)) {
return { ok: false, data: { section } };
}
return { ok: true, data: { section } };
},
() => null,
),
)(({ section }) => <WzManagementMain section={section} />);
export default ManagementRouter;