-
Notifications
You must be signed in to change notification settings - Fork 187
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
Remove agent AngularJS controller #6618
Merged
asteriscos
merged 15 commits into
4.9.0
from
enhancement/6548-refactor-angularjs-agent-controller
Apr 29, 2024
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a049ec4
Create AgentView component to replace controller
lucianogorza d6f1860
Replace Kibana visualization
lucianogorza 6974fa2
Improve Events count evolution chart
lucianogorza 039057c
Fix Dashboard embeddable
lucianogorza c0db1af
Fix url update when change tab
lucianogorza b59b5bd
Move file export-configuration
lucianogorza 6365751
Fix imports to move file export-configuration
lucianogorza 55d53fa
Delete agents angularjs controller
lucianogorza 04ab3ac
Merge branch '4.9.0' into enhancement/6548-refactor-angularjs-agent-c…
lucianogorza df413a4
Get agent on change tab
lucianogorza b279912
Update CHANGELOG
lucianogorza 2657861
Merge branch '4.9.0' into enhancement/6548-refactor-angularjs-agent-c…
lucianogorza 27ac45c
Merge branch '4.9.0' into enhancement/6548-refactor-angularjs-agent-c…
asteriscos e7c0d03
Remove unused VisFactoryHandler
lucianogorza 3d19dc6
Improve code and remove unused code
lucianogorza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 181 additions & 0 deletions
181
plugins/main/public/components/agents/export-configuration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = ( | ||
<EuiButtonEmpty | ||
iconType='importAction' | ||
iconSide='left' | ||
size='s' | ||
style={{ marginTop: '4px' }} | ||
onClick={this.exportClick.bind(this)} | ||
> | ||
Export PDF | ||
</EuiButtonEmpty> | ||
); | ||
return ( | ||
<EuiPopover | ||
id='trapFocus' | ||
ownFocus | ||
button={button} | ||
isOpen={this.state.isPopoverOpen} | ||
closePopover={this.closePopover.bind(this)} | ||
anchorPosition='downRight' | ||
> | ||
<EuiCheckboxGroup | ||
options={this.options} | ||
idToSelectedMap={this.state.checkboxIdToSelectedMap} | ||
onChange={this.onChange} | ||
compressed | ||
/> | ||
<EuiSpacer size='s' /> | ||
{this.options.length > 3 && ( | ||
<> | ||
<EuiButtonEmpty size='xs' onClick={() => this.selectAll(true)}> | ||
Select all | ||
</EuiButtonEmpty> | ||
<EuiSpacer size='s' /> | ||
<EuiButtonEmpty size='xs' onClick={() => this.selectAll(false)}> | ||
Unselect all | ||
</EuiButtonEmpty> | ||
</> | ||
)} | ||
<EuiSpacer size='m' /> | ||
<EuiButton | ||
isDisabled={this.state.buttonDisabled} | ||
onClick={() => { | ||
this.closePopover(); | ||
this.props.exportConfiguration( | ||
this.state.checkboxIdToSelectedMap, | ||
); | ||
}} | ||
fill | ||
> | ||
Generate PDF report | ||
</EuiButton> | ||
</EuiPopover> | ||
); | ||
} | ||
}, | ||
); | ||
|
||
ExportConfiguration.propTypes = { | ||
exportConfiguration: PropTypes.func, | ||
type: PropTypes.string, | ||
agentPlatform: PropTypes.string, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: we could have moved the file instead of creating a new one through copying it. Moving follows the tracking of the commits of the old file.