From 6874fc60afb1b73a7426e29808a77c31f68cea29 Mon Sep 17 00:00:00 2001 From: orweinberger Date: Fri, 13 Mar 2015 10:42:52 +0200 Subject: [PATCH 1/4] #27 Progress with spend --- www/js/controllers.js | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index aadd46f..843be91 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -235,7 +235,7 @@ angular.module('starter.controllers', []) }); $scope.scanQR = function () { $cordovaBarcodeScanner.scan().then(function (imageData) { - $scope.toAddress = imageData.text; + $scope.data.toAddress = imageData.text; }, function (error) { console.log("An error happened -> " + error); }); @@ -247,18 +247,48 @@ angular.module('starter.controllers', []) 'Amount' + '' + '' + - '
Scan

', + '' + + '
', title: 'Info', scope: $scope, buttons: [ + {text: 'Cancel'}, { - text: 'OK', + text: 'Send!', type: 'button-positive' } ] }); myPopup.then(function (res) { - console.log($scope.pockets.name, $scope.toAddress, $scope.amount); + + engine.bitcoin.handleTransaction({ + transactions: [ + { + from: { + name: $scope.pockets.name, + wallet: { + address: $scope.pockets.wallet.address, + key: $scope.pockets.wallet.key + } + }, + to: { + name: 'test', + wallet: { + address: $scope.data.toAddress + } + }, + amount: $scope.data.amount + } + ] + }).then(function (result) { + console.log(result); + }).error(function (err) { + console.log(err); + }) + console.log($scope.pockets.name, $scope.data.toAddress, $scope.data.amount); }); }; }) From 07cd077dc94139a8301fab02dfe210b9ca12a8eb Mon Sep 17 00:00:00 2001 From: orweinberger Date: Fri, 13 Mar 2015 10:53:39 +0200 Subject: [PATCH 2/4] Progress --- www/js/controllers.js | 2 +- www/templates/tab-pocket-details.html | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index 843be91..3d1468f 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -264,7 +264,7 @@ angular.module('starter.controllers', []) }); myPopup.then(function (res) { - engine.bitcoin.handleTransaction({ + engine.bitcoin.sendMoney({ transactions: [ { from: { diff --git a/www/templates/tab-pocket-details.html b/www/templates/tab-pocket-details.html index e480d31..9e7f4ac 100644 --- a/www/templates/tab-pocket-details.html +++ b/www/templates/tab-pocket-details.html @@ -1,6 +1,7 @@ - + -
+

{{pockets.wallet.balance}} BTC

+

From 2fe8033357071cb780cdee021c79dfd6d16d726b Mon Sep 17 00:00:00 2001 From: orweinberger Date: Fri, 13 Mar 2015 11:36:56 +0200 Subject: [PATCH 3/4] Improved pocket details page --- www/js/controllers.js | 36 +++++++++++++++------------------- www/js/directives.js | 8 +++++--- www/templates/tab-pockets.html | 9 ++++++--- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index 3d1468f..af15e77 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -113,7 +113,7 @@ angular.module('starter.controllers', []) } $scope.pockets = result; - console.log(result); + $scope.$digest(); }).error(function (err) { if (err) throw err; @@ -263,36 +263,32 @@ angular.module('starter.controllers', []) ] }); myPopup.then(function (res) { - engine.bitcoin.sendMoney({ - transactions: [ - { - from: { - name: $scope.pockets.name, - wallet: { - address: $scope.pockets.wallet.address, - key: $scope.pockets.wallet.key - } - }, - to: { - name: 'test', - wallet: { - address: $scope.data.toAddress - } - }, - amount: $scope.data.amount + from: { + name: $scope.pockets.name, + wallet: { + address: $scope.pockets.wallet.address, + key: $scope.pockets.wallet.key + } + }, + to: { + name: 'test', + wallet: { + address: $scope.data.toAddress } - ] + }, + amount: $scope.data.amount }).then(function (result) { console.log(result); }).error(function (err) { console.log(err); - }) + }); console.log($scope.pockets.name, $scope.data.toAddress, $scope.data.amount); }); }; }) .controller('DashCtrl', function ($scope) { + }) .controller('ChatsCtrl', function ($scope, Chats) { diff --git a/www/js/directives.js b/www/js/directives.js index d278136..862856d 100644 --- a/www/js/directives.js +++ b/www/js/directives.js @@ -2,17 +2,19 @@ angular.module('starter.directives', []) .directive('qrcode', function () { function link(scope, element, attrs) { var handled = false; - scope.$watch(function() { - if (scope.pockets && !handled) { + scope.$watch(function () { + if (scope.pockets && scope.pockets.wallet && scope.pockets.wallet.address && !handled) { handled = true; - new QRCode(document.getElementById("qrcode"), scope.pockets.wallet.address); + new QRCode(element[0], scope.pockets.wallet.address); } }); } + return { restrict: 'E', template: '
', link: link, + replace: true, scope: "=" }; }); \ No newline at end of file diff --git a/www/templates/tab-pockets.html b/www/templates/tab-pockets.html index c541ecf..aaac797 100644 --- a/www/templates/tab-pockets.html +++ b/www/templates/tab-pockets.html @@ -14,10 +14,13 @@
-
- +
+
+ +
+
From aa1c5b55074ce4c02207b6da5abcc3b0d31521dc Mon Sep 17 00:00:00 2001 From: orweinberger Date: Fri, 13 Mar 2015 11:51:35 +0200 Subject: [PATCH 4/4] Progress with pocket edit --- www/js/controllers.js | 74 ++++++++++++++++++++++++++++++++++ www/templates/tab-pockets.html | 7 ++++ 2 files changed, 81 insertions(+) diff --git a/www/js/controllers.js b/www/js/controllers.js index af15e77..cda2ecf 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -125,6 +125,80 @@ angular.module('starter.controllers', []) else $state.go('tab.pocket-details', {pocketName: pocketName}); }; + + $scope.editPocket = function(pocketName) { + console.log(pocketName); + engine.pockets.get({name: pocketName}).then(function(result) { + $scope.result = result; + var myPopup = $ionicPopup.show({ + template: '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '
', + title: 'Add a new pocket', + scope: $scope, + buttons: [ + {text: 'Cancel'}, + { + text: 'Add', + type: 'button-positive', + onTap: function (e) { + if (!$scope.result) { + //don't allow the user to close unless he enters wifi password + e.preventDefault(); + } else { + return $scope.result; + } + } + } + ] + }); + myPopup.then(function (res) { + console.log(res); + /* + $scope.newpocket.hard_ratio = $scope.newpocket.hard_ratio / 100; + engine.pockets.create($scope.newpocket).then(function () { + //$state.go('') + }).error(function (err) { + if (err) + throw err; + }); + */ + }); + }).error(function(err) { + if (err) + throw err; + }); + }; + $scope.pocketHold = function (pocketName) { var myPopup = $ionicPopup.alert({ template: "
Delete?
", diff --git a/www/templates/tab-pockets.html b/www/templates/tab-pockets.html index aaac797..b786054 100644 --- a/www/templates/tab-pockets.html +++ b/www/templates/tab-pockets.html @@ -21,6 +21,13 @@
+
+
+ +
+
+