mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #488 from cmgustavo/bug/bitpay-card-flash-get-started
Bug/bitpay card Get Started message
This commit is contained in:
commit
b48438be8c
|
@ -6,7 +6,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
$scope.dateRange = { value: 'last30Days'};
|
||||
$scope.network = bitpayCardService.getEnvironment();
|
||||
|
||||
var getFromCache = function(cb) {
|
||||
var updateHistoryFromCache = function(cb) {
|
||||
bitpayCardService.getBitpayDebitCardsHistory($scope.cardId, function(err, data) {
|
||||
if (err || lodash.isEmpty(data)) return cb();
|
||||
$scope.historyCached = true;
|
||||
|
@ -41,40 +41,55 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
};
|
||||
};
|
||||
|
||||
var setGetStarted = function(history, cb) {
|
||||
if (lodash.isEmpty(history.transactionList)) {
|
||||
var dateRange = setDateRange('all');
|
||||
bitpayCardService.getHistory($scope.cardId, dateRange, function(err, history) {
|
||||
if (lodash.isEmpty(history.transactionList)) return cb(true);
|
||||
return cb(false);
|
||||
});
|
||||
} else return cb(false);
|
||||
};
|
||||
|
||||
this.update = function() {
|
||||
var dateRange = setDateRange($scope.dateRange.value);
|
||||
|
||||
$scope.loadingHistory = true;
|
||||
bitpayCardService.getHistory($scope.cardId, dateRange, function(err, history) {
|
||||
$scope.loadingHistory = false;
|
||||
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
$scope.error = gettextCatalog.getString('Could not get transactions');
|
||||
return;
|
||||
}
|
||||
|
||||
var txs = lodash.clone(history.txs);
|
||||
for (var i = 0; i < txs.length; i++) {
|
||||
txs[i] = _getMerchantInfo(txs[i]);
|
||||
txs[i].icon = _getIconName(txs[i]);
|
||||
txs[i].desc = _processDescription(txs[i]);
|
||||
}
|
||||
self.bitpayCardTransactionHistory = txs;
|
||||
self.bitpayCardCurrentBalance = history.currentCardBalance;
|
||||
setGetStarted(history, function(getStarted) {
|
||||
self.getStarted = getStarted;
|
||||
|
||||
if ($scope.dateRange.value == 'last30Days') {
|
||||
$log.debug('BitPay Card: store cache history');
|
||||
var cacheHistory = {
|
||||
balance: history.currentCardBalance,
|
||||
transactions: history.txs
|
||||
};
|
||||
bitpayCardService.setBitpayDebitCardsHistory($scope.cardId, cacheHistory, {}, function(err) {
|
||||
if (err) $log.error(err);
|
||||
$scope.historyCached = true;
|
||||
var txs = lodash.clone(history.txs);
|
||||
for (var i = 0; i < txs.length; i++) {
|
||||
txs[i] = _getMerchantInfo(txs[i]);
|
||||
txs[i].icon = _getIconName(txs[i]);
|
||||
txs[i].desc = _processDescription(txs[i]);
|
||||
}
|
||||
self.bitpayCardTransactionHistory = txs;
|
||||
self.bitpayCardCurrentBalance = history.currentCardBalance;
|
||||
|
||||
if ($scope.dateRange.value == 'last30Days') {
|
||||
$log.debug('BitPay Card: store cache history');
|
||||
var cacheHistory = {
|
||||
balance: history.currentCardBalance,
|
||||
transactions: history.txs
|
||||
};
|
||||
bitpayCardService.setBitpayDebitCardsHistory($scope.cardId, cacheHistory, {}, function(err) {
|
||||
if (err) $log.error(err);
|
||||
$scope.historyCached = true;
|
||||
});
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -112,7 +127,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
$state.go('tabs.home');
|
||||
popupService.showAlert(null, msg);
|
||||
} else {
|
||||
getFromCache(function() {
|
||||
updateHistoryFromCache(function() {
|
||||
self.update();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ angular.module('copayApp.controllers').controller('bitpayCardIntroController', f
|
|||
|
||||
var checkOtp = function(obj, cb) {
|
||||
if (obj.otp) {
|
||||
var msg = gettextCatalog.getString('Enter Two Factor for BitPay Cards');
|
||||
var msg = gettextCatalog.getString('Enter Two Factor for BitPay Card');
|
||||
popupService.showPrompt(null, msg, null, function(res) {
|
||||
cb(res);
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ angular.module('copayApp.controllers').controller('bitpayCardIntroController', f
|
|||
popupService.showAlert(null, err);
|
||||
return;
|
||||
}
|
||||
var title = gettextCatalog.getString('Add BitPay Cards?');
|
||||
var title = gettextCatalog.getString('Add BitPay Card?');
|
||||
var msg = gettextCatalog.getString('Would you like to add this account ({{email}}) to your wallet?', {email: obj.email});
|
||||
var ok = gettextCatalog.getString('Add cards');
|
||||
var cancel = gettextCatalog.getString('Go back');
|
||||
|
|
|
@ -905,7 +905,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
screen.lockOrientation('portrait');
|
||||
|
||||
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
|
||||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
|
||||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
|
||||
cordova.plugins.Keyboard.disableScroll(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,22 +39,25 @@
|
|||
</div>
|
||||
|
||||
<div
|
||||
class="m10t text-center padding"
|
||||
ng-if="!loadingHistory && !bitpayCard.bitpayCardTransactionHistory[0] && !error">
|
||||
class="m10t text-center padding ng-hide"
|
||||
ng-show="bitpayCard.getStarted">
|
||||
<i class="icon ion-ios-arrow-thin-up size-24"></i>
|
||||
<h1>Get started</h1>
|
||||
<h4>Your BitPay Card is ready. Add funds to your card to start using your card at stores and ATMs worldwide.</h4>
|
||||
</div>
|
||||
|
||||
<div class="list" ng-if="bitpayCard.bitpayCardTransactionHistory[0] && !error">
|
||||
<div class="item item-divider">
|
||||
<select class="select-style" ng-model="dateRange.value" ng-change="bitpayCard.update()">
|
||||
<option value="last30Days">Recent Activity</option>
|
||||
<option value="lastMonth">Last Month</option>
|
||||
<option value="all">All Activity</option>
|
||||
</select>
|
||||
</div>
|
||||
<div
|
||||
<div class="list" ng-show="!bitpayCard.getStarted">
|
||||
<label class="item item-input item-select">
|
||||
<div class="input-label" translate>
|
||||
Activity
|
||||
</div>
|
||||
<select ng-model="dateRange.value" ng-change="bitpayCard.update()">
|
||||
<option value="last30Days" selected translate>Recent</option>
|
||||
<option value="lastMonth" translate>Last Month</option>
|
||||
<option value="all" translate>All</option>
|
||||
</select>
|
||||
</label>
|
||||
<div ng-if="bitpayCard.bitpayCardTransactionHistory[0]"
|
||||
ng-repeat="tx in bitpayCard.bitpayCardTransactionHistory | orderBy: ['pending','-timestamp']"
|
||||
class="item row">
|
||||
<div class="col col-10">
|
||||
|
@ -74,18 +77,18 @@
|
|||
{{tx.desc}}
|
||||
</div>
|
||||
-->
|
||||
<div class="col col-20 text-center p10t">
|
||||
<div class="col col-10 text-center p10t">
|
||||
<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="col col-20 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,
|
||||
'text-gray': tx.amount.indexOf('-') == -1 && tx.pending}">
|
||||
{{tx.amount | currency:'$':2 }}
|
||||
</div>
|
||||
<time ng-if="!tx.pending">{{tx.timestamp | amCalendar}}</time>
|
||||
<time ng-if="!tx.pending">{{tx.timestamp | amTimeAgo}}</time>
|
||||
<span ng-if="tx.pending" class="tu" translate>Pending</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
<div class="bg icon-bitpay-card"></div>
|
||||
</i>
|
||||
<h2>BitPay Visa® Card</h2>
|
||||
<p translate>Add your cards</p>
|
||||
<p translate>Add your card</p>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue