Merge branch 'master' of https://github.com/bitpay/copay into feat/app-identity

This commit is contained in:
Andy Phillipson 2017-01-03 14:08:41 -05:00
commit 189117433a
85 changed files with 1252 additions and 1224 deletions

View file

@ -10,7 +10,7 @@ angular.module('copayApp.controllers').controller('addressbookAddController', fu
'email': ''
};
$scope.onQrCodeScanned = function(data, addressbookForm) {
$scope.onQrCodeScannedAddressBook = function(data, addressbookForm) {
$timeout(function() {
var form = addressbookForm;
if (data && form) {

View file

@ -1,9 +1,8 @@
'use strict';
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicPopover, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, platformInfo) {
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, platformInfo) {
var UNUSED_ADDRESS_LIMIT = 5;
var BALANCE_ADDRESS_LIMIT = 5;
var MENU_ITEM_HEIGHT = 55;
var config;
var unitName;
var unitToSatoshi;
@ -100,6 +99,13 @@ angular.module('copayApp.controllers').controller('addressesController', functio
});
};
$scope.requestSpecificAmount = function() {
$state.go('tabs.receive.amount', {
customAmount: true,
toAddress: $stateParams.toAddress
});
}
$scope.showInformation = function() {
$timeout(function() {
$scope.showInfo = !$scope.showInfo;
@ -114,36 +120,13 @@ angular.module('copayApp.controllers').controller('addressesController', functio
}, 10);
};
$scope.showMenu = function(allAddresses, $event) {
var scanObj = {
text: gettextCatalog.getString('Scan addresses for funds'),
action: scan,
};
var sendAddressesObj = {
text: gettextCatalog.getString('Send addresses by email'),
action: sendByEmail,
}
$scope.items = allAddresses ? [sendAddressesObj] : [scanObj];
$scope.height = $scope.items.length * MENU_ITEM_HEIGHT;
$ionicPopover.fromTemplateUrl('views/includes/menu-popover.html', {
scope: $scope
}).then(function(popover) {
$scope.menu = popover;
$scope.menu.show($event);
});
};
var scan = function() {
$scope.scan = function() {
walletService.startScan($scope.wallet);
$scope.menu.hide();
$ionicHistory.clearHistory();
$state.go('tabs.home');
};
var sendByEmail = function() {
$scope.sendByEmail = function() {
function formatDate(ts) {
var dateObj = new Date(ts * 1000);
if (!dateObj) {

View file

@ -29,50 +29,6 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
};
};
$scope.global = $rootScope;
if (!$scope.global.developmentUtilitiesEnabled) {
$scope.global.developmentUtilitiesEnabled = {
value: false
};
}
$scope.toggledDevelopmentUtils = function() {
if ($scope.global.developmentUtilitiesEnabled.value) {
$log.debug('User enabled development utilities.');
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
} else {
$log.debug('User disabled development utilities.');
}
}
$scope.activateFeedbackCard = function() {
$scope.feedbackCardActivating = true;
storageService.getFeedbackInfo(function(error, info) {
var feedbackInfo = JSON.parse(info);
// hardcoding so we can distinguish from normal operation
feedbackInfo.time = 1231006505; // genesis block time
feedbackInfo.version = window.version;
feedbackInfo.sent = false;
storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() {
$log.debug('Activated feedback card with: ' + JSON.stringify(feedbackInfo));
$ionicHistory.clearCache();
$timeout(function() {
$scope.feedbackCardActivating = false;
$scope.feedbackCardActivated = true;
$timeout(function() {
$scope.feedbackCardActivated = false;
}, 10000);
}, 500);
});
});
}
$scope.resetActivateFeedbackCard = function() {
$scope.feedbackCardActivated = false;
}
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('amazonController',
function($scope, $timeout, $ionicModal, $log, lodash, amazonService, platformInfo, externalLinkService, popupService, gettextCatalog) {
function($scope, $timeout, $ionicModal, $log, $ionicScrollDelegate, lodash, amazonService, platformInfo, externalLinkService, popupService, ongoingProcess) {
$scope.network = amazonService.getEnvironment();
@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('amazonController',
var initAmazon = function() {
amazonService.getPendingGiftCards(function(err, gcds) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
popupService.showAlert('Error', err);
return;
}
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
@ -24,7 +24,7 @@ angular.module('copayApp.controllers').controller('amazonController',
claimCode: $scope.cardClaimCode
});
if (lodash.isEmpty(card)) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Card not found'));
popupService.showAlert('Error', 'Card not found');
return;
}
$scope.openCardModal(card);
@ -34,18 +34,29 @@ angular.module('copayApp.controllers').controller('amazonController',
};
$scope.updatePendingGiftCards = lodash.debounce(function() {
ongoingProcess.set('updatingGiftCards', true);
amazonService.getPendingGiftCards(function(err, gcds) {
if (lodash.isEmpty(gcds)) {
$timeout(function() {
ongoingProcess.set('updatingGiftCards', false);
}, 1000);
}
$timeout(function() {
$scope.giftCards = gcds;
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
$scope.$digest();
});
var index = 0;
lodash.forEach(gcds, function(dataFromStorage) {
if (++index == Object.keys(gcds).length) {
$timeout(function() {
ongoingProcess.set('updatingGiftCards', false);
}, 1000);
}
if (dataFromStorage.status == 'PENDING') {
$log.debug("creating gift card");
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
popupService.showAlert('Error', err);
return;
}
if (giftCard.status != 'PENDING') {
@ -65,13 +76,14 @@ angular.module('copayApp.controllers').controller('amazonController',
$log.debug("Saving new gift card");
amazonService.getPendingGiftCards(function(err, gcds) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
popupService.showAlert('Error', err);
return;
}
$scope.giftCards = gcds;
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
$timeout(function() {
$scope.$digest();
});
$ionicScrollDelegate.resize();
}, 10);
});
});
} else $log.debug("pending gift card not available yet");
@ -80,7 +92,9 @@ angular.module('copayApp.controllers').controller('amazonController',
});
});
}, 1000);
}, 1000, {
'leading': true
});
$scope.openCardModal = function(card) {
$scope.card = card;
@ -92,8 +106,8 @@ angular.module('copayApp.controllers').controller('amazonController',
$scope.amazonCardDetailsModal.show();
});
$scope.$on('UpdateAmazonList', function(event) {
initAmazon();
$scope.$on('modal.hidden', function() {
$scope.updatePendingGiftCards();
});
};

View file

@ -1,13 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, $ionicPopover, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService) {
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService) {
var unitToSatoshi;
var satToUnit;
var unitDecimals;
var satToBtc;
var SMALL_FONT_SIZE_LIMIT = 10;
var LENGTH_EXPRESSION_LIMIT = 19;
var MENU_ITEM_HEIGHT = 55;
$scope.$on('$ionicView.leave', function() {
angular.element($window).off('keydown');
@ -21,7 +20,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
$scope.cardId = data.stateParams.cardId;
$scope.showMenu = $ionicHistory.backView().stateName == 'tabs.send';
$scope.showMenu = $ionicHistory.backView() && $ionicHistory.backView().stateName == 'tabs.send';
var isWallet = data.stateParams.isWallet || 'false';
$scope.isWallet = (isWallet.toString().trim().toLowerCase() == 'true' ? true : false);
$scope.toAddress = data.stateParams.toAddress;
@ -29,6 +28,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera;
$scope.toColor = data.stateParams.toColor;
$scope.showSendMax = false;
$scope.customAmount = data.stateParams.customAmount;
@ -71,7 +71,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
var config = configService.getSync().wallet.settings;
$scope.unitName = config.unitName;
$scope.alternativeIsoCode = config.alternativeIsoCode;
$scope.alternativeIsoCode = !!$scope.cardId || !!$scope.isGiftCard ? 'USD' : config.alternativeIsoCode;
$scope.specificAmount = $scope.specificAlternativeAmount = '';
$scope.isCordova = platformInfo.isCordova;
unitToSatoshi = config.unitToSatoshi;
@ -93,25 +93,12 @@ angular.module('copayApp.controllers').controller('amountController', function($
}, 10);
});
$scope.showSendMaxMenu = function($event) {
var sendMaxObj = {
text: gettextCatalog.getString('Send max amount'),
action: setSendMax,
};
$scope.items = [sendMaxObj];
$scope.height = $scope.items.length * MENU_ITEM_HEIGHT;
$ionicPopover.fromTemplateUrl('views/includes/menu-popover.html', {
scope: $scope
}).then(function(popover) {
$scope.menu = popover;
$scope.menu.show($event);
});
$scope.showSendMaxMenu = function() {
$scope.showSendMax = true;
};
function setSendMax() {
$scope.menu.hide();
$scope.sendMax = function() {
$scope.showSendMax = false;
$state.transitionTo('tabs.send.confirm', {
isWallet: $scope.isWallet,
toAmount: null,
@ -205,11 +192,11 @@ angular.module('copayApp.controllers').controller('amountController', function($
};
function fromFiat(val) {
return parseFloat((rateService.fromFiat(val, $scope.alternativeIsoCode) * satToUnit).toFixed(unitDecimals), 10);
return parseFloat((rateService.fromFiat(val, $scope.alternativeIsoCode) * satToUnit).toFixed(unitDecimals));
};
function toFiat(val) {
return parseFloat((rateService.toFiat(val * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10);
return parseFloat((rateService.toFiat(val * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2));
};
function evaluate(val) {
@ -283,6 +270,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
}
var stateParams = {
cardId: $scope.cardId,
cardAmountUSD: amountUSD,
toName: $scope.toName,
toAmount: payProDetails.amount,
toAddress: payProDetails.toAddress,
@ -303,7 +291,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
try {
uuid = profileService.getWallets({
onlyComplete: true,
network: 'livenet',
network: amazonService.getEnvironment(),
})[0].id;
} catch (err) {
ongoingProcess.set('Preparing transaction...', false);

View file

@ -31,6 +31,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var isWallet = data.stateParams.isWallet || 'false';
$scope.isWallet = (isWallet.toString().trim().toLowerCase() == 'true' ? true : false);
$scope.cardId = data.stateParams.cardId;
$scope.cardAmountUSD = data.stateParams.cardAmountUSD;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
@ -62,9 +63,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (!$scope.wallets || !$scope.wallets.length) {
$scope.noMatchingWallet = true;
if ($scope.paypro) {
displayValues();
}
displayValues();
$log.warn('No ' + $scope.network + ' wallets to make the payment');
$timeout(function() {
$scope.$apply();
});
@ -106,6 +106,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
} else initConfirm();
} else {
if (!enoughFunds) $scope.insufficientFunds = true;
displayValues();
$log.warn('No wallet available to make the payment');
}
$timeout(function() {
@ -132,9 +133,15 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.amountStr = txFormatService.formatAmountStr(toAmount);
$scope.displayAmount = getDisplayAmount($scope.amountStr);
$scope.displayUnit = getDisplayUnit($scope.amountStr);
txFormatService.formatAlternativeStr(toAmount, function(v) {
$scope.alternativeAmountStr = v;
});
if ($scope.cardAmountUSD) {
$scope.alternativeAmountStr = $filter('formatFiatAmount')($scope.cardAmountUSD) + ' USD';
} else if ($scope.giftCardAmountUSD) {
$scope.alternativeAmountStr = $filter('formatFiatAmount')($scope.giftCardAmountUSD) + ' USD';
} else {
txFormatService.formatAlternativeStr(toAmount, function(v) {
$scope.alternativeAmountStr = v;
});
}
if ($scope.isGlidera == 'buy') $scope.getBuyPrice();
if ($scope.isGlidera == 'sell') $scope.getSellPrice();
};
@ -428,6 +435,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
};
$scope.cancel = function() {
$scope.payproModal.hide();
};
$scope.approve = function(onSendStatusChange) {
var wallet = $scope.wallet;
@ -783,6 +794,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
invoiceUrl: $scope.paypro.url,
invoiceTime: giftCardInvoiceTime
};
ongoingProcess.set('creatingGiftCard', true);
debounceCreate(count, dataSrc, onSendStatusChange);
}
}, onSendStatusChange);
@ -795,7 +807,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
var debounceCreateGiftCard = function(count, dataSrc, onSendStatusChange) {
amazonService.createGiftCard(dataSrc, function(err, giftCard) {
$log.debug("creating gift card " + count);
if (err) {
@ -830,6 +841,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}
amazonService.savePendingGiftCard(newData, null, function(err) {
ongoingProcess.set('creatingGiftCard', false);
$log.debug("Saving new gift card with status: " + newData.status);
$scope.amazonGiftCard = newData;
});

View file

@ -1,10 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, $window, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
var appName = $window.appConfig.userVisibleName;
var appUrl = $window.appConfig.url;
var appName = appConfigService.userVisibleName;
var appUrl = appConfigService.url;
$scope.isCordova = platformInfo.isCordova;
$scope.$on("$ionicView.beforeEnter", function(event, data) {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('createController',
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, $window) {
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) {
var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova;
@ -80,7 +80,7 @@ angular.module('copayApp.controllers').controller('createController',
*/
if ($window.appConfig.name == 'copay') {
if (appConfigService.name == 'copay') {
if (n > 1 && isChromeApp) {
seedOptions.push({
id: 'ledger',

View file

@ -18,8 +18,7 @@ angular.module('copayApp.controllers').controller('customAmountController', func
$scope.finish = function() {
$ionicHistory.nextViewOptions({
disableAnimate: false,
historyRoot: true
disableAnimate: false
});
$ionicHistory.goBack(-2);
};

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('exportController',
function($scope, $timeout, $log, $ionicHistory, $ionicScrollDelegate, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService, $window) {
function($scope, $timeout, $log, $ionicHistory, $ionicScrollDelegate, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService, appConfigService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.showAdvChange = function() {
@ -191,7 +191,7 @@ angular.module('copayApp.controllers').controller('exportController',
if ($scope.formData.noSignEnabled)
name = name + '(No Private Key)';
var subject = $window.appConfig.nameCase + ' Wallet Backup: ' + name;
var subject = appConfigService.nameCase + ' Wallet Backup: ' + name;
var body = 'Here is the encrypted backup of the wallet ' + name + ': \n\n' + ew + '\n\n To import this backup, copy all text between {...}, including the symbols {}';
window.plugins.socialsharing.shareViaEmail(
body,

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('sendController', function($scope, $state, $log, $timeout, $stateParams, $ionicNavBarDelegate, $ionicHistory, $ionicConfig, $window, gettextCatalog, popupService, configService, lodash, feedbackService, ongoingProcess) {
angular.module('copayApp.controllers').controller('sendController', function($scope, $state, $log, $timeout, $stateParams, $ionicNavBarDelegate, $ionicHistory, $ionicConfig, $window, gettextCatalog, popupService, configService, lodash, feedbackService, ongoingProcess, platformInfo) {
$scope.sendFeedback = function(feedback, goHome) {
@ -42,6 +42,7 @@ angular.module('copayApp.controllers').controller('sendController', function($sc
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.isCordova = platformInfo.isCordova;
$scope.score = (data.stateParams && data.stateParams.score) ? parseInt(data.stateParams.score) : null;
$scope.feedback = {};

View file

@ -1,7 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('headController',
function($scope, $window, $log) {
$scope.appConfig = $window.appConfig;
$log.info('Running head controller:' + $window.appConfig.nameCase)
});
angular.module('copayApp.controllers').controller('headController', function($scope, appConfigService, $log) {
$scope.appConfig = appConfigService;
$log.info('Running head controller:' + appConfigService.nameCase)
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('importController',
function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, $window) {
function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, appConfigService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
@ -17,7 +17,7 @@ angular.module('copayApp.controllers').controller('importController',
$scope.formData.derivationPath = derivationPathHelper.default;
$scope.formData.account = 1;
$scope.importErr = false;
$scope.showHardwareWallet = $window.appConfig.name == 'copay';
$scope.showHardwareWallet = appConfigService.name == 'copay';
if ($stateParams.code)
$scope.processWalletInfo($stateParams.code);
@ -238,6 +238,7 @@ angular.module('copayApp.controllers').controller('importController',
if (!words) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the recovery phrase'));
return;
} else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
return _importExtendedPrivateKey(words, opts);
} else if (words.indexOf('xpub') == 0 || words.indexOf('tpuv') == 0) {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, $window) {
function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
@ -33,7 +33,7 @@ angular.module('copayApp.controllers').controller('joinController',
}
};
this.onQrCodeScanned = function(data) {
this.onQrCodeScannedJoin = function(data) {
$scope.secret = data;
if ($scope.joinForm) {
$scope.joinForm.secret.$setViewValue(data);
@ -44,7 +44,7 @@ angular.module('copayApp.controllers').controller('joinController',
if ($stateParams.url) {
var data = $stateParams.url;
data = data.replace('copay:', '');
this.onQrCodeScanned(data);
this.onQrCodeScannedJoin(data);
}
var updateSeedSourceSelect = function() {
@ -63,7 +63,7 @@ angular.module('copayApp.controllers').controller('joinController',
*/
if ($window.appConfig.name == 'copay') {
if (appConfigService.name == 'copay') {
if (isChromeApp) {
self.seedOptions.push({
id: 'ledger',

View file

@ -1,18 +1,22 @@
'use strict';
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess, popupService, gettextCatalog, externalLinkService) {
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, $ionicScrollDelegate, bwcError, amazonService, lodash, ongoingProcess, popupService, externalLinkService) {
$scope.cancelGiftCard = function() {
ongoingProcess.set('Canceling gift card...', true);
ongoingProcess.set('cancelingGiftCard', true);
amazonService.cancelGiftCard($scope.card, function(err, data) {
ongoingProcess.set('Canceling gift card...', false);
ongoingProcess.set('cancelingGiftCard', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
popupService.showAlert('Error', bwcError.msg(err));
return;
}
$scope.card.cardStatus = data.cardStatus;
$timeout(function() {
$ionicScrollDelegate.resize();
$ionicScrollDelegate.scrollTop();
}, 10);
amazonService.savePendingGiftCard($scope.card, null, function(err) {
$scope.$emit('UpdateAmazonList');
$scope.refreshGiftCard();
});
});
};
@ -21,23 +25,34 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
amazonService.savePendingGiftCard($scope.card, {
remove: true
}, function(err) {
$scope.$emit('UpdateAmazonList');
$scope.cancel();
});
};
$scope.refreshGiftCard = function() {
ongoingProcess.set('updatingGiftCard', true);
amazonService.getPendingGiftCards(function(err, gcds) {
if (lodash.isEmpty(gcds)) {
$timeout(function() {
ongoingProcess.set('updatingGiftCard', false);
}, 1000);
}
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
popupService.showAlert('Error', err);
return;
}
var index = 0;
lodash.forEach(gcds, function(dataFromStorage) {
if (++index == Object.keys(gcds).length) {
$timeout(function() {
ongoingProcess.set('updatingGiftCard', false);
}, 1000);
}
if (dataFromStorage.status == 'PENDING' && dataFromStorage.invoiceId == $scope.card.invoiceId) {
$log.debug("creating gift card");
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
popupService.showAlert('Error', bwcError.msg(err));
return;
}
if (!lodash.isEmpty(giftCard)) {
@ -46,7 +61,6 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
amazonService.savePendingGiftCard(newData, null, function(err) {
$log.debug("Saving new gift card");
$scope.card = newData;
$scope.$emit('UpdateAmazonList');
$timeout(function() {
$scope.$digest();
});

View file

@ -1,9 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('payproController', function($scope) {
var self = $scope.self;
$scope.cancel = function() {
$scope.payproModal.hide();
};
});

View file

@ -7,15 +7,15 @@ angular.module('copayApp.controllers').controller('backupRequestController', fun
$scope.openPopup = function() {
var title = gettextCatalog.getString('Without a backup, you could lose money.');
var title = gettextCatalog.getString('Watch out!');
var message = gettextCatalog.getString('If this device is replaced or this app is deleted, neither you nor BitPay can recover your funds without a backup.');
var okText = gettextCatalog.getString('I understand');
var cancelText = gettextCatalog.getString('Go back');
popupService.showConfirm(title, message, okText, cancelText, function(val) {
if (val) {
var title = gettextCatalog.getString('Are you sure you want to skip the backup?');
var title = gettextCatalog.getString('Are you sure you want to skip it?');
var message = gettextCatalog.getString('You can create a backup later from your wallet settings.');
var okText = gettextCatalog.getString('Yes, skip backup');
var okText = gettextCatalog.getString('Yes, skip');
var cancelText = gettextCatalog.getString('Go back');
popupService.showConfirm(title, message, okText, cancelText, function(val) {
if (val) {

View file

@ -5,7 +5,8 @@ angular.module('copayApp.controllers').controller('disclaimerController', functi
$scope.$on("$ionicView.afterEnter", function() {
startupService.ready();
});
$scope.init = function() {
$scope.$on("$ionicView.beforeEnter", function() {
$scope.lang = uxLanguage.currentLanguage;
$scope.terms = {};
$scope.accepted = {};
@ -13,10 +14,7 @@ angular.module('copayApp.controllers').controller('disclaimerController', functi
$scope.backedUp = $stateParams.backedUp;
$scope.resume = $stateParams.resume;
$scope.shrinkView = false;
$timeout(function() {
$scope.$apply();
}, 1);
};
});
$scope.confirm = function() {
profileService.setDisclaimerAccepted(function(err) {

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, $window, uxLanguage, profileService, externalLinkService, gettextCatalog) {
angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, appConfigService, uxLanguage, profileService, externalLinkService, gettextCatalog) {
$scope.lang = uxLanguage.currentLanguage;
$scope.confirm = function() {
@ -15,10 +15,10 @@ angular.module('copayApp.controllers').controller('termsController', function($s
};
$scope.openExternalLink = function() {
var url = $window.appConfig.disclaimerUrl;
var url = appConfigService.disclaimerUrl;
var optIn = true;
var title = gettextCatalog.getString('View Terms of Service');
var message = gettextCatalog.getString('The official English Terms of Service are available on the BitPay website. Would you like to view them?');
var message = gettextCatalog.getString('The official English Terms of Service are available on the BitPay website.');
var okText = gettextCatalog.getString('Open Website');
var cancelText = gettextCatalog.getString('Go Back');
externalLinkService.open(url, optIn, title, message, okText, cancelText);

View file

@ -8,13 +8,6 @@ angular.module('copayApp.controllers').controller('welcomeController', function(
startupService.ready();
});
$scope.goImport = function(code) {
$state.go('onboarding.import', {
fromOnboarding: true,
code: code
});
};
$scope.createProfile = function() {
$log.debug('Creating profile');
profileService.createProfile(function(err) {

View file

@ -1,14 +1,14 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAbout',
function($scope, $window, gettextCatalog, externalLinkService) {
function($scope, $window, appConfigService, gettextCatalog, externalLinkService) {
$scope.title = gettextCatalog.getString('About') + ' ' + $window.appConfig.nameCase;
$scope.title = gettextCatalog.getString('About') + ' ' + appConfigService.nameCase;
$scope.version = $window.version;
$scope.commitHash = $window.commitHash;
$scope.openExternalLink = function() {
var url = 'https://github.com/bitpay/' + $window.appConfig.gitHubRepoName + '/tree/' + $window.commitHash + '';
var url = 'https://github.com/bitpay/' + appConfigService.gitHubRepoName + '/tree/' + $window.commitHash + '';
var optIn = true;
var title = gettextCatalog.getString('Open GitHub Project');
var message = gettextCatalog.getString('You can see the latest developments and contribute to this open source app by visiting our project on GitHub.');

View file

@ -1,14 +1,14 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
function($scope, $log, $stateParams, configService, applicationService, profileService, storageService, $window) {
function($scope, $log, $stateParams, configService, applicationService, profileService, storageService, appConfigService) {
$scope.success = null;
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
var defaults = configService.getDefaults();
var config = configService.getSync();
$scope.appName = $window.appConfig.nameCase;
$scope.appName = appConfigService.nameCase;
$scope.bwsurl = {
value: (config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url
};

View file

@ -1,11 +1,11 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesHistory',
function($scope, $log, $stateParams, $timeout, $state, $ionicHistory, storageService, platformInfo, profileService, lodash, $window) {
function($scope, $log, $stateParams, $timeout, $state, $ionicHistory, storageService, platformInfo, profileService, lodash, appConfigService) {
$scope.wallet = profileService.getWallet($stateParams.walletId);
$scope.csvReady = false;
$scope.isCordova = platformInfo.isCordova;
$scope.appName = $window.appConfig.nameCase;
$scope.appName = appConfigService.nameCase;
$scope.csvHistory = function(cb) {
var allTxs = [];

View file

@ -1,9 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $timeout, $window, lodash, configService, platformInfo, pushNotificationsService, profileService, emailService) {
angular.module('copayApp.controllers').controller('preferencesNotificationsController', function($scope, $log, $timeout, appConfigService, lodash, configService, platformInfo, pushNotificationsService, profileService, emailService) {
var updateConfig = function() {
var config = configService.getSync();
$scope.appName = $window.appConfig.nameCase;
$scope.appName = appConfigService.nameCase;
$scope.PNEnabledByUser = true;
$scope.usePushNotifications = platformInfo.isCordova && !platformInfo.isWP;
$scope.isIOSApp = platformInfo.isIOS && platformInfo.isCordova;

View file

@ -1,14 +1,14 @@
'use strict';
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService, startupService, addressbookService, feedbackService) {
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, bitpayCardService, startupService, addressbookService, feedbackService) {
var wallet;
var listeners = [];
var notifications = [];
$scope.externalServices = {};
$scope.openTxpModal = txpModalService.open;
$scope.version = $window.version;
$scope.name = $window.appConfig.nameCase;
$scope.name = appConfigService.nameCase;
$scope.homeTip = $stateParams.fromOnboarding;
$scope.isCordova = platformInfo.isCordova;
$scope.isAndroid = platformInfo.isAndroid;
@ -43,7 +43,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
} else {
var feedbackInfo = JSON.parse(info);
//Check if current version is greater than saved version
var currentVersion = window.version;
var currentVersion = $scope.version;
var savedVersion = feedbackInfo.version;
var isVersionUpdated = feedbackService.isVersionUpdated(currentVersion, savedVersion);
if (!isVersionUpdated) {
@ -62,7 +62,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
function initFeedBackInfo() {
var feedbackInfo = {};
feedbackInfo.time = moment().unix();
feedbackInfo.version = window.version;
feedbackInfo.version = $scope.version;
feedbackInfo.sent = false;
storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() {
$scope.showRateCard.value = false;

View file

@ -3,7 +3,6 @@
angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, $ionicPopover, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService, bwcError) {
var listeners = [];
var MENU_ITEM_HEIGHT = 55;
$scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
$scope.walletAddrs = {};
@ -50,8 +49,9 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
};
$scope.showAddresses = function() {
$state.transitionTo('tabs.receive.addresses', {
walletId: $scope.wallet.credentials.walletId
$state.go('tabs.receive.addresses', {
walletId: $scope.wallet.credentials.walletId,
toAddress: $scope.addr
});
};
@ -140,31 +140,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
});
};
var goRequestAmount = function() {
$scope.menu.hide();
$state.go('tabs.receive.amount', {
customAmount: true,
toAddress: $scope.addr
});
}
$scope.showMenu = function(allAddresses, $event) {
var requestAmountObj = {
text: gettextCatalog.getString('Request Specific amount'),
action: goRequestAmount,
};
$scope.items = [requestAmountObj];
$scope.height = $scope.items.length * MENU_ITEM_HEIGHT;
$ionicPopover.fromTemplateUrl('views/includes/menu-popover.html', {
scope: $scope
}).then(function(popover) {
$scope.menu = popover;
$scope.menu.show($event);
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.wallets = profileService.getWallets();

View file

@ -133,13 +133,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
lodash.each(wallets, function(w) {
walletService.getStatus(w, {}, function(err, status) {
++index;
if (index == wallets.length) $scope.checkingBalance = false;
if (err || !status) {
if (err && !status) {
$log.error(err);
return;
}
if (status.availableBalanceSat > 0) {
} else if (status.availableBalanceSat > 0) {
$scope.hasFunds = true;
$rootScope.everHasFunds = true;
}
@ -148,6 +144,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
if ($scope.hasFunds != true) {
$ionicScrollDelegate.freezeScroll(true);
}
$scope.checkingBalance = false;
$timeout(function() {
$scope.$apply();
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $window, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService, gettextCatalog) {
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, appConfigService, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService, gettextCatalog) {
var updateConfig = function() {
var isCordova = platformInfo.isCordova;
@ -10,13 +10,13 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
$scope.usePushNotifications = isCordova && !isWP;
$scope.isCordova = isCordova;
$scope.appName = $window.appConfig.nameCase;
$scope.appName = appConfigService.nameCase;
$scope.currentLanguageName = uxLanguage.getCurrentLanguageName();
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.wallets = profileService.getWallets();
configService.whenAvailable(function(config) {
$scope.unitName = config.wallet.settings.unitName;
$scope.selectedAlternative = {
@ -33,7 +33,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
if (!lodash.isEmpty(data)) {
$scope.bitpayCards = true;
}
});
});
}
if ($scope.glideraEnabled) {
@ -50,7 +50,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
var url = 'https://help.bitpay.com/bitpay-app';
var optIn = true;
var title = gettextCatalog.getString('BitPay Help Center');
var message = gettextCatalog.getString('Help and support information is available at the BitPay Help Center website. Would you like to go there now?');
var message = gettextCatalog.getString('Help and support information is available at the BitPay Help Center website.');
var okText = gettextCatalog.getString('Open Help Center');
var cancelText = gettextCatalog.getString('Go Back');
externalLinkService.open(url, optIn, title, message, okText, cancelText);

View file

@ -1,9 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('termOfUseController',
function($scope, $window, uxLanguage, externalLinkService) {
function($scope, appConfigService, uxLanguage, externalLinkService) {
$scope.lang = uxLanguage.currentLanguage;
$scope.disclaimerUrl = $window.appConfig.disclaimerUrl;
$scope.disclaimerUrl = appConfigService.disclaimerUrl;
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);

View file

@ -122,8 +122,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
var btx = $scope.btx;
var url = 'https://' + ($scope.getShortNetworkName() == 'test' ? 'test-' : '') + 'insight.bitpay.com/tx/' + btx.txid;
var optIn = true;
var title = gettextCatalog.getString('View Transaction on Insight');
var message = gettextCatalog.getString('Would you like to view this transaction on the Insight blockchain explorer?');
var title = null;
var message = gettextCatalog.getString('View Transaction on Insight');
var okText = gettextCatalog.getString('Open Insight');
var cancelText = gettextCatalog.getString('Go Back');
externalLinkService.open(url, optIn, title, message, okText, cancelText);