Skip to content
Snippets Groups Projects
Commit f41c5764 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

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

parent 2a36f49d
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
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();
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment