diff --git a/public/views/activity.html b/public/views/activity.html index 8a1738373..ea976412a 100644 --- a/public/views/activity.html +++ b/public/views/activity.html @@ -19,7 +19,7 @@
-
+
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..e1e2c3640 100644 --- a/public/views/modals/tx-details.html +++ b/public/views/modals/tx-details.html @@ -1,5 +1,5 @@ - + @@ -9,11 +9,11 @@ -
+
- +
@@ -30,23 +30,23 @@
-
- Sent from {{wallet.credentials.walletName}} -
- -
+
+ Sent from {{wallet.credentials.walletName}} +
+
+
-
-
- -
- Received Funds +
+
+
+ Received Funds +
-
- Moved Funds -
+
+ Moved Funds +
- @@ -75,14 +75,22 @@
-
Created by
- {{btx.creatorName}} - - - +
+ Date + + + +
+
+
Created by
+ {{btx.creatorName}} + + + +
-
+
Fee
{{btx.feeLevel}} ({{btx.feeStr}}) diff --git a/public/views/tab-home.html b/public/views/tab-home.html index 60849ecf8..a60921131 100644 --- a/public/views/tab-home.html +++ b/public/views/tab-home.html @@ -30,12 +30,12 @@ {{txpsN}} - +
-
+ diff --git a/src/js/controllers/activity.js b/src/js/controllers/activity.js index 6205357c5..025a4b062 100644 --- a/src/js/controllers/activity.js +++ b/src/js/controllers/activity.js @@ -1,9 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('activityController', - function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) { - var self = this; - + function($timeout, $scope, $log, $ionicModal, lodash, txpModalService, profileService, walletService, ongoingProcess, popupService, gettextCatalog) { + $scope.openTxpModal = txpModalService.open; $scope.init = function() { $scope.fetchingNotifications = true; @@ -14,9 +13,57 @@ angular.module('copayApp.controllers').controller('activityController', } $scope.fetchingNotifications = false; $scope.notifications = n; - $timeout(function() { - $scope.$apply(); - }, 1); + + profileService.getTxps({}, function(err, txps, n) { + if (err) $log.error(err); + $scope.txps = txps; + $timeout(function() { + $scope.$apply(); + }); + }); }); - } + }; + + $scope.openNotificationModal = function(n) { + if (!n.txpId && n.txid) { + openTxModal(n); + } else { + var txp = lodash.find($scope.txps, { + id: n.txpId + }); + if (txp) txpModalService.open(txp); + else { + $log.warn('No txp found'); + return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null); + } + } + }; + + var openTxModal = function(n) { + var wallet = profileService.getWallet(n.walletId); + + ongoingProcess.set('loadingTxInfo', true); + walletService.getTx(wallet, n.txid, function(err, tx) { + ongoingProcess.set('loadingTxInfo', false); + + if (err) { + $log.error(err); + return popupService.showAlert(gettextCatalog.getString('Error'), err); + } + + if (!tx) { + $log.warn('No tx found'); + return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null); + } + + $scope.wallet = wallet; + $scope.btx = lodash.cloneDeep(tx); + $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { + scope: $scope + }).then(function(modal) { + $scope.txDetailsModal = modal; + $scope.txDetailsModal.show(); + }); + }); + }; }); diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index 2324ac4b9..dd2ed813c 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -1,20 +1,18 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { - var self = $scope.self; - var wallet = profileService.getWallet($stateParams.walletId); +angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { var config = configService.getSync(); var configWallet = config.wallet; var walletSettings = configWallet.settings; + var wallet; + $scope.title = gettextCatalog.getString('Transaction'); $scope.init = function() { + wallet = $scope.wallet; $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; if ($scope.btx.action != 'invalid') { @@ -22,7 +20,30 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); } + + updateMemo(); initActionList(); + getAlternativeAmount(); + + $timeout(function() { + $scope.$apply(); + }); + }; + + function updateMemo() { + wallet.getTxNote({ + txid: $scope.btx.txid + }, function(err, note) { + if (err || !note) { + $log.debug(gettextCatalog.getString('Could not fetch transaction note')); + return; + } + + $scope.note = note; + $timeout(function() { + $scope.$apply(); + }); + }); }; function initActionList() { @@ -60,12 +81,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio }; $scope.showCommentPopup = function() { - popupService.showPrompt(gettextCatalog.getString('Memo'), ' ', {}, function(res) { + popupService.showPrompt(gettextCatalog.getString('Memo'), ' ', {}, function(text) { $log.debug('Saving memo'); var args = { txid: $scope.btx.txid, - body: res + body: text }; wallet.editTxNote(args, function(err) { @@ -77,7 +98,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.btx.note = null; if (args.body) { $scope.btx.note = {}; - $scope.btx.note.body = res; + $scope.btx.note.body = text; $scope.btx.note.editedByName = wallet.credentials.copayerName; $scope.btx.note.editedOn = Math.floor(Date.now() / 1000); } @@ -85,12 +106,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $timeout(function() { $scope.$apply(); - }, 200); + }); }); }); }; - $scope.getAlternativeAmount = function() { + var getAlternativeAmount = function() { var satToBtc = 1 / 100000000; wallet.getFiatRate({ @@ -123,5 +144,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..12d7547c5 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, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) { $scope.externalServices = {}; $scope.bitpayCardEnabled = true; // TODO $scope.openTxpModal = txpModalService.open; @@ -16,6 +16,49 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp; }); + $scope.openNotificationModal = function(n) { + if (!n.txpId && n.txid) { + openTxModal(n); + } else { + var txp = lodash.find($scope.txps, { + id: n.txpId + }); + if (txp) txpModalService.open(txp); + else { + $log.warn('No txp found'); + return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null); + } + } + }; + + var openTxModal = function(n) { + var wallet = profileService.getWallet(n.walletId); + + ongoingProcess.set('loadingTxInfo', true); + walletService.getTx(wallet, n.txid, function(err, tx) { + ongoingProcess.set('loadingTxInfo', false); + + if (err) { + $log.error(err); + return popupService.showAlert(gettextCatalog.getString('Error'), err); + } + + if (!tx) { + $log.warn('No tx found'); + return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null); + } + + $scope.wallet = wallet; + $scope.btx = lodash.cloneDeep(tx); + $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 +155,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/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index 1a49736f8..5734e6eac 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -152,18 +152,13 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.close = function() { $scope.searchModal.hide(); } - }; $scope.openTxModal = function(btx) { - var self = this; - $scope.btx = lodash.cloneDeep(btx); - $scope.self = self; - + $scope.walletId = wallet.id; $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { - scope: $scope, - hideDelay: 500 + scope: $scope }).then(function(modal) { $scope.txDetailsModal = modal; $scope.txDetailsModal.show(); diff --git a/src/js/services/onGoingProcess.js b/src/js/services/onGoingProcess.js index be1d5ee70..642051951 100644 --- a/src/js/services/onGoingProcess.js +++ b/src/js/services/onGoingProcess.js @@ -32,6 +32,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti 'sweepingWallet': gettext('Sweeping Wallet...'), 'validatingWallet': gettext('Validating wallet integrity...'), 'validatingWords': gettext('Validating recovery phrase...'), + 'loadingTxInfo': gettext('Loading transaction info...'), }; root.clear = function() { 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, + // }); }; }); diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index d23c8b906..abeff92ee 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -502,6 +502,32 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; + root.getTx = function(wallet, txid, cb) { + var tx; + + if (wallet.completeHistory && wallet.completeHistory.isValid) { + tx = lodash.find(wallet.completeHistory, { + txid: txid + }); + + finish(); + } else { + root.getTxHistory(wallet, {}, function(err, txHistory) { + if (err) return cb(err); + + tx = lodash.find(txHistory, { + txid: txid + }); + + finish(); + }); + } + + function finish() { + if (tx) return cb(null, tx); + else return cb(); + }; + }; root.getTxHistory = function(wallet, opts, cb) { opts = opts || {};