...
 
Commits (2)
This diff is collapsed.
......@@ -5,6 +5,7 @@
"dependencies": {
"@material-ui/core": "^1.4.3",
"@material-ui/lab": "^1.0.0-alpha.9",
"file-saver": "^2.0.0-rc.4",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-intl": "^2.4.0",
......
......@@ -2,6 +2,7 @@ import React, { Component } from "react";
import Button from "@material-ui/core/Button";
import Icon from "@material-ui/core/Icon";
import { defineMessages, FormattedMessage, injectIntl } from "react-intl";
import FileSaver from "file-saver";
const messages = defineMessages({
export: {
......@@ -65,14 +66,21 @@ class ExportButton extends Component {
onClick = e => {
e.preventDefault();
const blob = new Blob(this.makeData(), { type: "text/csv" });
const csvURL = window.URL.createObjectURL(blob);
const tempLink = document.createElement("a");
tempLink.setAttribute("href", csvURL);
tempLink.setAttribute("download", "talk.csv");
document.body.appendChild(tempLink);
tempLink.click();
document.body.removeChild(tempLink);
const now = new Date();
const todayString =
now.getFullYear() +
"-" +
now
.getMonth()
.toString()
.padStart(2, "0") +
"-" +
now
.getDate()
.toString()
.padStart(2, "0");
const blob = new Blob(this.makeData(), { type: "text/csv; charset=utf-8" });
FileSaver.saveAs(blob, "talk-" + todayString + ".csv");
};
render() {
......