diff --git a/index.html b/index.html index 855540b08..e62cab0c0 100644 --- a/index.html +++ b/index.html @@ -32,15 +32,21 @@
Balance: - ... - {{totalBalance || 0}} -
+ + + + {{totalBalance || 0}} + +
Available to Spend: - ... - {{availableBalance || 0}} - + + + + {{availableBalance || 0}} + +
@@ -317,37 +323,58 @@
-
+
-
- +
+

- ... - {{balanceByAddr[selectedAddr] || 0}} - + + + + + {{balanceByAddr[selectedAddr.address] || 0}} + + + + + {{selectedAddr.balance || 0}} + +

-
+

Create a New Address

-
+
@@ -362,19 +389,17 @@
  • -
    -
    -
    -
    -
    {{out.value}}
    -
    -
    {{out.address}}
    -
    -
    -
    -
    {{tx.createdTs | amCalendar}}
    +
    +
    +
    +
    {{out.value}}
    +
    +
    {{out.address}}
    +
    +
    {{tx.createdTs | amCalendar}}
    +
    @@ -409,7 +434,7 @@
    -
    +
    - +
    - +
    -
    +
    Transaction finally rejected
    diff --git a/js/controllers/addresses.js b/js/controllers/addresses.js index a17a44aa2..c34931dd2 100644 --- a/js/controllers/addresses.js +++ b/js/controllers/addresses.js @@ -11,14 +11,32 @@ angular.module('copay.addresses').controller('AddressesController', $timeout(function() { controllerUtils.setSocketHandlers(); controllerUtils.updateAddressList(); - $rootScope.selectedAddr = $rootScope.addrInfos[0].address.toString(); $scope.loading = false; - $rootScope.$digest(); },1); }); }; - $scope.selectAddr = function (addr) { - return addr === $rootScope.selectedAddr ? 'selected' : ''; + $scope.selectAddress = function (addr) { + $scope.selectedAddr = addr; }; + + $rootScope.$watch('addrInfos', function(addrInfos) { + $scope.addressList(addrInfos); + }); + + $scope.addressList = function (addrInfos) { + $scope.addresses = []; + if (addrInfos) { + for(var i=0;i 0) { $notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : 'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount); } }); + $rootScope.$watch('receivedFund', function(receivedFund) { + if (receivedFund) { + var currentAddr; + for(var i=0;i<$rootScope.addrInfos.length;i++) { + var addrinfo = $rootScope.addrInfos[i]; + if (addrinfo.address.toString() == receivedFund[1] && !addrinfo.isChange) { + currentAddr = addrinfo.address.toString(); + break; + } + } + if (currentAddr) { + $notification.funds('Received fund', currentAddr, receivedFund); + beep.play(); + } + } + }); + $scope.isActive = function(item) { if (item.link && item.link.replace('#','') == $location.path()) { return true; @@ -46,6 +64,7 @@ angular.module('copay.header').controller('HeaderController', var w = $rootScope.wallet; w.connectToAll(); controllerUtils.updateBalance(function() { + $rootScope.$digest(); }); }; diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index dc85a032a..d0298f0d7 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copay.controllerUtils') - .factory('controllerUtils', function($rootScope, $sce, $location, Socket, video) { + .factory('controllerUtils', function($rootScope, $sce, $location, $notification, Socket, video) { var root = {}; var bitcore = require('bitcore'); @@ -49,6 +49,9 @@ angular.module('copay.controllerUtils') }; $rootScope.$digest(); }; + + $notification.enableHtml5Mode(); // for chrome: if support, enable it + w.on('badMessage', function(peerId) { $rootScope.$flashMessage = { type: 'error', @@ -114,7 +117,6 @@ angular.module('copay.controllerUtils') w.getBalance(function(balance, balanceByAddr, safeBalance) { $rootScope.totalBalance = balance; $rootScope.balanceByAddr = balanceByAddr; - $rootScope.selectedAddr = $rootScope.addrInfos[0].address.toString(); $rootScope.availableBalance = safeBalance; $rootScope.updatingBalance = false; console.log('Done updating balance.'); //TODO @@ -189,6 +191,7 @@ angular.module('copay.controllerUtils') newAddrs.forEach(function(addr) { Socket.on(addr, function(txid) { console.log('Received!', txid); + $rootScope.receivedFund = [txid, addr]; root.updateBalance(function(){ $rootScope.$digest(); }); diff --git a/js/services/notifications.js b/js/services/notifications.js index 0ba227a04..ebd594b70 100644 --- a/js/services/notifications.js +++ b/js/services/notifications.js @@ -3,12 +3,13 @@ angular.module('notifications', []). factory('$notification', ['$timeout',function($timeout){ - console.log('notification service online'); +// console.log('notification service online'); var notifications = JSON.parse(localStorage.getItem('$notifications')) || [], queue = []; var settings = { info: { duration: 5000, enabled: true }, + funds: { duration: 5000, enabled: true }, warning: { duration: 5000, enabled: true }, error: { duration: 5000, enabled: true }, success: { duration: 5000, enabled: true }, @@ -115,6 +116,11 @@ angular.module('notifications', []). console.log(title, content); return this.awesomeNotify('info','loop', title, content, userData); }, + + funds: function(title, content, userData){ + console.log(title, content); + return this.awesomeNotify('funds','bitcoin', title, content, userData); + }, error: function(title, content, userData){ return this.awesomeNotify('error', 'remove', title, content, userData); diff --git a/sound/transaction.mp3 b/sound/transaction.mp3 new file mode 100644 index 000000000..57081caee Binary files /dev/null and b/sound/transaction.mp3 differ