unify strings to "payment". Add retry on balance update

This commit is contained in:
Matias Alejo Garcia 2015-05-18 16:21:36 -03:00
parent 876ae63a25
commit 17deda9000
8 changed files with 92 additions and 55 deletions

View File

@ -22,7 +22,7 @@
</div> </div>
</div> </div>
<h4 class="title m0" translate>Information</h4> <h4 class="title m0" translate>Details</h4>
<ul class="no-bullet size-14 m0"> <ul class="no-bullet size-14 m0">
<li ng-if="btx.addressTo && btx.addressTo != 'N/A'" class="line-b p10 oh" ng-click="copyAddress(btx.addressTo)"> <li ng-if="btx.addressTo && btx.addressTo != 'N/A'" class="line-b p10 oh" ng-click="copyAddress(btx.addressTo)">
<span class="text-gray" translate>To</span>: <span class="text-gray" translate>To</span>:
@ -68,7 +68,7 @@
</ul> </ul>
<div ng-if="btx.actions[0] && isShared"> <div ng-if="btx.actions[0] && isShared">
<h4 class="title m0" translate>Signatures</h4> <h4 class="title m0" translate>Participants</h4>
<ul class="no-bullet size-14 m0"> <ul class="no-bullet size-14 m0">
<li class="line-b p10 text-gray" ng-repeat="c in btx.actions"> <li class="line-b p10 text-gray" ng-repeat="c in btx.actions">
<span class="right"> <span class="right">

View File

@ -1,5 +1,5 @@
<div ng-if="statusStr && statusStr == 'Transaction broadcasted'" class="popup-txsent"> <div ng-if="type == 'broadcasted'" class="popup-txsent">
<i class="small-centered columns fi-check m20tp"></i> <i class="small-centered columns fi-check m20tp"></i>
<div class="text-center size-18 text-white text-bold tu p20"> <div class="text-center size-18 text-white text-bold tu p20">
<span translate>Payment Sent</span> <span translate>Payment Sent</span>
@ -9,20 +9,33 @@
</div> </div>
</div> </div>
<div ng-if="statusStr && statusStr == 'Transaction proposal signed'" class="popup-txsigned">
<div ng-if="type == 'created'" class="popup-txsigned">
<i class="small-centered columns fi-check m20tp"></i> <i class="small-centered columns fi-check m20tp"></i>
<div class="text-center size-18 text-primary tu text-bold p20"> <div class="text-center size-18 text-primary tu text-bold p20">
{{statusStr|translate}} <span translate>Payment Proposal Created</span>
</div> </div>
<div class="text-center"> <div class="text-center">
<a class="button outline round light-gray tiny small-4" ng-click="cancel()" translate>OKAY</a> <a class="button outline round light-gray tiny small-4" ng-click="cancel()" translate>OKAY</a>
</div> </div>
</div> </div>
<div ng-if="statusStr && statusStr == 'Transaction was rejected'" class="popup-txrejected">
<div ng-if="type == 'accepted'" class="popup-txsigned">
<i class="small-centered columns fi-check m20tp"></i>
<div class="text-center size-18 text-primary tu text-bold p20">
<span translate>Payment Accepted</span>
</div>
<div class="text-center">
<a class="button outline round light-gray tiny small-4" ng-click="cancel()" translate>OKAY</a>
</div>
</div>
<div ng-if="type=='rejected'" class="popup-txrejected">
<i class="fi-x small-centered columns m20tp"></i> <i class="fi-x small-centered columns m20tp"></i>
<div class="text-center size-18 tu text-warning text-bold p20"> <div class="text-center size-18 tu text-warning text-bold p20">
{{statusStr|translate}} <span translate>Payment Rejected</span>
</div> </div>
<div class="text-center"> <div class="text-center">
<a class="button outline light-gray round tiny small-4" ng-click="cancel()" translate>OKAY</a> <a class="button outline light-gray round tiny small-4" ng-click="cancel()" translate>OKAY</a>

View File

@ -7,12 +7,12 @@
</section> </section>
<section class="middle tab-bar-section"> <section class="middle tab-bar-section">
<h1 class="title ellipsis" ng-style="{'color':color}" translate> <h1 class="title ellipsis" ng-style="{'color':color}" translate>
Transaction proposal Payment Proposal
</h1> </h1>
</section> </section>
</nav> </nav>
<div class="p45t" ng-init="updateCopayerList()"> <div class="p45t" ng-init="updateCopayerList()">
<h4 class="title m0" translate>Information</h4> <h4 class="title m0" translate>Details</h4>
<ul class="no-bullet size-14 m0"> <ul class="no-bullet size-14 m0">
<li class="line-b p10 oh" ng-click="copyAddress(tx.toAddress)"> <li class="line-b p10 oh" ng-click="copyAddress(tx.toAddress)">
<span class="text-gray" translate>To</span>: <span class="text-gray" translate>To</span>:
@ -66,7 +66,7 @@
</div> </div>
<div ng-if="tx.actions[0] && !txRejected && !txBroadcasted"> <div ng-if="tx.actions[0] && !txRejected && !txBroadcasted">
<h4 class="title m0" translate>Signatures</h4> <h4 class="title m0" translate>Participants</h4>
<ul class="no-bullet size-14 m0"> <ul class="no-bullet size-14 m0">
<li class="line-b p10 text-gray" ng-repeat="ac in tx.actions"> <li class="line-b p10 text-gray" ng-repeat="ac in tx.actions">
<i class="icon-contact size-24"></i> <i class="icon-contact size-24"></i>
@ -87,7 +87,7 @@
<div class="row column m20t text-center text-warning" ng-if="tx.removed" translate> <div class="row column m20t text-center text-warning" ng-if="tx.removed" translate>
The transaction was removed by creator The payment was removed by creator
</div> </div>
<div class="row m20t" ng-if="tx.pendingForUs"> <div class="row m20t" ng-if="tx.pendingForUs">
@ -103,7 +103,7 @@
ng-style="{'background-color':color}" ng-style="{'background-color':color}"
ng-disabled="loading"> ng-disabled="loading">
<i class="fi-check"></i> <i class="fi-check"></i>
<span translate>Sign</span> <span translate>Accept</span>
</button> </button>
</div> </div>
</div> </div>
@ -111,7 +111,7 @@
<div class="text-center text-gray" ng-show="tx.status != 'pending'"> <div class="text-center text-gray" ng-show="tx.status != 'pending'">
<div class="m10t" <div class="m10t"
ng-show="tx.status=='accepted'" translate> ng-show="tx.status=='accepted'" translate>
Transaction accepted... Payment accepted...
</div> </div>
<div class="m10t" <div class="m10t"
ng-show="!loading && tx.status!='broadcasted' && tx.status=='accepted' && tx.status!='rejected'"> ng-show="!loading && tx.status!='broadcasted' && tx.status=='accepted' && tx.status!='rejected'">
@ -119,27 +119,27 @@
<button class="primary round" <button class="primary round"
ng-click="broadcast(tx)" ng-click="broadcast(tx)"
ng-disabled="loading"> <i class="fi-upload-cloud"></i> ng-disabled="loading"> <i class="fi-upload-cloud"></i>
<span translate>Broadcast Transaction</span> <span translate>Broadcast Payment</span>
</button> </button>
</div> </div>
<div class="text-success m10t" <div class="text-success m10t"
ng-show="tx.status=='broadcasted'" translate> ng-show="tx.status=='broadcasted'" translate>
Transaction sent! Payment sent!
</div> </div>
<div class="text-center text-warning" <div class="text-center text-warning"
ng-show="tx.status=='rejected'" translate> ng-show="tx.status=='rejected'" translate>
Transaction finally rejected Payment finally rejected
</div> </div>
</div> </div>
<div class="row column m20t" ng-if="tx.couldRemove"> <div class="row column m20t" ng-if="tx.couldRemove">
<div class="text-gray size-12 text-center m20b" show="tx.couldRemove" translate> <div class="text-gray size-12 text-center m20b" show="tx.couldRemove" translate>
* Only transactions created by yourself with no peer signatures can be removed * Only payment proposals created by yourself with no peer actions can be removed
</div> </div>
<button class="tiny expand round outline dark-gray" ng-click="remove(tx)" <button class="tiny expand round outline dark-gray" ng-click="remove(tx)"
ng-disabled="loading" ng-show="tx.couldRemove"> ng-disabled="loading" ng-show="tx.couldRemove">
<i class="fi-trash size-14 m5r"></i> <i class="fi-trash size-14 m5r"></i>
<span translate>Remove transaction</span> <span translate>Delete Payment Proposal</span>
</button> </button>
</div> </div>

View File

@ -152,7 +152,7 @@
<div ng-if="index.txps[0]"> <div ng-if="index.txps[0]">
<div ng-show="index.requiresMultipleSignatures"> <div ng-show="index.requiresMultipleSignatures">
<h4 class="title m0" translate>Spend proposals</h4> <h4 class="title m0" translate>Payment Proposals</h4>
<div class="last-transactions pr" ng-repeat="tx in index.txps" <div class="last-transactions pr" ng-repeat="tx in index.txps"
ng-include="'views/includes/transaction.html'"> ng-include="'views/includes/transaction.html'">
</div> </div>
@ -266,20 +266,31 @@
--> -->
<div id="send" class="send tab-view"> <div id="send" class="send tab-view">
<div ng-show="index.lockedBalance"> <div>
<h4 class="title m0"> <h4 class="title m0">
<div class="left">
<i class="fi-info size-36 m10r lh"></i> <div ng-show="!index.lockedBalance">
<div class="size-12">
<span class="db text-bold">
<span translate>Available Balance</span>:
{{index.availableBalanceStr }}
</span>
</div>
</div> </div>
<div class="size-12"> <div ng-show="index.lockedBalance">
<span class="db text-bold"> <div class="left">
<span translate>Available Balance</span>: <i class="fi-info size-36 m10r lh"></i>
{{index.availableBalanceStr }} </div>
</span> <div class="size-12">
<span class="text-gray"> <span class="db text-bold">
{{index.lockedBalanceStr}} <span translate>Available Balance</span>:
<span translate>in pending transactions</span> {{index.availableBalanceStr }}
</span> </span>
<span class="text-gray" >
{{index.lockedBalanceStr}}
<span translate>in pending payments</span>
</span>
</div>
</div> </div>
</h4> </h4>
</div> </div>

View File

@ -145,7 +145,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$emit('Local/TabChanged', tab); $rootScope.$emit('Local/TabChanged', tab);
}; };
self.updateAll = function(walletStatus) { self.updateAll = function(walletStatus, untilItChanges, initBalance, tries) {
tries = tries || 0;
if (untilItChanges && lodash.isUndefined(initBalance)) {
initBalance = self.totalBalanceSat;
}
var get = function(cb) { var get = function(cb) {
if (walletStatus) if (walletStatus)
return cb(null, walletStatus); return cb(null, walletStatus);
@ -169,6 +173,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setOngoingProcess('updatingStatus', true); self.setOngoingProcess('updatingStatus', true);
$log.debug('Updating Status:', fc); $log.debug('Updating Status:', fc);
get(function(err, walletStatus) { get(function(err, walletStatus) {
if (!err && untilItChanges && initBalance == walletStatus.balance.totalAmount && tries < 10) {
return $timeout(function() {
return self.updateAll(null, true, initBalance, ++tries);
}, 1000);
}
self.setOngoingProcess('updatingStatus', false); self.setOngoingProcess('updatingStatus', false);
if (err) { if (err) {
self.handleError(err); self.handleError(err);
@ -711,8 +720,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
lodash.each(['NewOutgoingTx', 'NewTxProposal', 'TxProposalFinallyRejected', 'transactionProposalRemoved', 'TxProposalRemoved', lodash.each(['NewOutgoingTx', 'NewTxProposal', 'TxProposalFinallyRejected', 'transactionProposalRemoved', 'TxProposalRemoved',
'Local/NewTxProposal', 'Local/TxProposalAction', 'ScanFinished' 'Local/NewTxProposal', 'Local/TxProposalAction', 'ScanFinished'
], function(eventName) { ], function(eventName) {
$rootScope.$on(eventName, function() { $rootScope.$on(eventName, function(event, untilItChanges) {
self.updateAll(); self.updateAll(null, untilItChanges);
$timeout(function() { $timeout(function() {
self.updateTxHistory(); self.updateTxHistory();
}, 3000); }, 3000);

View File

@ -190,7 +190,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return; return;
}; };
self.setOngoingProcess(gettext('Signing transaction')); self.setOngoingProcess(gettext('Signing payment'));
$scope.loading = true; $scope.loading = true;
$scope.error = null; $scope.error = null;
$timeout(function() { $timeout(function() {
@ -229,7 +229,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}; };
$scope.reject = function(txp) { $scope.reject = function(txp) {
self.setOngoingProcess(gettext('Rejecting transaction')); self.setOngoingProcess(gettext('Rejecting payment'));
$scope.loading = true; $scope.loading = true;
$scope.error = null; $scope.error = null;
$timeout(function() { $timeout(function() {
@ -249,7 +249,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.remove = function(txp) { $scope.remove = function(txp) {
self.setOngoingProcess(gettext('Deleting transaction')); self.setOngoingProcess(gettext('Deleting payment'));
$scope.loading = true; $scope.loading = true;
$scope.error = null; $scope.error = null;
$timeout(function() { $timeout(function() {
@ -270,7 +270,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}; };
$scope.broadcast = function(txp) { $scope.broadcast = function(txp) {
self.setOngoingProcess(gettext('Broadcasting transaction')); self.setOngoingProcess(gettext('Broadcasting Payment'));
$scope.loading = true; $scope.loading = true;
$scope.error = null; $scope.error = null;
$timeout(function() { $timeout(function() {
@ -313,7 +313,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.setOngoingProcess(); self.setOngoingProcess();
if (txp) { if (txp) {
txStatus.notify(txp, function() { txStatus.notify(txp, function() {
$scope.$emit('Local/TxProposalAction'); $scope.$emit('Local/TxProposalAction', true);
}); });
} else { } else {
$timeout(function() { $timeout(function() {

View File

@ -4,7 +4,7 @@ angular.module('copayApp.services')
var root = {}; var root = {};
var groupingTime = 4000; var groupingTime = 5000;
var lastNotificationOnWallet = {}; var lastNotificationOnWallet = {};
root.getLast = function(walletId) { root.getLast = function(walletId) {
@ -57,23 +57,23 @@ angular.module('copayApp.services')
switch (notificationData.type) { switch (notificationData.type) {
case 'NewTxProposal': case 'NewTxProposal':
notification.new(gettext('New Transaction'), notification.new(gettext('New Payment Proposal'),
name, {color: color} ); name, {color: color} );
break; break;
case 'TxProposalAcceptedBy': case 'TxProposalAcceptedBy':
notification.success(gettext('Transaction Signed'), notification.success(gettext('Payment Proposal Signed by Copayer'),
name, {color: color} ); name, {color: color} );
break; break;
case 'TxProposalRejectedBy': case 'TxProposalRejectedBy':
notification.error(gettext('Transaction Rejected'), notification.error(gettext('Payment Proposal Rejected by Copayer'),
name, {color: color} ); name, {color: color} );
break; break;
case 'TxProposalFinallyRejected': case 'TxProposalFinallyRejected':
notification.error(gettext('A transaction was finally rejected'), notification.error(gettext('Payment Proposal Finally Rejected'),
name, {color: color} ); name, {color: color} );
break; break;
case 'NewOutgoingTx': case 'NewOutgoingTx':
notification.sent(gettext('Transaction Sent'), notification.sent(gettext('Payment Proposal Sent'),
name, {color: color} ); name, {color: color} );
break; break;
case 'NewIncomingTx': case 'NewIncomingTx':

View File

@ -5,31 +5,35 @@ angular.module('copayApp.services').factory('txStatus', function($modal, lodash,
root.notify = function(txp, cb) { root.notify = function(txp, cb) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
var msg;
var status = txp.status; var status = txp.status;
var type;
if (status == 'broadcasted') { if (status == 'broadcasted') {
msg = gettext('Transaction broadcasted'); type = 'broadcasted';
} else { } else {
var n = txp.actions.length;
var action = lodash.find(txp.actions, { var action = lodash.find(txp.actions, {
copayerId: fc.credentials.copayerId copayerId: fc.credentials.copayerId
}); });
if (!action) {
msg = gettext('Transaction proposal created'); if (!action || (action.type == 'accept' && n == 1)) {
type = 'created';
} else if (action.type == 'accept') { } else if (action.type == 'accept') {
msg = gettext('Transaction proposal signed'); type = 'accepted';
} else if (action.type == 'reject') { } else if (action.type == 'reject') {
msg = gettext('Transaction was rejected'); type = 'rejected';
} else {
throw new Error('Unknown type:' + type);
} }
} }
root.openModal(msg, cb); root.openModal(type, cb);
}; };
root.openModal = function(statusStr, cb) { root.openModal = function(type, cb) {
var ModalInstanceCtrl = function($scope, $modalInstance) { var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.statusStr = statusStr; $scope.type = type;
$scope.cancel = function() { $scope.cancel = function() {
$modalInstance.dismiss('cancel'); $modalInstance.dismiss('cancel');
}; };