...
 
Commits (1)
import React, { Component } from 'react';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import Icon from '@material-ui/core/Icon';
import Tooltip from '@material-ui/core/Tooltip';
class ExportButton extends Component {
......@@ -38,23 +40,27 @@ class ExportButton extends Component {
e.preventDefault();
const blob = new Blob(this.makeData(), {type: 'text/csv'});
const csvURL = window.URL.createObjectURL(blob);
//window.open(csvURL);
const tempLink = document.createElement('a');
tempLink.href = csvURL;
tempLink.setAttribute('download', 'talk.csv');
tempLink.click();
window.open(csvURL);
// Allows setting the filename, but does not work on Firefox
//const tempLink = document.createElement('a');
//tempLink.href = csvURL;
//tempLink.setAttribute('download', 'talk.csv');
//tempLink.click();
}
render() {
return (
<Button
variant="text"
color="default"
onClick={this.onClick}
size="small"
<Tooltip
title="Sauvegarder"
placement="left"
>
Exporter
</Button>
<IconButton
color="default"
onClick={this.onClick}
>
<Icon>save_alt</Icon>
</IconButton>
</Tooltip>
);
}
}
......