Use more generic download-url and remove older download-text utility

This commit is contained in:
Paul Kaplan committed 2019-02-01 13:17:43 -05:00
1 parent 2a36f49d7c
commit f41c5764ff
2 files changed
+3 -15

No files matched your search

+3 -2
View File
@@ -8,7 +8,7 @@ import MonitorComponent, {monitorModes} from '../components/monitor/monitor.jsx'
import {addMonitorRect, getInitialPosition, resizeMonitorRect, removeMonitorRect} from '../reducers/monitor-layout';
import {getVariable, setVariableValue} from '../lib/variable-utils';
import importCSV from '../lib/import-csv';
import downloadText from '../lib/download-text';
import download from '../lib/download-url';
import {connect} from 'react-redux';
import {Map} from 'immutable';
@@ -155,7 +155,8 @@ class Monitor extends React.Component {
handleExport () {
const {vm, targetId, id: variableId} = this.props;
const variable = getVariable(vm, targetId, variableId);
downloadText(`${variable.name}.txt`, variable.value.join('\r\n'));
const text = variable.value.join('\r\n');
download(`${variable.name}.txt`, `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`);
}
render () {
const monitorProps = monitorAdapter(this.props);
-13
View File
@@ -1,13 +0,0 @@
export default (filename, text) => {
const pom = document.createElement('a');
pom.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`);
pom.setAttribute('download', filename);
if (document.createEvent) {
const event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
} else {
pom.click();
}
};