forked from p15670423/monkey
Final CR comments, improved doc and extracted a saveJsonToFIle function
This commit is contained in:
parent
871e7b11d7
commit
6e0c974215
|
@ -15,7 +15,7 @@ def get_ip_if_in_subnet(ip_addresses, subnet):
|
||||||
"""
|
"""
|
||||||
:param ip_addresses: IP address list.
|
:param ip_addresses: IP address list.
|
||||||
:param subnet: Subnet to check if one of ip_addresses is in there. This is common.network.network_range.NetworkRange
|
:param subnet: Subnet to check if one of ip_addresses is in there. This is common.network.network_range.NetworkRange
|
||||||
:return: The first IP in ip_addresses which is in the subnet.
|
:return: The first IP in ip_addresses which is in the subnet if there is one, otherwise returns None.
|
||||||
"""
|
"""
|
||||||
for ip_address in ip_addresses:
|
for ip_address in ip_addresses:
|
||||||
if subnet.is_in_range(ip_address):
|
if subnet.is_in_range(ip_address):
|
||||||
|
|
|
@ -2,8 +2,8 @@ import React, {Component} from "react";
|
||||||
import {Modal} from "react-bootstrap";
|
import {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 FileSaver from "file-saver";
|
|
||||||
import ExportEventsButton from "./ExportEventsButton";
|
import ExportEventsButton from "./ExportEventsButton";
|
||||||
|
import saveJsonToFile from "../../utils/SaveJsonToFile";
|
||||||
|
|
||||||
export default class EventsModal extends Component {
|
export default class EventsModal extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -27,9 +27,9 @@ export default class EventsModal extends Component {
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
<ExportEventsButton onClick={() => {
|
<ExportEventsButton onClick={() => {
|
||||||
const content = JSON.stringify(this.props.events, null, 2);
|
const dataToSave = this.props.events;
|
||||||
const blob = new Blob([content], {type: "text/plain;charset=utf-8"});
|
const filename = this.props.exportFilename;
|
||||||
FileSaver.saveAs(blob, this.props.exportFilename + ".json");
|
saveJsonToFile(dataToSave, filename);
|
||||||
}}/>
|
}}/>
|
||||||
</div>
|
</div>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import FileSaver from "file-saver";
|
||||||
|
|
||||||
|
export default function saveJsonToFile(dataToSave, filename) {
|
||||||
|
const content = JSON.stringify(dataToSave, null, 2);
|
||||||
|
const blob = new Blob([content], {type: "text/plain;charset=utf-8"});
|
||||||
|
FileSaver.saveAs(blob, filename + ".json");
|
||||||
|
}
|
Loading…
Reference in New Issue