2016-08-10 15:29:31 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('preferencesBitpayCardController',
|
2017-01-27 17:54:41 -03:00
|
|
|
function($scope, $state, $timeout, $ionicHistory, bitpayCardService, popupService, gettextCatalog, $log) {
|
2016-08-10 15:29:31 -03:00
|
|
|
|
2016-11-11 18:11:52 -05:00
|
|
|
$scope.remove = function(card) {
|
2016-11-14 16:58:54 -05:00
|
|
|
var msg = gettextCatalog.getString('Are you sure you would like to remove your BitPay Card ({{lastFourDigits}}) from this device?', {
|
2016-11-14 16:24:52 -05:00
|
|
|
lastFourDigits: card.lastFourDigits
|
|
|
|
|
});
|
2016-10-05 11:42:40 -03:00
|
|
|
popupService.showConfirm(null, msg, null, null, function(res) {
|
2017-01-27 17:54:41 -03:00
|
|
|
$log.info('Removing bitpay card:' + card.eid)
|
|
|
|
|
if (res)
|
|
|
|
|
remove(card.eid);
|
2016-09-06 15:14:07 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-27 17:54:41 -03:00
|
|
|
var remove = function(cardEid) {
|
|
|
|
|
bitpayCardService.remove(cardEid, function(err) {
|
2016-11-21 15:10:59 -05:00
|
|
|
if (err) {
|
2016-11-21 17:24:42 -05:00
|
|
|
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not remove card'));
|
2016-11-21 15:10:59 -05:00
|
|
|
}
|
2016-11-14 15:17:05 -03:00
|
|
|
$ionicHistory.clearHistory();
|
2016-09-06 15:14:07 -03:00
|
|
|
$timeout(function() {
|
2016-09-28 21:09:41 -03:00
|
|
|
$state.go('tabs.home');
|
2016-09-06 15:14:07 -03:00
|
|
|
}, 100);
|
2016-08-10 15:29:31 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-10-07 15:51:15 -03:00
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
2017-01-27 17:54:41 -03:00
|
|
|
bitpayCardService.getCards(function(err, data) {
|
2016-10-07 15:51:15 -03:00
|
|
|
if (err) return;
|
2017-01-27 17:54:41 -03:00
|
|
|
|
2016-11-11 18:11:52 -05:00
|
|
|
$scope.bitpayCards = data;
|
2016-10-07 15:51:15 -03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-10 15:29:31 -03:00
|
|
|
});
|