forked from p15670423/monkey
Improved display of post breach actions
This commit is contained in:
parent
308a1e3547
commit
dbf56b5531
|
@ -2,30 +2,39 @@ import React from 'react';
|
||||||
import ReactTable from 'react-table'
|
import ReactTable from 'react-table'
|
||||||
|
|
||||||
let renderArray = function(val) {
|
let renderArray = function(val) {
|
||||||
return <div>{val.map(x => <div>{x}</div>)}</div>;
|
return <span>{val.map(x => <span> {x}</span>)}</span>;
|
||||||
};
|
};
|
||||||
|
|
||||||
let renderIpAddresses = function (val) {
|
let renderIpAddresses = function (val) {
|
||||||
return <div>{renderArray(val.ip_addresses)} {(val.domain_name ? " (".concat(val.domain_name, ")") : "")} </div>;
|
return <span> {renderArray(val.ip_addresses)} {(val.domain_name ? " (".concat(val.domain_name, ")") : "")} </span>;
|
||||||
};
|
};
|
||||||
|
|
||||||
let renderPostBreach = function (machine, pbaList) {
|
let renderMachine = function (data) {
|
||||||
if (pbaList.length === 0){
|
return <div>{data.label} ( {renderIpAddresses(data)} )</div>
|
||||||
return
|
};
|
||||||
} else {
|
|
||||||
return <div>Machine: {machine.label}<br/>
|
const subColumns = [
|
||||||
{pbaList.map(x => <div>Name: {x.name}<br/>
|
{id: 'pba_name', Header: "Name", accessor: x => x.name, style: { 'white-space': 'unset' }},
|
||||||
Command: {x.command}<br/>
|
{id: 'pba_output', Header: "Output", accessor: x => x.output, style: { 'white-space': 'unset' }}
|
||||||
Output: {x.output}<br/></div>)}
|
];
|
||||||
</div>;
|
|
||||||
}
|
let renderDetails = function (data) {
|
||||||
|
let defaultPageSize = data.length > pageSize ? pageSize : data.length;
|
||||||
|
let showPagination = data.length > pageSize;
|
||||||
|
return <ReactTable
|
||||||
|
data={data}
|
||||||
|
columns={subColumns}
|
||||||
|
defaultPageSize={defaultPageSize}
|
||||||
|
showPagination={showPagination}
|
||||||
|
style={{"background-color": "#ededed"}}
|
||||||
|
/>
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
Header: 'Post breach actions',
|
Header: 'Post breach actions',
|
||||||
columns: [
|
columns: [
|
||||||
{id: 'post_breach_actions', accessor: x => renderPostBreach(x, x.pba_results)}
|
{id: 'pba_machine', Header:'Machine', accessor: x => renderMachine(x)}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -38,17 +47,24 @@ class PostBreachComponent extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let defaultPageSize = this.props.data.length > pageSize ? pageSize : this.props.data.length;
|
let pbaMachines = this.props.data.filter(function(value, index, arr){
|
||||||
let showPagination = this.props.data.length > pageSize;
|
return ( value.pba_results !== "None" && value.pba_results.length);
|
||||||
|
});
|
||||||
|
let defaultPageSize = pbaMachines.length > pageSize ? pageSize : pbaMachines.length;
|
||||||
|
let showPagination = pbaMachines > pageSize;
|
||||||
return (
|
return (
|
||||||
<div className="data-table-container">
|
<div className="data-table-container">
|
||||||
<ReactTable
|
<ReactTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={this.props.data}
|
data={pbaMachines}
|
||||||
showPagination={showPagination}
|
showPagination={showPagination}
|
||||||
defaultPageSize={defaultPageSize}
|
defaultPageSize={defaultPageSize}
|
||||||
|
SubComponent={row => {
|
||||||
|
return renderDetails(row.original.pba_results);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue