notifications

This commit is contained in:
Matias Alejo Garcia 2014-11-20 02:05:57 -03:00
parent 0b136cef34
commit d4a0f5c008
2 changed files with 32 additions and 18 deletions

View File

@ -150,10 +150,10 @@ angular.module('copayApp.controllers').controller('SendController',
if (merchantData.pr.ca) { if (merchantData.pr.ca) {
message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.'; message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.';
} }
message += ' Message from server: ' + merchantData.pr.pd.memo; message += merchantData.pr.pd.memo;
message += ' For merchant: ' + merchantData.pr.pd.payment_url; message += ' Merchant: ' + merchantData.pr.pd.payment_url;
} }
notification.success('Success', message); $scope.success = message;
$scope.loadTxs(); $scope.loadTxs();
} else { } else {
w.sendTx(ntxid, function(txid, merchantData) { w.sendTx(ntxid, function(txid, merchantData) {
@ -163,10 +163,10 @@ angular.module('copayApp.controllers').controller('SendController',
if (merchantData.pr.ca) { if (merchantData.pr.ca) {
message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.'; message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.';
} }
message += ' Message from server: ' + merchantData.pr.pd.memo; message += merchantData.pr.pd.memo;
message += ' For merchant: ' + merchantData.pr.pd.payment_url; message += ' Merchant: ' + merchantData.pr.pd.payment_url;
} }
notification.success('Transaction broadcasted', message); $scope.success = 'Transaction broadcasted' + message;
} else { } else {
$scope.error = 'There was an error sending the transaction'; $scope.error = 'There was an error sending the transaction';
} }
@ -362,7 +362,7 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.submitAddressBook = function(form) { $scope.submitAddressBook = function(form) {
if (form.$invalid) { if (form.$invalid) {
notification.error('Form Error', 'Please complete required fields'); scope.error = 'Please complete required fields';
return; return;
} }
var entry = { var entry = {
@ -390,6 +390,7 @@ angular.module('copayApp.controllers').controller('SendController',
errorMsg = e.message; errorMsg = e.message;
} }
// TODO change this notifications
if (errorMsg) { if (errorMsg) {
notification.error('Error', errorMsg); notification.error('Error', errorMsg);
} else { } else {
@ -415,7 +416,7 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.error = 'There was an error sending the transaction'; $scope.error = 'There was an error sending the transaction';
} else { } else {
if (!merchantData) { if (!merchantData) {
notification.success('Transaction broadcasted', 'Transaction id: ' + txid); $scope.success = 'Transaction broadcasted!';
} else { } else {
var message = 'Transaction ID: ' + txid; var message = 'Transaction ID: ' + txid;
if (merchantData.pr.ca) { if (merchantData.pr.ca) {
@ -423,7 +424,7 @@ angular.module('copayApp.controllers').controller('SendController',
} }
message += ' Message from server: ' + merchantData.ack.memo; message += ' Message from server: ' + merchantData.ack.memo;
message += ' For merchant: ' + merchantData.pr.pd.payment_url; message += ' For merchant: ' + merchantData.pr.pd.payment_url;
notification.success('Transaction sent', message); $scope.success = 'Transaction sent' + message;
} }
} }
@ -527,19 +528,18 @@ angular.module('copayApp.controllers').controller('SendController',
} }
}; };
notification.info('Fetching Payment', scope.fetchingURL = uri.merchant;
'Retrieving Payment Request from ' + uri.merchant);
scope.loading = true; scope.loading = true;
apply(); apply();
var timeout = setTimeout(function() { var timeout = setTimeout(function() {
timeout = null; timeout = null;
scope.fetchingURL = null;
scope.loading = false; scope.loading = false;
scope.sendForm.address.$setViewValue(''); scope.sendForm.address.$setViewValue('');
scope.sendForm.address.$render(); scope.sendForm.address.$render();
scope.sendForm.address.$isValid = false; scope.sendForm.address.$isValid = false;
notification.error('Error', 'Payment server timed out.'); scope.error = 'Payment server timed out';
apply(); apply();
}, 10 * 1000); }, 10 * 1000);
@ -549,6 +549,7 @@ angular.module('copayApp.controllers').controller('SendController',
clearTimeout(timeout); clearTimeout(timeout);
scope.loading = false; scope.loading = false;
scope.fetchingURL = null;
apply(); apply();
var balance = $rootScope.availableBalance; var balance = $rootScope.availableBalance;
@ -581,7 +582,7 @@ angular.module('copayApp.controllers').controller('SendController',
} }
scope.sendForm.address.$isValid = false; scope.sendForm.address.$isValid = false;
notification.error('Error', err.message || 'Bad payment server.'); scope.error = err.message || 'Bad payment server';
apply(); apply();
return; return;
@ -613,10 +614,8 @@ angular.module('copayApp.controllers').controller('SendController',
apply(); apply();
notification.info('Payment Request', scope.success = 'Payment Request:' + merchantData.unitTotal +
'Server is requesting ' + merchantData.unitTotal + ' ' + w.settings.unitName + '. ' + (merchantData.pr.pd.memo || '');
' ' + w.settings.unitName +
'.' + ' Message: ' + merchantData.pr.pd.memo);
}); });
}; };
}); });

View File

@ -21,6 +21,13 @@
<i class="fi-alert"></i> <i class="fi-alert"></i>
{{error|translate}} {{error|translate}}
</p> </p>
<p class="text-success size-16"
ng-show="success">
<i class="fi-check"></i>
{{success|translate}}
</p>
<div class="row collapse"> <div class="row collapse">
<label for="address" class="left"> <label for="address" class="left">
@ -120,6 +127,14 @@
</div> </div>
<div class="row"> <div class="row">
<div class="large-12 columns" ng-show="fetchingURL">
<h3>
<i class="glyphicon glyphicon-refresh icon-rotate"></i>
Fetching payment
</h3>
<p> From {{fetchingURL}}
</div>
<div class="large-12 columns" ng-show="!!$root.merchant"> <div class="large-12 columns" ng-show="!!$root.merchant">
<h3>This is a payment protocol transaction</h3> <h3>This is a payment protocol transaction</h3>
<div class="send-note"> <div class="send-note">