From f1adde8e444f087f5131e6af4177a26f84f589d2 Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Mon, 10 Nov 2014 18:00:43 -0300 Subject: [PATCH] Added csv file generation --- js/controllers/history.js | 24 ++++++++++++++++++++++++ views/history.html | 12 +++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/js/controllers/history.js b/js/controllers/history.js index 391dfd51c..58d450a95 100644 --- a/js/controllers/history.js +++ b/js/controllers/history.js @@ -19,11 +19,33 @@ angular.module('copayApp.controllers').controller('HistoryController', $scope.alternativeCurrency = []; + $scope.selectPage = function(page) { $scope.currentPage = page; $scope.update(); }; + + + $scope.downloadHistory = function() { + var data = $scope.blockchain_txs; + var csvContent = "data:text/csv;charset=utf-8,"; + + data.forEach(function(it, index) { + var dataString = it.ts + ',' + it.amount + ',' + it.action + ',' + it.addressTo; + csvContent += index < data.length ? dataString + "\n" : dataString; + }); + + var encodedUri = encodeURI(csvContent); + var link = document.createElement("a"); + link.setAttribute("href", encodedUri); + link.setAttribute("download", "my_data.csv"); + + link.click(); + }; + + + $scope.update = function() { $scope.getTransactions(); }; @@ -73,6 +95,8 @@ angular.module('copayApp.controllers').controller('HistoryController', $scope.hasAction = function(actions, action) { + + return actions.hasOwnProperty('create'); }; diff --git a/views/history.html b/views/history.html index 99adf5746..5ee062a86 100644 --- a/views/history.html +++ b/views/history.html @@ -12,7 +12,7 @@ class="row" ng-if="blockchain_txs[0].txid">
- +
@@ -99,6 +99,16 @@ More details
+ +
+ + Generating file... +
+
+ + + Download +