var React = require('react'); var Chart = require('../chart/chart'), ChartHelperMixin = require('../chart/chart_helper_mixin'), Refresh = require('../refresh/refresh'); export default React.createClass({ displayName: 'HostActivity', mixins: [ChartHelperMixin], getDefaultProps() { return { options: { legend: { logins: 'Logins to host', sudo: 'Sudo calls on host', reads: 'Secret reads by host', updates: 'Secret updates by host', warnings: 'Warnings' }, axis: { y: { label: 'Value' } } } }; }, getDefaultItem() { return { logins: 0, sudo: 0, reads: 0, updates: 0, warnings: 0 }; }, getEventType(e) { if (e.hasOwnProperty('facility') && e.facility === 'ssh') { if (e.action === 'sudo' && e.allowed === true) { return 'sudo'; } if (e.action === 'login' && e.allowed === true) { return 'logins'; } } if (e.hasOwnProperty('error') || e.allowed === false) { return 'warnings'; } if (e.action === 'check' && e.hasOwnProperty('allowed') && e.allowed === true) { if (e.hasOwnProperty('role') && e.role === this.props.roleid) { if (e.hasOwnProperty('resource') && e.resource.split(':')[1] === 'variable') { if (e.privilege === 'update') { return 'updates'; } if (e.privilege === 'execute') { return 'reads'; } } } } return null; }, getInitialState() { return {showActivity: false}; }, toggleActivity(e) { e.preventDefault(); this.setState({showActivity: !this.state.showActivity}); }, render() { var data = this.getData(this.props.audit); var activityBody = []; var msg = this.state.showActivity ? 'Hide' : 'Show graph'; if (this.state.showActivity) { activityBody.push(