mirror of https://github.com/BTCPrivate/copay.git
Moved Pending transactions proposals from Send to Home
This commit is contained in:
parent
738995fd80
commit
615e421014
|
@ -1,7 +1,95 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope) {
|
||||
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, rateService) {
|
||||
$scope.init = function() {
|
||||
$rootScope.title = 'Home';
|
||||
|
||||
$scope.rateService = rateService;
|
||||
$scope.isRateAvailable = false;
|
||||
|
||||
var w = $rootScope.wallet;
|
||||
w.on('txProposalEvent', function() { _updateTxs()});
|
||||
$timeout(function() {
|
||||
_updateTxs();
|
||||
}, 1);
|
||||
|
||||
rateService.whenAvailable(function() {
|
||||
$scope.isRateAvailable = true;
|
||||
$scope.$digest();
|
||||
});
|
||||
};
|
||||
|
||||
// This is necesarry, since wallet can change in homeWallet, without running init() again.
|
||||
var removeWatch = $rootScope.$watch('wallet.id', function(newWallet, oldWallet) {
|
||||
if ($rootScope.wallet && $rootScope.wallet.isComplete() && newWallet !== oldWallet) {
|
||||
var w = $rootScope.wallet;
|
||||
$rootScope.pendingTxCount = 0;
|
||||
w.on('txProposalEvent', function() { _updateTxs()});
|
||||
_updateTxs();
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on("$destroy", function(){
|
||||
var w = $rootScope.wallet;
|
||||
removeWatch();
|
||||
w.removeListener('txProposalEvent', function() {_updateTxs()} );
|
||||
});
|
||||
|
||||
$scope.setAlternativeAmount = function(w, tx, cb) {
|
||||
rateService.whenAvailable(function() {
|
||||
_.each(tx.outs, function(out) {
|
||||
var valueSat = out.valueSat * w.settings.unitToSatoshi;
|
||||
out.alternativeAmount = $filter('noFractionNumber')(rateService.toFiat(valueSat, $scope.alternativeIsoCode), 2);
|
||||
out.alternativeIsoCode = $scope.alternativeIsoCode;
|
||||
});
|
||||
if (cb) return cb(tx);
|
||||
});
|
||||
};
|
||||
|
||||
var _updateTxs = _.throttle(function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (!w) return;
|
||||
|
||||
$scope.alternativeIsoCode = w.settings.alternativeIsoCode;
|
||||
$scope.myId = w.getMyCopayerId();
|
||||
|
||||
var res = w.getPendingTxProposals();
|
||||
_.each(res.txs, function(tx) {
|
||||
$scope.setAlternativeAmount(w, tx);
|
||||
if (tx.merchant) {
|
||||
var url = tx.merchant.request_url;
|
||||
var domain = /^(?:https?)?:\/\/([^\/:]+).*$/.exec(url)[1];
|
||||
tx.merchant.domain = domain;
|
||||
}
|
||||
if (tx.outs) {
|
||||
_.each(tx.outs, function(out) {
|
||||
out.valueSat = out.value;
|
||||
out.value = $filter('noFractionNumber')(out.value);
|
||||
});
|
||||
}
|
||||
});
|
||||
$scope.txps = res.txs;
|
||||
console.log('[homeWallet.js:45]',$scope.txps); //TODO
|
||||
}, 100);
|
||||
|
||||
|
||||
|
||||
$scope.sign = function(ntxid) {
|
||||
var w = $rootScope.wallet;
|
||||
$scope.loading = true;
|
||||
$scope.error = $scope.success = null;
|
||||
w.signAndSend(ntxid, function(err, id, status) {
|
||||
$scope.loading = false;
|
||||
$scope.notifyStatus(status);
|
||||
_updateTxs();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reject = function(ntxid) {
|
||||
var w = $rootScope.wallet;
|
||||
w.reject(ntxid);
|
||||
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
||||
_updateTxs();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -41,29 +41,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
$scope.updateTxs = _.throttle(function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (!w) return;
|
||||
|
||||
var res = w.getPendingTxProposals();
|
||||
_.each(res.txs, function(tx) {
|
||||
$scope.setAlternativeAmount(w, tx);
|
||||
if (tx.merchant) {
|
||||
var url = tx.merchant.request_url;
|
||||
var domain = /^(?:https?)?:\/\/([^\/:]+).*$/.exec(url)[1];
|
||||
tx.merchant.domain = domain;
|
||||
}
|
||||
if (tx.outs) {
|
||||
_.each(tx.outs, function(out) {
|
||||
out.valueSat = out.value;
|
||||
out.value = $filter('noFractionNumber')(out.value);
|
||||
});
|
||||
}
|
||||
});
|
||||
$scope.txps = res.txs;
|
||||
}, 1000);
|
||||
|
||||
/**
|
||||
* Setting the two related amounts as properties prevents an infinite
|
||||
* recursion for watches while preserving the original angular updates
|
||||
|
@ -119,17 +96,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
|
||||
$scope.init = function() {
|
||||
$rootScope.pendingTxCount = 0;
|
||||
$scope.updateTxs();
|
||||
var w = $rootScope.wallet;
|
||||
w.on('txProposalEvent', $scope.updateTxs);
|
||||
// Empty
|
||||
};
|
||||
|
||||
$scope.$on("$destroy", function(){
|
||||
var w = $rootScope.wallet;
|
||||
w.removeListener('txProposalEvent', $scope.updateTxs );
|
||||
});
|
||||
|
||||
$scope.showAddressBook = function() {
|
||||
return w && _.keys(w.addressBook).length > 0;
|
||||
};
|
||||
|
@ -155,7 +124,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
$scope.error = message;
|
||||
$scope.loading = false;
|
||||
$scope.updateTxs();
|
||||
};
|
||||
|
||||
$scope.submitForm = function(form) {
|
||||
|
@ -201,7 +169,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
if (err) return $scope._showError(err);
|
||||
|
||||
$scope.notifyStatus(status);
|
||||
$scope.updateTxs();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -422,26 +389,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
w.issueTx(ntxid, function(err, txid, status) {
|
||||
$scope.notifyStatus(status);
|
||||
if (cb) return cb();
|
||||
else $scope.updateTxs();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.sign = function(ntxid) {
|
||||
$scope.loading = true;
|
||||
$scope.error = $scope.success = null;
|
||||
w.signAndSend(ntxid, function(err, id, status) {
|
||||
$scope.loading = false;
|
||||
$scope.notifyStatus(status);
|
||||
$scope.updateTxs();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reject = function(ntxid) {
|
||||
w.reject(ntxid);
|
||||
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
||||
$scope.updateTxs();
|
||||
};
|
||||
|
||||
$scope.clearMerchant = function(callback) {
|
||||
// TODO: Find a better way of detecting
|
||||
// whether we're in the Send scope or not.
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
<div class="large-4 medium-6 small-9 columns">
|
||||
<div class="text-right">
|
||||
<span class="size-21">
|
||||
<strong>
|
||||
<span ng-if="!$root.updatingBalance">{{$root.wallet.balanceInfo.totalBalance || 0}}</span>
|
||||
<span ng-if="$root.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||
{{$root.wallet.settings.unitName}}
|
||||
</strong>
|
||||
<strong>
|
||||
<span ng-if="!$root.updatingBalance">{{$root.wallet.balanceInfo.totalBalance || 0}}</span>
|
||||
<span ng-if="$root.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||
{{$root.wallet.settings.unitName}}
|
||||
</strong>
|
||||
</span>
|
||||
<span class="size-14 db m5t text-gray">
|
||||
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && $root.wallet.balanceInfo.alternativeBalanceAvailable">{{$root.wallet.balanceInfo.totalBalanceAlternative}} {{$root.wallet.balanceInfo.alternativeIsoCode}}</span>
|
||||
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && !$root.wallet.balanceInfo.alternativeBalanceAvailable">N/A</span>
|
||||
<span ng-if="$root.wallet.balanceInfo.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && $root.wallet.balanceInfo.alternativeBalanceAvailable">{{$root.wallet.balanceInfo.totalBalanceAlternative}} {{$root.wallet.balanceInfo.alternativeIsoCode}}</span>
|
||||
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && !$root.wallet.balanceInfo.alternativeBalanceAvailable">N/A</span>
|
||||
<span ng-if="$root.wallet.balanceInfo.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -35,23 +35,34 @@
|
|||
<div class="right size-10">
|
||||
<span ng-if="!$root.wallet.isShared()">Personal Wallet</span>
|
||||
<span ng-if="$root.wallet.isShared()">
|
||||
Multisignature wallet [{{$root.wallet.requiredCopayers}} of {{$root.wallet.totalCopayers}} ]
|
||||
</span>
|
||||
Multisignature wallet [{{$root.wallet.requiredCopayers}} of {{$root.wallet.totalCopayers}} ]
|
||||
</span>
|
||||
<span ng-if="$root.wallet.isTestnet()"> in TESTNET</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-if="$root.wallet.isShared()">
|
||||
<!-- List of copayers -->
|
||||
<div ng-show="$root.wallet.isShared() && txps.length != 0">
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<div class="panel oh">
|
||||
<h2 class="line-b" translate>Copayers</h2>
|
||||
<div ng-include="'views/includes/copayer.html'"></div>
|
||||
</div>
|
||||
<h2 translate>Pending Transactions Proposals</h2>
|
||||
<div class="panel last-transactions pr"
|
||||
ng-repeat="tx in txps | paged"
|
||||
ng-include="'views/includes/transaction.html'"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-if="$root.wallet.isShared()">
|
||||
<!-- List of copayers -->
|
||||
<div class="large-12 columns">
|
||||
<div class="panel oh">
|
||||
<h2 class="line-b" translate>Copayers</h2>
|
||||
<div ng-include="'views/includes/copayer.html'"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -187,18 +187,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-show="$root.wallet.isShared() && txps.length != 0">
|
||||
<div class="line-dashed-h m20b"></div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<h2 translate>Pending Transactions Proposals</h2>
|
||||
<div class="panel last-transactions pr"
|
||||
ng-repeat="tx in txps | paged"
|
||||
ng-include="'views/includes/transaction.html'"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="line-dashed-h m20b"></div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
|
|
Loading…
Reference in New Issue