Added basic findings table, no access to events yet

This commit is contained in:
Shay Nehmad 2019-08-05 15:13:55 +03:00
parent eaf923a0e4
commit 50e020403b
3 changed files with 52 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import {Button, Col} from 'react-bootstrap';
import AuthComponent from '../AuthComponent'; import AuthComponent from '../AuthComponent';
import ReportHeader, { ReportTypes } from "../report-components/common/ReportHeader"; import ReportHeader, { ReportTypes } from "../report-components/common/ReportHeader";
import ZeroTrustReportPillarGrades from "../report-components/zerotrust/ZeroTrustReportPillarGrades"; import ZeroTrustReportPillarGrades from "../report-components/zerotrust/ZeroTrustReportPillarGrades";
import ZeroTrustReportFindingsTable from "../report-components/zerotrust/ZeroTrustReportFindingsTable";
class ZeroTrustReportPageComponent extends AuthComponent { class ZeroTrustReportPageComponent extends AuthComponent {
@ -43,7 +44,10 @@ class ZeroTrustReportPageComponent extends AuthComponent {
content = "Still empty"; content = "Still empty";
} else { } else {
content = <div> content = <div>
<h2>Pillars Overview</h2>
<ZeroTrustReportPillarGrades findings={this.state.report.findings} /> <ZeroTrustReportPillarGrades findings={this.state.report.findings} />
<h2>Findings</h2>
<ZeroTrustReportFindingsTable findings={this.state.report.findings} />
</div>; </div>;
} }
@ -59,6 +63,7 @@ class ZeroTrustReportPageComponent extends AuthComponent {
<ReportHeader report_type={ReportTypes.zeroTrust}/> <ReportHeader report_type={ReportTypes.zeroTrust}/>
<hr/> <hr/>
{content} {content}
<hr/>
THIS IS THE RAW SERVER DATA THIS IS THE RAW SERVER DATA
<pre id="json-report"> <pre id="json-report">
{JSON.stringify(this.state.report, undefined, 2)} {JSON.stringify(this.state.report, undefined, 2)}

View File

@ -0,0 +1,47 @@
import React, {Component} from "react";
import ReactTable from "react-table";
const columns = [
{
Header: 'Findings',
columns: [
{ Header: 'Test', accessor: 'test'},
{ Header: 'Pillars', id: "pillars",
accessor: x => {
const pillars = x.pillars;
const listItems = pillars.map((pillar) =>
<li key={pillar}><span className="label label-warning" style={{margin: '2px'}}>{pillar}</span></li>
);
return <ul>{listItems}</ul>
}
},
{ Header: 'Events', id:"events", accessor: x => ZeroTrustReportFindingsTable.buildEventsComponent(x)}
]
}
];
const pageSize = 10;
class ZeroTrustReportFindingsTable extends Component {
render() {
let defaultPageSize = this.props.findings.length > pageSize ? pageSize : this.props.findings.length;
let showPagination = this.props.findings.length > pageSize;
return (
<div>
<ReactTable
columns={columns}
data={this.props.findings}
showPagination={showPagination}
defaultPageSize={defaultPageSize}
/>
</div>
);
}
static buildEventsComponent(events) {
return <button>Click to see events...</button>;
}
}
export default ZeroTrustReportFindingsTable;

View File

@ -23,9 +23,6 @@ export class ZeroTrustReportPillarGrades extends Component {
return ( return (
<div id="pillar-grades"> <div id="pillar-grades">
<h2>
Pillars Overview
</h2>
<p> <p>
TODO: table with conditional colouring. TODO: table with conditional colouring.
</p> </p>