Skip to content

Commit

Permalink
#30 final tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
orweinberger committed Mar 13, 2015
1 parent acb2e8a commit 8d9df0e
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 52 deletions.
10 changes: 10 additions & 0 deletions app/www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', '
}
})

.state('tab.rootinfo', {
url: '/rootinfo',
views: {
'tab-rootinfo': {
templateUrl: 'templates/tab-rootinfo.html',
controller: 'rootinfoCtrl'
}
}
})

.state('tab.persona', {
url: '/persona',
views: {
Expand Down
132 changes: 82 additions & 50 deletions app/www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,51 @@ angular.module('starter.controllers', [])
$state.go('tab.pocket-details', {pocketName: pocketName});
};

$scope.editPocket = function(pocketName) {
console.log(pocketName);
engine.pockets.get({name: pocketName}).then(function(result) {
$scope.spend = function () {
$scope.data = {};
var myPopup = $ionicPopup.show({
template: '<div class="list">' +
'<label class="item item-input item-select">' +
'<span class="input-label">Spend from</span>' +
'<select ng-model="data.pocket">' +
'<option ng-repeat="(key, pocket) in pockets.pockets" value="{{pocket.name}}">{{pocket.name}}</option>' +
'</select>' +
'</label>' +
'<label class="item item-input">' +
'<span class="input-label">Amount</span>' +
'<input ng-model="data.amount" type="number" placeholder="0.01">' +
'</label>' +
'<label class="item item-input">' +
'<span class="input-label">To address</span>' +
'<input ng-model="data.toAddress" type="text" placeholder="0.01">' +
'</label>' +
'<br><div style="text-align:center"><button class="btn btn-primary" ng-click="scanQR()">Scan</button></div>' +
'</div>',
title: 'Send money',
scope: $scope,
buttons: [
{text: 'Cancel'},
{
text: '<b>Send</b>',
type: 'button-positive',
onTap: function (e) {
if (!$scope.data) {
//don't allow the user to close unless he enters wifi password
e.preventDefault();
} else {
return $scope.result;
}
}
}
]
});
myPopup.then(function (res) {
console.log($scope.data);
});
};

$scope.editPocket = function (pocketName) {
engine.pockets.get({name: pocketName}).then(function (result) {
$scope.result = result;
var myPopup = $ionicPopup.show({
template: '<div class="list">' +
Expand Down Expand Up @@ -163,12 +205,12 @@ angular.module('starter.controllers', [])
'<input ng-model="result.limit" type="number" placeholder="1">' +
'</label>' +
'</div>',
title: 'Add a new pocket',
title: 'Edit pocket',
scope: $scope,
buttons: [
{text: 'Cancel'},
{
text: '<b>Add</b>',
text: '<b>Save</b>',
type: 'button-positive',
onTap: function (e) {
if (!$scope.result) {
Expand All @@ -182,18 +224,14 @@ angular.module('starter.controllers', [])
]
});
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('')
engine.pockets.update(res).then(function () {

}).error(function (err) {
if (err)
throw err;
if (err) throw err;
});
*/

});
}).error(function(err) {
}).error(function (err) {
if (err)
throw err;
});
Expand Down Expand Up @@ -286,22 +324,14 @@ angular.module('starter.controllers', [])
});
};
$scope.rootInfo = function () {
var myPopup = $ionicPopup.show({
template: '<div>QR</div>',
title: 'Info',
scope: $scope,
buttons: [
{
text: '<b>OK</b>',
type: 'button-positive'
}
]
});
myPopup.then(function (res) {
$state.go('tab.rootinfo');
}
})

});
};
.controller('rootinfoCtrl', function ($scope) {
console.log('in root');
})

.controller('pocketDetailsCtrl', function ($scope, $state, $ionicPopup, $stateParams, $cordovaBarcodeScanner) {
engine.pockets.get({name: $stateParams.pocketName}).then(function (result) {
$scope.pockets = result;
Expand All @@ -326,7 +356,7 @@ angular.module('starter.controllers', [])
'<input ng-model="data.toAddress" type="text" placeholder="0.01">' +
'</label>' +
'<br><div style="text-align:center"><button class="btn btn-primary" ng-click="scanQR()">Scan</button></div>',
title: 'Info',
title: 'Spend from ' + $scope.pockets.name,
scope: $scope,
buttons: [
{text: 'Cancel'},
Expand All @@ -337,27 +367,29 @@ angular.module('starter.controllers', [])
]
});
myPopup.then(function (res) {
engine.bitcoin.sendMoney({
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);
if (res) {
engine.bitcoin.sendMoney({
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);
}
});
};
})
Expand Down
4 changes: 2 additions & 2 deletions app/www/templates/tab-pockets.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<div ng-if="pockets.name != 'root'">
<div style="position:absolute;top:50px; right: 8px;">
<button type="button" ng-click="editPocket('{{pockets.name}}')" class="btn btn-primary btn-rootinfo btn-circle btn-lg"><i
<button type="button" ng-click="editPocket(pockets.name)" data-pocketName="{{pockets.name}}" class="btn btn-primary btn-rootinfo btn-circle btn-lg"><i
class="fa fa-pencil"></i></button>
</div>
</div>
Expand All @@ -33,6 +33,6 @@
class="fa fa-plus"></i></button>
</div>
<div style="position:absolute;bottom:8px; left: 8px;">
<button type="button" class="btn btn-primary btn-spend btn-circle btn-lg"><i class="fa fa-bitcoin"></i></button>
<button type="button" ng-click="spend()" class="btn btn-primary btn-spend btn-circle btn-lg"><i class="fa fa-bitcoin"></i></button>
</div>
</ion-view>
7 changes: 7 additions & 0 deletions app/www/templates/tab-rootinfo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ion-view view-title="Parent wallet info">
<ion-content class="padding">
<div style="text-align:center;padding-top:50px;">
root info
</div>
</ion-content>
</ion-view>
6 changes: 6 additions & 0 deletions app/www/templates/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<ion-nav-view name="tab-home"></ion-nav-view>
</ion-tab>


<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/rootinfo">
<ion-nav-view name="tab-rootinfo"></ion-nav-view>
</ion-tab>


<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/persona">
<ion-nav-view name="tab-persona"></ion-nav-view>
</ion-tab>
Expand Down

0 comments on commit 8d9df0e

Please sign in to comment.