fix merge conflicts

This commit is contained in:
Marty Alcala 2016-10-18 17:23:43 -04:00
commit 78bd523391
272 changed files with 8069 additions and 5496 deletions

View file

@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('activityController',
$scope.openTxpModal = txpModalService.open;
$scope.fetchingNotifications = true;
$scope.$on("$ionicView.enter", function(event, data){
$scope.$on("$ionicView.enter", function(event, data) {
profileService.getNotifications(50, function(err, n) {
if (err) {
$log.error(err);
@ -74,7 +74,7 @@ angular.module('copayApp.controllers').controller('activityController',
});
walletService.getTxNote(wallet, n.txid, function(err, note) {
if (err) $log.debug('Could not fetch transaction note');
if (err) $log.warn('Could not fetch transaction note: ' + err);
$scope.btx.note = note;
});
});

View file

@ -2,33 +2,10 @@
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, $stateParams, lodash, addressbookService, popupService, $ionicHistory) {
$scope.$on("$ionicView.beforeEnter", function(event, data){
var address = data.stateParams.address;
if (!address) {
$ionicHistory.back();
return;
}
addressbookService.get(address, function(err, obj) {
if (err) {
popupService.showAlert(err);
return;
}
if (!lodash.isObject(obj)) {
var name = obj;
obj = {
'name': name,
'address': address,
'email': ''
};
}
$scope.addressbookEntry = obj;
$timeout(function() {
$scope.$apply();
});
});
});
$scope.addressbookEntry = {};
$scope.addressbookEntry.name = $stateParams.name;
$scope.addressbookEntry.email = $stateParams.email;
$scope.addressbookEntry.address = $stateParams.address;
$scope.sendTo = function() {
$ionicHistory.removeBackView();

View file

@ -5,8 +5,8 @@ angular.module('copayApp.controllers').controller('amazonController',
$scope.network = amazonService.getEnvironment();
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
var initAmazon = function() {
@ -83,7 +83,7 @@ angular.module('copayApp.controllers').controller('amazonController',
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
$scope.$on("$ionicView.beforeEnter", function(event, data) {
initAmazon();
});
});

View file

@ -17,13 +17,14 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.isWallet = data.stateParams.isWallet;
$scope.isCard = data.stateParams.isCard;
$scope.cardId = data.stateParams.cardId;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.isCard;
$scope.showAlternativeAmount = !!$scope.cardId;
$scope.toColor = data.stateParams.toColor;
if (!$scope.isCard && !$stateParams.toAddress) {
if (!$scope.cardId && !$stateParams.toAddress) {
$log.error('Bad params at amount')
throw ('bad params');
}
@ -93,7 +94,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.pushDigit = function(digit) {
if ($scope.amount && $scope.amount.length >= LENGTH_EXPRESSION_LIMIT) return;
if ($scope.amount.indexOf('.') > -1 && digit == '.') return;
if($scope.showAlternativeAmount && $scope.amount.indexOf('.') > -1 && $scope.amount[$scope.amount.indexOf('.') + 2]) return;
if ($scope.showAlternativeAmount && $scope.amount.indexOf('.') > -1 && $scope.amount[$scope.amount.indexOf('.') + 2]) return;
$scope.amount = ($scope.amount + digit).replace('..', '.');
checkFontSize();
@ -189,7 +190,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.finish = function() {
var _amount = evaluate(format($scope.amount));
if ($scope.isCard) {
if ($scope.cardId) {
var amountUSD = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount));
var dataSrc = {
@ -199,7 +200,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
ongoingProcess.set('Processing Transaction...', true);
$timeout(function() {
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
bitpayCardService.topUp($scope.cardId, dataSrc, function(err, invoiceId) {
if (err) {
ongoingProcess.set('Processing Transaction...', false);
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
@ -215,7 +216,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
var payProUrl = data.paymentUrls.BIP73;
$state.transitionTo('tabs.bitpayCard.confirm', {
isCard: $scope.isCard,
cardId: $scope.cardId,
toName: $scope.toName,
paypro: payProUrl
});

View file

@ -131,6 +131,7 @@ angular.module('copayApp.controllers').controller('backupController',
}
profileService.setBackupFlag(wallet.credentials.walletId);
profileService.setBackupNeededModalFlag(wallet.credentials.walletId);
return cb();
}, 1);
};

View file

@ -1,39 +1,19 @@
'use strict';
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, popupService, gettextCatalog, bwcError) {
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $timeout, $log, $state, lodash, bitpayCardService, moment, popupService, gettextCatalog, $ionicHistory) {
var self = this;
$scope.dateRange = 'last30Days';
$scope.dateRange = { value: 'last30Days'};
$scope.network = bitpayCardService.getEnvironment();
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) {
for (var i = 0; i < invoices.length; i++) {
var matched = false;
for (var j = 0; j < history.length; j++) {
if (history[j].description[0].indexOf(invoices[i].id) > -1) {
matched = true;
}
}
if (!matched && ['paid', 'confirmed', 'complete'].indexOf(invoices[i].status) > -1) {
history.unshift({
timestamp: invoices[i].invoiceTime,
description: invoices[i].itemDesc,
amount: invoices[i].price,
type: '00611 = Client Funded Deposit',
pending: true,
status: invoices[i].status
});
}
}
return history;
var updateHistoryFromCache = function(cb) {
bitpayCardService.getBitpayDebitCardsHistory($scope.cardId, function(err, data) {
if (err || lodash.isEmpty(data)) return cb();
$scope.historyCached = true;
self.bitpayCardTransactionHistory = data.transactions;
self.bitpayCardCurrentBalance = data.balance;
return cb();
});
};
var setDateRange = function(preset) {
@ -61,120 +41,96 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
};
};
var setGetStarted = function(history, cb) {
if (lodash.isEmpty(history.transactionList)) {
var dateRange = setDateRange('all');
bitpayCardService.getHistory($scope.cardId, dateRange, function(err, history) {
if (lodash.isEmpty(history.transactionList)) return cb(true);
return cb(false);
});
} else return cb(false);
};
this.update = function() {
var dateRange = setDateRange($scope.dateRange);
self.loadingSession = true;
bitpayCardService.isAuthenticated(function(err, bpSession) {
self.loadingSession = false;
var dateRange = setDateRange($scope.dateRange.value);
$scope.loadingHistory = true;
bitpayCardService.getHistory($scope.cardId, dateRange, function(err, history) {
$scope.loadingHistory = false;
if (err) {
$log.error(err);
$scope.error = gettextCatalog.getString('Could not get transactions');
return;
}
self.bitpayCardAuthenticated = bpSession.isAuthenticated;
self.bitpayCardTwoFactorPending = bpSession.twoFactorPending ? true : false;
setGetStarted(history, function(getStarted) {
self.getStarted = getStarted;
if (self.bitpayCardTwoFactorPending) return;
var txs = lodash.clone(history.txs);
for (var i = 0; i < txs.length; i++) {
txs[i] = _getMerchantInfo(txs[i]);
txs[i].icon = _getIconName(txs[i]);
txs[i].desc = _processDescription(txs[i]);
}
self.bitpayCardTransactionHistory = txs;
self.bitpayCardCurrentBalance = history.currentCardBalance;
if (self.bitpayCardAuthenticated) {
$scope.loadingHistory = true;
bitpayCardService.invoiceHistory(function(err, invoices) {
if (err) $log.error(err);
bitpayCardService.transactionHistory(dateRange, function(err, history) {
$scope.loadingHistory = false;
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
return;
}
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);
});
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();
});
});
};
this.authenticate = function(email, password) {
var data = {
emailAddress : email,
hashedPassword : pbkdf2Service.pbkdf2Sync(password, '..............', 200, 64).toString('hex')
};
// POST /authenticate
// emailAddress:
// hashedPassword:
self.authenticating = true;
bitpayCardService.authenticate(data, function(err, auth) {
self.authenticating = false;
if (err && err.data && err.data.error && !err.data.error.twoFactorPending) {
popupService.showAlert(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error');
return;
}
self.update();
$timeout(function() {
$scope.$apply();
}, 100);
});
};
this.authenticate2FA = function(twoFactorCode) {
var data = {
twoFactorCode : twoFactorCode
};
self.authenticating = true;
bitpayCardService.authenticate2FA(data, function(err, auth) {
self.authenticating = false;
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error'));
return;
}
self.update();
$timeout(function() {
$scope.$apply();
}, 100);
});
};
this.getMerchantInfo = function(tx) {
var _getMerchantInfo = function(tx) {
var bpTranCodes = bitpayCardService.bpTranCodes;
lodash.keys(bpTranCodes).forEach(function(code) {
if (tx.type.indexOf(code) === 0) {
lodash.assign(tx, bpTranCodes[code]);
}
});
return tx;
};
this.getIconName = function(tx) {
var _getIconName = function(tx) {
var icon = tx.mcc || tx.category || null;
if (!icon) return 'default';
return bitpayCardService.iconMap[icon];
};
this.processDescription = function(tx) {
var _processDescription = function(tx) {
if (lodash.isArray(tx.description)) {
return tx.description[0];
}
return tx.description;
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
self.update();
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.cardId = data.stateParams.id;
if (!$scope.cardId) {
var msg = gettextCatalog.getString('Bad param');
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$state.go('tabs.home');
popupService.showAlert(null, msg);
} else {
updateHistoryFromCache(function() {
self.update();
});
}
});
});

View file

@ -0,0 +1,72 @@
'use strict';
angular.module('copayApp.controllers').controller('bitpayCardIntroController', function($scope, $log, $state, $ionicHistory, storageService, externalLinkService, bitpayCardService, gettextCatalog, popupService) {
var checkOtp = function(obj, cb) {
if (obj.otp) {
var msg = gettextCatalog.getString('Enter Two Factor for BitPay Card');
popupService.showPrompt(null, msg, null, function(res) {
cb(res);
});
} else {
cb();
}
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
if (data.stateParams && data.stateParams.secret) {
var obj = {
secret: data.stateParams.secret,
email: data.stateParams.email,
otp: data.stateParams.otp
};
checkOtp(obj, function(otp) {
obj.otp = otp;
bitpayCardService.bitAuthPair(obj, function(err, data) {
if (err) {
popupService.showAlert(null, err);
return;
}
var title = gettextCatalog.getString('Add BitPay Card?');
var msg = gettextCatalog.getString('Would you like to add this account ({{email}}) to your wallet?', {email: obj.email});
var ok = gettextCatalog.getString('Add cards');
var cancel = gettextCatalog.getString('Go back');
popupService.showConfirm(title, msg, ok, cancel, function(res) {
if (res) {
// Set flag for nextStep
storageService.setNextStep('BitpayCard', true, function(err) {});
// Save data
bitpayCardService.setBitpayDebitCards(data, function(err) {
if (err) return;
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$state.go('tabs.home').then(function() {
if (data.cards[0]) {
$state.transitionTo('tabs.bitpayCard', {id: data.cards[0].id});
}
});
});
}
});
});
});
} else {
bitpayCardService.getCredentials(function(err, credentials) {
if (err) popupService.showAlert(null, err);
else $log.info('BitPay Debit Card Credentials: Ok.');
});
}
});
$scope.orderBitPayCard = function() {
var url = 'https://bitpay.com/visa/';
externalLinkService.open(url);
};
$scope.connectBitPayCard = function() {
var url = 'https://bitpay.com/visa/login';
externalLinkService.open(url);
};
});

View file

@ -16,12 +16,14 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
$log.debug('Wallet changed: ' + w.name);
});
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
this.confirm = function() {
var message = gettextCatalog.getString('Amazon.com Gift Card purchase for ${{amount}} USD', {amount: $scope.formData.fiat});
var message = gettextCatalog.getString('Amazon.com Gift Card purchase for ${{amount}} USD', {
amount: $scope.formData.fiat
});
var ok = gettextCatalog.getString('Buy');
popupService.showConfirm(null, message, ok, null, function(res) {
if (res) self.createTx();
@ -209,8 +211,10 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
});
};
$scope.$on("$ionicView.enter", function(event, data){
$scope.formData = { fiat: null };
$scope.$on("$ionicView.enter", function(event, data) {
$scope.formData = {
fiat: null
};
$scope.wallets = profileService.getWallets({
network: network,
onlyComplete: true

View file

@ -8,7 +8,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.isWallet = data.stateParams.isWallet;
$scope.isCard = data.stateParams.isCard;
$scope.cardId = data.stateParams.cardId;
$scope.toAmount = data.stateParams.toAmount;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
@ -226,6 +226,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var setSendError = function(msg) {
$scope.sendStatus = '';
$timeout(function() {
$scope.$apply();
});
popupService.showAlert(gettextCatalog.getString('Error at confirm:'), msg);
};
@ -377,11 +380,24 @@ angular.module('copayApp.controllers').controller('confirmController', function(
};
$scope.onSuccessConfirm = function() {
var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName;
var fromBitPayCard = previousView.match(/tabs.bitpayCard/) ? true : false;
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$ionicHistory.removeBackView();
$scope.sendStatus = '';
$state.go('tabs.send');
if (fromBitPayCard) {
$timeout(function() {
$state.transitionTo('tabs.bitpayCard', {
id: $stateParams.cardId
});
}, 100);
} else {
$state.go('tabs.send');
}
};
function publishAndSign(wallet, txp, onSendStatusChange) {

View file

@ -15,6 +15,45 @@ angular.module('copayApp.controllers').controller('exportController',
});
};
function getPassword(cb) {
if ($scope.password) return cb(null, $scope.password);
walletService.prepare(wallet, function(err, password) {
if (err) return cb(err);
$scope.password = password;
return cb(null, password);
});
};
$scope.generateQrCode = function() {
if ($scope.formData.exportWalletInfo || !walletService.isEncrypted(wallet)) {
$scope.file.value = false;
}
getPassword(function(err, password) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
walletService.getEncodedWalletInfo(wallet, password, function(err, code) {
if (err) return cb(err);
if (!code)
$scope.formData.supported = false;
else {
$scope.formData.supported = true;
$scope.formData.exportWalletInfo = code;
}
$scope.file.value = false;
$timeout(function() {
$scope.$apply();
});
});
});
};
var init = function() {
$scope.formData = {};
$scope.isEncrypted = wallet.isPrivKeyEncrypted();
@ -24,24 +63,6 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.showAdvanced = false;
$scope.wallet = wallet;
$scope.canSign = wallet.canSign();
walletService.getEncodedWalletInfo(wallet, function(err, code) {
if (err || !code) {
$log.warn(err);
return $ionicHistory.goBack();
}
if (!code)
$scope.formData.supported = false;
else {
$scope.formData.supported = true;
$scope.formData.exportWalletInfo = code;
}
$timeout(function() {
$scope.$apply();
}, 1);
});
};
/*
@ -67,23 +88,31 @@ angular.module('copayApp.controllers').controller('exportController',
};
$scope.downloadWalletBackup = function() {
$scope.getAddressbook(function(err, localAddressBook) {
getPassword(function(err, password) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
var opts = {
noSign: $scope.formData.noSignEnabled,
addressBook: localAddressBook
};
backupService.walletDownload($scope.formData.password, opts, function(err) {
$scope.getAddressbook(function(err, localAddressBook) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
return;
}
$ionicHistory.removeBackView();
$state.go('tabs.home');
var opts = {
noSign: $scope.formData.noSignEnabled,
addressBook: localAddressBook,
password: password
};
backupService.walletDownload($scope.formData.password, opts, function(err) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
return;
}
$ionicHistory.removeBackView();
$state.go('tabs.home');
});
});
});
};
@ -104,21 +133,29 @@ angular.module('copayApp.controllers').controller('exportController',
};
$scope.getBackup = function(cb) {
$scope.getAddressbook(function(err, localAddressBook) {
getPassword(function(err, password) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
return cb(null);
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
var opts = {
noSign: $scope.formData.noSignEnabled,
addressBook: localAddressBook
};
var ew = backupService.walletExport($scope.formData.password, opts);
if (!ew) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
}
return cb(ew);
$scope.getAddressbook(function(err, localAddressBook) {
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
return cb(null);
}
var opts = {
noSign: $scope.formData.noSignEnabled,
addressBook: localAddressBook,
password: password
};
var ew = backupService.walletExport($scope.formData.password, opts);
if (!ew) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export'));
}
return cb(ew);
});
});
};
@ -171,6 +208,11 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.$on("$ionicView.beforeEnter", function(event, data) {
init();
$scope.file = {
value: true
};
$scope.formData.exportWalletInfo = null;
$scope.password = null;
});
});

View file

@ -5,12 +5,12 @@ angular.module('copayApp.controllers').controller('glideraController',
$scope.network = glideraService.getEnvironment();
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
$scope.openExternalLink = function(url) {
externalLinkService.open(url);
};
var initGlidera = function(accessToken) {
$scope.token = null;
$scope.token = accessToken;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
@ -27,7 +27,9 @@ angular.module('copayApp.controllers').controller('glideraController',
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
$scope.update({
fullUpdate: true
});
});
};
@ -113,7 +115,7 @@ angular.module('copayApp.controllers').controller('glideraController',
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
$scope.$on("$ionicView.beforeEnter", function(event, data) {
initGlidera();
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess, popupService, gettextCatalog) {
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess, popupService, gettextCatalog, externalLinkService) {
$scope.cancelGiftCard = function() {
ongoingProcess.set('Canceling gift card...', true);
@ -62,4 +62,8 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
$scope.amazonCardDetailsModal.hide();
};
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
});

View file

@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
function updateMemo() {
walletService.getTxNote(wallet, $scope.btx.txid, function(err, note) {
if (err) {
$log.warn('Could not fetch transaction note ' + err);
$log.warn('Could not fetch transaction note: ' + err);
return;
}
@ -139,8 +139,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
});
};
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
$scope.getShortNetworkName = function() {

View file

@ -96,16 +96,20 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
};
$scope.reject = function(txp) {
$scope.loading = true;
var title = gettextCatalog.getString('Warning!');
var msg = gettextCatalog.getString('Are you sure you want to reject this transaction?');
popupService.showConfirm(title, msg, null, null, function(res) {
if (res) {
$scope.loading = true;
walletService.reject($scope.wallet, $scope.tx, function(err, txpr) {
if (err)
return setError(err, gettextCatalog.getString('Could not reject payment'));
walletService.reject($scope.wallet, $scope.tx, function(err, txpr) {
if (err)
return setError(err, gettextCatalog.getString('Could not reject payment'));
$scope.close();
$scope.close();
});
}
});
};
$scope.remove = function() {

View file

@ -15,8 +15,8 @@ angular.module('copayApp.controllers').controller('termsController', function($s
});
};
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
});

View file

@ -8,7 +8,7 @@ angular.module('copayApp.controllers').controller('preferencesAbout',
$scope.commitHash = $window.commitHash;
$scope.name = $window.appConfig.gitHubRepoName;
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
});

View file

@ -1,17 +1,17 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesBitpayCardController',
function($scope, $state, $timeout, $ionicHistory, bitpayCardService, popupService) {
function($scope, $state, $timeout, $ionicHistory, bitpayCardService, popupService, gettextCatalog) {
$scope.logout = function() {
var title = 'Are you sure you would like to log out of your Bitpay Card account?';
popupService.showConfirm(title, null, null, null, function(res) {
if (res) logout();
$scope.remove = function() {
var msg = gettextCatalog.getString('Are you sure you would like to remove your BitPay Card account from this device?');
popupService.showConfirm(null, msg, null, null, function(res) {
if (res) remove();
});
};
var logout = function() {
bitpayCardService.logout(function() {
var remove = function() {
bitpayCardService.remove(function() {
$ionicHistory.removeBackView();
$timeout(function() {
$state.go('tabs.home');
@ -19,4 +19,11 @@ angular.module('copayApp.controllers').controller('preferencesBitpayCardControll
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
bitpayCardService.getBitpayDebitCards(function(err, data) {
if (err) return;
$scope.bitpayCards = data.cards;
});
});
});

View file

@ -21,7 +21,8 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
} else {
$ionicHistory.removeBackView();
$ionicHistory.clearHistory();
$ionicHistory.clearCache();
$state.go('tabs.home');
}
});

View file

@ -2,23 +2,25 @@
angular.module('copayApp.controllers').controller('preferencesEmailController', function($scope, $ionicHistory, $stateParams, gettextCatalog, profileService, walletService, configService) {
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
$scope.wallet = profileService.getWallet($stateParams.walletId);
var walletId = $scope.wallet.credentials.walletId;
var config = configService.getSync();
config.emailFor = config.emailFor || {};
$scope.emailForExist = config.emailFor && config.emailFor[walletId];
$scope.email = {
value: config.emailFor && config.emailFor[walletId]
};
$scope.save = function() {
$scope.save = function(val) {
var opts = {
emailFor: {}
};
opts.emailFor[walletId] = $scope.email.value;
opts.emailFor[walletId] = val;
walletService.updateRemotePreferences(wallet, {
email: $scope.email.value,
walletService.updateRemotePreferences($scope.wallet, {
email: val,
}, function(err) {
if (err) $log.warn(err);
configService.set(opts, function(err) {

View file

@ -52,7 +52,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
$scope.$on("$ionicView.enter", function(event, data){
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.token = null;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;

View file

@ -28,8 +28,14 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
$log.debug('Generating CSV from History');
getHistory(function(err, txs) {
if (err || lodash.isEmpty(txs)) {
if (err) $log.warn('Failed to generate CSV:', err);
else $log.warn('Failed to generate CSV: no transactions');
if (err) {
$log.warn('Failed to generate CSV:', err);
$scope.err = err;
}
else {
$log.warn('Failed to generate CSV: no transactions');
$scope.err = 'no transactions';
}
if (cb) return cb(err);
return;
}

View file

@ -6,12 +6,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
var listeners = [];
var notifications = [];
$scope.externalServices = {};
$scope.bitpayCardEnabled = true; // TODO
$scope.openTxpModal = txpModalService.open;
$scope.version = $window.version;
$scope.name = $window.appConfig.nameCase;
$scope.homeTip = $stateParams.fromOnboarding;
$scope.isCordova = platformInfo.isCordova;
$scope.isAndroid = platformInfo.isAndroid;
$scope.$on("$ionicView.afterEnter", function() {
startupService.ready();
@ -19,7 +19,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
if (!$scope.homeTip) {
storageService.getHomeTipAccepted(function(error, value) {
$scope.homeTip = (value == 'false') ? false : true;
$scope.homeTip = (value == 'accepted') ? false : true;
});
}
@ -76,7 +76,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
walletService.getTxNote(wallet, n.txid, function(err, note) {
if (err) $log.debug(gettextCatalog.getString('Could not fetch transaction note'));
if (err) $log.warn('Could not fetch transaction note: ' + err);
$scope.btx.note = note;
});
});
@ -175,7 +175,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
};
$scope.hideHomeTip = function() {
storageService.setHomeTipAccepted(false, function(error, value) {
storageService.setHomeTipAccepted('accepted', function() {
$scope.homeTip = false;
$timeout(function() {
$scope.$apply();
@ -203,19 +203,32 @@ angular.module('copayApp.controllers').controller('tabHomeController',
};
var bitpayCardCache = function() {
bitpayCardService.getCacheData(function(err, data) {
if (err ||  lodash.isEmpty(data)) return;
$scope.bitpayCard = data;
bitpayCardService.getBitpayDebitCards(function(err, data) {
if (err) return;
if (lodash.isEmpty(data)) {
$scope.bitpayCards = null;
return;
}
$scope.bitpayCards = data.cards;
});
bitpayCardService.getBitpayDebitCardsHistory(null, function(err, data) {
if (err) return;
if (lodash.isEmpty(data)) {
$scope.cardsHistory = null;
return;
}
$scope.cardsHistory = data;
});
};
$scope.onRefresh = function() {
$scope.$broadcast('scroll.refreshComplete');
$timeout(function() {
$scope.$broadcast('scroll.refreshComplete');
}, 300);
updateAllWallets();
};
$scope.$on("$ionicView.enter", function(event, data) {
$scope.bitpayCard = null;
nextStep();
updateAllWallets();

View file

@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
var showModalTimeout;
$scope.shareAddress = function(addr) {
if ($scope.generatingAddress) return;
@ -14,16 +14,21 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
};
$scope.setAddress = function(forceNew) {
if ($scope.generatingAddress || !$scope.wallet.isComplete()) return;
if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return;
$scope.addr = null;
$scope.generatingAddress = true;
walletService.getAddress($scope.wallet, forceNew, function(err, addr) {
$scope.generatingAddress = false;
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
$scope.addr = addr;
if ($scope.wallet.showBackupNeededModal) $scope.openBackupNeededModal();
$scope.$apply();
if ($scope.wallet.showBackupNeededModal) {
showModalTimeout = $timeout(function() {
$scope.openBackupNeededModal();
}, 2000);
}
$timeout(function() {
$scope.$apply();
}, 10);
});
};
@ -74,6 +79,10 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$log.debug('No wallet provided');
return;
}
if (wallet == $scope.wallet) {
$log.debug('No change in wallet');
return;
}
$scope.wallet = wallet;
$log.debug('Wallet changed: ' + wallet.name);
$timeout(function() {
@ -81,6 +90,10 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
}, 100);
});
$scope.$on("$ionicView.leave", function(event, data) {
$timeout.cancel(showModalTimeout);
});
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.wallets = profileService.getWallets();
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService) {
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, $rootScope) {
var originalList;
var CONTACTS_SHOW_LIMIT;
@ -102,23 +102,28 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
isWallet: item.isWallet,
toAddress: addr,
toName: item.name,
toEmail: item.email
toEmail: item.email,
toColor: item.color
})
});
});
};
var updateHasFunds = function() {
$scope.hasFunds = null;
if ($rootScope.everHasFunds) {
$scope.hasFunds = true;
return;
}
$scope.hasFunds = false;
var wallets = profileService.getWallets({
onlyComplete: true,
});
if (!wallets || !wallets.length) {
$scope.hasFunds = false;
$timeout(function() {
return $timeout(function() {
$scope.$apply();
});
}
@ -132,11 +137,12 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
return;
}
if (status.availableBalanceSat) {
if (status.availableBalanceSat > 0) {
$scope.hasFunds = true;
$rootScope.everHasFunds = true;
}
if (index == wallets.length) {
$scope.hasFunds = $scope.hasFunds || false;
$timeout(function() {
$scope.$apply();
});

View file

@ -24,8 +24,8 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
$scope.wallets = profileService.getWallets();
};
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
externalLinkService.open(url, optIn, title, message, okText, cancelText);
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {

View file

@ -6,7 +6,7 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro
if (!incomingData.redir(data)) {
popupService.showAlert(null, gettextCatalog.getString('Invalid data'));
}
}
};
$scope.setScanFn = function(scanFn) {
$scope.scan = function() {
@ -22,32 +22,8 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro
}, 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;
}
});
$scope.$on("$ionicView.beforeEnter", function(event, data){
$rootScope.hideTabs = '';
});
});

View file

@ -9,6 +9,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
$scope.completeTxHistory = [];
$scope.openTxpModal = txpModalService.open;
$scope.isCordova = platformInfo.isCordova;
$scope.isAndroid = platformInfo.isAndroid;
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
@ -161,7 +162,9 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
};
$scope.onRefresh = function() {
$scope.$broadcast('scroll.refreshComplete');
$timeout(function() {
$scope.$broadcast('scroll.refreshComplete');
}, 300);
$scope.updateAll(true);
};