Merge branch 'ref/design' of https://github.com/bitpay/bitpay-wallet into feature/onboarding_last_steps

# Conflicts:
#	src/js/controllers/backup.js
This commit is contained in:
Jamal Jackson 2016-09-29 14:51:12 -04:00
commit 19a3e9afdc
85 changed files with 1579 additions and 1003 deletions

View file

@ -0,0 +1,113 @@
'use strict';
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
var updateConfig = function() {
var config = configService.getSync();
$scope.spendUnconfirmed = {
value: config.wallet.spendUnconfirmed
};
$scope.bitpayCardEnabled = {
value: config.bitpayCard.enabled
};
$scope.amazonEnabled = {
value: config.amazon.enabled
};
$scope.glideraEnabled = {
value: config.glidera.enabled
};
$scope.coinbaseEnabled = {
value: config.coinbase.enabled
};
$scope.recentTransactionsEnabled = {
value: config.recentTransactions.enabled
};
$scope.frequentlyUsedEnabled = {
value: config.frequentlyUsed.enabled
};
};
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {
spendUnconfirmed: $scope.spendUnconfirmed.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.bitpayCardChange = function() {
var opts = {
bitpayCard: {
enabled: $scope.bitpayCardEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.amazonChange = function() {
var opts = {
amazon: {
enabled: $scope.amazonEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.glideraChange = function() {
var opts = {
glidera: {
enabled: $scope.glideraEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.coinbaseChange = function() {
var opts = {
coinbase: {
enabled: $scope.coinbaseEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.recentTransactionsChange = function() {
var opts = {
recentTransactions: {
enabled: $scope.recentTransactionsEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.frequentlyUsedChange = function() {
var opts = {
frequentlyUsed: {
enabled: $scope.frequentlyUsedEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService) {
var unitToSatoshi;
var satToUnit;
@ -10,18 +10,20 @@ angular.module('copayApp.controllers').controller('amountController', function($
var SMALL_FONT_SIZE_LIMIT = 13;
var LENGTH_EXPRESSION_LIMIT = 19;
$scope.isWallet = $stateParams.isWallet;
$scope.toAddress = $stateParams.toAddress;
$scope.toName = $stateParams.toName;
$scope.toEmail = $stateParams.toEmail;
$scope.$on('$ionicView.beforeLeave', function() {
$scope.$on('$ionicView.leave', function() {
angular.element($window).off('keydown');
});
$scope.$on("$ionicView.beforeEnter", function(event, data) {
if (!$stateParams.toAddress) {
$scope.isWallet = data.stateParams.isWallet;
$scope.isCard = data.stateParams.isCard;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.isCard;
if (!$scope.isCard && !$stateParams.toAddress) {
$log.error('Bad params at amount')
throw ('bad params');
}
@ -60,6 +62,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
satToBtc = 1 / 100000000;
unitDecimals = config.unitDecimals;
$scope.resetAmount();
// in SAT ALWAYS
if ($stateParams.toAmount) {
$scope.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals);
@ -69,7 +73,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$timeout(function() {
$ionicScrollDelegate.resize();
}, 100);
}, 10);
});
$scope.toggleAlternative = function() {
@ -95,7 +99,6 @@ angular.module('copayApp.controllers').controller('amountController', function($
};
$scope.pushOperator = function(operator) {
console.log('[amount.js.90:operator:]', operator); //TODO
if (!$scope.amount || $scope.amount.length == 0) return;
$scope.amount = _pushOperator($scope.amount);
@ -183,14 +186,50 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.finish = function() {
var _amount = evaluate(format($scope.amount));
var amount = $scope.showAlternativeAmount ? fromFiat(_amount).toFixed(unitDecimals) : _amount.toFixed(unitDecimals);
$state.transitionTo('tabs.send.confirm', {
isWallet: $scope.isWallet,
toAmount: amount * unitToSatoshi,
toAddress: $scope.toAddress,
toName: $scope.toName,
toEmail: $scope.toEmail
});
if ($scope.isCard) {
var amountUSD = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount));
var dataSrc = {
amount: amountUSD,
currency: 'USD'
};
ongoingProcess.set('Processing Transaction...', true);
$timeout(function() {
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
if (err) {
ongoingProcess.set('Processing Transaction...', false);
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
bitpayCardService.getInvoice(invoiceId, function(err, data) {
ongoingProcess.set('Processing Transaction...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
var payProUrl = data.paymentUrls.BIP73;
$state.transitionTo('tabs.bitpayCard.confirm', {
isCard: $scope.isCard,
toName: $scope.toName,
paypro: payProUrl
});
});
});
});
} else {
var amount = $scope.showAlternativeAmount ? fromFiat(_amount).toFixed(unitDecimals) : _amount.toFixed(unitDecimals);
$state.transitionTo('tabs.send.confirm', {
isWallet: $scope.isWallet,
toAmount: amount * unitToSatoshi,
toAddress: $scope.toAddress,
toName: $scope.toName,
toEmail: $scope.toEmail
});
}
};
});

View file

@ -3,15 +3,14 @@
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, popupService, gettextCatalog, bwcError) {
var self = this;
var wallet;
$scope.dateRange = 'last30Days';
$scope.network = bitpayCardService.getEnvironment();
$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);
bitpayCardService.getCacheData(function(err, data) {
if (err || lodash.isEmpty(data)) return;
$scope.bitpayCardCached = true;
self.bitpayCardTransactionHistory = data.transactions;
self.bitpayCardCurrentBalance = data.balance;
});
var processTransactions = function(invoices, history) {
@ -89,6 +88,14 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
self.bitpayCardTransactionHistory = processTransactions(invoices, history.transactionList);
self.bitpayCardCurrentBalance = history.currentCardBalance;
var cacheData = {
balance: self.bitpayCardCurrentBalance,
transactions: self.bitpayCardTransactionHistory
};
bitpayCardService.setCacheData(cacheData, function(err) {
if (err) $log.error(err);
});
});
});
}
@ -98,103 +105,11 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
});
};
this.init = function() {
$scope.dateRange = 'last30Days';
$scope.network = bitpayCardService.getEnvironment();
$scope.wallets = profileService.getWallets({
network: $scope.network,
onlyComplete: true
});
self.update();
wallet = $scope.wallets[0];
if (wallet && wallet.credentials.n > 1)
self.isMultisigWallet = true;
};
this.sendFunds = function() {
if (lodash.isEmpty(wallet)) return;
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key');
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
return;
}
var dataSrc = {
amount: $scope.fiat,
currency: 'USD'
};
var outputs = [];
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
ongoingProcess.set('Processing Transaction...', true);
$timeout(function() {
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
if (err) {
ongoingProcess.set('Processing Transaction...', false);
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
bitpayCardService.getInvoice(invoiceId, function(err, data) {
var address, comment, amount;
address = data.bitcoinAddress;
amount = parseInt((data.btcPrice * 100000000).toFixed(0));
comment = data.itemDesc;
outputs.push({
'toAddress': address,
'amount': amount,
'message': comment
});
var txp = {
toAddress: address,
amount: amount,
outputs: outputs,
message: comment,
payProUrl: null,
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
feeLevel: walletSettings.feeLevel || 'normal'
};
walletService.createTx(wallet, txp, function(err, createdTxp) {
ongoingProcess.set('Processing Transaction...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
return;
}
self.update();
$scope.addFunds = false;
$timeout(function() {
$scope.$digest();
});
});
});
});
});
}, 100);
};
this.authenticate = function() {
this.authenticate = function(email, password) {
var data = {
emailAddress : $scope.email,
hashedPassword : pbkdf2Service.pbkdf2Sync($scope.password, '..............', 200, 64).toString('hex')
emailAddress : email,
hashedPassword : pbkdf2Service.pbkdf2Sync(password, '..............', 200, 64).toString('hex')
};
// POST /authenticate
@ -215,10 +130,10 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
});
};
this.authenticate2FA = function() {
this.authenticate2FA = function(twoFactorCode) {
var data = {
twoFactorCode : $scope.twoFactorCode
twoFactorCode : twoFactorCode
};
self.authenticating = true;
@ -258,5 +173,9 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
return tx.description;
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
self.update();
});
});

View file

@ -1,18 +1,18 @@
'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, $ionicHistory, popupService) {
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) {
var cachedTxp = {};
var isChromeApp = platformInfo.isChromeApp;
$scope.isWallet = $stateParams.isWallet;
$scope.toAmount = $stateParams.toAmount;
$scope.toAddress = $stateParams.toAddress;
$scope.toName = $stateParams.toName;
$scope.toEmail = $stateParams.toEmail;
$scope.description = $stateParams.description;
$scope.paypro = $stateParams.paypro;
$scope.$on("$ionicView.enter", function(event, data) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.isWallet = data.stateParams.isWallet;
$scope.isCard = data.stateParams.isCard;
$scope.toAmount = data.stateParams.toAmount;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
$scope.description = data.stateParams.description;
$scope.paypro = data.stateParams.paypro;
initConfirm();
});
@ -243,7 +243,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
walletService.createTx(wallet, txp, function(err, ctxp) {
if (err) {
return setSendError(err);
setSendError(err);
return cb(err);
}
return cb(null, ctxp);
});
@ -312,8 +313,4 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (err) return setSendError(err);
});
};
$scope.cancel = function() {
$state.go('tabs.send');
};
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $log, $ionicNavBarDelegate, $timeout, $stateParams, $state, $rootScope, $ionicHistory, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
init();

View file

@ -37,7 +37,9 @@ angular.module('copayApp.controllers').controller('createController',
};
$scope.showAdvChange = function() {
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
};
function updateRCSelect(n) {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('importController',
function($scope, $timeout, $log, $state, $stateParams, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, $state, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
function($scope, $rootScope, $timeout, $state, $ionicHistory, profileService, configService, storageService, applicationService, gettext, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
@ -146,7 +146,19 @@ angular.module('copayApp.controllers').controller('joinController',
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
});
$ionicHistory.removeBackView();
$state.go('tabs.home');
if (!client.isComplete()) {
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.copayers', {
walletId: client.credentials.walletId
});
}, 100);
}
else $state.go('tabs.home')
});
}, 100);
};

View file

@ -14,7 +14,9 @@ angular.module('copayApp.controllers').controller('searchController', function($
window.plugins.toast.hide();
currentTxHistoryPage = 0;
throttleSearch(search);
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
}
var throttleSearch = lodash.throttle(function(search) {

View file

@ -73,6 +73,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
time: $scope.btx.time,
description: actionDescriptions['broadcasted'],
});
$scope.actionList.reverse();
};
$scope.showCommentPopup = function() {
@ -126,6 +128,9 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + $scope.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('formatFiatAmount')(alternativeAmountBtc * res.rate) + ' ' + $scope.alternativeIsoCode;
$timeout(function() {
$scope.$apply();
});
}
});
};

View file

@ -1,15 +1,27 @@
'use strict';
angular.module('copayApp.controllers').controller('txStatusController', function($scope, $timeout, $state, $ionicHistory, $log, addressbookService) {
angular.module('copayApp.controllers').controller('txStatusController', function($scope, $timeout, $state, $stateParams, $ionicHistory, $log, addressbookService) {
if ($scope.cb) $timeout($scope.cb, 100);
$scope.fromSendTab = $ionicHistory.viewHistory().backView.stateName === "tabs.send.amount" || "tabs.send";
var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName;
$scope.fromSendTab = previousView.match(/tabs.send/) ? true : false;
$scope.fromBitPayCard = previousView.match(/tabs.bitpayCard/) ? true : false;
$scope.fromPayPro = $stateParams.paypro ? true : false;
$scope.cancel = function() {
$scope.txStatusModal.hide();
if ($scope.fromSendTab) {
$ionicHistory.removeBackView();
$state.go('tabs.home');
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.home');
}, 100);
} else if ($scope.fromBitPayCard) {
$ionicHistory.removeBackView();
$timeout(function() {
$state.transitionTo('tabs.bitpayCard');
}, 100);
}
};
@ -21,7 +33,7 @@ angular.module('copayApp.controllers').controller('txStatusController', function
});
$ionicHistory.removeBackView();
$state.go('tabs.send.addressbook', {
fromSendTab: true,
fromSendTab: $scope.fromSendTab,
addressbookEntry: addressbookEntry
});
}

View file

@ -7,6 +7,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
var isGlidera = $scope.isGlidera;
var GLIDERA_LOCK_TIME = 6 * 60 * 60;
var now = Math.floor(Date.now() / 1000);
var countDown;
$scope.init = function() {
$scope.loading = null;
@ -18,6 +19,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.data = {};
initActionList();
checkPaypro();
}
function initActionList() {
@ -47,14 +49,14 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
by: action.copayerName
});
});
$scope.actionList.reverse();
};
$scope.$on('accepted', function(event) {
$scope.sign();
});
checkPaypro();
// ToDo: use tx.customData instead of tx.message
if (tx.message === 'Glidera transaction' && isGlidera) {
tx.isGlidera = true;
@ -145,7 +147,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
paymentTimeControl(tx.paypro.expires);
$timeout(function() {
$ionicScrollDelegate.resize();
}, 100);
}, 10);
});
}
};
@ -154,7 +156,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.paymentExpired = false;
setExpirationTime();
self.countDown = $interval(function() {
countDown = $interval(function() {
setExpirationTime();
}, 1000);
@ -162,7 +164,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
var now = Math.floor(Date.now() / 1000);
if (now > expirationTime) {
$scope.paymentExpired = true;
if (self.countDown) $interval.cancel(self.countDown);
if (countDown) $interval.cancel(countDown);
return;
}
var totalSecs = expirationTime - now;

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $stateParams, $ionicPopup, popupService, gettextCatalog) {
angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $stateParams, popupService, gettextCatalog) {
$scope.walletId = $stateParams.walletId;

View file

@ -1,24 +1,35 @@
'use strict';
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $timeout, $stateParams, $ionicPopup, profileService, $ionicModal) {
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $timeout, $stateParams, profileService, $ionicModal) {
$scope.walletId = $stateParams.walletId;
$scope.openPopup = function() {
$ionicModal.fromTemplateUrl('views/includes/screenshotWarningModal.html', {
scope: $scope,
backdropClickToClose: false,
hardwareBackButtonClose: false
}).then(function(modal) {
$scope.warningModal = modal;
$scope.warningModal.show();
});
scope: $scope,
backdropClickToClose: false,
hardwareBackButtonClose: false
}).then(function(modal) {
$scope.warningModal = modal;
$scope.warningModal.show();
});
$scope.close = function() {
$scope.warningModal.hide();
$state.go('onboarding.backup', {
walletId: $stateParams.walletId,
fromOnboarding: true
});
if ($stateParams.from == 'onboarding.backupRequest')
$state.go('onboarding.backup', {
walletId: $stateParams.walletId
});
else
$state.go($stateParams.from + '.backup', {
walletId: $stateParams.walletId
});
};
}
$scope.goBack = function() {
$state.go($stateParams.from, {
walletId: $stateParams.walletId
});
};
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) {
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, profileService) {
$scope.goImport = function(code) {
$state.go('onboarding.import', {

View file

@ -1,11 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAbout',
function($scope, $window, $ionicNavBarDelegate, gettextCatalog, externalLinkService) {
$scope.$on("$ionicView.beforeEnter", function(event, data){
$ionicNavBarDelegate.title(gettextCatalog.getString('About') + ' ' + $window.appConfig.nameCase);
});
function($scope, $window, gettextCatalog, externalLinkService) {
$scope.title = gettextCatalog.getString('About') + ' ' + $window.appConfig.nameCase;
$scope.version = $window.version;
$scope.commitHash = $window.commitHash;
$scope.name = $window.appConfig.gitHubRepoName;

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesBitpayCardController',
function($scope, $state, $timeout, bitpayCardService, popupService) {
function($scope, $state, $timeout, $ionicHistory, bitpayCardService, popupService) {
$scope.logout = function() {
var title = 'Are you sure you would like to log out of your Bitpay Card account?';
@ -12,8 +12,9 @@ angular.module('copayApp.controllers').controller('preferencesBitpayCardControll
var logout = function() {
bitpayCardService.logout(function() {
$ionicHistory.removeBackView();
$timeout(function() {
$state.go('bitpayCard.main');
$state.go('tabs.home');
}, 100);
});
};

View file

@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
function($scope, $stateParams, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' ';
$scope.walletName = '[' + wallet.credentials.walletName + ']';
$scope.walletName = wallet.credentials.walletName;
$scope.showDeletePopup = function() {
var title = gettextCatalog.getString('Warning!');

View file

@ -114,9 +114,9 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
}
$scope.addrs = last10;
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
});
$ionicScrollDelegate.resize();
}, 10);
});
});

View file

@ -0,0 +1,52 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesNotificationsController',
function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
var updateConfig = function() {
var config = configService.getSync();
var isCordova = platformInfo.isCordova;
var isIOS = platformInfo.isIOS;
$scope.PNEnabledByUser = true;
$scope.isIOSApp = isIOS && isCordova;
if ($scope.isIOSApp) {
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) {
$scope.PNEnabledByUser = isEnabled;
$scope.$digest();
});
}
$scope.pushNotifications = {
value: config.pushNotifications.enabled
};
};
$scope.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');
}, function(err) {
$log.debug(err);
});
};
$scope.pushNotificationsChange = function() {
var opts = {
pushNotifications: {
enabled: $scope.pushNotifications.value
}
};
configService.set(opts, function(err) {
if (opts.pushNotifications.enabled)
pushNotificationsService.enableNotifications(profileService.walletClients);
else
pushNotificationsService.disableNotifications(profileService.walletClients);
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) {
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService) {
var wallet;
$scope.externalServices = {};
$scope.bitpayCardEnabled = true; // TODO
@ -76,7 +76,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
}
$state.go('tabs.details', {
$state.go('tabs.wallet', {
walletId: wallet.credentials.walletId
});
};
@ -88,11 +88,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
if (err) $log.error(err);
$scope.txps = txps;
$scope.txpsN = n;
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
}, 1);
}, 10);
})
};
@ -118,6 +117,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
});
if (!$scope.recentTransactionsEnabled) return;
$scope.fetchingNotifications = true;
profileService.getNotifications({
limit: 3
@ -128,11 +128,11 @@ angular.module('copayApp.controllers').controller('tabHomeController',
}
$scope.fetchingNotifications = false;
$scope.notifications = n;
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
}, 1);
}, 10);
})
};
@ -145,6 +145,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
return;
}
wallet.status = status;
updateTxps();
if (!$scope.recentTransactionsEnabled) return;
$scope.fetchingNotifications = true;
profileService.getNotifications({
@ -156,8 +159,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
return;
}
$scope.notifications = notifications;
updateTxps();
})
});
};
@ -175,11 +176,20 @@ angular.module('copayApp.controllers').controller('tabHomeController',
lodash.each(['AmazonGiftCards', 'BitpayCard', 'BuyAndSell'], function(service) {
storageService.getNextStep(service, function(err, value) {
$scope.externalServices[service] = value ? true : false;
$ionicScrollDelegate.resize();
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
});
});
};
$scope.shouldHideNextSteps = function() {
$scope.hideNextSteps = !$scope.hideNextSteps;
$timeout(function() {
$ionicScrollDelegate.resize();
}, 10);
};
var listeners = [
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
var wallet = profileService.getWallet(walletId);
@ -198,12 +208,27 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
});
var bitpayCardCache = function() {
bitpayCardService.getCacheData(function(err, data) {
if (err ||  lodash.isEmpty(data)) return;
$scope.bitpayCard = data;
});
};
$scope.$on("$ionicView.enter", function(event, data) {
$scope.bitpayCard = null;
configService.whenAvailable(function() {
var config = configService.getSync();
var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova;
$scope.hideNextSteps = false;
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
$scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp;
$scope.amazonEnabled = config.amazon.enabled;
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
$scope.nextStepEnabled = $scope.glideraEnabled || $scope.coinbaseEnabled || $scope.amazonEnabled || $scope.bitpayCardEnabled;
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
if ($scope.bitpayCardEnabled) bitpayCardCache();
});
$scope.nextStep();
$scope.updateAllWallets();

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, $state, $ionicHistory, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
$scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
@ -29,29 +29,25 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
};
$scope.setAddress = function(forceNew) {
if ($scope.generatingAddress) return;
if ($scope.generatingAddress || !$scope.wallet.isComplete()) return;
$scope.addr = null;
$scope.generatingAddress = true;
$timeout(function() {
walletService.getAddress($scope.wallet, forceNew, function(err, addr) {
$scope.generatingAddress = false;
if (err || lodash.isEmpty(addr)) {
popupService.showAlert(gettextCatalog.getString('Error'), err || gettextCatalog.getString('Address is empty'));
return;
}
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.addr = addr;
if ($scope.wallet.showBackupNeededModal) $scope.openBackupNeededModal();
$scope.$apply();
});
}, 1);
}, 100);
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
if (!$scope.isCordova) $scope.checkTips();
$scope.wallets = profileService.getWallets({
onlyComplete: true
});
$scope.wallets = profileService.getWallets();
$scope.$on('Wallet/Changed', function(event, wallet) {
if (!wallet) {
$log.debug('No wallet provided');
@ -62,4 +58,46 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$scope.setAddress();
});
});
$scope.goCopayers = function() {
$ionicHistory.removeBackView();
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.copayers', {
walletId: $scope.wallet.credentials.walletId
});
}, 100);
};
$scope.openBackupNeededModal = function() {
$ionicModal.fromTemplateUrl('views/includes/backupNeededPopup.html', {
scope: $scope,
backdropClickToClose: false,
hardwareBackButtonClose: false
}).then(function(modal) {
$scope.BackupNeededModal = modal;
$scope.BackupNeededModal.show();
});
};
$scope.close = function() {
$scope.BackupNeededModal.hide();
$scope.BackupNeededModal.remove();
profileService.setBackupNeededModalFlag($scope.wallet.credentials.walletId);
};
$scope.doBackup = function() {
$scope.close();
$scope.goToBackupFlow();
};
$scope.goToBackupFlow = function() {
$state.go('tabs.receive.backupWarning', {
from: 'tabs.receive',
walletId: $scope.wallet.credentials.walletId
});
}
});

View file

@ -1,8 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, addressbookService, profileService, lodash, $state, walletService, incomingData) {
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService) {
var originalList;
var CONTACTS_SHOW_LIMIT = 10;
var currentContactsPage = 0;
var updateList = function() {
originalList = [];
@ -11,6 +13,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
onlyComplete: true
});
$scope.hasWallets = lodash.isEmpty(wallets) ? false : true;
$scope.oneWallet = wallets.length == 1;
lodash.each(wallets, function(v) {
originalList.push({
@ -27,9 +30,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
if (err) $log.error(err);
$scope.hasContacts = lodash.isEmpty(ab) ? false : true;
var contacts = [];
var completeContacts = [];
lodash.each(ab, function(v, k) {
contacts.push({
completeContacts.push({
name: lodash.isObject(v) ? v.name : v,
address: k,
email: lodash.isObject(v) ? v.email : null,
@ -39,15 +42,23 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
});
});
var contacts = completeContacts.slice(0, (currentContactsPage + 1) * CONTACTS_SHOW_LIMIT);
$scope.contactsShowMore = completeContacts.length > contacts.length;
originalList = originalList.concat(contacts);
$scope.list = lodash.clone(originalList);
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();
}, 1);
}, 10);
});
};
$scope.showMore = function() {
currentContactsPage++;
updateList();
};
$scope.findContact = function(search) {
if (incomingData.redir(search)) {
@ -86,8 +97,16 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
$scope.formData = { search: null };
$scope.onQrCodeScanned = function(data) {
if (!incomingData.redir(data)) {
popupService.showAlert(null, gettextCatalog.getString('Invalid data'));
}
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.formData = {
search: null
};
updateList();
});

View file

@ -9,6 +9,8 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
$scope.usePushNotifications = isCordova && !isWP;
$scope.appName = $window.appConfig.nameCase;
$scope.unitName = config.wallet.settings.unitName;
@ -19,87 +21,13 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
};
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.usePushNotifications = isCordova && !isWP;
$scope.PNEnabledByUser = true;
$scope.isIOSApp = isIOS && isCordova;
if ($scope.isIOSApp) {
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) {
$scope.PNEnabledByUser = isEnabled;
$scope.$digest();
});
}
$scope.spendUnconfirmed = {
value: config.wallet.spendUnconfirmed
};
$scope.glideraEnabled = {
value: config.glidera.enabled
};
$scope.coinbaseEnabled = config.coinbase.enabled;
$scope.pushNotifications = {
value: config.pushNotifications.enabled
};
$scope.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) {
return w.id != self.walletId;
});
$scope.wallets = profileService.getWallets();
};
$scope.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');
}, function(err) {
$log.debug(err);
});
};
$scope.spendUnconfirmedChange = function() {
var opts = {
wallet: {
spendUnconfirmed: $scope.spendUnconfirmed.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.pushNotificationsChange = function() {
var opts = {
pushNotifications: {
enabled: $scope.pushNotifications.value
}
};
configService.set(opts, function(err) {
if (opts.pushNotifications.enabled)
pushNotificationsService.enableNotifications(profileService.walletClients);
else
pushNotificationsService.disableNotifications(profileService.walletClients);
if (err) $log.debug(err);
});
};
$scope.glideraChange = function() {
var opts = {
glidera: {
enabled: $scope.glideraEnabled.value
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.coinbaseChange = function() {
var opts = {
coinbase: {
enabled: $scope.coinbaseEnabled
}
};
configService.set(opts, function(err) {
if (err) $log.debug(err);
});
};
$scope.$on("$ionicView.enter", function(event, data) {
updateConfig();
});

View file

@ -1,12 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('tabsController', function($log, $scope, $stateParams, $ionicModal, $timeout, incomingData) {
angular.module('copayApp.controllers').controller('tabsController', function($rootScope, $log, $scope, $state, $stateParams, $timeout, incomingData, lodash, popupService) {
$scope.onScan = function(data) {
if (!incomingData.redir(data)) {
$ionicPopup.alert({
title: 'Invalid data',
});
popupService.showAlert(null, gettextCatalog.getString('Invalid data'));
}
}
@ -22,6 +20,34 @@ angular.module('copayApp.controllers').controller('tabsController', function($lo
$timeout(function() {
$scope.$apply();
}, 1);
}
};
var hideTabsViews = [
'tabs.send.amount',
'tabs.send.confirm',
'tabs.send.addressbook',
'tabs.addressbook',
'tabs.addressbook.add',
'tabs.addressbook.view',
'tabs.preferences.backupWarning',
'tabs.preferences.backup',
'tabs.receive.backupWarning',
'tabs.receive.backup',
'tabs.bitpayCard.amount',
'tabs.bitpayCard.confirm',
];
$rootScope.$on('$ionicView.beforeEnter', function() {
$rootScope.hideTabs = false;
var currentState = $state.current.name;
lodash.each(hideTabsViews, function(view) {
if (currentState === view) {
$rootScope.hideTabs = true;
}
});
});
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, $ionicPopup, txpModalService, externalLinkService) {
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettextCatalog, platformInfo, walletService, txpModalService, externalLinkService, popupService) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid;
@ -204,15 +204,13 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
wallet = profileService.getWallet($stateParams.walletId);
/* Set color for header bar */
$rootScope.walletDetailsColor = wallet.color;
$rootScope.walletDetailsName = wallet.name;
$scope.walletDetailsColor = wallet.color;
$scope.walletDetailsName = wallet.name;
$scope.wallet = wallet;
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
$scope.newTx = false;
$ionicNavBarDelegate.title(wallet.name);
$scope.updateAll(function() {
if ($stateParams.txid) {
var tx = lodash.find($scope.completeTxHistory, {
@ -221,9 +219,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
if (tx) {
$scope.openTxModal(tx);
} else {
$ionicPopup.alert({
title: gettext('TX not available'),
});
popupService.showAlert(null, gettextCatalog.getString('TX not available'));
}
} else if ($stateParams.txpId) {
var txp = lodash.find($scope.txps, {
@ -232,9 +228,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
if (txp) {
$scope.openTxpModal(txp);
} else {
$ionicPopup.alert({
title: gettext('Proposal not longer available'),
});
popupService.showAlert(null, gettextCatalog.getString('Proposal not longer available'));
}
}
});