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