From ae266e397b1f1f13fdec218b8df8ec7468b4c731 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 20 Sep 2016 12:02:45 -0300 Subject: [PATCH] wip --- public/views/includes/walletActivity.html | 50 +++++++++---------- public/views/modals/tx-details.html | 6 +-- public/views/tab-home.html | 4 +- src/js/controllers/modals/txDetails.js | 59 ++++++++++++++++------- src/js/controllers/tab-home.js | 18 ++++++- src/js/services/profileService.js | 10 ++-- 6 files changed, 93 insertions(+), 54 deletions(-) diff --git a/public/views/includes/walletActivity.html b/public/views/includes/walletActivity.html index ed0f57e07..0e9fceb76 100644 --- a/public/views/includes/walletActivity.html +++ b/public/views/includes/walletActivity.html @@ -1,65 +1,65 @@ -
- Copayer joined +
+ Copayer joined
-
+
Wallet created
-
+
Payment Sent
- {{x.amountStr}} + {{notification.amountStr}}
-
+
Payment Received
- {{x.amountStr}} + {{notification.amountStr}}
-
- Proposal Deleted: - {{x.message}} +
+ Proposal Deleted: + {{notification.message}}
- {{x.amountStr}}: + {{notification.amountStr}}:
-
+
Proposal Rejected: - {{x.message}} + {{notification.message}}
- {{x.amountStr}}: + {{notification.amountStr}}:
- + New Proposal: - {{x.message}} + {{notification.message}}
- {{x.amountStr}} + {{notification.amountStr}}
- + Proposal Accepted: - {{x.message}} + {{notification.message}}
- {{x.amountStr}} + {{notification.amountStr}}

- - - {{ x.creatorName}}@ - {{x.wallet.name}} - + + + {{ notification.creatorName}}@ + {{notification.wallet.name}} +

diff --git a/public/views/modals/tx-details.html b/public/views/modals/tx-details.html index d7145f679..a0f3571c8 100644 --- a/public/views/modals/tx-details.html +++ b/public/views/modals/tx-details.html @@ -9,11 +9,11 @@ -
+
- - + +
diff --git a/public/views/tab-home.html b/public/views/tab-home.html index 60849ecf8..7be004eab 100644 --- a/public/views/tab-home.html +++ b/public/views/tab-home.html @@ -35,7 +35,7 @@
-
+ diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index 2324ac4b9..b6c2f3f32 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -1,28 +1,54 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { +angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { var self = $scope.self; - var wallet = profileService.getWallet($stateParams.walletId); + var wallet = profileService.getWallet($stateParams.walletId || $scope.walletId); var config = configService.getSync(); var configWallet = config.wallet; var walletSettings = configWallet.settings; $scope.init = function() { - $scope.alternativeIsoCode = walletSettings.alternativeIsoCode; - $scope.color = wallet.color; - $scope.copayerId = wallet.credentials.copayerId; - $scope.isShared = wallet.credentials.n > 1; + findTx($scope.txid, function(err, tx) { + if (err) { + $log.error(err); + return; + } + console.log('TX FOUND', tx); + $scope.btx = lodash.cloneDeep(tx); + $scope.alternativeIsoCode = walletSettings.alternativeIsoCode; + $scope.color = wallet.color; + $scope.copayerId = wallet.credentials.copayerId; + $scope.isShared = wallet.credentials.n > 1; + // $scope.btx.amountStr = txFormatService.formatAmount($scope.btx.amount, true) + ' ' + walletSettings.unitName; + // $scope.btx.feeStr = txFormatService.formatAmount($scope.btx.fees, true) + ' ' + walletSettings.unitName; + $scope.btx.feeLevel = walletSettings.feeLevel; - $scope.btx.amountStr = txFormatService.formatAmount($scope.btx.amount, true) + ' ' + walletSettings.unitName; - $scope.btx.feeStr = txFormatService.formatAmount($scope.btx.fees, true) + ' ' + walletSettings.unitName; - $scope.btx.feeLevel = walletSettings.feeLevel; + if ($scope.btx.action != 'invalid') { + if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); + if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); + if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); + } - if ($scope.btx.action != 'invalid') { - if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); - if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); - if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); - } - initActionList(); + initActionList(); + getAlternativeAmount(); + + $timeout(function() { + $scope.$apply(); + }, 10); + }); + }; + + function findTx(txid, cb) { + walletService.getTxHistory(wallet, {}, function(err, txHistory) { + if (err) return cb(err); + + var tx = lodash.find(txHistory, { + txid: txid + }); + + if (tx) return cb(null, tx); + else return cb(); + }); }; function initActionList() { @@ -90,7 +116,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio }); }; - $scope.getAlternativeAmount = function() { + var getAlternativeAmount = function() { var satToBtc = 1 / 100000000; wallet.getFiatRate({ @@ -123,5 +149,4 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.cancel = function() { $scope.txDetailsModal.hide(); }; - }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 2ed46ed6d..0efcbaddf 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('tabHomeController', - function($rootScope, $timeout, $scope, $state, $stateParams, $ionicScrollDelegate, lodash, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) { + function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, lodash, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) { $scope.externalServices = {}; $scope.bitpayCardEnabled = true; // TODO $scope.openTxpModal = txpModalService.open; @@ -16,6 +16,18 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp; }); + $scope.openTxModal = function(n) { + console.log(n); + $scope.txid = n.txid; + $scope.walletId = n.walletId; + $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { + scope: $scope + }).then(function(modal) { + $scope.txDetailsModal = modal; + $scope.txDetailsModal.show(); + }); + }; + $scope.openWallet = function(wallet) { if (!wallet.isComplete()) { return $state.go('tabs.copayers', { @@ -112,7 +124,9 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.hideHomeTip = function() { $scope.homeTip = null; $state.transitionTo($state.current, null, { - reload: false, inherit: false, notify: false + reload: false, + inherit: false, + notify: false }); }; diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index d3a81e915..c6bc0d3d0 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -822,11 +822,11 @@ angular.module('copayApp.services') x.action = function() { // TODO? - $state.go('tabs.details', { - walletId: x.walletId, - txpId: x.txpId, - txid: x.txid, - }); + // $state.go('tabs.details', { + // walletId: x.walletId, + // txpId: x.txpId, + // txid: x.txid, + // }); }; });