Gaëtan Renaudeau
7 years ago
committed by
GitHub
10 changed files with 172 additions and 38 deletions
@ -0,0 +1,60 @@ |
|||
// @flow
|
|||
import logger from 'logger' |
|||
import moment from 'moment' |
|||
import fs from 'fs' |
|||
import { webFrame, remote } from 'electron' |
|||
import React, { Component } from 'react' |
|||
import { translate } from 'react-i18next' |
|||
import { connect } from 'react-redux' |
|||
import { createStructuredSelector, createSelector } from 'reselect' |
|||
import { accountsSelector, encodeAccountsModel } from 'reducers/accounts' |
|||
import { storeSelector as settingsSelector } from 'reducers/settings' |
|||
import Button from './base/Button' |
|||
|
|||
const mapStateToProps = createStructuredSelector({ |
|||
accounts: createSelector(accountsSelector, encodeAccountsModel), |
|||
settings: settingsSelector, |
|||
}) |
|||
|
|||
class ExportLogsBtn extends Component<{ |
|||
t: *, |
|||
settings: *, |
|||
accounts: *, |
|||
}> { |
|||
handleExportLogs = () => { |
|||
const { accounts, settings } = this.props |
|||
const logs = logger.exportLogs() |
|||
const resourceUsage = webFrame.getResourceUsage() |
|||
const report = { resourceUsage, logs, accounts, settings, date: new Date() } |
|||
console.log(report) // eslint-disable-line no-console
|
|||
const reportJSON = JSON.stringify(report) |
|||
const path = remote.dialog.showSaveDialog({ |
|||
title: 'Export logs', |
|||
defaultPath: `ledger_export_${moment().format('YYYY-MM-DD_HHmmss')}.json`, |
|||
filters: [ |
|||
{ |
|||
name: 'All Files', |
|||
extensions: ['json'], |
|||
}, |
|||
], |
|||
}) |
|||
if (path) { |
|||
fs.writeFile(path, reportJSON, err => { |
|||
if (err) { |
|||
logger.error(err) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
|
|||
render() { |
|||
const { t } = this.props |
|||
return ( |
|||
<Button primary onClick={this.handleExportLogs}> |
|||
{t('settings:exportLogs.btn')} |
|||
</Button> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default translate()(connect(mapStateToProps)(ExportLogsBtn)) |
@ -0,0 +1,34 @@ |
|||
// @flow
|
|||
import memoize from 'lodash/memoize' |
|||
import { listCryptoCurrencies as listCC } from '@ledgerhq/live-common/lib/helpers/currencies' |
|||
import type { CryptoCurrencyIds } from '@ledgerhq/live-common/lib/types' |
|||
|
|||
const supported: CryptoCurrencyIds[] = [ |
|||
'bitcoin', |
|||
'ethereum', |
|||
'ripple', |
|||
'bitcoin_cash', |
|||
'litecoin', |
|||
'dash', |
|||
'ethereum_classic', |
|||
'qtum', |
|||
'zcash', |
|||
'bitcoin_gold', |
|||
'stratis', |
|||
'dogecoin', |
|||
'digibyte', |
|||
'hcash', |
|||
'komodo', |
|||
'pivx', |
|||
'zencash', |
|||
'vertcoin', |
|||
'peercoin', |
|||
'viacoin', |
|||
'stealthcoin', |
|||
'poswallet', |
|||
'bitcoin_testnet', |
|||
] |
|||
|
|||
export const listCryptoCurrencies = memoize((withDevCrypto?: boolean) => |
|||
listCC(withDevCrypto).filter(c => supported.includes(c.id)), |
|||
) |
Loading…
Reference in new issue