From a72ae412a2c724d92cf0faf298367f1f08ff5968 Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Wed, 19 Nov 2014 15:47:28 -0300 Subject: [PATCH] Added column signers to CSV file --- js/controllers/history.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/js/controllers/history.js b/js/controllers/history.js index b77cb6d59..911659760 100644 --- a/js/controllers/history.js +++ b/js/controllers/history.js @@ -29,7 +29,6 @@ angular.module('copayApp.controllers').controller('HistoryController', $scope.downloadHistory = function() { - if (window.cordova) { log.info('Not available on mobile'); return; @@ -41,18 +40,25 @@ angular.module('copayApp.controllers').controller('HistoryController', w.getTransactionHistory(function(err, res) { if (err) throw err; - if (!res) { - return; - } + if (!res) return; var unit = w.settings.unitName; var data = res.items; var filename = "copay_history.csv"; var csvContent = "data:text/csv;charset=utf-8,"; - csvContent += "Date,Amount(" + unit + "),Action,AddressTo,Comment\n"; + csvContent += "Date,Amount(" + unit + "),Action,AddressTo,Comment"; + + if (w.isShared()) { + csvContent += ",Signers\n"; + } else { + csvContent += "\n"; + } data.forEach(function(it, index) { - var dataString = formatDate(it.minedTs || it.sentTs) + ',' + it.amount + ',' + it.action + ',' + it.addressTo + ',' + formatString(it.comment); + var dataString = formatDate(it.minedTs || it.sentTs) + ',' + it.amount + ',' + it.action + ',' + formatString(it.addressTo) + ',' + formatString(it.comment); + if (it.actionList) { + dataString += ',' + formatSigners(it.actionList); + } csvContent += index < data.length ? dataString + "\n" : dataString; }); @@ -91,12 +97,22 @@ angular.module('copayApp.controllers').controller('HistoryController', return str; } - }); + function formatSigners(item) { + if (!item) return ''; + var str = ''; + item.forEach(function(it, index) { + str += index == 0 ? w.publicKeyRing.nicknameForCopayer(it.cId) : '|' + w.publicKeyRing.nicknameForCopayer(it.cId); + }); + return str; + } + + }) }; + $scope.update = function() { $scope.getTransactions(); };