From 589200b455c8f66d9c51815534a649a16a04c261 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 23 Apr 2015 12:27:43 -0300 Subject: [PATCH 01/10] one page --- public/views/history.html | 64 ---- public/views/includes/menu.html | 4 +- public/views/receive.html | 68 ---- public/views/walletHome.html | 287 +++++++++++++++- src/css/main.css | 98 ------ src/js/controllers/history.js | 72 ---- src/js/controllers/index.js | 2 + src/js/controllers/receive.js | 4 +- src/js/controllers/walletHome.js | 558 ++++++++++++++++++++++++++++++- src/js/routes.js | 57 ---- 10 files changed, 847 insertions(+), 367 deletions(-) diff --git a/public/views/history.html b/public/views/history.html index 65a3a3c0c..a9ea5e970 100644 --- a/public/views/history.html +++ b/public/views/history.html @@ -1,65 +1 @@ -
-
-
-
- Getting transactions... - - - Could not fetch transaction history -
[Tap to retry] -
- - No transactions yet - -
-
-
-
-
-
-
- Received - Sent - Moved -
- -
- - + - - - {{btx.amountStr}} - {{history.getUnitName()}} - -
-
-
- - - Unconfirmed - -
-
-
- {{btx.message || btx.addressTo}} -
-
-
-
- -
-
-
-
diff --git a/public/views/includes/menu.html b/public/views/includes/menu.html index 78208dc95..e9f651a10 100644 --- a/public/views/includes/menu.html +++ b/public/views/includes/menu.html @@ -1,8 +1,8 @@
- +
{{item.title|translate}} diff --git a/public/views/receive.html b/public/views/receive.html index 3fc6c72b0..1dc122042 100644 --- a/public/views/receive.html +++ b/public/views/receive.html @@ -1,70 +1,2 @@ -
- -
-
- - - WARNING: Backup needed - -
-
- Before receiving funds, it is highly recommended you backup your wallet keys. -
- -
- - SKIP BACKUP - -
-
- - Backup now - -
-
- -
- -
- - {{receive.error|translate}} - -
- -
- -
-

My Bitcoin address

-
- -
-

{{receive.addr}}

-
-
-
- - - Share address - -
-
- Share this with anyone to have them send you payments. To protect your privacy, new addresses are generated automatically once you use them. -
-
-
-
-
- -
-
-
- -
diff --git a/public/views/walletHome.html b/public/views/walletHome.html index dbce3f15d..572ff73a9 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -1,5 +1,7 @@
+ +
+ +
+ +
+
+ + + WARNING: Backup needed + +
+
+ Before receiving funds, it is highly recommended you backup your wallet keys. +
+ +
+ + SKIP BACKUP + +
+
+ + Backup now + +
+
+
+
+ + {{home.error|translate}} + +
+
+ +
+

My Bitcoin address

+
+ +
+

{{home.addr}}

+
+
+
+ + + Share address + +
+
+ Share this with anyone to have them send you payments. To protect your privacy, new addresses are generated automatically once you use them. +
+
+
+
+
+ +
+
+
+ +
+ + + +
+ + +
+
+
+
+ Getting transactions... + + + Could not fetch transaction history +
[Tap to retry] +
+ + No transactions yet + +
+
+
+
+
+
+
+ Received + Sent + Moved +
+ +
+ + + + - + {{btx.amountStr}} + {{home.getUnitName()}} + +
+
+
+ + + Unconfirmed + +
+
+
+ {{btx.message || btx.addressTo}} +
+
+
+
+ +
+
+
+
+ + + +
You do not have any wallet diff --git a/src/css/main.css b/src/css/main.css index 007adb6eb..b2b831fcd 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -1106,104 +1106,6 @@ input.ng-invalid-match, input.ng-invalid-match:focus { cursor: pointer !important; } - - - -.updating { - -webkit-animation-iteration-count: infinite; - -webkit-animation-name: up-animation; - -webkit-animation-duration: 1s; - -webkit-animation-iteration-count: infinite; - animation-iteration-count: infinite; - animation-name: up-animation; - animation-duration: 1s; - animation-iteration-count: infinite; -} - - - -/* Generated with Bounce.js. Edit at http://goo.gl/Vn2Euz */ - -@-webkit-keyframes up-animation { - 0% { -webkit-transform: matrix3d(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 3.4% { -webkit-transform: matrix3d(0.658, 0, 0, 0, 0, 0.703, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.658, 0, 0, 0, 0, 0.703, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 4.7% { -webkit-transform: matrix3d(0.725, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.725, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 6.81% { -webkit-transform: matrix3d(0.83, 0, 0, 0, 0, 0.946, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.83, 0, 0, 0, 0, 0.946, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 9.41% { -webkit-transform: matrix3d(0.942, 0, 0, 0, 0, 1.084, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.942, 0, 0, 0, 0, 1.084, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 10.21% { -webkit-transform: matrix3d(0.971, 0, 0, 0, 0, 1.113, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.971, 0, 0, 0, 0, 1.113, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 13.61% { -webkit-transform: matrix3d(1.062, 0, 0, 0, 0, 1.166, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.062, 0, 0, 0, 0, 1.166, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 14.11% { -webkit-transform: matrix3d(1.07, 0, 0, 0, 0, 1.165, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.07, 0, 0, 0, 0, 1.165, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 17.52% { -webkit-transform: matrix3d(1.104, 0, 0, 0, 0, 1.12, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.104, 0, 0, 0, 0, 1.12, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 18.72% { -webkit-transform: matrix3d(1.106, 0, 0, 0, 0, 1.094, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.106, 0, 0, 0, 0, 1.094, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 21.32% { -webkit-transform: matrix3d(1.098, 0, 0, 0, 0, 1.035, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.098, 0, 0, 0, 0, 1.035, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 24.32% { -webkit-transform: matrix3d(1.075, 0, 0, 0, 0, 0.98, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.075, 0, 0, 0, 0, 0.98, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 25.23% { -webkit-transform: matrix3d(1.067, 0, 0, 0, 0, 0.969, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.067, 0, 0, 0, 0, 0.969, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 29.03% { -webkit-transform: matrix3d(1.031, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.031, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 29.93% { -webkit-transform: matrix3d(1.024, 0, 0, 0, 0, 0.949, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.024, 0, 0, 0, 0, 0.949, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 35.54% { -webkit-transform: matrix3d(0.99, 0, 0, 0, 0, 0.981, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.99, 0, 0, 0, 0, 0.981, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 36.74% { -webkit-transform: matrix3d(0.986, 0, 0, 0, 0, 0.989, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.986, 0, 0, 0, 0, 0.989, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 41.04% { -webkit-transform: matrix3d(0.98, 0, 0, 0, 0, 1.011, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.98, 0, 0, 0, 0, 1.011, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 44.44% { -webkit-transform: matrix3d(0.983, 0, 0, 0, 0, 1.016, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.983, 0, 0, 0, 0, 1.016, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 52.15% { -webkit-transform: matrix3d(0.996, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.996, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 59.86% { -webkit-transform: matrix3d(1.003, 0, 0, 0, 0, 0.995, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.003, 0, 0, 0, 0, 0.995, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 63.26% { -webkit-transform: matrix3d(1.004, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.004, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 75.28% { -webkit-transform: matrix3d(1.001, 0, 0, 0, 0, 1.002, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.001, 0, 0, 0, 0, 1.002, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 85.49% { -webkit-transform: matrix3d(0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 90.69% { -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 100% { -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } -} - - -@keyframes up-animation { - 0% { transform: matrix3d(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 3.4% { transform: matrix3d(0.658, 0, 0, 0, 0, 0.703, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.658, 0, 0, 0, 0, 0.703, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 4.7% { transform: matrix3d(0.725, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.725, 0, 0, 0, 0, 0.8, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 6.81% { transform: matrix3d(0.83, 0, 0, 0, 0, 0.946, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.83, 0, 0, 0, 0, 0.946, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 9.41% { transform: matrix3d(0.942, 0, 0, 0, 0, 1.084, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.942, 0, 0, 0, 0, 1.084, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 10.21% { transform: matrix3d(0.971, 0, 0, 0, 0, 1.113, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.971, 0, 0, 0, 0, 1.113, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 13.61% { transform: matrix3d(1.062, 0, 0, 0, 0, 1.166, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.062, 0, 0, 0, 0, 1.166, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 14.11% { transform: matrix3d(1.07, 0, 0, 0, 0, 1.165, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.07, 0, 0, 0, 0, 1.165, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 17.52% { transform: matrix3d(1.104, 0, 0, 0, 0, 1.12, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.104, 0, 0, 0, 0, 1.12, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 18.72% { transform: matrix3d(1.106, 0, 0, 0, 0, 1.094, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.106, 0, 0, 0, 0, 1.094, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 21.32% { transform: matrix3d(1.098, 0, 0, 0, 0, 1.035, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.098, 0, 0, 0, 0, 1.035, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 24.32% { transform: matrix3d(1.075, 0, 0, 0, 0, 0.98, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.075, 0, 0, 0, 0, 0.98, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 25.23% { transform: matrix3d(1.067, 0, 0, 0, 0, 0.969, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.067, 0, 0, 0, 0, 0.969, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 29.03% { transform: matrix3d(1.031, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.031, 0, 0, 0, 0, 0.948, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 29.93% { transform: matrix3d(1.024, 0, 0, 0, 0, 0.949, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.024, 0, 0, 0, 0, 0.949, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 35.54% { transform: matrix3d(0.99, 0, 0, 0, 0, 0.981, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.99, 0, 0, 0, 0, 0.981, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 36.74% { transform: matrix3d(0.986, 0, 0, 0, 0, 0.989, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.986, 0, 0, 0, 0, 0.989, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 41.04% { transform: matrix3d(0.98, 0, 0, 0, 0, 1.011, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.98, 0, 0, 0, 0, 1.011, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 44.44% { transform: matrix3d(0.983, 0, 0, 0, 0, 1.016, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.983, 0, 0, 0, 0, 1.016, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 52.15% { transform: matrix3d(0.996, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.996, 0, 0, 0, 0, 1.003, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 59.86% { transform: matrix3d(1.003, 0, 0, 0, 0, 0.995, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.003, 0, 0, 0, 0, 0.995, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 63.26% { transform: matrix3d(1.004, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.004, 0, 0, 0, 0, 0.996, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 75.28% { transform: matrix3d(1.001, 0, 0, 0, 0, 1.002, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1.001, 0, 0, 0, 0, 1.002, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 85.49% { transform: matrix3d(0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 90.69% { transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } - 100% { transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } -} - - -.opacityCycle { - -webkit-animation-iteration-count: infinite; - -webkit-animation-name: opCycle-animation; - -webkit-animation-duration: 20s; - -webkit-animation-iteration-count: infinite; -} - - - -@-webkit-keyframes opCycle-animation -{ -0% {opacity:1} -15% {opacity:0.7} -30% {opacity:0.85} -45% {opacity:0.5} -60% {opacity:0.8} -75% {opacity:0.7} -99% {opacity:1;} -} - .onGoingProcess { text-align: center; max-width: 14.5rem; diff --git a/src/js/controllers/history.js b/src/js/controllers/history.js index 7dc20d6ec..9f9275abe 100644 --- a/src/js/controllers/history.js +++ b/src/js/controllers/history.js @@ -3,76 +3,4 @@ angular.module('copayApp.controllers').controller('historyController', function($scope, $rootScope, $filter, $timeout, $modal, $log, profileService, notification, go, configService, rateService, lodash) { - function strip(number) { - return (parseFloat(number.toPrecision(12))); - } - - var fc = profileService.focusedClient; - var config = configService.getSync().wallet.settings; - this.unitToSatoshi = config.unitToSatoshi; - this.satToUnit = 1 / this.unitToSatoshi; - this.unitName = config.unitName; - this.alternativeIsoCode = config.alternativeIsoCode; - - this.getUnitName = function() { - return this.unitName; - }; - - this.getAlternativeIsoCode = function() { - return this.alternativeIsoCode; - }; - - this._addRates = function(txs, cb) { - if (!txs || txs.length == 0) return cb(); - var index = lodash.groupBy(txs, 'rateTs'); - - rateService.getHistoricRates(config.alternativeIsoCode, lodash.keys(index), function(err, res) { - if (err || !res) return cb(err); - lodash.each(res, function(r) { - lodash.each(index[r.ts], function(tx) { - var alternativeAmount = (r.rate != null ? tx.amount * rateService.SAT_TO_BTC * r.rate : null); - tx.alternativeAmount = alternativeAmount ? $filter('noFractionNumber')(alternativeAmount, 2) : null; - }); - }); - return cb(); - }); - }; - - this.openTxModal = function(btx) { - var self = this; - var fc = profileService.focusedClient; - var ModalInstanceCtrl = function($scope, $modalInstance) { - $scope.btx = btx; - $scope.settings = config; - $scope.color = fc.backgroundColor; - - $scope.getAmount = function(amount) { - return self.getAmount(amount); - }; - - $scope.getUnitName = function() { - return self.getUnitName(); - }; - - $scope.getShortNetworkName = function() { - var n = fc.credentials.network; - return n.substring(0, 4); - }; - - $scope.cancel = function() { - $modalInstance.dismiss('cancel'); - }; - }; - - $modal.open({ - templateUrl: 'views/modals/tx-details.html', - windowClass: 'full', - controller: ModalInstanceCtrl, - }); - }; - - this.hasAction = function(actions, action) { - return actions.hasOwnProperty('create'); - }; - }); diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 78fc79ad4..310ae7388 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -28,6 +28,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r 'link': 'history' }]; + self.tab = 'walletHome'; + self.availableLanguages = [{ name: 'English', isoCode: 'en', diff --git a/src/js/controllers/receive.js b/src/js/controllers/receive.js index bd5d47acc..dd82b60f6 100644 --- a/src/js/controllers/receive.js +++ b/src/js/controllers/receive.js @@ -3,8 +3,6 @@ angular.module('copayApp.controllers').controller('receiveController', function($rootScope, $scope, $timeout, $modal, $log, isCordova, isMobile, profileService, storageService) { var self = this; - var fc = profileService.focusedClient; - this.isCordova = isCordova; self.addresses = []; @@ -15,6 +13,7 @@ angular.module('copayApp.controllers').controller('receiveController', $scope.$on('$destroy', newAddrListener); this.newAddress = function() { + var fc = profileService.focusedClient; self.generatingAddress = true; self.error = null; fc.createAddress(function(err, addr) { @@ -32,6 +31,7 @@ angular.module('copayApp.controllers').controller('receiveController', }; this.getAddress = function() { + var fc = profileService.focusedClient; $timeout(function() { storageService.getLastAddress(fc.credentials.walletId, function(err, addr) { if (addr) { diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 2450616cb..ff72de7f0 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -1,8 +1,57 @@ 'use strict'; -angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, notification, txStatus, isCordova, profileService, lodash) { +angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService) { + var self = this; $rootScope.hideMenuBar = false; + $rootScope.wpInputFocused = false; + + // INIT + var config = configService.getSync().wallet.settings; + this.unitToSatoshi = config.unitToSatoshi; + this.satToUnit = 1 / this.unitToSatoshi; + this.unitName = config.unitName; + this.alternativeIsoCode = config.alternativeIsoCode; + this.alternativeName = config.alternativeName; + this.alternativeAmount = 0; + this.unitDecimals = config.unitDecimals; + this.isCordova = isCordova; + this.addresses = []; + this.isMobile = isMobile.any(); + this.isWindowsPhoneApp = isMobile.Windows() && isCordova; + this.blockUx = false; + this.isRateAvailable = false; + this.showScanner = false; + this.isMobile = isMobile.any(); + + var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) { + self.setForm(data); + }); + + var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) { + $timeout(function() { + self.setForm(uri); + }, 100); + }); + + var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() { + self.getAddress(); + }); + + $scope.$on('$destroy', function() { + disableAddrListener(); + disableScannerListener(); + disablePaymentUriListener(); + $rootScope.hideMenuBar = false; + }); + + rateService.whenAvailable(function() { + self.isRateAvailable = true; + $rootScope.$digest(); + }); + + // walletHome + $scope.openCopayersModal = function(copayers, copayerId) { var fc = profileService.focusedClient; @@ -21,8 +70,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }); }; - - $scope.openTxModal = function(tx, copayers) { var fc = profileService.focusedClient; var ModalInstanceCtrl = function($scope, $modalInstance) { @@ -213,4 +260,509 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }; + // Receive + + this.newAddress = function() { + var fc = profileService.focusedClient; + self.generatingAddress = true; + self.error = null; + fc.createAddress(function(err, addr) { + self.generatingAddress = false; + if (err) { + $log.debug('Creating address ERROR:', err); + $scope.$emit('Local/ClientError', err); + self.error = 'Could not generate address'; + } else { + self.addr = addr.address; + storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() {}); + } + $scope.$digest(); + }); + }; + + this.getAddress = function() { + var fc = profileService.focusedClient; + $timeout(function() { + storageService.getLastAddress(fc.credentials.walletId, function(err, addr) { + if (addr) { + self.addr = addr; + } else { + self.newAddress(); + } + }); + }); + }; + + this.copyAddress = function(addr) { + if (isCordova) { + window.cordova.plugins.clipboard.copy('bitcoin:' + addr); + window.plugins.toast.showShortCenter('Copied to clipboard'); + } + }; + + this.shareAddress = function(addr) { + if (isCordova) { + if (isMobile.Android() || isMobile.Windows()) { + window.ignoreMobilePause = true; + } + window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null); + } + }; + + // Send + this.resetError = function() { + this.error = this.success = null; + }; + + + var hideMenuBar = lodash.debounce(function(hide) { + if (hide) { + $rootScope.hideMenuBar = true; + } else { + $rootScope.hideMenuBar = false; + } + $rootScope.$digest(); + }, 100); + + + this.formFocus = function(what) { + if (isCordova) { + hideMenuBar(what); + } + if (!this.isWindowsPhoneApp) return + + if (!what) { + this.hideAddress = false; + this.hideAmount = false; + + } else { + if (what == 'amount') { + this.hideAddress = true; + } else if (what == 'msg') { + this.hideAddress = true; + this.hideAmount = true; + } + } + $timeout(function() { + $rootScope.$digest(); + }, 1); + }; + + this.setInputs = function() { + var unitToSat = this.unitToSatoshi; + var satToUnit = 1 / unitToSat; + /** + * Setting the two related amounts as properties prevents an infinite + * recursion for watches while preserving the original angular updates + * + */ + Object.defineProperty($scope, + "_alternative", { + get: function() { + return $scope.__alternative; + }, + set: function(newValue) { + $scope.__alternative = newValue; + if (typeof(newValue) === 'number' && self.isRateAvailable) { + $scope._amount = parseFloat((rateService.fromFiat(newValue, self.alternativeIsoCode) * satToUnit).toFixed(self.unitDecimals), 10); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty($scope, + "_amount", { + get: function() { + return $scope.__amount; + }, + set: function(newValue) { + $scope.__amount = newValue; + if (typeof(newValue) === 'number' && self.isRateAvailable) { + $scope.__alternative = parseFloat((rateService.toFiat(newValue * self.unitToSatoshi, self.alternativeIsoCode)).toFixed(2), 10); + } else { + $scope.__alternative = 0; + } + self.alternativeAmount = $scope.__alternative; + self.resetError(); + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty($scope, + "_address", { + get: function() { + return $scope.__address; + }, + set: function(newValue) { + $scope.__address = self.onAddressChange(newValue); + }, + enumerable: true, + configurable: true + }); + }; + + this.setError = function(err) { + $log.warn(err); + var errMessage = 'The transaction' + (fc.credentials.m > 1 ? ' proposal' : '') + + + ' could not be created: ' + (err.message ? err.message : err); + + this.error = errMessage; + + $timeout(function() { + $scope.$digest(); + }, 1); + }; + + + this.setOngoingProcess = function(name) { + var self = this; + $timeout(function() { + self.onGoingProcess = name; + $rootScope.$apply(); + }) + }; + + this.submitForm = function(form) { + var unitToSat = this.unitToSatoshi; + + if (form.$invalid) { + this.error = 'Unable to send transaction proposal'; + return; + } + + if (fc.isPrivKeyEncrypted()) { + profileService.unlockFC(function(err) { + if (err) return self.setError(err); + return self.submitForm(form); + }); + return; + }; + + self.blockUx = true; + self.setOngoingProcess('Sending'); + + if (isCordova) { + window.plugins.spinnerDialog.show(null, 'Creating transaction...', true); + } + + $timeout(function() { + var comment = form.comment.$modelValue; + var paypro = self._paypro; + var address, amount; + + address = form.address.$modelValue; + amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0)); + + fc.sendTxProposal({ + toAddress: address, + amount: amount, + message: comment, + payProUrl: paypro ? paypro.url : null, + }, function(err, txp) { + self.setOngoingProcess(); + if (err) { + profileService.lockFC(); + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } + self.blockUx = false; + return self.setError(err); + } + + self.signAndBroadcast(txp, function(err) { + self.setOngoingProcess(); + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } + self.blockUx = false; + if (err) { + profileService.lockFC(); + return self.setError(err); + } + self.resetForm(form); + }); + }); + }, 100); + }; + + + this.signAndBroadcast = function(txp, cb) { + self.setOngoingProcess('Signing'); + fc.signTxProposal(txp, function(err, signedTx) { + profileService.lockFC(); + self.setOngoingProcess(); + + if (err) return cb(err); + + if (signedTx.status == 'accepted') { + self.setOngoingProcess('Broadcasting'); + fc.broadcastTxProposal(signedTx, function(err, btx) { + self.setOngoingProcess(); + if (err) { + $scope.error = 'Transaction not broadcasted. Please try again.'; + $scope.$digest(); + } else { + txStatus.notify(btx); + $scope.$emit('Local/TxProposalAction'); + } + return cb(); + }); + } else { + txStatus.notify(signedTx); + $scope.$emit('Local/TxProposalAction'); + return cb(); + } + }); + }; + + this.setTopAmount = function() { + throw new Error('todo: setTopAmount'); + var form = $scope.sendForm; + if (form) { + form.amount.$setViewValue(w.balanceInfo.topAmount); + form.amount.$render(); + form.amount.$isValid = true; + } + }; + + this.setForm = function(to, amount, comment) { + var form = $scope.sendForm; + if (to) { + form.address.$setViewValue(to); + form.address.$isValid = true; + form.address.$render(); + this.lockAddress = true; + } + + if (amount) { + form.amount.$setViewValue("" + amount); + form.amount.$isValid = true; + form.amount.$render(); + this.lockAmount = true; + } + + if (comment) { + form.comment.$setViewValue(comment); + form.comment.$isValid = true; + form.comment.$render(); + } + }; + + + + this.resetForm = function(form) { + this.resetError(); + this.fetchingURL = null; + this._paypro = null; + + this.lockAddress = false; + this.lockAmount = false; + + this._amount = this._address = null; + + if (form && form.amount) { + form.amount.$pristine = true; + form.amount.$setViewValue(''); + form.amount.$render(); + + form.comment.$setViewValue(''); + form.comment.$render(); + form.$setPristine(); + + if (form.address) { + form.address.$pristine = true; + form.address.$setViewValue(''); + form.address.$render(); + } + } + $timeout(function() { + $rootScope.$digest(); + }, 1); + }; + + this.openPPModal = function(paypro) { + var ModalInstanceCtrl = function($scope, $modalInstance) { + var satToUnit = 1 / self.unitToSatoshi; + $scope.paypro = paypro; + $scope.alternative = self.alternativeAmount; + $scope.alternativeIsoCode = self.alternativeIsoCode; + $scope.isRateAvailable = self.isRateAvailable; + $scope.unitTotal = (paypro.amount * satToUnit).toFixed(self.unitDecimals); + $scope.unitName = self.unitName; + $scope.color = fc.backgroundColor; + + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + }; + $modal.open({ + templateUrl: 'views/modals/paypro.html', + windowClass: 'full', + controller: ModalInstanceCtrl, + }); + }; + + this.setFromPayPro = function(uri, form) { + if (isChromeApp) { + this.error = 'Payment Protocol not supported on Chrome App'; + return; + } + + var satToUnit = 1 / this.unitToSatoshi; + this.fetchingURL = uri; + this.blockUx = true; + var self = this; + + $log.debug('Fetch PayPro Request...', uri); + $timeout(function() { + fc.fetchPayPro({ + payProUrl: uri, + }, function(err, paypro) { + $log.debug(paypro); + self.blockUx = false; + self.fetchingURL = null; + + if (err) { + $log.warn(err); + self.resetForm(form); + var msg = err.toString(); + if (msg.match('HTTP')) { + msg = 'Could not fetch payment information'; + } + self.error = msg; + } else { + self._paypro = paypro; + self.setForm(paypro.toAddress, (paypro.amount * satToUnit).toFixed(self.unitDecimals), + paypro.memo); + } + }); + }, 1); + }; + + this.setFromUri = function(uri) { + function sanitizeUri(uri) { + // Fixes when a region uses comma to separate decimals + var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i; + var match = regex.exec(uri); + if (!match || match.length === 0) { + return uri; + } + var value = match[0].replace(',', '.'); + var newUri = uri.replace(regex, value); + return newUri; + }; + + var satToUnit = 1 / this.unitToSatoshi; + + uri = sanitizeUri(uri); + + if (!bitcore.URI.isValid(uri)) { + return uri; + } + var parsed = new bitcore.URI(uri); + var addr = parsed.address.toString(); + var message = parsed.message; + if (parsed.r) + return this.setFromPayPro(parsed.r); + + var amount = parsed.amount ? + (parsed.amount.toFixed(0) * satToUnit).toFixed(this.unitDecimals) : 0; + + this.setForm(addr, amount, message); + return addr; + }; + + this.onAddressChange = function(value) { + this.resetError(); + if (!value) return ''; + + if (this._paypro) + return value; + + if (value.indexOf('bitcoin:') === 0) { + return this.setFromUri(value); + } else if (/^https?:\/\//.test(value)) { + return this.setFromPayPro(value); + } else { + return value; + } + }; + + + // History + + function strip(number) { + return (parseFloat(number.toPrecision(12))); + } + + this.getUnitName = function() { + return this.unitName; + }; + + this.getAlternativeIsoCode = function() { + return this.alternativeIsoCode; + }; + + this._addRates = function(txs, cb) { + if (!txs || txs.length == 0) return cb(); + var index = lodash.groupBy(txs, 'rateTs'); + + rateService.getHistoricRates(config.alternativeIsoCode, lodash.keys(index), function(err, res) { + if (err || !res) return cb(err); + lodash.each(res, function(r) { + lodash.each(index[r.ts], function(tx) { + var alternativeAmount = (r.rate != null ? tx.amount * rateService.SAT_TO_BTC * r.rate : null); + tx.alternativeAmount = alternativeAmount ? $filter('noFractionNumber')(alternativeAmount, 2) : null; + }); + }); + return cb(); + }); + }; + + this.openTxModal = function(btx) { + var self = this; + var fc = profileService.focusedClient; + var ModalInstanceCtrl = function($scope, $modalInstance) { + $scope.btx = btx; + $scope.settings = config; + $scope.color = fc.backgroundColor; + + $scope.getAmount = function(amount) { + return self.getAmount(amount); + }; + + $scope.getUnitName = function() { + return self.getUnitName(); + }; + + $scope.getShortNetworkName = function() { + var n = fc.credentials.network; + return n.substring(0, 4); + }; + + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + }; + + $modal.open({ + templateUrl: 'views/modals/tx-details.html', + windowClass: 'full', + controller: ModalInstanceCtrl, + }); + }; + + this.hasAction = function(actions, action) { + return actions.hasOwnProperty('create'); + }; + + // ToDo a send... + this.resetError(); + this.setInputs(); + // Todo Receive + this.getAddress(); + + }); diff --git a/src/js/routes.js b/src/js/routes.js index 831c301a7..b8122ac63 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -179,63 +179,6 @@ angular templateUrl: 'views/profile.html', needProfile: true }) - .state('receive', { - url: '/receive', - walletShouldBeComplete: true, - needProfile: true, - views: { - 'main': { - templateUrl: 'views/receive.html' - }, - 'topbar': { - templateUrl: 'views/includes/topbar.html' - }, - 'menu': { - templateUrl: 'views/includes/menu.html', - controller: function($scope) { - $scope.activeMenu = 'receive'; - } - } - } - }) - .state('send', { - url: '/send', - walletShouldBeComplete: true, - needProfile: true, - views: { - 'main': { - templateUrl: 'views/send.html' - }, - 'topbar': { - templateUrl: 'views/includes/topbar.html' - }, - 'menu': { - templateUrl: 'views/includes/menu.html', - controller: function($scope) { - $scope.activeMenu = 'send'; - } - } - } - }) - .state('history', { - url: '/history', - walletShouldBeComplete: true, - needProfile: true, - views: { - 'main': { - templateUrl: 'views/history.html' - }, - 'topbar': { - templateUrl: 'views/includes/topbar.html' - }, - 'menu': { - templateUrl: 'views/includes/menu.html', - controller: function($scope) { - $scope.activeMenu = 'history'; - } - } - } - }) .state('preferences', { url: '/preferences', templateUrl: 'views/preferences.html', From 867c4b20bdd26b5dca701b2b43bdea4147068c83 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 23 Apr 2015 12:58:08 -0300 Subject: [PATCH 02/10] add 3d transform --- public/views/walletHome.html | 20 ++++++++++++++------ src/css/mobile.css | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 572ff73a9..38502a396 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -1,7 +1,7 @@
-
+
@@ -114,8 +114,12 @@
- -
+ +
@@ -187,7 +191,7 @@ send --> -
+

@@ -328,8 +332,12 @@
- -
+ +
diff --git a/src/css/mobile.css b/src/css/mobile.css index 21404d8da..7ac7e3413 100644 --- a/src/css/mobile.css +++ b/src/css/mobile.css @@ -687,3 +687,22 @@ a.pin-button:active { opacity: 0; } +.tab-view { + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + width:100%; + position: absolute; +} + +.tab-in { + -webkit-transform: translate3d(0, 0, 0) !important; + transform: translate3d(0, 0, 0) !important; +} + +.tab-out { + -webkit-transform: translate3d(-100%, 0, 0) !important; + transform: translate3d(-100%, 0, 0) !important; +} + + + From faea6dfb6d340f0f07555b2a0ac35fa17a196907 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 23 Apr 2015 13:12:30 -0300 Subject: [PATCH 03/10] rm ng class --- public/views/includes/menu.html | 2 +- public/views/walletHome.html | 8 ++++---- src/js/controllers/index.js | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/public/views/includes/menu.html b/public/views/includes/menu.html index e9f651a10..d1cf44609 100644 --- a/public/views/includes/menu.html +++ b/public/views/includes/menu.html @@ -1,7 +1,7 @@
-
diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 38502a396..ac397e499 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -1,7 +1,7 @@
-
+
@@ -119,7 +119,7 @@ receive --> -
+
@@ -191,7 +191,7 @@ send --> -
+

@@ -337,7 +337,7 @@ history --> -
+
diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 310ae7388..3ca87ad9d 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -102,6 +102,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); }; + self.setTab = function(tab) { + document.getElementById(self.tab).className='tab-out tab-view ' + self.tab; + document.getElementById(tab).className='tab-in tab-view ' + tab; + self.tab = tab; + }; + self.updateAll = function(walletStatus) { var get = function(cb) { if (walletStatus) From ea7484512f4bca1c91e7b635e5fc11addb49306c Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 23 Apr 2015 14:12:32 -0300 Subject: [PATCH 04/10] rm fastclick --- Gruntfile.js | 1 - bower.json | 1 - public/views/includes/menu.html | 3 +-- public/views/walletHome.html | 3 +++ src/js/controllers/index.js | 12 +++++++++++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 14a621b13..005e0e602 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -78,7 +78,6 @@ module.exports = function(grunt) { }, angular: { src: [ - 'bower_components/fastclick/lib/fastclick.js', 'bower_components/qrcode-generator/js/qrcode.js', 'bower_components/qrcode-decoder-js/lib/qrcode-decoder.js', 'bower_components/moment/min/moment-with-locales.js', diff --git a/bower.json b/bower.json index 87666e046..d90c214cb 100644 --- a/bower.json +++ b/bower.json @@ -21,7 +21,6 @@ "angular-bitcore-wallet-client": "^0.0.18", "angular-ui-router": "~0.2.13", "qrcode-decoder-js": "*", - "fastclick": "*", "angular-ui-switch": "~0.1.0" }, "resolutions": { diff --git a/public/views/includes/menu.html b/public/views/includes/menu.html index d1cf44609..f9d0c767d 100644 --- a/public/views/includes/menu.html +++ b/public/views/includes/menu.html @@ -1,8 +1,7 @@
- +
{{item.title|translate}} diff --git a/public/views/walletHome.html b/public/views/walletHome.html index ac397e499..407ca21d9 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -338,6 +338,8 @@ history -->
+ +
@@ -401,6 +403,7 @@ history
+
diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 3ca87ad9d..4536f0f60 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -13,7 +13,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.menu = [{ 'title': 'Home', 'icon': 'icon-home', - 'link': 'walletHome' + 'link': 'walletHome', + 'active': true, }, { 'title': 'Receive', 'icon': 'icon-receive', @@ -105,6 +106,15 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.setTab = function(tab) { document.getElementById(self.tab).className='tab-out tab-view ' + self.tab; document.getElementById(tab).className='tab-in tab-view ' + tab; + + var old =document.getElementById('menu-'+self.tab); + old.className=''; + old.style.borderTopColor = ''; + + var newe = document.getElementById('menu-'+tab); + newe.className='active'; + newe.style.borderTopColor = self.backgroundColor; + self.tab = tab; }; From e899eb969691a878763775187f9c366bed3ce190 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 23 Apr 2015 14:37:36 -0300 Subject: [PATCH 05/10] Fix wallethome --- public/views/walletHome.html | 195 +++++++++++++++++------------------ src/css/mobile.css | 6 +- 2 files changed, 98 insertions(+), 103 deletions(-) diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 407ca21d9..9d5cc2161 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -1,119 +1,114 @@ -
-
- -
-
-
-
- Could not update Wallet -
Tap to retry -
- -
- Scan status finished with error -
Tap to retry -
- -
-
- {{index.totalBalanceStr}} +
+
+
+
+
+
+ Could not update Wallet +
Tap to retry
-
- + +
+ Scan status finished with error +
Tap to retry +
+ +
+ {{index.totalBalanceStr}} +
{{index.totalBalanceAlternative}} {{index.alternativeIsoCode}} - +
+
+
+ +
+
+ ...
- -
-
- ... +
+
{{index.walletName | limitTo: 1}}
+ +
+

+ {{index.m}} of {{index.n}} +

+
+ Multisignature wallet + Personal Wallet + - Testnet +
+
-
-
{{index.walletName | limitTo: 1}}
-
- -
- Opening Wallet... - Updating Status... - Updating Balance... - Updating Pending Transactions... - Scanning Wallet funds... - Recreating Wallet on BWS... -
- -
-
- - - WARNING: Wallet not registered - -
-
- This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information. -
-
- - Recreate - -
-
- - -
-

Spend proposals

-
-
- Total Locked Balance: - {{index.lockedBalance}} {{index.unitName}} - {{index.lockedBalanceAlternative}} - {{index.alternativeIsoCode}} + +
+

Spend proposals

+
+
+ +
+ Total Locked Balance: + {{index.lockedBalance}} {{index.unitName}} + {{index.lockedBalanceAlternative}} + {{index.alternativeIsoCode}} +
+ +
+

No pending spend proposals at the moment.

+
-
-

No pending spend proposals at the moment.

+
+

Unsent transactions

+
+
-
-

Unsent transactions

-
-
-
-
-
- -
@@ -398,7 +396,6 @@ history
-
diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 4536f0f60..cc355f667 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -625,6 +625,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.updateTxHistory(); }); + $rootScope.$on('Local/SetTab', function(event, tab) { + self.setTab(tab); + }); + + + $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) { self.askPassword = { isSetup: isSetup, diff --git a/src/js/controllers/topbar.js b/src/js/controllers/topbar.js index 8b78686f4..868c059d1 100644 --- a/src/js/controllers/topbar.js +++ b/src/js/controllers/topbar.js @@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('topbarController', function($ }, 100); alert('Scanning error'); }); - go.send(); + $scope.$emit('Local/SetTab', 'send'); }; var modalOpenScanner = function() { @@ -79,7 +79,7 @@ angular.module('copayApp.controllers').controller('topbarController', function($ $scope.init = function() { setScanner(); $timeout(function() { - go.send(); + $scope.$emit('Local/SetTab', 'send'); canvas = document.getElementById('qr-canvas'); context = canvas.getContext('2d'); diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index d2d3a0b62..fa66648b0 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService) { +angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp) { var self = this; $rootScope.hideMenuBar = false; @@ -25,11 +25,13 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi this.isMobile = isMobile.any(); var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) { + $scope.$emit('Local/SetTab', 'send'); self.setForm(data); }); var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) { $timeout(function() { + $scope.$emit('Local/SetTab', 'send'); self.setForm(uri); }, 100); }); diff --git a/src/js/services/go.js b/src/js/services/go.js index 331aa4a0d..8bdaf2cdc 100644 --- a/src/js/services/go.js +++ b/src/js/services/go.js @@ -66,10 +66,6 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, $state.go('add'); }; - root.send = function() { - $state.go('send'); - }; - root.preferences = function() { $state.go('preferences'); }; From 1515b9446fefca8578a1e064ddb6714886b0f36b Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 23 Apr 2015 15:19:30 -0300 Subject: [PATCH 08/10] fix send --- src/js/controllers/index.js | 35 +++++++++++++++++--------------- src/js/controllers/topbar.js | 4 ++-- src/js/controllers/walletHome.js | 20 +++++++++++------- src/js/services/go.js | 7 +++++++ 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index cc355f667..dcd6495c9 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r var self = this; self.isCordova = isCordova; self.onGoingProcess = {}; - self.limitHistory = 5; + self.limitHistory = 5; function strip(number) { return (parseFloat(number.toPrecision(12))); @@ -27,7 +27,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r 'title': 'History', 'icon': 'icon-history', 'link': 'history' - }]; + }]; self.tab = 'walletHome'; @@ -104,18 +104,22 @@ angular.module('copayApp.controllers').controller('indexController', function($r }; self.setTab = function(tab) { - document.getElementById(self.tab).className='tab-out tab-view ' + self.tab; - document.getElementById(tab).className='tab-in tab-view ' + tab; + if (self.tab && document.getElementById(self.tab)) { + document.getElementById(self.tab).className = 'tab-out tab-view ' + self.tab; + var old = document.getElementById('menu-' + self.tab); + old.className = ''; + old.style.borderTopColor = ''; + } - var old =document.getElementById('menu-'+self.tab); - old.className=''; - old.style.borderTopColor = ''; - - var newe = document.getElementById('menu-'+tab); - newe.className='active'; - newe.style.borderTopColor = self.backgroundColor; + if (document.getElementById(tab)) { + document.getElementById(tab).className = 'tab-in tab-view ' + tab; + var newe = document.getElementById('menu-' + tab); + newe.className = 'active'; + newe.style.borderTopColor = self.backgroundColor; + } self.tab = tab; + $rootScope.$emit('Local/TabChanged', tab); }; self.updateAll = function(walletStatus) { @@ -472,8 +476,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r gettextCatalog.setCurrentLanguage(userLang); amMoment.changeLocale(userLang); } - } - else { + } else { configService.set({ wallet: { settings: { @@ -486,7 +489,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); } self.defaultLanguageIsoCode = setLang || userLang; - self.defaultLanguageName = lodash.result(lodash.find(self.availableLanguages, { 'isoCode': self.defaultLanguageIsoCode }), 'name'); + self.defaultLanguageName = lodash.result(lodash.find(self.availableLanguages, { + 'isoCode': self.defaultLanguageIsoCode + }), 'name'); }; // UX event handlers @@ -629,8 +634,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.setTab(tab); }); - - $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) { self.askPassword = { isSetup: isSetup, diff --git a/src/js/controllers/topbar.js b/src/js/controllers/topbar.js index 868c059d1..af4f625ed 100644 --- a/src/js/controllers/topbar.js +++ b/src/js/controllers/topbar.js @@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('topbarController', function($ }, 100); alert('Scanning error'); }); - $scope.$emit('Local/SetTab', 'send'); + go.send(); }; var modalOpenScanner = function() { @@ -79,7 +79,7 @@ angular.module('copayApp.controllers').controller('topbarController', function($ $scope.init = function() { setScanner(); $timeout(function() { - $scope.$emit('Local/SetTab', 'send'); + go.send(); canvas = document.getElementById('qr-canvas'); context = canvas.getContext('2d'); diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index fa66648b0..7c554574d 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -40,10 +40,23 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi self.getAddress(); }); + + var disableTabListener = $rootScope.$on('Local/TabChanged', function(e,tab){ + switch(tab) { + case 'send': + self.resetError(); + self.setInputs(); + case 'receive': + self.getAddress(); + break; + }; + }); + $scope.$on('$destroy', function() { disableAddrListener(); disableScannerListener(); disablePaymentUriListener(); + disableTabListener(); $rootScope.hideMenuBar = false; }); @@ -765,11 +778,4 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi return actions.hasOwnProperty('create'); }; - // ToDo a send... - this.resetError(); - this.setInputs(); - // Todo Receive - this.getAddress(); - - }); diff --git a/src/js/services/go.js b/src/js/services/go.js index 8bdaf2cdc..931f9fe74 100644 --- a/src/js/services/go.js +++ b/src/js/services/go.js @@ -52,9 +52,16 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, root.path('copayers'); } else { root.path('walletHome'); + $rootScope.$emit('Local/SetTab', 'walletHome'); } }; + + root.send = function() { + root.path('walletHome'); + $rootScope.$emit('Local/SetTab', 'walletHome'); + }; + root.home = function() { if ($rootScope.iden) root.walletHome(); From c769f69c4e571f8200bdeefb36d6622798382511 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 23 Apr 2015 15:32:11 -0300 Subject: [PATCH 09/10] fix send --- src/js/controllers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index dcd6495c9..e870fdac3 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -245,8 +245,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.openWallet = function() { var fc = profileService.focusedClient; self.updateColor(); - $rootScope.$apply(); $timeout(function() { + $rootScope.$apply(); self.setOngoingProcess('openingWallet', true); self.updateError = false; fc.openWallet(function(err, walletStatus) { From cd901f5b3ecc9e6579d27fc16d81cb9ecdc082fb Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 23 Apr 2015 16:17:18 -0300 Subject: [PATCH 10/10] only show matching network wallet in payment intents --- public/views/paymentUri.html | 7 +- src/js/controllers/index.js | 15 +++- src/js/controllers/paymentUri.js | 115 ++++++++++++++++--------------- src/js/services/go.js | 17 +++-- 4 files changed, 88 insertions(+), 66 deletions(-) diff --git a/public/views/paymentUri.html b/public/views/paymentUri.html index 8c201128f..528000cb9 100644 --- a/public/views/paymentUri.html +++ b/public/views/paymentUri.html @@ -9,15 +9,18 @@
Address: {{uri.address.toString()}}
Amount: {{uri.amount}}
Message: {{uri.message}}
+
Network: {{uri.network}}

Select a wallet

-
    + diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index e870fdac3..b53b798c5 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -104,11 +104,20 @@ angular.module('copayApp.controllers').controller('indexController', function($r }; self.setTab = function(tab) { - if (self.tab && document.getElementById(self.tab)) { + + if (self.tab === tab) + return; + + if (!self.tab) + self.tab = 'walletHome'; + + if (document.getElementById(self.tab)) { document.getElementById(self.tab).className = 'tab-out tab-view ' + self.tab; var old = document.getElementById('menu-' + self.tab); - old.className = ''; - old.style.borderTopColor = ''; + if (old) { + old.className = ''; + old.style.borderTopColor = ''; + } } if (document.getElementById(tab)) { diff --git a/src/js/controllers/paymentUri.js b/src/js/controllers/paymentUri.js index 974e966ca..2dac95c32 100644 --- a/src/js/controllers/paymentUri.js +++ b/src/js/controllers/paymentUri.js @@ -1,63 +1,68 @@ 'use strict'; -angular.module('copayApp.controllers').controller('paymentUriController', - function($rootScope, $stateParams, $location, $timeout, profileService, configService, lodash, bitcore, go) { +angular.module('copayApp.controllers').controller('paymentUriController', + function($rootScope, $stateParams, $location, $timeout, profileService, configService, lodash, bitcore, go) { - function strip(number) { - return (parseFloat(number.toPrecision(12))); - }; + function strip(number) { + return (parseFloat(number.toPrecision(12))); + }; - // Build bitcoinURI with querystring - this.checkBitcoinUri = function() { - var query = []; - angular.forEach($location.search(), function(value, key) { - query.push(key + "=" + value); - }); - var queryString = query ? query.join("&") : null; - this.bitcoinURI = $stateParams.data + ( queryString ? '?' + queryString : ''); + // Build bitcoinURI with querystring + this.checkBitcoinUri = function() { + var query = []; + angular.forEach($location.search(), function(value, key) { + query.push(key + "=" + value); + }); + var queryString = query ? query.join("&") : null; + this.bitcoinURI = $stateParams.data + (queryString ? '?' + queryString : ''); - var URI = bitcore.URI; - var isUriValid = URI.isValid(this.bitcoinURI); - if (!URI.isValid(this.bitcoinURI)) { - this.error = true; - return; - } - var uri = new URI(this.bitcoinURI); + var URI = bitcore.URI; + var isUriValid = URI.isValid(this.bitcoinURI); + if (!URI.isValid(this.bitcoinURI)) { + this.error = true; + return; + } + var uri = new URI(this.bitcoinURI); - if (uri && uri.address) { - var config = configService.getSync().wallet.settings; - var unitToSatoshi = config.unitToSatoshi; - var satToUnit = 1 / unitToSatoshi; - var unitName = config.unitName; + if (uri && uri.address) { + var config = configService.getSync().wallet.settings; + var unitToSatoshi = config.unitToSatoshi; + var satToUnit = 1 / unitToSatoshi; + var unitName = config.unitName; - uri.amount = strip(uri.amount * satToUnit) + ' ' + unitName; - return uri; - } - }; + uri.amount = strip(uri.amount * satToUnit) + ' ' + unitName; + uri.network = uri.address.network.name; + return uri; + } + }; - this.getWallets = function() { - if (!profileService.profile) return; - var config = configService.getSync(); - config.colorFor = config.colorFor || {}; - var ret = lodash.map(profileService.profile.credentials, function(c) { - return { - m: c.m, - n: c.n, - name: c.walletName, - id: c.walletId, - color: config.colorFor[c.walletId] || '#2C3E50' - }; - }); - return lodash.sortBy(ret, 'walletName'); - }; + this.getWallets = function(network) { + if (!profileService.profile) return; + var config = configService.getSync(); + config.colorFor = config.colorFor || {}; + var ret = lodash.map(profileService.profile.credentials, function(c) { + return { + m: c.m, + n: c.n, + name: c.walletName, + id: c.walletId, + network: c.network, + color: config.colorFor[c.walletId] || '#2C3E50' + }; + }); + ret = lodash.filter(ret, function(w) { + return (w.network == network); + }); + return lodash.sortBy(ret, 'walletName'); + }; - this.selectWallet = function(wid) { - var self = this; - if (wid != profileService.focusedClient.credentials.walletId) { - profileService.setAndStoreFocus(wid, function() {}); - } - go.send(); - $timeout(function() { - $rootScope.$emit('paymentUri', self.bitcoinURI); - }, 100); - }; - }); + this.selectWallet = function(wid) { + var self = this; + if (wid != profileService.focusedClient.credentials.walletId) { + profileService.setAndStoreFocus(wid, function() {}); + } + go.send(); + $timeout(function() { + $rootScope.$emit('paymentUri', self.bitcoinURI); + }, 100); + }; + }); diff --git a/src/js/services/go.js b/src/js/services/go.js index 931f9fe74..71482e8c9 100644 --- a/src/js/services/go.js +++ b/src/js/services/go.js @@ -36,8 +36,11 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, var ref = window.open(url, '_blank', 'location=no'); }; - root.path = function(path) { - $state.transitionTo(path); + root.path = function(path, cb) { + $state.transitionTo(path) + .then(function() { + if (cb) return cb(); + }); hideSidebars(); }; @@ -51,15 +54,17 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, if (fc && !fc.isComplete()) { root.path('copayers'); } else { - root.path('walletHome'); - $rootScope.$emit('Local/SetTab', 'walletHome'); + root.path('walletHome', function() { + $rootScope.$emit('Local/SetTab', 'walletHome'); + }); } }; root.send = function() { - root.path('walletHome'); - $rootScope.$emit('Local/SetTab', 'walletHome'); + root.path('walletHome', function() { + $rootScope.$emit('Local/SetTab', 'send'); + }); }; root.home = function() {