Merge pull request #21 from cmgustavo/ref/design-08

popupServices: BitPay Card and Glidera
This commit is contained in:
Matias Alejo Garcia 2016-08-31 17:11:05 -03:00 committed by GitHub
commit 15a288e194
17 changed files with 219 additions and 375 deletions

View file

@ -31,11 +31,6 @@
<span ng-show="!bitpayCard.bitpayCardTwoFactorPending">Login to your account</span>
<span ng-show="bitpayCard.bitpayCardTwoFactorPending">2-Step Verification</span>
</h4>
<div class="box-notification error"
ng-show="bitpayCard.error"
ng-click="bitpayCard.error = null">
{{bitpayCard.error}}
</div>
<form
ng-show="!bitpayCard.bitpayCardTwoFactorPending"
@ -121,14 +116,9 @@
<option value="all">All Activity</option>
</select>
<div class="box-notification error"
ng-show="bitpayCard.error">
{{bitpayCard.error}}
</div>
<div
class="oh pr m20t text-gray size-12 text-center"
ng-show="!bitpayCard.error && !bitpayCard.bitpayCardTransactionHistory[0] &&
ng-show="!bitpayCard.bitpayCardTransactionHistory[0] &&
!bitpayCard.bitpayCardInvoiceHistory[0] && !loadingHistory">
No transactions yet
</div>
@ -176,11 +166,6 @@
</div>
<div ng-show="bitpayCard.bitpayCardAuthenticated && !bitpayCard.visaCardActivated && addFunds">
<div class="box-notification error"
ng-show="bitpayCard.error"
ng-click="bitpayCard.error = null">
{{bitpayCard.error}}
</div>
<form
name="createInvoiceForm"
ng-submit="bitpayCard.sendFunds()"
@ -215,7 +200,7 @@
<div class="col">
<button class="button button-block button-stable"
type="button"
ng-click="addFunds = false; bitpayCard.error = null">
ng-click="addFunds = false">
Cancel
</button>
</div>

View file

@ -10,12 +10,11 @@
<ion-content ng-controller="buyGlideraController as buy" ng-init="init()">
<div class="box-notification text-center size-12 text-warning" ng-show="network == 'testnet'">
<i class="fi-info"></i>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts
</div>
<h5 class="padding" ng-show="limits && !buy.show2faCodeInput && !buy.success">
<div class="box-notification notice" ng-show="limits && !buy.show2faCodeInput && !buy.success">
<span class="text-light">Daily buy limit</span>:
{{limits.dailyBuy|currency:'':2}} {{limits.currency}}
(remaining {{limits.dailyBuyRemaining|currency:'':2}} {{limits.currency}})
@ -23,7 +22,7 @@
<span class="text-light">Monthly buy limit</span>:
{{limits.monthlyBuy|currency:'':2}} {{limits.currency}}
(remaining {{limits.monthlyBuyRemaining|currency:'':2}} {{limits.currency}})
</h5>
</div>
<div class="box-notification m20b" ng-show="limits.transactDisabledPendingFirstTransaction && !buy.success">
<span class="text-warning">
@ -37,21 +36,6 @@
ng-submit="buy.get2faCode(token)" novalidate>
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet</span>
<input type="text"
id="address"
name="address"
ng-disabled="buy.selectedWalletId"
ng-attr-placeholder="{{'Choose your destination wallet'}}"
ng-model="buy.selectedWalletName" required>
<a on-tap="openWalletsModal(buy.allWallets)">
<i class="icon ion-briefcase size-18"></i>
</a>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Amount in {{showAlternative ? 'USD' : 'BTC'}}</span>
<input ng-show="!showAlternative"
@ -81,6 +65,8 @@
class="postfix"
on-tap="showAlternative = false; fiat = null; buy.buyPrice = null">USD</a>
</label>
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
</div>
<div class="text-center text-gray size-12 m20b" ng-show="!buy.gettingBuyPrice && buy.buyPrice.qty">
@ -99,7 +85,7 @@
<button class="button button-block"
type="submit"
ng-disabled="limits.transactDisabledPendingFirstTransaction || !buy.buyPrice.qty || !buy.selectedWalletId || buy.loading">
ng-disabled="limits.transactDisabledPendingFirstTransaction || !buy.buyPrice.qty || buy.loading">
Continue
</button>
</form>
@ -128,11 +114,6 @@
</p>
</div>
</div>
<div class="box-notification m20b" ng-show="buy.error && !buy.success">
<span class="text-warning">
{{buy.error}}
</span>
</div>
<div class="text-center" ng-show="buy.success">
<h1>Purchase initiated</h1>
<p class="text-gray">

View file

@ -10,38 +10,14 @@
<ion-content ng-controller="glideraController as glidera" ng-init="init()">
<div class="box-notification text-center size-12 text-warning" ng-show="network == 'testnet'">
<i class="fi-info"></i>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts
</div>
<div class="m20b box-notification" ng-if="error">
<div class="text-warning">
<span>{{error}}</span>
</div>
</div>
<div class="m10t text-center" ng-show="error">
<button
class="button"
ng-show="error.indexOf('Forbidden') == 40"
ng-click="token = null; error = null">
Request a new token
</button>
<div ng-show="error.indexOf('Forbidden') != 40">
<button
class="button"
ng-click="init(token)">
Retry
</button>
<div class="m20t size-12">
<a class="text-gray" href ui-sref="glidera.preferences">Preferences</a>
</div>
</div>
</div>
<div ng-if="!token && !error">
<div ng-if="!token">
<div ng-init="showOauthForm = false">
<div class="text-center m20b">
<div class="text-center m20v">
<img src="img/glidera-logo.png" ng-click="update(token, permissions)" width="200">
</div>
<div class="text-center small-10 small-centered columns" ng-show="!showOauthForm">
@ -70,9 +46,6 @@
</div>
</div>
<div ng-show="showOauthForm">
<div class="text-left box-notification size-12 text-warning" ng-show="error">
{{error}}
</div>
<form name="oauthCodeForm" ng-submit="glidera.submitOauthCode(code)" novalidate>
<div class="list">
<label class="item item-input item-stacked-label">
@ -87,7 +60,7 @@
<input type="button"
value="Cancel"
class="button button-block"
ng-click="showOauthForm = false; error = null">
ng-click="showOauthForm = false">
</div>
<div class="col">
<input
@ -103,16 +76,17 @@
</div>
<div ng-if="token && permissions">
<div class="p20v text-center">
<img src="img/glidera-logo.png" ng-click="update(token, permissions)" width="100">
<div class="text-center m20v">
<img src="img/glidera-logo.png" ng-click="update(token, permissions)" width="200">
</div>
<div class="list">
<a class="item item-icon-left" href ui-sref="glidera.preferences">
<i class="icon ion-gear-a"></i>
<a class="item item-icon-left item-icon-right" href ui-sref="glidera.preferences">
<i class="icon ion-ios-gear"></i>
<span ng-show="personalInfo">{{personalInfo.firstName}} {{personalInfo.lastName}}</span>
<span class="item-note" ng-show="email">
{{email}}
</span>
<i class="icon ion-ios-arrow-right"></i>
</a>
</div>
<div class="padding">
@ -133,54 +107,56 @@
<div class="list"
ng-show="status && status.userCanTransact">
<a ng-show="status.userCanBuy"
class="item item-avatar"
class="item item-icon-right"
href ui-sref="glidera.buy">
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="40">
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="25">
Buy Bitcoin
<i class="icon ion-ios-arrow-right"></i>
</a>
<a class="item item-avatar"
<a class="item item-icon-right"
ng-show="status.userCanSell"
href ui-sref="glidera.sell">
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="40">
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="25">
Sell Bitcoin
<i class="icon ion-ios-arrow-right"></i>
</a>
</div>
<div ng-show="permissions.transaction_history">
<h4>Activity</h4>
<div class="card" ng-show="permissions.transaction_history">
<div class="item item-divider">
Activity
</div>
<div ng-show="txs.length == 0 "
class="size-12 p10 text-center text-gray">
class="item">
No activity in your account
</div>
<div class="list">
<a ng-repeat="tx in txs"
ng-click="glidera.openTxModal(token, tx)"
class="item item-avatar">
<img src="img/bought.svg" alt="bought" width="39" ng-show="tx.type == 'BUY' && tx.status == 'COMPLETE'">
<img src="img/bought-pending.svg" alt="bought" width="33" ng-show="tx.type == 'BUY' && tx.status == 'PROCESSING'">
<img src="img/sold.svg" alt="bought" width="39" ng-show="tx.type == 'SELL' && tx.status == 'COMPLETE'">
<img src="img/sold-pending.svg" alt="bought" width="33" ng-show="tx.type == 'SELL' && tx.status == 'PROCESSING'">
<a ng-repeat="tx in txs"
ng-click="glidera.openTxModal(token, tx)"
class="item">
<h2>
<span ng-show="tx.type == 'BUY'">Bought</span>
<span ng-show="tx.type == 'SELL'">Sold</span>
<b>{{tx.qty}}</b> BTC
</h2>
<p>
{{tx.subtotal|currency:'':2}} {{tx.currency}}
</p>
<div class="right">
<div class="m5t size-12 text-gray">
<div ng-show="tx.status == 'COMPLETE'">
<time ng-if="tx.transactionDate">{{tx.transactionDate | amTimeAgo}}</time>
</div>
<div ng-show="tx.status == 'PROCESSING'">
<span class="label outline gray radius text-gray text-info" ng-if="tx.status == 'PROCESSING'">Processing</span>
</div>
</div>
<span class="item-note">
<div ng-show="tx.status == 'COMPLETE'">
<time ng-if="tx.transactionDate">{{tx.transactionDate | amTimeAgo}}</time>
</div>
</a>
</div>
<div ng-show="tx.status == 'PROCESSING'">
<span ng-if="tx.status == 'PROCESSING'">Processing</span>
</div>
</span>
<img class="left m10r" src="img/bought.svg" alt="bought" width="39" ng-show="tx.type == 'BUY' && tx.status == 'COMPLETE'">
<img class="left m10r" src="img/bought-pending.svg" alt="bought" width="33" ng-show="tx.type == 'BUY' && tx.status == 'PROCESSING'">
<img class="left m10r" src="img/sold.svg" alt="bought" width="39" ng-show="tx.type == 'SELL' && tx.status == 'COMPLETE'">
<img class="left m10r" src="img/sold-pending.svg" alt="bought" width="33" ng-show="tx.type == 'SELL' && tx.status == 'PROCESSING'">
<h2>
<span ng-show="tx.type == 'BUY'">Bought</span>
<span ng-show="tx.type == 'SELL'">Sold</span>
<b>{{tx.qty}}</b> BTC
</h2>
<p>
{{tx.subtotal|currency:'':2}} {{tx.currency}}
</p>
</a>
</div>
</div>
</ion-content>

View file

@ -1,22 +1,24 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Glidera'; closeToHome = true">
</div>
<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>Glidera</ion-nav-title>
</ion-nav-bar>
<div class="content glidera" ng-controller="glideraUriController as glidera" ng-init="glidera.checkCode()">
<ion-content ng-controller="glideraUriController" ng-init="checkCode()">
<div class="row m20t">
<div class="large-12 columns">
<div class="text-center">
<img src="img/glidera-logo.png"
ng-click="index.updateGlidera()" width="100">
</div>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts
</div>
<div class="m10t text-center" ng-show="glidera.error">
<div class="notification m10b size-12 text-warning">{{glidera.error}}</div>
<button class="outline dark-gray tiny round" ng-click="glidera.submitOauthCode(glidera.code)">Try again</button>
<div class="text-center">
<img src="img/glidera-logo.png" width="100">
<div class="m20t" translate>
Connecting...
</div>
</div>
</div>
</div>
</ion-content>
</ion-view>

View file

@ -1,5 +1,5 @@
<ion-modal-view ng-controller="glideraTxDetailsController">
<ion-header-bar align-title="center" class="tab-bar">
<ion-header-bar align-title="center" class="bar-stable">
<button class="button button-clear button-positive"
ng-click="cancel()">
Close
@ -8,8 +8,7 @@
</ion-header-bar>
<ion-content>
<div class="modal-content fix-modals-touch">
<div class="header-modal bg-gray text-center">
<div class="text-center">
<div class="p20">
<img src="img/bought.svg" alt="bought" width="80" ng-show="tx.type == 'BUY' && tx.status == 'COMPLETE'">
<img src="img/bought-pending.svg" alt="bought" width="65" ng-show="tx.type == 'BUY' && tx.status == 'PROCESSING'">
@ -19,46 +18,46 @@
<span ng-show="tx.type == 'BUY'">Bought</span>
<span ng-show="tx.type == 'SELL'">Sold</span>
<b>{{tx.qty}}</b> BTC
<div class="size-36 m20b">
<div class="size-36 m20v">
{{tx.subtotal|currency:'':2}} {{tx.currency}}
</div>
</div>
<ul class="no-bullet size-14">
<ul class="list">
<li class="line-b p10 oh">
<span class="text-gray">Status</span>
<span class="text-success right" ng-if="tx.status == 'COMPLETE'">Completed</span>
<span class="text-info right" ng-if="tx.status == 'PROCESSING'">Processing</span>
<span class="text-warning right" ng-if="tx.status == 'ERROR'">Error</span>
<li class="item">
Status
<span class="item-note">
<span class="text-success" ng-if="tx.status == 'COMPLETE'">Completed</span>
<span class="text-info" ng-if="tx.status == 'PROCESSING'">Processing</span>
<span class="text-warning" ng-if="tx.status == 'ERROR'">Error</span>
</span>
</li>
<li ng-show="tx.transactionDate" class="line-b p10 oh">
<span class="text-gray">Date</span>
<span class="right">{{tx.transactionDate | amCalendar}}</span>
<li ng-show="tx.transactionDate" class="item">
Date
<span class="item-note">{{tx.transactionDate | amCalendar}}</span>
</li>
<li ng-show="tx.price" class="line-b p10 oh">
<span class="text-gray">Exchange rate</span>
<span class="right">{{tx.price|currency:'':2}} {{tx.currency}}/BTC</span>
<li ng-show="tx.price" class="item">
Exchange rate
<span class="item-note">{{tx.price|currency:'':2}} {{tx.currency}}/BTC</span>
</li>
<li ng-show="tx.subtotal" class="line-b p10 oh">
<span class="text-gray">Subtotal</span>
<span class="right">{{tx.subtotal|currency:'':2}} {{tx.currency}}</span>
<li ng-show="tx.subtotal" class="item">
Subtotal
<span class="item-note">{{tx.subtotal|currency:'':2}} {{tx.currency}}</span>
</li>
<li ng-show="tx.fees" class="line-b p10 oh">
<span class="text-gray">Fees</span>
<span class="right">{{tx.fees|currency:'':2}} {{tx.currency}}</span>
<li ng-show="tx.fees" class="item">
Fees
<span class="item-note">{{tx.fees|currency:'':2}} {{tx.currency}}</span>
</li>
<li ng-show="tx.total" class="line-b p10 oh text-bold">
<span class="text-gray">Total</span>
<span class="right">{{tx.total|currency:'':2}} {{tx.currency}}</span>
<li ng-show="tx.total" class="item">
Total
<span class="item-note">{{tx.total|currency:'':2}} {{tx.currency}}</span>
</li>
</ul>
<div class="extra-margin-bottom"></div>
</div>
</ion-content>
</ion-modal-view>

View file

@ -10,7 +10,11 @@
<ion-content ng-controller="sellGlideraController as sell" ng-init="init()">
<h4 class="padding" ng-show="limits && !sell.show2faCodeInput && !sell.success">
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts
</div>
<div class="box-notification notice" ng-show="limits && !sell.show2faCodeInput && !sell.success">
<span class="text-light">Daily sell limit</span>:
{{limits.dailySell|currency:'':2}} {{limits.currency}}
(remaining {{limits.dailySellRemaining|currency:'':2}} {{limits.currency}})
@ -18,7 +22,7 @@
<span class="text-light">Monthly sell limit</span>:
{{limits.monthlySell|currency:'':2}} {{limits.currency}}
(remaining {{limits.monthlySellRemaining|currency:'':2}} {{limits.currency}})
</h4>
</div>
<div class="box-notification m20b" ng-show="limits.transactDisabledPendingFirstTransaction">
<span class="text-warning">
@ -31,19 +35,6 @@
ng-submit="sell.get2faCode(token)" novalidate>
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet</span>
<input type="text"
id="address"
name="address"
ng-disabled="sell.selectedWalletId"
ng-attr-placeholder="{{'Choose your source wallet'}}"
ng-model="sell.selectedWalletName" required>
<a on-tap="openWalletsModal(sell.allWallets)">
<i class="icon ion-briefcase size-18"></i>
</a>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label"><span>Amount in</span> {{showAlternative ? 'USD' : 'BTC'}}</span>
<input ng-show="!showAlternative"
@ -73,6 +64,8 @@
class="postfix"
on-tap="showAlternative = false; fiat = null; sell.sellPrice = null">USD</a>
</label>
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
</div>
<div class="text-center text-gray size-12 m20b" ng-show="!sell.gettingSellPrice && sell.sellPrice.qty">
@ -92,7 +85,7 @@
<button class="button button-block"
type="submit"
ng-disabled="limits.transactDisabledPendingFirstTransaction || !sell.sellPrice.qty || !sell.selectedWalletId ">
ng-disabled="limits.transactDisabledPendingFirstTransaction || !sell.sellPrice.qty">
Continue
</button>
</form>
@ -122,11 +115,6 @@
</p>
</div>
</div>
<div class="box-notification" ng-show="sell.error && !sell.success">
<span class="text-warning size-14">
{{sell.error}}
</span>
</div>
<div class="text-center" ng-show="sell.success">
<h1>Sale initiated</h1>
<p class="text-gray">

View file

@ -1,14 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $rootScope, $timeout, $log, $ionicModal, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, platformInfo) {
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, popupService) {
var self = this;
var wallet;
if (platformInfo.isCordova && StatusBar.isVisible) {
StatusBar.backgroundColorByHexString("#293C92");
}
$scope.$on('Wallet/Changed', function(event, w) {
if (lodash.isEmpty(w)) {
$log.debug('No wallet provided');
@ -87,7 +83,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.transactionHistory(dateRange, function(err, history) {
$scope.loadingHistory = false;
if (err) {
self.error = 'Error getting transactions';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
return;
}
@ -120,13 +116,11 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
};
this.sendFunds = function() {
self.error = null;
if (lodash.isEmpty(wallet)) return;
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key');
self.error = bwcError.msg('MISSING_PRIVATE_KEY');
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
return;
}
@ -146,10 +140,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
if (err) {
ongoingProcess.set('Processing Transaction...', false);
self.error = bwcError.msg(err);
$timeout(function() {
$scope.$digest();
});
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
@ -178,18 +169,12 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
walletService.createTx(wallet, txp, function(err, createdTxp) {
if (err) {
self.error = bwcError.msg(err);
$timeout(function() {
$scope.$digest();
});
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
if (err) {
self.error = err;
$timeout(function() {
$scope.$digest();
});
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
self.update();
@ -205,7 +190,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
};
this.authenticate = function() {
self.error = null;
var data = {
emailAddress : $scope.email,
@ -219,7 +203,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.authenticate(data, function(err, auth) {
self.authenticating = false;
if (err && err.data && err.data.error && !err.data.error.twoFactorPending) {
self.error = err.statusText || err.data.error || 'Authentiation error';
popupService.showAlert(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error');
return;
}
@ -231,7 +215,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
};
this.authenticate2FA = function() {
self.error = null;
var data = {
twoFactorCode : $scope.twoFactorCode
@ -241,7 +224,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
bitpayCardService.authenticate2FA(data, function(err, auth) {
self.authenticating = false;
if (err) {
self.error = 'Authentiation error';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error'));
return;
}

View file

@ -39,7 +39,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key');
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
return;
}
@ -59,7 +59,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
if (err) {
ongoingProcess.set('Processing Transaction...', false);
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}

View file

@ -1,19 +1,26 @@
'use strict';
angular.module('copayApp.controllers').controller('buyGlideraController',
function($scope, $timeout, $log, $ionicModal, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess) {
function($scope, $timeout, $log, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess, popupService, gettextCatalog) {
var wallet;
var self = this;
this.show2faCodeInput = null;
this.error = null;
this.success = null;
$scope.$on('Wallet/Changed', function(event, w) {
if (lodash.isEmpty(w)) {
$log.debug('No wallet provided');
return;
}
wallet = w;
$log.debug('Wallet changed: ' + w.name);
});
$scope.init = function(accessToken) {
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.error = null;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
@ -25,7 +32,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
$scope.error = err;
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
@ -33,21 +40,11 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
$scope.update({fullUpdate: true});
});
self.allWallets = profileService.getWallets({
$scope.wallets = profileService.getWallets({
network: $scope.network,
n: 1,
onlyComplete: true
});
if (lodash.isEmpty(self.allWallets)) return;
wallet = self.allWallets[0];
if (wallet) {
$timeout(function() {
self.selectedWalletId = wallet.credentials.walletId;
self.selectedWalletName = wallet.credentials.walletName;
$scope.$apply();
}, 100);
}
};
$scope.update = function(opts) {
@ -84,33 +81,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
}
};
$scope.openWalletsModal = function(wallets) {
self.error = null;
$scope.type = 'BUY';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.self = self;
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.walletsModal = modal;
$scope.walletsModal.show();
});
$scope.$on('walletSelected', function(ev, walletId) {
$timeout(function() {
wallet = profileService.getClient(walletId);
self.selectedWalletId = walletId;
self.selectedWalletName = wallet.credentials.walletName;
$scope.$apply();
}, 100);
$scope.walletsModal.hide();
});
};
this.getBuyPrice = function(token, price) {
var self = this;
this.error = null;
@ -122,7 +92,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
glideraService.buyPrice(token, price, function(err, buyPrice) {
self.gettingBuyPrice = false;
if (err) {
self.error = 'Could not get exchange information. Please, try again.';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
return;
}
self.buyPrice = buyPrice;
@ -131,13 +101,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
this.get2faCode = function(token) {
var self = this;
self.error = null;
ongoingProcess.set('Sending 2FA code...', true);
$timeout(function() {
glideraService.get2faCode(token, function(err, sent) {
ongoingProcess.set('Sending 2FA code...', false);
if (err) {
self.error = 'Could not send confirmation code to your phone';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
return;
}
self.show2faCodeInput = sent;
@ -147,13 +116,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
this.sendRequest = function(token, permissions, twoFaCode) {
var self = this;
self.error = null;
ongoingProcess.set('Buying Bitcoin...', true);
$timeout(function() {
walletService.getAddress(wallet, false, function(err, walletAddr) {
if (err) {
ongoingProcess.set('Buying Bitcoin...', false);
self.error = bwcError.cb(err, 'Could not create address');
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.cb(err, 'Could not create address'));
return;
}
var data = {
@ -166,11 +134,13 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
glideraService.buy(token, twoFaCode, data, function(err, data) {
ongoingProcess.set('Buying Bitcoin...', false);
if (err) {
self.error = err;
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
self.success = data;
$scope.$emit('Local/GlideraTx');
$timeout(function() {
$scope.$digest();
});
});
});
}, 100);

View file

@ -1,11 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('glideraController',
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, storageService, glideraService, lodash, ongoingProcess, platformInfo, nodeWebkit) {
if (platformInfo.isCordova && StatusBar.isVisible) {
StatusBar.backgroundColorByHexString("#4B6178");
}
function($scope, $timeout, $ionicModal, $log, storageService, glideraService, ongoingProcess, platformInfo, nodeWebkit, popupService, gettextCatalog) {
$scope.openExternalLink = function(url, target) {
if (platformInfo.isNW) {
@ -20,7 +16,6 @@ angular.module('copayApp.controllers').controller('glideraController',
$scope.network = glideraService.getEnvironment();
$scope.token = null;
$scope.error = null;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
@ -32,7 +27,7 @@ angular.module('copayApp.controllers').controller('glideraController',
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
$scope.error = err;
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
@ -81,15 +76,11 @@ angular.module('copayApp.controllers').controller('glideraController',
this.submitOauthCode = function(code) {
ongoingProcess.set('connectingGlidera', true);
$scope.error = null;
$timeout(function() {
glideraService.getToken(code, function(err, data) {
ongoingProcess.set('connectingGlidera', false);
if (err) {
$scope.error = err;
$timeout(function() {
$scope.$apply();
}, 100);
popupService.showAlert(gettextCatalog.getString('Error'), err);
} else if (data && data.access_token) {
storageService.setGlideraToken($scope.network, data.access_token, function() {
$scope.init(data.access_token);
@ -108,7 +99,11 @@ angular.module('copayApp.controllers').controller('glideraController',
$scope.self = self;
$scope.tx = tx;
glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) {
glideraService.getTransaction(token, tx.transactionUuid, function(err, tx) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
return;
}
$scope.tx = tx;
});

View file

@ -1,41 +1,34 @@
'use strict';
angular.module('copayApp.controllers').controller('glideraUriController',
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, $state, ongoingProcess) {
function($scope, $log, $stateParams, $timeout, glideraService, storageService, $state, ongoingProcess, popupService, gettextCatalog) {
this.submitOauthCode = function(code) {
var submitOauthCode = function(code) {
$log.debug('Glidera Oauth Code:' + code);
var self = this;
var glideraTestnet = configService.getSync().glidera.testnet;
var network = glideraTestnet ? 'testnet' : 'livenet';
$scope.network = glideraService.getEnvironment();
ongoingProcess.set('connectingGlidera', true);
this.error = null;
$timeout(function() {
glideraService.getToken(code, function(err, data) {
ongoingProcess.set('connectingGlidera', false);
if (err) {
self.error = err;
$timeout(function() {
$scope.$apply();
}, 100);
popupService.showAlert(gettextCatalog.getString('Error'), err);
} else if (data && data.access_token) {
storageService.setGlideraToken(network, data.access_token, function() {
$scope.$emit('Local/GlideraUpdated', data.access_token);
storageService.setGlideraToken($scope.network, data.access_token, function() {
$timeout(function() {
$state.go('glidera');
$state.go('glidera.main');
$scope.$apply();
}, 100);
}, 500);
});
}
});
}, 100);
};
this.checkCode = function() {
$scope.checkCode = function() {
if ($stateParams.url) {
var match = $stateParams.url.match(/code=(.+)/);
if (match && match[1]) {
this.code = match[1];
return this.submitOauthCode(this.code);
submitOauthCode(match[1]);
return;
}
}
$log.error('Bad state: ' + JSON.stringify($stateParams));

View file

@ -1,13 +1,13 @@
'use strict';
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess) {
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess, popupService, gettextCatalog) {
$scope.cancelGiftCard = function() {
ongoingProcess.set('Canceling gift card...', true);
amazonService.cancelGiftCard($scope.card, function(err, data) {
ongoingProcess.set('Canceling gift card...', false);
if (err) {
$scope.error = bwcError.msg(err);
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
$scope.card.cardStatus = data.cardStatus;
@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
$scope.refreshGiftCard = function() {
amazonService.getPendingGiftCards(function(err, gcds) {
if (err) {
self.error = err;
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
lodash.forEach(gcds, function(dataFromStorage) {
@ -37,8 +37,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
$log.debug("creating gift card");
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
if (err) {
self.error = bwcError.msg(err);
$log.debug(bwcError.msg(err));
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
if (!lodash.isEmpty(giftCard)) {

View file

@ -1,13 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesGlideraController',
function($scope, $log, $ionicModal, ongoingProcess, glideraService) {
function($scope, $log, $timeout, $state, ongoingProcess, glideraService, popupService, gettextCatalog) {
$scope.init = function(accessToken) {
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.error = null;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
@ -19,7 +18,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
$scope.error = err;
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
@ -63,11 +62,14 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
};
$scope.revokeToken = function() {
$ionicModal.fromTemplateUrl('views/modals/glidera-confirmation.html', {
scope: $scope
}).then(function(modal) {
$scope.glideraConfirmationModal = modal;
$scope.glideraConfirmationModal.show();
popupService.showConfirm('Glidera', 'Are you sure you would like to log out of your Glidera account?', function(res) {
if (res) {
glideraService.removeToken(function() {
$timeout(function() {
$state.go('glidera.main');
}, 100);
});
}
});
};

View file

@ -1,28 +1,27 @@
'use strict';
angular.module('copayApp.controllers').controller('sellGlideraController',
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, glideraService, bwcError, lodash, walletService, fingerprintService, configService, ongoingProcess) {
function($scope, $timeout, $log, profileService, glideraService, bwcError, lodash, walletService, configService, ongoingProcess, popupService, gettextCatalog) {
var self = this;
this.data = {};
this.show2faCodeInput = null;
this.success = null;
this.error = null;
var wallet;
var handleEncryptedWallet = function(wallet, cb) {
if (!walletService.isEncrypted(wallet)) return cb();
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
if (err) return cb(err);
return cb(walletService.unlock(wallet, password));
});
};
$scope.$on('Wallet/Changed', function(event, w) {
if (lodash.isEmpty(w)) {
$log.debug('No wallet provided');
return;
}
wallet = w;
$log.debug('Wallet changed: ' + w.name);
});
$scope.init = function(accessToken) {
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.error = null;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
@ -34,7 +33,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
$scope.error = err;
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
@ -42,21 +41,11 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
$scope.update({fullUpdate: true});
});
self.allWallets = profileService.getWallets({
$scope.wallets = profileService.getWallets({
network: $scope.network,
n: 1,
onlyComplete: true
});
if (lodash.isEmpty(self.allWallets)) return;
wallet = self.allWallets[0];
if (wallet) {
$timeout(function() {
self.selectedWalletId = wallet.credentials.walletId;
self.selectedWalletName = wallet.credentials.walletName;
$scope.$apply();
}, 100);
}
};
$scope.update = function(opts) {
@ -93,36 +82,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
}
};
$scope.openWalletsModal = function(wallets) {
self.error = null;
$scope.type = 'SELL';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.self = self;
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.walletsModal = modal;
$scope.walletsModal.show();
});
$scope.$on('walletSelected', function(ev, walletId) {
$timeout(function() {
wallet = profileService.getClient(walletId);
self.selectedWalletId = walletId;
self.selectedWalletName = wallet.credentials.walletName;
$scope.$apply();
}, 100);
$scope.walletsModal.hide();
});
};
this.getSellPrice = function(token, price) {
var self = this;
self.error = null;
if (!price || (price && !price.qty && !price.fiat)) {
self.sellPrice = null;
return;
@ -131,7 +92,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
glideraService.sellPrice(token, price, function(err, sellPrice) {
self.gettingSellPrice = false;
if (err) {
self.error = 'Could not get exchange information. Please, try again.';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
return;
}
self.sellPrice = sellPrice;
@ -145,7 +106,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
glideraService.get2faCode(token, function(err, sent) {
ongoingProcess.set('Sending 2FA code...', false);
if (err) {
self.error = 'Could not send confirmation code to your phone';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
} else {
self.show2faCodeInput = sent;
}
@ -155,29 +116,27 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
this.createTx = function(token, permissions, twoFaCode) {
var self = this;
self.error = null;
var outputs = [];
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
if (!wallet) {
self.error = 'No wallet selected';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('No wallet selected'));
return;
}
ongoingProcess.set('creatingTx', true);
walletService.getAddress(wallet, null, function(err, refundAddress) {
if (!refundAddress) {
ongoingProcess.clear();
self.error = bwcError.msg(err, 'Could not create address');
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, 'Could not create address'));
return;
}
glideraService.getSellAddress(token, function(error, sellAddress) {
if (!sellAddress) {
glideraService.getSellAddress(token, function(err, sellAddress) {
if (!sellAddress || err) {
ongoingProcess.clear();
self.error = 'Could not get the destination bitcoin address';
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get the destination bitcoin address'));
return;
}
var amount = parseInt((self.sellPrice.qty * 100000000).toFixed(0));
@ -205,28 +164,30 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
walletService.createTx(wallet, txp, function(err, createdTxp) {
ongoingProcess.clear();
if (err) {
self.error = err.message ||  bwcError.msg(err);
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
return;
}
walletService.prepare(wallet, txp, function(err, password) {
walletService.prepare(wallet, function(err, password) {
if (err) {
self.error = err.message ||  bwcError.msg(err);
ongoingProcess.clear();
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
return;
}
ongoingProcess.set('signingTx', true);
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
if (err) {
ongoingProcess.clear();
self.error = err.message ||  bwcError.msg(err);
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
return;
}
walletService.signTx(wallet, publishedTxp, function(err, password, signedTxp) {
walletService.removeTx(wallet, signedTxp, function(err) {
if (err) $log.debug(err);
});
ongoingProcess.clear();
walletService.signTx(wallet, publishedTxp, password, function(err, signedTxp) {
if (err) {
self.error = err.message ||  bwcError.msg(err);
ongoingProcess.clear();
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
walletService.removeTx(wallet, signedTxp, function(err) {
if (err) $log.debug(err);
});
return;
}
var rawTx = signedTxp.raw;
@ -237,15 +198,17 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
ip: null
};
ongoingProcess.set('Seling Bitcoin', true);
ongoingProcess.set('Selling Bitcoin', true);
glideraService.sell(token, twoFaCode, data, function(err, data) {
ongoingProcess.clear();
if (err) {
self.error = err.message ||  bwcError.msg(err);
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
return;
}
self.success = data;
$scope.update();
$timeout(function() {
$scope.$digest();
});
});
});
});

View file

@ -824,7 +824,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
});
$ionicPlatform.on('resume', function() {
$rootScope.$emit('Local/Resume');
// Nothing tot do
});
$ionicPlatform.on('menubutton', function() {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, bitcore) {
var root = {};
root.redir = function(data) {
@ -32,7 +32,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
data = sanitizeUri(data);
// BIP21
// BIP21
if (bitcore.URI.isValid(data)) {
var parsed = new bitcore.URI(data);
@ -52,7 +52,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
}
return true;
// Plain URL
// Plain URL
} else if (/^https?:\/\//.test(data)) {
return $state.go('send.confirm', {paypro: data})
@ -64,10 +64,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
// copay: protocol
} else if (data.indexOf('copay:glidera')==0) {
return $state.go('send.uriglidera', {url: data})
} else if (data.indexOf('copay:coinbase')==0) {
return $state.go('send.uricoinbase', {url: data})
} else if (data.indexOf('copay://glidera')==0) {
return $state.go('uriglidera', {url: data})
} else if (data.indexOf('copay://coinbase')==0) {
return $state.go('uricoinbase', {url: data})
// Join
} else if (data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {

View file

@ -885,6 +885,14 @@ input[type=file] {
text-align: left;
}
.right {
float: right;
}
.left {
float: left;
}
.input-label {
max-width: none;
width: inherit;