mirror of https://github.com/BTCPrivate/copay.git
Generate CSV using a new plugin
This commit is contained in:
parent
94a0ffa02e
commit
0efbf28f1a
|
@ -59,6 +59,8 @@ module.exports = function(grunt) {
|
||||||
'bower_components/angular-gettext/dist/angular-gettext.js',
|
'bower_components/angular-gettext/dist/angular-gettext.js',
|
||||||
'bower_components/angular-touch/angular-touch.js',
|
'bower_components/angular-touch/angular-touch.js',
|
||||||
'bower_components/angular-ui-switch/angular-ui-switch.js',
|
'bower_components/angular-ui-switch/angular-ui-switch.js',
|
||||||
|
'bower_components/angular-sanitize/angular-sanitize.js',
|
||||||
|
'bower_components/ng-csv/build/ng-csv.js',
|
||||||
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'
|
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'
|
||||||
],
|
],
|
||||||
dest: 'public/lib/angular.js'
|
dest: 'public/lib/angular.js'
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"moment": "2.10.3",
|
"moment": "2.10.3",
|
||||||
"ng-lodash": "0.2.3",
|
"ng-lodash": "0.2.3",
|
||||||
"qrcode-decoder-js": "*",
|
"qrcode-decoder-js": "*",
|
||||||
"trezor-connect": "~1.0.1"
|
"trezor-connect": "~1.0.1",
|
||||||
|
"ng-csv": "~0.3.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
<h4></h4>
|
<h4></h4>
|
||||||
<ul class="no-bullet m0">
|
<ul class="no-bullet m0">
|
||||||
<li>
|
<li>
|
||||||
<div ng-show="!index.isCordova">
|
<div ng-if="!index.isCordova" ng-init="index.csvHistory()">
|
||||||
<input id="export_file" type="file" nwsaveas="Copay-{{index.alias || index.walletName}}.csv" accept=".csv" style="display:none">
|
|
||||||
<a ng-style="{'color':index.backgroundColor}" ng-click="index.csvHistory();">
|
<a ng-style="{'color':index.backgroundColor}" ng-csv="index.csvContent" csv-header="index.csvHeader" filename="{{ index.csvFilename }}">
|
||||||
<span translate>Export to file</span>
|
<span translate>Export to file</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -175,7 +175,7 @@
|
||||||
<div translate>Updating transaction history. Please stand by.</div>
|
<div translate>Updating transaction history. Please stand by.</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="oh pr" ng-show="index.txHistory[0]">
|
<div class="oh pr" ng-show="index.txHistory[0]">
|
||||||
<h4 class="title m0">
|
<h4 class="title m0">
|
||||||
|
|
|
@ -8,6 +8,8 @@ var modules = [
|
||||||
'gettext',
|
'gettext',
|
||||||
'ngLodash',
|
'ngLodash',
|
||||||
'uiSwitch',
|
'uiSwitch',
|
||||||
|
'ngSanitize',
|
||||||
|
'ngCsv',
|
||||||
'bwcModule',
|
'bwcModule',
|
||||||
'copayApp.filters',
|
'copayApp.filters',
|
||||||
'copayApp.services',
|
'copayApp.services',
|
||||||
|
|
|
@ -768,7 +768,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
$log.debug('Generating CSV from History');
|
$log.debug('Generating CSV from History');
|
||||||
self.setOngoingProcess('generatingCSV', true);
|
self.setOngoingProcess('generatingCSV', true);
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
getHistory(function(err, txs) {
|
getHistory(function(err, txs) {
|
||||||
self.setOngoingProcess('generatingCSV', false);
|
self.setOngoingProcess('generatingCSV', false);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -779,14 +778,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.satToUnit = 1 / self.unitToSatoshi;
|
self.satToUnit = 1 / self.unitToSatoshi;
|
||||||
var data = txs;
|
var data = txs;
|
||||||
var satToBtc = 1 / 100000000;
|
var satToBtc = 1 / 100000000;
|
||||||
var filename = 'Copay-' + (self.alias || self.walletName) + '.csv';
|
self.csvContent = [];
|
||||||
var csvContent = '';
|
self.csvFilename = 'Copay-' + (self.alias || self.walletName) + '.csv';
|
||||||
|
self.csvHeader = ['Date', 'Destination', 'Note', 'Amount', 'Currency', 'Txid', 'Creator', 'Copayers'];
|
||||||
if (!isNode) csvContent = 'data:text/csv;charset=utf-8,';
|
|
||||||
csvContent += 'Date,Destination,Note,Amount,Currency,Txid,Creator,Copayers\n';
|
|
||||||
|
|
||||||
var _amount, _note, _copayers, _creator;
|
var _amount, _note, _copayers, _creator;
|
||||||
var dataString;
|
|
||||||
data.forEach(function(it, index) {
|
data.forEach(function(it, index) {
|
||||||
var amount = it.amount;
|
var amount = it.amount;
|
||||||
|
|
||||||
|
@ -810,28 +806,34 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
if (it.action == 'moved')
|
if (it.action == 'moved')
|
||||||
_note += ' Moved:' + (it.amount * satToBtc).toFixed(8)
|
_note += ' Moved:' + (it.amount * satToBtc).toFixed(8)
|
||||||
|
|
||||||
dataString = formatDate(it.time * 1000) + ',' + formatString(it.addressTo) + ',' + _note + ',' + _amount + ',BTC,' + it.txid + ',' + _creator + ',' + _copayers;
|
self.csvContent.push({
|
||||||
csvContent += dataString + "\n";
|
'Date': formatDate(it.time * 1000),
|
||||||
|
'Destination': formatString(it.addressTo),
|
||||||
|
'Note': _note,
|
||||||
|
'Amount': _amount,
|
||||||
|
'Currency': 'BTC',
|
||||||
|
'Txid': it.txid,
|
||||||
|
'Creator': _creator,
|
||||||
|
'Copayers': _copayers
|
||||||
|
});
|
||||||
|
|
||||||
if (it.fees && (it.action == 'moved' || it.action == 'sent')) {
|
if (it.fees && (it.action == 'moved' || it.action == 'sent')) {
|
||||||
var _fee = (it.fees * satToBtc).toFixed(8)
|
var _fee = (it.fees * satToBtc).toFixed(8)
|
||||||
csvContent += formatDate(it.time * 1000) + ',Bitcoin Network Fees,, -' + _fee + ',BTC,,,' + "\n";
|
self.csvContent.push({
|
||||||
|
'Date': formatDate(it.time * 1000),
|
||||||
|
'Destination': 'Bitcoin Network Fees',
|
||||||
|
'Note': '',
|
||||||
|
'Amount': '-'+_fee,
|
||||||
|
'Currency': 'BTC',
|
||||||
|
'Txid': '',
|
||||||
|
'Creator': '',
|
||||||
|
'Copayers': ''
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
if (isNode) {
|
|
||||||
saveFile('#export_file', csvContent);
|
|
||||||
} else {
|
|
||||||
var encodedUri = encodeURI(csvContent);
|
|
||||||
var link = document.createElement("a");
|
|
||||||
link.setAttribute("href", encodedUri);
|
|
||||||
link.setAttribute("download", filename);
|
|
||||||
link.click();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$rootScope.$apply();
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.removeSoftConfirmedTx = function(txs) {
|
self.removeSoftConfirmedTx = function(txs) {
|
||||||
|
|
Loading…
Reference in New Issue