Wallet/js/controllers/receive.js

69 lines
1.7 KiB
JavaScript
Raw Normal View History

2014-03-26 09:18:42 -03:00
'use strict';
2014-10-30 14:13:40 -03:00
angular.module('copayApp.controllers').controller('ReceiveController',
2014-11-29 18:35:48 -03:00
function($scope, $rootScope, $timeout, $modal) {
2014-10-30 18:17:41 -03:00
$rootScope.title = 'Receive';
2014-04-30 19:50:13 -03:00
$scope.loading = false;
$scope.showAll = false;
2014-05-19 17:51:21 -03:00
$scope.newAddr = function() {
2014-10-28 11:34:19 -03:00
var w = $rootScope.wallet;
2014-05-19 17:51:21 -03:00
$scope.loading = true;
w.generateAddress(null);
2014-11-30 03:23:15 -03:00
$scope.setAddressList();
$timeout(function() {
$scope.loading = false;
}, 1);
};
$scope.openAddressModal = function(address) {
var ModalInstanceCtrl = function($scope, $modalInstance, address) {
$scope.address = address;
2014-07-30 00:51:38 -03:00
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
$modal.open({
templateUrl: 'views/modals/qr-address.html',
2014-07-22 11:03:08 -03:00
windowClass: 'tiny',
controller: ModalInstanceCtrl,
resolve: {
address: function() {
return address;
}
}
});
};
$scope.toggleShowAll = function() {
$scope.showAll = !$scope.showAll;
2014-11-30 03:23:15 -03:00
$scope.setAddressList();
};
2014-11-30 03:23:15 -03:00
$scope.setAddressList = function() {
2014-11-29 18:35:48 -03:00
var w = $rootScope.wallet;
var balance = w.balanceInfo.balanceByAddr;
2014-11-30 03:23:15 -03:00
var addresses = w.getAddressesOrderer();
2014-11-29 18:35:48 -03:00
if (addresses) {
$scope.addrLength = addresses.length;
2014-11-30 03:23:15 -03:00
if (!$scope.showAll)
addresses = addresses.slice(0,3);
var list = [];
2014-11-29 18:35:48 -03:00
_.each(addresses, function(address, index){
2014-11-30 03:23:15 -03:00
list.push({
2014-11-29 18:35:48 -03:00
'index': index,
'address': address,
'balance': balance ? balance[address] : null,
2014-11-29 18:35:48 -03:00
'isChange': w.addressIsChange(address),
});
2014-11-29 18:35:48 -03:00
});
2014-11-30 03:23:15 -03:00
$scope.addresses = list;
}
};
}
);