forked from p34709852/monkey
Improved the Events modal
This commit is contained in:
parent
68383f069b
commit
4d24d8432e
|
@ -104,6 +104,7 @@
|
||||||
"react-tooltip-lite": "^1.9.1",
|
"react-tooltip-lite": "^1.9.1",
|
||||||
"redux": "^4.0.0",
|
"redux": "^4.0.0",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"sha3": "^2.0.0"
|
"sha3": "^2.0.0",
|
||||||
|
"pluralize": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,8 @@ export default class EventsButton extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
createEventsAmountBadge() {
|
createEventsAmountBadge() {
|
||||||
let eventsAmountBadge;
|
const eventsAmountBadgeContent = this.props.events.length > 9 ? "9+" : this.props.events.length;
|
||||||
if (this.props.events.length > 9) {
|
return <Badge>{eventsAmountBadgeContent}</Badge>;
|
||||||
eventsAmountBadge = <Badge>9+</Badge>;
|
|
||||||
} else {
|
|
||||||
eventsAmountBadge = <Badge>{this.props.events.length}</Badge>;
|
|
||||||
}
|
|
||||||
return eventsAmountBadge;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import React, {Component} from "react";
|
import React, {Component} from "react";
|
||||||
import {Modal} from "react-bootstrap";
|
import {Badge, Modal} from "react-bootstrap";
|
||||||
import EventsTimeline from "./EventsTimeline";
|
import EventsTimeline from "./EventsTimeline";
|
||||||
import * as PropTypes from "prop-types";
|
import * as PropTypes from "prop-types";
|
||||||
import ExportEventsButton from "./ExportEventsButton";
|
|
||||||
import saveJsonToFile from "../../utils/SaveJsonToFile";
|
import saveJsonToFile from "../../utils/SaveJsonToFile";
|
||||||
|
import EventsModalButtons from "./EventsModalButtons";
|
||||||
|
import Pluralize from 'pluralize'
|
||||||
|
import {statusToLabelType} from "./StatusLabel";
|
||||||
|
|
||||||
export default class EventsModal extends Component {
|
export default class EventsModal extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -15,28 +17,31 @@ export default class EventsModal extends Component {
|
||||||
<div>
|
<div>
|
||||||
<Modal show={this.props.showEvents} onHide={() => this.props.hideCallback()}>
|
<Modal show={this.props.showEvents} onHide={() => this.props.hideCallback()}>
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
<h2>
|
<h3>
|
||||||
<div className="text-center">Events</div>
|
<div className="text-center">Events</div>
|
||||||
</h2>
|
</h3>
|
||||||
|
<hr />
|
||||||
|
<p>
|
||||||
|
There {Pluralize('is', this.props.events.length)} {<div className={"label label-primary"}>{this.props.events.length}</div>} {Pluralize('event', this.props.events.length)} associated with this finding.
|
||||||
|
</p>
|
||||||
|
{this.props.events.length > 5 ? this.renderButtons() : null}
|
||||||
<EventsTimeline events={this.props.events}/>
|
<EventsTimeline events={this.props.events}/>
|
||||||
|
{this.renderButtons()}
|
||||||
<div className="text-center">
|
|
||||||
<button type="button" className="btn btn-success btn-lg" style={{margin: '5px'}}
|
|
||||||
onClick={() => this.props.hideCallback()}>
|
|
||||||
Close
|
|
||||||
</button>
|
|
||||||
<ExportEventsButton onClick={() => {
|
|
||||||
const dataToSave = this.props.events;
|
|
||||||
const filename = this.props.exportFilename;
|
|
||||||
saveJsonToFile(dataToSave, filename);
|
|
||||||
}}/>
|
|
||||||
</div>
|
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderButtons() {
|
||||||
|
return <EventsModalButtons
|
||||||
|
onClickClose={() => this.props.hideCallback()}
|
||||||
|
onClickExport={() => {
|
||||||
|
const dataToSave = this.props.events;
|
||||||
|
const filename = this.props.exportFilename;
|
||||||
|
saveJsonToFile(dataToSave, filename);
|
||||||
|
}}/>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventsModal.propTypes = {
|
EventsModal.propTypes = {
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import React, {Component} from "react";
|
||||||
|
import ExportEventsButton from "./ExportEventsButton";
|
||||||
|
import * as PropTypes from "prop-types";
|
||||||
|
|
||||||
|
export default class EventsModalButtons extends Component {
|
||||||
|
render() {
|
||||||
|
return <div className="text-center">
|
||||||
|
<button type="button" className="btn btn-success btn-lg" style={{margin: '5px'}}
|
||||||
|
onClick={this.props.onClickClose}>
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
<ExportEventsButton onClick={this.props.onClickExport}/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventsModalButtons.propTypes = {
|
||||||
|
onClickClose: PropTypes.func,
|
||||||
|
onClickExport: PropTypes.func
|
||||||
|
};
|
|
@ -14,7 +14,7 @@ export default class EventsTimeline extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Timeline>
|
<Timeline style={{fontSize: '100%'}}>
|
||||||
{
|
{
|
||||||
this.props.events.map((event, index) => {
|
this.props.events.map((event, index) => {
|
||||||
const event_time = new Date(event.timestamp['$date']).toString();
|
const event_time = new Date(event.timestamp['$date']).toString();
|
||||||
|
@ -22,7 +22,6 @@ export default class EventsTimeline extends Component {
|
||||||
key={index}
|
key={index}
|
||||||
createdAt={event_time}
|
createdAt={event_time}
|
||||||
title={event.title}
|
title={event.title}
|
||||||
|
|
||||||
icon={<img src={eventTypeToIcon[event.event_type]} alt="icon" style={{width: '24px'}} />}>
|
icon={<img src={eventTypeToIcon[event.event_type]} alt="icon" style={{width: '24px'}} />}>
|
||||||
{event.message}
|
{event.message}
|
||||||
</TimelineEvent>)
|
</TimelineEvent>)
|
||||||
|
|
Loading…
Reference in New Issue