Merge pull request #2866 from ethcore/ng-accounts-backup
Export accounts as JSON or CSV
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import FileSaver from 'file-saver';
|
||||
import FileDownloadIcon from 'material-ui/svg-icons/file/file-download';
|
||||
|
||||
@@ -38,19 +39,18 @@ class ActionbarExport extends Component {
|
||||
className={ className }
|
||||
icon={ <FileDownloadIcon /> }
|
||||
label='export'
|
||||
onClick={ this.onDownloadBackup } />
|
||||
onClick={ this.handleExport }
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
onDownloadBackup = () => {
|
||||
handleExport = () => {
|
||||
const { filename, content } = this.props;
|
||||
|
||||
const text = (typeof content === 'string')
|
||||
? content
|
||||
: JSON.stringify(content, null, 4);
|
||||
const text = JSON.stringify(content, null, 4);
|
||||
|
||||
const blob = new Blob([ text ], { type: 'text/plain;charset=utf-8' });
|
||||
FileSaver.saveAs(blob, filename);
|
||||
const blob = new Blob([ text ], { type: 'application/json' });
|
||||
FileSaver.saveAs(blob, `${filename}.json`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user