Added export events button

This commit is contained in:
Shay Nehmad 2019-08-08 10:28:22 +03:00
parent 274b861adc
commit bcc12657a4
3 changed files with 24 additions and 8 deletions

View File

@ -5198,6 +5198,11 @@
}
}
},
"file-saver": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.2.tgz",
"integrity": "sha512-Wz3c3XQ5xroCxd1G8b7yL0Ehkf0TC9oYC6buPFkNnU9EnaPlifeAFCyCh+iewXTyFRcg0a6j3J7FmJsIhlhBdw=="
},
"filename-regex": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",

View File

@ -65,12 +65,14 @@
"webpack-dev-server": "^3.1.9"
},
"dependencies": {
"@emotion/core": "^10.0.10",
"@kunukn/react-collapse": "^1.0.5",
"classnames": "^2.2.6",
"bootstrap": "3.4.1",
"classnames": "^2.2.6",
"core-js": "^2.5.7",
"downloadjs": "^1.4.7",
"fetch": "^1.1.0",
"file-saver": "^2.0.2",
"filepond": "^4.2.0",
"js-file-download": "^0.4.4",
"json-loader": "^0.5.7",
@ -85,6 +87,7 @@
"react-bootstrap": "^0.32.4",
"react-copy-to-clipboard": "^5.0.1",
"react-data-components": "^1.2.0",
"react-desktop-notification": "^1.0.9",
"react-dimensions": "^1.3.0",
"react-dom": "^16.5.2",
"react-fa": "^5.0.0",
@ -94,14 +97,12 @@
"react-jsonschema-form": "^1.0.5",
"react-redux": "^5.1.1",
"react-router-dom": "^4.3.1",
"react-spinners": "^0.5.4",
"react-table": "^6.8.6",
"react-toggle": "^4.0.1",
"react-tooltip-lite": "^1.9.1",
"redux": "^4.0.0",
"sass-loader": "^7.1.0",
"sha3": "^2.0.0",
"react-spinners": "^0.5.4",
"@emotion/core": "^10.0.10",
"react-desktop-notification": "^1.0.9"
"sha3": "^2.0.0"
}
}

View File

@ -2,6 +2,7 @@ import React, {Component} from "react";
import ReactTable from "react-table";
import {Button} from "react-bootstrap";
import {EventsModal} from "./EventsModal";
import FileSaver from "file-saver";
function PillarLabel(props) {
return <span className="label label-primary" style={{margin: '2px'}}>{props.pillar}</span>
@ -28,11 +29,20 @@ class EventsAndButtonComponent extends Component {
return (
<div>
<EventsModal events={this.props.events} showEvents={this.state.show} hideCallback={this.hide}/>
<p style={{margin: '5px'}}>
<Button className="btn btn-danger btn-lg center-block"
<p style={{margin: '1px'}}>
<Button className="btn btn-info btn-lg center-block"
onClick={this.show}>
Show Events
</Button>
<Button className="btn btn-primary btn-lg center-block"
onClick={() => {
const content = JSON.stringify(this.props.events, null, 2);
const blob = new Blob([content], {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, this.props.exportFilename+".json");
}}
>
Export Events
</Button>
</p>
</div>
);
@ -58,7 +68,7 @@ const columns = [
},
{ Header: 'Events', id:"events",
accessor: x => {
return <EventsAndButtonComponent events={x.events}/>;
return <EventsAndButtonComponent events={x.events} exportFilename={"Events_" + x.test}/>;
}
}
]