add txStatus service
This commit is contained in:
parent
5f5d74944f
commit
a70e7e61a4
6 changed files with 130 additions and 56 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, identityService) {
|
||||
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService) {
|
||||
$scope.initHome = function() {
|
||||
var w = $rootScope.wallet;
|
||||
|
||||
|
|
@ -44,23 +44,7 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
// TODO duplicated on controller send. move to a service.
|
||||
$scope.notifyStatus = function(status) {
|
||||
if (status == copay.Wallet.TX_BROADCASTED)
|
||||
notification.success('Success', 'Transaction broadcasted!');
|
||||
else if (status == copay.Wallet.TX_PROPOSAL_SENT)
|
||||
notification.info('Success', 'Transaction proposal created');
|
||||
else if (status == copay.Wallet.TX_SIGNED)
|
||||
notification.success('Success', 'Transaction proposal was signed');
|
||||
else if (status == copay.Wallet.TX_SIGNED_AND_BROADCASTED)
|
||||
notification.success('Success', 'Transaction signed and broadcasted!');
|
||||
else
|
||||
notification.error('Error', 'Unknown error occured');
|
||||
};
|
||||
|
||||
|
||||
$scope.$on("$destroy", function() {
|
||||
$scope.$on("$destroy", function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (w) {
|
||||
removeWatch();
|
||||
|
|
@ -113,7 +97,8 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
|||
$scope.error = $scope.success = null;
|
||||
w.signAndSend(ntxid, function(err, id, status) {
|
||||
$scope.loading = false;
|
||||
$scope.notifyStatus(status);
|
||||
if (!txStatus.notify(status))
|
||||
$scope.error = status;
|
||||
_updateTxs();
|
||||
});
|
||||
};
|
||||
|
|
@ -121,14 +106,14 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
|||
$scope.reject = function(ntxid) {
|
||||
var w = $rootScope.wallet;
|
||||
w.reject(ntxid);
|
||||
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
||||
txStatus.notify('txRejected');
|
||||
_updateTxs();
|
||||
};
|
||||
|
||||
|
||||
$scope.openTxModal = function(btx) {
|
||||
$scope.openTxModal = function(tx) {
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.btx = btx;
|
||||
$scope.tx = tx;
|
||||
|
||||
$scope.getShortNetworkName = function() {
|
||||
var w = $rootScope.wallet;
|
||||
|
|
@ -141,7 +126,7 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
|||
};
|
||||
|
||||
$modal.open({
|
||||
templateUrl: 'views/modals/tx-details.html',
|
||||
templateUrl: 'views/modals/txp-details.html',
|
||||
windowClass: 'tiny',
|
||||
controller: ModalInstanceCtrl,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue