Improves buy page

This commit is contained in:
Gustavo Maximiliano Cortez 2015-09-07 13:35:59 -03:00
commit 693b0da4a2
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
3 changed files with 78 additions and 37 deletions

View file

@ -6,6 +6,20 @@
<div class="content glidera p20v" ng-controller="buyGlideraController as buy"> <div class="content glidera p20v" ng-controller="buyGlideraController as buy">
<div class="onGoingProcess" ng-show="buy.loading">
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<span translate>Sending request to Glidera...</span>
</div>
</div>
<div class="row"> <div class="row">
<div class="columns"> <div class="columns">
<div ng-show="!buy.show2faCodeInput && !buy.success"> <div ng-show="!buy.show2faCodeInput && !buy.success">
@ -26,42 +40,49 @@
ng-click="showAlternative = true; qty = null; buy.buyPrice = null">BTC</a> ng-click="showAlternative = true; qty = null; buy.buyPrice = null">BTC</a>
<a ng-show="showAlternative" class="postfix" <a ng-show="showAlternative" class="postfix"
ng-click="showAlternative = false; fiat = null; buy.buyPrice = null">USD</a> ng-click="showAlternative = false; fiat = null; buy.buyPrice = null">USD</a>
<input class="button dark-gray outline round"
type="submit" value="Continue" ng-disabled="!buy.buyPrice.qty"> <div class="text-center text-gray size-12 m20b" ng-show="buy.buyPrice.qty">
Buy
<span ng-show="qty">${{buy.buyPrice.subtotal}} {{buy.buyPrice.currency}} in Bitcoin</span>
<span ng-show="fiat">{{buy.buyPrice.qty}} BTC</span>
at ${{buy.buyPrice.price}} {{buy.buyPrice.currency}}
</div>
<input class="button dark-gray outline round expand"
type="submit" value="Continue" ng-disabled="!buy.buyPrice.qty || buy.loading">
</div> </div>
</form> </form>
<div class="text-gray size-12 m10b" ng-show="buy.buyPrice.qty">
Buy
<span ng-show="qty">${{buy.buyPrice.subtotal}} {{buy.buyPrice.currency}} in Bitcoin</span>
<span ng-show="fiat">{{buy.buyPrice.qty}} BTC</span>
at ${{buy.buyPrice.price}} {{buy.buyPrice.currency}}
</div>
</div> </div>
<div ng-show="buy.show2faCodeInput && !buy.success"> <div ng-show="buy.show2faCodeInput && !buy.success">
<p class="text-center text-gray"> <p class="text-center text-gray" translate>
The purchase price of ${{buy.buyPrice.price}} USD will be immediately withdrawn from your bank account. The purchase price of ${{buy.buyPrice.price}} {{buy.buyPrice.currency}} will be immediately withdrawn from your bank account.
</p> </p>
<p class="text-center text-gray"> <p class="text-center text-gray" translate>
The total of {{buy.buyPrice.qty}} BTC will be purchased and deposited in your bitcoin wallet ({{index.walletName}}) in 2-4 business days. The total of {{buy.buyPrice.qty}} BTC will be purchased and deposited in your bitcoin wallet ({{index.walletName}}) in 2-4 business days.
</p> </p>
<p class="text-center text-gray">
<form name="buyForm" <form name="buyForm"
ng-submit="buy.sendRequest(index.glideraToken, twoFaCode)" novalidate> ng-submit="buy.sendRequest(index.glideraToken, index.glideraPermissions, twoFaCode)" novalidate>
<label>Enter 2FA Code</label> <label>Enter 2FA Code</label>
<input type="number" ng-model="twoFaCode" required> <input type="number" ng-model="twoFaCode" required>
<input class="button dark-gray outline round" <input class="button dark-gray outline round expand"
type="submit" value="Buy Bitcoin"> type="submit" value="Buy Bitcoin" ng-disabled="buyForm.$invalid || buy.loading">
</form> </form>
</div> </div>
<div ng-show="buy.error && !buy.success" class="text-warning m10b">{{buy.error}}</div> <div class="box-notification" ng-show="buy.error && !buy.success">
<span class="text-warning size-14">
{{buy.error|translate}}
</span>
</div>
<div class="text-center" ng-show="buy.success"> <div class="text-center" ng-show="buy.success">
<h1>Purchase complete</h1> <h1>Purchase complete</h1>
<p class="text-gray"> <p class="text-gray" translate>
A transfer has been initiated from your bank account. Your bitcoin should arrive in your wallet in 4-6 business days. A transfer has been initiated from your bank account. Your bitcoin should arrive in your wallet in 4-6 business days.
</p> </p>
<button class="outline dark-gray round expand" <button class="outline dark-gray round expand"
ng-click="$root.go('glidera')">Finish</button> ng-click="$root.go('glidera')">
Finish
</button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -79,7 +79,7 @@
<div class="size-12" ng-show="index.glideraEmail">{{index.glideraEmail}}</div> <div class="size-12" ng-show="index.glideraEmail">{{index.glideraEmail}}</div>
<div ng-show="index.glideraPersonalInfo" class="size-12"> <div ng-show="index.glideraPersonalInfo" class="size-12">
{{index.glideraPersonalInfo.firstName}} {{index.glideraPersonalInfo.lastName}} {{index.glideraPersonalInfo.personalInfoState}} {{index.glideraPersonalInfo.firstName}} {{index.glideraPersonalInfo.lastName}}
</div> </div>
</div> </div>

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('buyGlideraController', angular.module('copayApp.controllers').controller('buyGlideraController',
function($scope, $timeout, profileService, addressService, glideraService) { function($scope, $timeout, profileService, addressService, glideraService, gettext) {
this.addr = {}; this.addr = {};
this.show2faCodeInput = null; this.show2faCodeInput = null;
@ -14,27 +14,44 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
this.buyPrice = null; this.buyPrice = null;
return; return;
} }
glideraService.buyPrice(token, price, function(error, buyPrice) { glideraService.buyPrice(token, price, function(err, buyPrice) {
self.buyPrice = buyPrice; if (err) {
self.error = gettext('Glidera could not get pricing to buy bitcoin');
}
else {
self.buyPrice = buyPrice;
}
}); });
}; };
this.get2faCode = function(token) { this.get2faCode = function(token) {
var self = this; var self = this;
this.loading = true;
$timeout(function() { $timeout(function() {
glideraService.get2faCode(token, function(error, sent) { glideraService.get2faCode(token, function(err, sent) {
self.show2faCodeInput = sent; self.loading = false;
if (err) {
self.error = gettext('Glidera could not the 2FA code to your phone');
}
else {
self.show2faCodeInput = sent;
}
}); });
}, 100); }, 100);
}; };
this.sendRequest = function(token, twoFaCode) { this.sendRequest = function(token, permissions, twoFaCode) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
if (!fc) return; if (!fc) return;
this.loading = true;
var self = this; var self = this;
self.error = null;
addressService.getAddress(fc.credentials.walletId, null, function(err, addr) { addressService.getAddress(fc.credentials.walletId, null, function(err, addr) {
if (addr) { if (!addr) {
self.error = gettext('Could not get the bitcoin address');
$scope.$apply();
}
else {
self.loading = true;
var data = { var data = {
destinationAddress: addr, destinationAddress: addr,
qty: self.buyPrice.qty, qty: self.buyPrice.qty,
@ -42,15 +59,18 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
useCurrentPrice: false, useCurrentPrice: false,
ip: null ip: null
}; };
glideraService.buy(token, twoFaCode, data, function(error, data) { $timeout(function() {
self.loading = false; glideraService.buy(token, twoFaCode, data, function(err, data) {
if (error) { self.loading = false;
self.error = error; if (err) {
} self.error = gettext('Could not buy bitcoin');
else { }
self.success = data else {
} self.success = data;
}); $scope.$emit('Local/GlideraUpdated', token, permissions);
}
});
}, 100);
} }
}); });
}; };