BitPay card. Fix initial wallet home

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-22 17:43:31 -03:00
parent 6816f9a496
commit 894223a47f
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
9 changed files with 208 additions and 206 deletions

View File

@ -1,32 +1,21 @@
<div ng-controller="bitpayCardController as bitpayCard">
<div class="topbar-container">
<nav ng-controller="topbarController as topbar" ng-style="{'background-color': '#293C92'}" class="tab-bar">
<section ng-show="!addFunds" class="left-small">
<a class="p10"
ng-click="topbar.goHome()">
<span class="text-close">Close</span>
</a>
</section>
<ion-view>
<ion-nav-bar class="bar-stable">
<ion-nav-buttons side="primary">
<button class="button no-border" ui-sref="tabs.home">
Close
</button>
</ion-nav-buttons>
<ion-nav-title>BitPay Card</ion-nav-title>
<ion-nav-buttons side="secondary">
<button class="button no-border" ui-sref="bitpayCard.preferences">
<i class="icon ion-gear-b"></i>
</button>
</ion-nav-buttons>
</ion-nav-bar>
<section class="right-small" ng-show="bitpayCard.bitpayCardAuthenticated && !addFunds">
<a class="p10" href ui-sref="preferencesBitpayCard">
<i class="fi-widget size-24"></i>
</a>
</section>
<ion-content ng-controller="bitpayCardController as bitpayCard" ng-init="bitpayCard.init()">
<section class="middle tab-bar-section">
<h1 class="title ellipsis">
<span ng-show="!addFunds">BitPay Card</span>
<span ng-show="addFunds">Add Funds</span>
</h1>
</section>
</nav>
</div>
<div class="content bitpay_card p20b" ng-init="bitpayCard.init()">
<div class="box-notification text-center size-12 text-warning" ng-show="bitpayCard.sandbox">
<i class="fi-info"></i>
<div class="text-center size-12" ng-show="bitpayCard.sandbox">
Sandbox version. Only for testing purpose
</div>
@ -34,16 +23,15 @@
Loading...
</div>
<div class="row" ng-show="!bitpayCard.bitpayCardAuthenticated && !bitpayCard.loadingSession">
<div class="columns large-centered large-6 medium-centered medium-6 small-centered small-10">
<div class="text-center m20v">
<div ng-show="!bitpayCard.bitpayCardAuthenticated && !bitpayCard.loadingSession">
<div class="text-center">
<img src="img/bitpay-card-visa.svg" width="200">
</div>
<h2 class="m20b text-center">
<h4 class="text-center">
<span ng-show="!bitpayCard.bitpayCardTwoFactorPending">Login to your account</span>
<span ng-show="bitpayCard.bitpayCardTwoFactorPending">2-Step Verification</span>
</h2>
<div class="m10b box-notification size-12 text-warning"
</h4>
<div class="m10b size-12"
ng-show="bitpayCard.error"
ng-click="bitpayCard.error = null">
{{bitpayCard.error}}
@ -55,37 +43,30 @@
ng-submit="bitpayCard.authenticate()"
novalidate>
<label>
Email
<div class="input">
<input
name="email"
type="email"
ng-model="email"
ng-disabled="bitpayCard.authenticating"
required>
</div>
</label>
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">Email</span>
<input name="email"
type="email"
ng-model="email"
ng-disabled="bitpayCard.authenticating"
required>
</label>
<label>
Password
<div class="input">
<input
name="password"
type="password"
ng-model="password"
ng-disabled="bitpayCard.authenticating"
required>
</div>
</label>
<div class="input text-center">
<input class="button black round tiny"
ng-style="{'background-color': '#293C92'}"
type="submit"
ng-disabled="!authenticateForm.$valid || bitpayCard.authenticating"
value="Login">
<label class="item item-input item-stacked-label">
<span class="input-label">Password</span>
<input name="password"
type="password"
ng-model="password"
ng-disabled="bitpayCard.authenticating"
required>
</label>
</div>
<input class="button button-block button-positive"
type="submit"
ng-disabled="!authenticateForm.$valid || bitpayCard.authenticating"
value="Login">
</form>
<p ng-show="bitpayCard.bitpayCardTwoFactorPending" class="size-12 text-center text-gray">
@ -98,27 +79,22 @@
ng-submit="bitpayCard.authenticate2FA()"
novalidate>
<label>
Verification Code
<div class="input">
<input
name="twoFactorCode"
type="text"
ng-model="twoFactorCode"
ng-disabled="bitpayCard.authenticating"
required>
</div>
</label>
<div class="input text-center">
<input class="button black round tiny"
ng-style="{'background-color': '#293C92'}"
type="submit"
ng-disabled="!authenticate2FAForm.$valid || bitpayCard.authenticating"
value="Login">
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">Verification Code</span>
<input name="twoFactorCode"
type="text"
ng-model="twoFactorCode"
ng-disabled="bitpayCard.authenticating"
required>
</label>
</div>
<input class="button button-block button-positive"
type="submit"
ng-disabled="!authenticate2FAForm.$valid || bitpayCard.authenticating"
value="Login">
</form>
</div>
</div>
<div ng-show="bitpayCard.bitpayCardAuthenticated && !bitpayCard.visaCardActivated && !addFunds">
@ -134,7 +110,7 @@
</div>
<div class="camera-icon" ng-show="bitpayCard.bitpayCardCurrentBalance">
<a ng-click="addFunds = true">
<i class="fi-plus size-21"></i>
<i class="icon ion-plus size-21"></i>
</a>
</div>
</div>
@ -158,19 +134,19 @@
</div>
<div ng-show="loadingHistory" class="oh pr m20t text-gray text-center">
<img style="height:2em" class="animated flash infinite" src="img/icon-sync.svg">
<i class="icon ion-android-sync"></i>
</div>
<div
ng-show="!loadingHistory"
ng-repeat="tx in bitpayCard.bitpayCardTransactionHistory | orderBy: ['pending','-timestamp']"
class="row collapse last-transactions-content"
class="row"
ng-init="bitpayCard.getMerchantInfo(tx)">
<div class="large-1 medium-1 small-1 columns" ng-init="icon = bitpayCard.getIconName(tx)">
<div class="col" ng-init="icon = bitpayCard.getIconName(tx)">
<img class="m5t" ng-src="img/mcc-icons/{{icon}}.svg" width="22">
</div>
<div class="large-4 medium-4 small-4 columns">
<div class="col">
<div class="size-12 text-bold">
{{tx.merchant.name}}
</div>
@ -180,14 +156,14 @@
</div>
<div
ng-init="desc = bitpayCard.processDescription(tx)"
class="large-3 medium-3 small-3 show-for-medium-up columns size-12 text-gray text-right">
class="col">
{{desc}}
</div>
<div class="large-1 medium-1 small-1 columns text-right">
<div class="col">
<img ng-show="!tx.pending" ng-src="img/check.svg" width="14">
<img ng-show="tx.pending" ng-src="img/sync.svg" width="14">
</div>
<div class="large-3 medium-3 small-3 columns text-right size-12 text-gray">
<div class="col text-right size-12 text-gray">
<div class="size-14"
ng-class="{
'text-success': tx.amount.indexOf('-') == -1 && !tx.pending,
@ -199,8 +175,7 @@
</div>
</div>
<div class="row m20t" ng-show="bitpayCard.bitpayCardAuthenticated && !bitpayCard.visaCardActivated && addFunds">
<div class="columns">
<div ng-show="bitpayCard.bitpayCardAuthenticated && !bitpayCard.visaCardActivated && addFunds">
<div class="m10b box-notification size-12 text-warning"
ng-show="bitpayCard.error"
ng-click="bitpayCard.error = null">
@ -211,41 +186,38 @@
ng-submit="bitpayCard.sendFunds()"
novalidate>
<label>
Amount
<div class="input">
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">Amount</span>
<input
type="number"
id="fiat"
name="fiat"
ng-attr-placeholder="{{'Amount in USD'}}"
min="0.01"
max="2000"
ng-model="fiat"
autocomplete="off"
required>
type="number"
id="fiat"
name="fiat"
ng-attr-placeholder="{{'Amount in USD'}}"
min="0.01"
max="2000"
ng-model="fiat"
autocomplete="off"
required>
<a class="postfix button black">USD</a>
</div>
</label>
</label>
<label>
Add From Copay Wallet
</label>
<div class="input">
<input
type="text"
id="address"
name="address"
ng-disabled="bitpayCard.selectedWalletId"
ng-attr-placeholder="{{'Choose your source wallet'}}"
ng-model="bitpayCard.selectedWalletName" required>
<a
class="postfix size-12 m0 text-gray"
ng-style="{'color': '#293C92'}"
ng-click="openWalletsModal(bitpayCard.allWallets)">
<i class="icon-wallet size-18"></i>
</a>
<label class="item item-input item-stacked-label">
<span class="input-label">Add From Copay Wallet</span>
<input
type="text"
id="address"
name="address"
ng-disabled="bitpayCard.selectedWalletId"
ng-attr-placeholder="{{'Choose your source wallet'}}"
ng-model="bitpayCard.selectedWalletName" required>
<a
class="postfix size-12 m0 text-gray"
ng-style="{'color': '#293C92'}"
on-tap="openWalletsModal(bitpayCard.allWallets)">
<i class="icon-wallet size-18"></i>
</a>
</label>
</div>
<p class="size-12 text-warning" ng-show="bitpayCard.isMultisigWallet">
@ -253,22 +225,24 @@
Activity when the payment is fully signed.
</p>
<div class="input row">
<div class="columns large-6 medium-6 small-6">
<input class="button outline dark-gray round expand"
type="button" value="Cancel" ng-click="addFunds = false; bitpayCard.error = null">
<div class="row">
<div class="col">
<button class="button button-block button-stable"
type="button"
ng-click="addFunds = false; bitpayCard.error = null">
Cancel
</button>
</div>
<div class="columns large-6 medium-6 small-6">
<input class="button black round expand"
ng-style="{'background-color': '#293C92'}"
ng-disabled="!bitpayCard.selectedWalletId || !fiat"
type="submit" value="Send">
<div class="col">
<button class="button button-block button-positive"
ng-disabled="!bitpayCard.selectedWalletId || !fiat"
type="submit">
Send
</button>
</div>
</div>
</form>
</div>
</div>
</ion-content>
</ion-view>
<div class="extra-margin-bottom"></div>
</div>
</div>

View File

@ -1,18 +1,20 @@
<ion-modal-view ng-controller="bitpayCardConfirmationController">
<div class="m20tp text-center">
<div class="row">
<h1 class="text-center m20b p20h">Are you sure you would like to log out of your Bitpay Card account?</h1>
<p class="text-gray p20h">You will need to log back for fill in your Bitpay Card.</p>
<div class="large-6 medium-6 small-6 columns">
<button class="button light-gray expand outline round" ng-click="cancel()">
<i class="fi-arrow-left"></i> <span class="tu">Back</span>
</button>
<ion-modal-view>
<ion-content ng-controller="bitpayCardConfirmationController">
<div class="text-center">
<h1 class="text-center m20b p20h">Are you sure you would like to log out of your Bitpay Card account?</h1>
<p class="text-gray p20h">You will need to log back for fill in your Bitpay Card.</p>
<div class="row">
<div class="col">
<button class="button button-block button-stable" ng-click="cancel()">
Cancel
</button>
</div>
<div class="col">
<button class="button button-block button-assertive" ng-click="ok()">
<span>Log out</span>
</button>
</div>
</div>
</div>
<div class="large-6 medium-6 small-6 columns">
<button class="button warning expand round" ng-click="ok()">
<span>Log out</span>
</button>
</div>
</div>
</div>
</ion-content>
</ion-modal-view>

View File

@ -1,19 +1,19 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Preferences'; goBackToState = 'bitpayCard'; noColor = true">
</div>
<ion-view>
<ion-nav-bar class="bar-stable">
<ion-nav-buttons side="primary">
<button class="button no-border" ui-sref="bitpayCard.main">
<i class="icon ion-chevron-left"></i> Back
</button>
</ion-nav-buttons>
<ion-nav-title>Preferences</ion-nav-title>
</ion-nav-bar>
<div class="content preferences" ng-controller="preferencesBitpayCardController as bitpay">
<ion-content ng-controller="preferencesBitpayCardController as bitpay">
<ul class="list">
<li class="item assertive" ng-click="bitpay.logout()">
Log out
</li>
</ul>
</ion-content>
</ion-view>
<ul class="no-bullet m0">
<h4></h4>
<li ng-click="bitpay.logout()">
<i class="icon-arrow-right3 size-24 right text-gray"></i>
<span class="text-warning">Log out</span>
</li>
</ul>
<h4></h4>
</div>
<div class="extra-margin-bottom"></div>

View File

@ -3,7 +3,7 @@
<ion-nav-bar class="bar-stable">
<ion-nav-title>Home</ion-nav-title>
</ion-nav-bar>
<ion-content class="padding home" ng-controller="tabHomeController" cache-view="false" ng-init="init()">
<ion-content class="padding" ng-controller="tabHomeController">
<div ng-if="txps[0]">
<h3 class="title m0" translate>Payment Proposals</h3>
@ -56,12 +56,10 @@
</div>
</div>
<div class="list card">
<ul class="pr">
<li ng-show="wallets[0]"
ng-repeat="item in wallets track by $index" class="item item-icon-left"
ui-sref="wallet.details({'walletId': item.id})">
<div class="card" ng-show="wallets[0]">
<div ng-repeat="item in wallets track by $index"
class="item item-icon-left"
ui-sref="wallet.details({'walletId': item.id})">
<i class="icon ion-briefcase size-21" ng-style="{'color':item.color}"></i>
{{item.name || item.id}}
<span ng-show="item.n > 1" class="text-gray">
@ -74,14 +72,13 @@
<span class="item-note" ng-show="item.isComplete()">
{{item.status.availableBalanceStr}}
</span>
</li>
</ul>
</div>
</div>
<h3>Next steps </h3>
<div class="list card">
<ul class="pr">
<li ui-sref="bitpayCard" ng-show="bitpayCardEnabled" class="item item-icon-left">
<li ui-sref="bitpayCard.main" ng-show="bitpayCardEnabled" class="item item-icon-left">
<i class="icon ion-card"></i>
BitPay Card
</li>

View File

@ -5,8 +5,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
var self = this;
var client;
var network = 'livenet';
self.sandbox = network == 'testnet' ? true : false;
self.sandbox = bitpayCardService.getEnvironment() == 'testnet' ? true : false;
if (platformInfo.isCordova && StatusBar.isVisible) {
StatusBar.backgroundColorByHexString("#293C92");
@ -71,7 +70,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
this.update = function() {
var dateRange = setDateRange($scope.dateRange);
self.loadingSession = true;
bitpayCardService.setCredentials(network);
bitpayCardService.isAuthenticated(function(err, bpSession) {
self.loadingSession = false;
if (err) {
@ -110,14 +108,16 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
$scope.dateRange = 'last30Days';
self.update();
self.allWallets = profileService.getWallets(network);
client = profileService.focusedClient;
if (!client) return;
var network = bitpayCardService.getEnvironment();
self.allWallets = profileService.getWallets({
network: network,
n: 1,
onlyComplete: true
});
if (lodash.isEmpty(self.allWallets)) return;
if (client.credentials.network != network) return;
client = self.allWallets[0];
if (client.credentials.n > 1)
self.isMultisigWallet = true;

View File

@ -1,10 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('bitpayCardConfirmationController', function($scope, $timeout, go, bitpayCardService) {
angular.module('copayApp.controllers').controller('bitpayCardConfirmationController', function($scope, $timeout, $location, bitpayCardService) {
$scope.ok = function() {
bitpayCardService.logout(function() {
go.path('bitpayCard');
$location.path('/bitpayCard/main');
});
$scope.cancel();
};

View File

@ -4,7 +4,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
var self = this;
self.glideraEnabled = configService.getSync().glidera.enabled;
self.setWallets = function() {
$scope.wallets = profileService.getWallets();
};
var setPendingTxps = function(txps) {
@ -108,7 +110,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
if (err) {
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
return;
}
}
if (status.pendingTxps && status.pendingTxps[0]) {
var txps = lodash.filter($scope.txps, function(x) {
return x.walletId != wallet.id;
@ -136,14 +138,13 @@ angular.module('copayApp.controllers').controller('tabHomeController',
c1();
});
var config = configService.getSync().wallet;
var GLIDERA_LOCK_TIME = 6 * 60 * 60;
var glideraActive = true; // TODO TODO TODO
// isGlidera flag is a security measure so glidera status is not
// only determined by the tx.message
$scope.openTxpModal = function(tx) {
var config = configService.getSync().wallet;
var scope = $rootScope.$new(true);
scope.tx = tx;
scope.wallet = tx.wallet;
@ -159,12 +160,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
};
$scope.init = function() {
configService.whenAvailable(function() {
var config = configService.getSync();
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
var glideraEnabled = config.glidera.enabled;
var coinbaseEnabled = config.coinbase.enabled;
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
$scope.buyAndSellEnabled = !isWindowsPhoneApp && (glideraEnabled || coinbaseEnabled);
}
});
});

View File

@ -85,7 +85,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*
*/
.state('disclaimer', {
.state('disclaimer', {
url: '/disclaimer',
templateUrl: 'views/disclaimer.html',
})
@ -557,13 +557,26 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*
*/
.state('bitpayCard', {
url: '/bitpay-card',
templateUrl: 'views/bitpayCard.html'
.state('bitpayCard', {
url: '/bitpayCard',
abstract: true,
template: '<ion-nav-view name="bitpayCard"></ion-nav-view>'
})
.state('preferencesBitpayCard', {
url: '/preferences-bitpay-card',
templateUrl: 'views/preferencesBitpayCard.html'
.state('bitpayCard.main', {
url: '/main',
views: {
'bitpayCard': {
templateUrl: 'views/bitpayCard.html'
}
}
})
.state('bitpayCard.preferences', {
url: '/preferences',
views: {
'bitpayCard': {
templateUrl: 'views/preferencesBitpayCard.html'
}
}
})
/*

View File

@ -5,9 +5,13 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
var credentials = {};
var bpSession = {};
root.setCredentials = function(network) {
credentials.NETWORK = network;
if (network == 'testnet') {
var _setCredentials = function() {
/*
* Development: 'testnet'
* Production: 'livenet'
*/
credentials.NETWORK = 'livenet';
if (credentials.NETWORK == 'testnet') {
credentials.BITPAY_API_URL = 'https://test.bitpay.com';
}
else {
@ -16,6 +20,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
};
var _getUser = function(cb) {
_setCredentials();
storageService.getBitpayCard(credentials.NETWORK, function(err, user) {
if (err) return cb(err);
if (lodash.isString(user)) {
@ -26,6 +31,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
};
var _setUser = function(user, cb) {
_setCredentials();
user = JSON.stringify(user);
storageService.setBitpayCard(credentials.NETWORK, user, function(err) {
return cb(err);
@ -33,6 +39,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
};
var _getSession = function(cb) {
_setCredentials();
$http({
method: 'GET',
url: credentials.BITPAY_API_URL + '/visa-api/session',
@ -50,6 +57,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
};
var _getBitPay = function(endpoint) {
_setCredentials();
return {
method: 'GET',
url: credentials.BITPAY_API_URL + endpoint,
@ -61,6 +69,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
};
var _postBitPay = function(endpoint, data) {
_setCredentials();
return {
method: 'POST',
url: credentials.BITPAY_API_URL + endpoint,
@ -72,6 +81,11 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
};
};
root.getEnvironment = function() {
_setCredentials();
return credentials.NETWORK;
};
root.topUp = function(data, cb) {
var dataSrc = {
amount: data.amount,
@ -173,6 +187,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
};
root.logout = function(cb) {
_setCredentials();
storageService.removeBitpayCard(credentials.NETWORK, function(err) {
$http(_getBitPay('/visa-api/logout')).then(function(data) {
$log.info('BitPay Logout: SUCCESS');