Skip to content

Commit 8d9df0e

Browse files
committed
#30 final tweaks
1 parent acb2e8a commit 8d9df0e

File tree

5 files changed

+107
-52
lines changed

5 files changed

+107
-52
lines changed

app/www/js/app.js

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', '
4848
}
4949
})
5050

51+
.state('tab.rootinfo', {
52+
url: '/rootinfo',
53+
views: {
54+
'tab-rootinfo': {
55+
templateUrl: 'templates/tab-rootinfo.html',
56+
controller: 'rootinfoCtrl'
57+
}
58+
}
59+
})
60+
5161
.state('tab.persona', {
5262
url: '/persona',
5363
views: {

app/www/js/controllers.js

+82-50
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,51 @@ angular.module('starter.controllers', [])
126126
$state.go('tab.pocket-details', {pocketName: pocketName});
127127
};
128128

129-
$scope.editPocket = function(pocketName) {
130-
console.log(pocketName);
131-
engine.pockets.get({name: pocketName}).then(function(result) {
129+
$scope.spend = function () {
130+
$scope.data = {};
131+
var myPopup = $ionicPopup.show({
132+
template: '<div class="list">' +
133+
'<label class="item item-input item-select">' +
134+
'<span class="input-label">Spend from</span>' +
135+
'<select ng-model="data.pocket">' +
136+
'<option ng-repeat="(key, pocket) in pockets.pockets" value="{{pocket.name}}">{{pocket.name}}</option>' +
137+
'</select>' +
138+
'</label>' +
139+
'<label class="item item-input">' +
140+
'<span class="input-label">Amount</span>' +
141+
'<input ng-model="data.amount" type="number" placeholder="0.01">' +
142+
'</label>' +
143+
'<label class="item item-input">' +
144+
'<span class="input-label">To address</span>' +
145+
'<input ng-model="data.toAddress" type="text" placeholder="0.01">' +
146+
'</label>' +
147+
'<br><div style="text-align:center"><button class="btn btn-primary" ng-click="scanQR()">Scan</button></div>' +
148+
'</div>',
149+
title: 'Send money',
150+
scope: $scope,
151+
buttons: [
152+
{text: 'Cancel'},
153+
{
154+
text: '<b>Send</b>',
155+
type: 'button-positive',
156+
onTap: function (e) {
157+
if (!$scope.data) {
158+
//don't allow the user to close unless he enters wifi password
159+
e.preventDefault();
160+
} else {
161+
return $scope.result;
162+
}
163+
}
164+
}
165+
]
166+
});
167+
myPopup.then(function (res) {
168+
console.log($scope.data);
169+
});
170+
};
171+
172+
$scope.editPocket = function (pocketName) {
173+
engine.pockets.get({name: pocketName}).then(function (result) {
132174
$scope.result = result;
133175
var myPopup = $ionicPopup.show({
134176
template: '<div class="list">' +
@@ -163,12 +205,12 @@ angular.module('starter.controllers', [])
163205
'<input ng-model="result.limit" type="number" placeholder="1">' +
164206
'</label>' +
165207
'</div>',
166-
title: 'Add a new pocket',
208+
title: 'Edit pocket',
167209
scope: $scope,
168210
buttons: [
169211
{text: 'Cancel'},
170212
{
171-
text: '<b>Add</b>',
213+
text: '<b>Save</b>',
172214
type: 'button-positive',
173215
onTap: function (e) {
174216
if (!$scope.result) {
@@ -182,18 +224,14 @@ angular.module('starter.controllers', [])
182224
]
183225
});
184226
myPopup.then(function (res) {
185-
console.log(res);
186-
/*
187-
$scope.newpocket.hard_ratio = $scope.newpocket.hard_ratio / 100;
188-
engine.pockets.create($scope.newpocket).then(function () {
189-
//$state.go('')
227+
engine.pockets.update(res).then(function () {
228+
190229
}).error(function (err) {
191-
if (err)
192-
throw err;
230+
if (err) throw err;
193231
});
194-
*/
232+
195233
});
196-
}).error(function(err) {
234+
}).error(function (err) {
197235
if (err)
198236
throw err;
199237
});
@@ -286,22 +324,14 @@ angular.module('starter.controllers', [])
286324
});
287325
};
288326
$scope.rootInfo = function () {
289-
var myPopup = $ionicPopup.show({
290-
template: '<div>QR</div>',
291-
title: 'Info',
292-
scope: $scope,
293-
buttons: [
294-
{
295-
text: '<b>OK</b>',
296-
type: 'button-positive'
297-
}
298-
]
299-
});
300-
myPopup.then(function (res) {
327+
$state.go('tab.rootinfo');
328+
}
329+
})
301330

302-
});
303-
};
331+
.controller('rootinfoCtrl', function ($scope) {
332+
console.log('in root');
304333
})
334+
305335
.controller('pocketDetailsCtrl', function ($scope, $state, $ionicPopup, $stateParams, $cordovaBarcodeScanner) {
306336
engine.pockets.get({name: $stateParams.pocketName}).then(function (result) {
307337
$scope.pockets = result;
@@ -326,7 +356,7 @@ angular.module('starter.controllers', [])
326356
'<input ng-model="data.toAddress" type="text" placeholder="0.01">' +
327357
'</label>' +
328358
'<br><div style="text-align:center"><button class="btn btn-primary" ng-click="scanQR()">Scan</button></div>',
329-
title: 'Info',
359+
title: 'Spend from ' + $scope.pockets.name,
330360
scope: $scope,
331361
buttons: [
332362
{text: 'Cancel'},
@@ -337,27 +367,29 @@ angular.module('starter.controllers', [])
337367
]
338368
});
339369
myPopup.then(function (res) {
340-
engine.bitcoin.sendMoney({
341-
from: {
342-
name: $scope.pockets.name,
343-
wallet: {
344-
address: $scope.pockets.wallet.address,
345-
key: $scope.pockets.wallet.key
346-
}
347-
},
348-
to: {
349-
name: 'test',
350-
wallet: {
351-
address: $scope.data.toAddress
352-
}
353-
},
354-
amount: $scope.data.amount
355-
}).then(function (result) {
356-
console.log(result);
357-
}).error(function (err) {
358-
console.log(err);
359-
});
360-
console.log($scope.pockets.name, $scope.data.toAddress, $scope.data.amount);
370+
if (res) {
371+
engine.bitcoin.sendMoney({
372+
from: {
373+
name: $scope.pockets.name,
374+
wallet: {
375+
address: $scope.pockets.wallet.address,
376+
key: $scope.pockets.wallet.key
377+
}
378+
},
379+
to: {
380+
name: 'test',
381+
wallet: {
382+
address: $scope.data.toAddress
383+
}
384+
},
385+
amount: $scope.data.amount
386+
}).then(function (result) {
387+
console.log(result);
388+
}).error(function (err) {
389+
console.log(err);
390+
});
391+
console.log($scope.pockets.name, $scope.data.toAddress, $scope.data.amount);
392+
}
361393
});
362394
};
363395
})

app/www/templates/tab-pockets.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<div ng-if="pockets.name != 'root'">
2525
<div style="position:absolute;top:50px; right: 8px;">
26-
<button type="button" ng-click="editPocket('{{pockets.name}}')" class="btn btn-primary btn-rootinfo btn-circle btn-lg"><i
26+
<button type="button" ng-click="editPocket(pockets.name)" data-pocketName="{{pockets.name}}" class="btn btn-primary btn-rootinfo btn-circle btn-lg"><i
2727
class="fa fa-pencil"></i></button>
2828
</div>
2929
</div>
@@ -33,6 +33,6 @@
3333
class="fa fa-plus"></i></button>
3434
</div>
3535
<div style="position:absolute;bottom:8px; left: 8px;">
36-
<button type="button" class="btn btn-primary btn-spend btn-circle btn-lg"><i class="fa fa-bitcoin"></i></button>
36+
<button type="button" ng-click="spend()" class="btn btn-primary btn-spend btn-circle btn-lg"><i class="fa fa-bitcoin"></i></button>
3737
</div>
3838
</ion-view>

app/www/templates/tab-rootinfo.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<ion-view view-title="Parent wallet info">
2+
<ion-content class="padding">
3+
<div style="text-align:center;padding-top:50px;">
4+
root info
5+
</div>
6+
</ion-content>
7+
</ion-view>

app/www/templates/tabs.html

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
<ion-nav-view name="tab-home"></ion-nav-view>
1111
</ion-tab>
1212

13+
14+
<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/rootinfo">
15+
<ion-nav-view name="tab-rootinfo"></ion-nav-view>
16+
</ion-tab>
17+
18+
1319
<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/persona">
1420
<ion-nav-view name="tab-persona"></ion-nav-view>
1521
</ion-tab>

0 commit comments

Comments
 (0)