ionic modals in coinbase and glidera and delete confirmation

This commit is contained in:
Gabriel Bazán 2016-06-10 15:16:02 -03:00
commit d2bdca00f4
28 changed files with 566 additions and 717 deletions

View file

@ -1,8 +1,8 @@
'use strict';
angular.module('copayApp.controllers').controller('buyCoinbaseController',
function($scope, $modal, $log, $timeout, lodash, profileService, coinbaseService, animationService, bwsError, addressService) {
angular.module('copayApp.controllers').controller('buyCoinbaseController',
function($scope, $modal, $log, $ionicModal, $timeout, lodash, profileService, coinbaseService, bwsError, addressService) {
window.ignoreMobilePause = true;
var self = this;
var fc;
@ -31,7 +31,7 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
});
} catch (e) {
$log.debug(e);
};
};
};
this.getPaymentMethods = function(token) {
@ -62,48 +62,20 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
$scope.openWalletsModal = function(wallets) {
self.error = null;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.type = 'BUY';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
self.selectedWalletId = null;
self.selectedWalletName = null;
$scope.selectWallet = function(walletId, walletName) {
var client = profileService.getClient(walletId);
profileService.isReady(client, function(err) {
if (err) {
self.error = {errors: [{ message: err }]};
$modalInstance.dismiss('cancel');
} else {
$modalInstance.close({
'walletId': walletId,
'walletName': walletName,
});
}
});
};
};
$scope.type = 'BUY';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.self = self;
var modalInstance = $modal.open({
templateUrl: 'views/modals/wallets.html',
windowClass: animationService.modalAnimated.slideUp,
controller: ModalInstanceCtrl,
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutDown);
});
modalInstance.result.then(function(obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
fc = profileService.getClient(obj.walletId);
$scope.$apply();
}, 100);
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.walletsModal = modal;
$scope.walletsModal.show();
});
};
@ -147,9 +119,13 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
coinbaseService.getTransaction(token, accountId, tx.id, function(err, updatedTx) {
if (err) $log.debug(err);
addressService.getAddress(self.selectedWalletId, false, function(err, addr) {
if (err) {
if (err) {
self.loading = null;
self.error = {errors: [{ message: 'Could not create address' }]};
self.error = {
errors: [{
message: 'Could not create address'
}]
};
return;
}
updatedTx.data['toAddr'] = addr;
@ -190,7 +166,9 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController',
self.receiveInfo = res.data;
if (!res.data.id) return;
coinbaseService.getTransaction(token, accountId, res.data.id, function(err, sendTx) {
coinbaseService.savePendingTransaction(tx, {remove: true}, function(err) {
coinbaseService.savePendingTransaction(tx, {
remove: true
}, function(err) {
coinbaseService.savePendingTransaction(sendTx.data, {}, function(err) {
$timeout(function() {
$scope.$emit('Local/CoinbaseTx');

View file

@ -1,13 +1,13 @@
'use strict';
angular.module('copayApp.controllers').controller('buyGlideraController',
function($scope, $timeout, $modal, profileService, addressService, glideraService, bwsError, lodash, animationService) {
angular.module('copayApp.controllers').controller('buyGlideraController',
function($scope, $timeout, $modal, $ionicModal, profileService, addressService, glideraService, bwsError, lodash) {
var self = this;
this.show2faCodeInput = null;
this.error = null;
this.success = null;
this.loading = null;
this.loading = null;
window.ignoreMobilePause = true;
@ -32,7 +32,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
}, 100);
}
});
} catch(e) {
} catch (e) {
$log.debug(e);
};
};
@ -41,47 +41,18 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
self.error = null;
self.selectedWalletId = null;
self.selectedWalletName = null;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.type = 'BUY';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
$scope.selectWallet = function(walletId, walletName) {
var client = profileService.getClient(walletId);
profileService.isReady(client, function(err) {
if (err) {
self.error = err;
$modalInstance.dismiss('cancel');
return;
}
$modalInstance.close({
'walletId': walletId,
'walletName': walletName,
});
});
};
};
$scope.type = 'BUY';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.self = self;
var modalInstance = $modal.open({
templateUrl: 'views/modals/wallets.html',
windowClass: animationService.modalAnimated.slideUp,
controller: ModalInstanceCtrl,
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutDown);
});
modalInstance.result.then(function(obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
$scope.$apply();
}, 100);
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.walletsModal = modal;
$scope.walletsModal.show();
});
};
@ -100,7 +71,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
return;
}
self.buyPrice = buyPrice;
});
});
};
this.get2faCode = function(token) {
@ -134,7 +105,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
qty: self.buyPrice.qty,
priceUuid: self.buyPrice.priceUuid,
useCurrentPrice: false,
ip: null
ip: null
};
glideraService.buy(token, twoFaCode, data, function(err, data) {
self.loading = null;

View file

@ -1,11 +1,11 @@
'use strict';
angular.module('copayApp.controllers').controller('coinbaseController',
function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, coinbaseService, animationService, lodash, platformInfo) {
angular.module('copayApp.controllers').controller('coinbaseController',
function($rootScope, $scope, $timeout, $modal, $ionicModal, profileService, configService, storageService, coinbaseService, lodash, platformInfo) {
var isNW = platformInfo.isNW;
window.ignoreMobilePause = true;
this.openAuthenticateWindow = function() {
var oauthUrl = this.getAuthenticateUrl();
if (!isNW) {
@ -17,7 +17,7 @@ angular.module('copayApp.controllers').controller('coinbaseController',
focus: true,
position: 'center'
});
win.on ('loaded', function(){
win.on('loaded', function() {
var title = win.title;
if (title.indexOf('Coinbase') == -1) {
$scope.code = title;
@ -46,8 +46,7 @@ angular.module('copayApp.controllers').controller('coinbaseController',
$timeout(function() {
$scope.$apply();
}, 100);
}
else if (data && data.access_token && data.refresh_token) {
} else if (data && data.access_token && data.refresh_token) {
storageService.setCoinbaseToken(network, data.access_token, function() {
storageService.setCoinbaseRefreshToken(network, data.refresh_token, function() {
$scope.$emit('Local/CoinbaseUpdated', data.access_token);
@ -62,44 +61,14 @@ angular.module('copayApp.controllers').controller('coinbaseController',
};
this.openTxModal = function(tx) {
$rootScope.modalOpened = true;
var self = this;
var config = configService.getSync().wallet.settings;
var fc = profileService.focusedClient;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.tx = tx;
$scope.settings = config;
$scope.color = fc.backgroundColor;
$scope.noColor = true;
$scope.tx = tx;
$scope.remove = function() {
coinbaseService.savePendingTransaction($scope.tx, {remove: true}, function(err) {
$rootScope.$emit('Local/CoinbaseTx');
$scope.cancel();
});
};
$scope.cancel = lodash.debounce(function() {
$modalInstance.dismiss('cancel');
}, 0, 1000);
};
var modalInstance = $modal.open({
templateUrl: 'views/modals/coinbase-tx-details.html',
windowClass: animationService.modalAnimated.slideRight,
controller: ModalInstanceCtrl,
});
var disableCloseModal = $rootScope.$on('closeModal', function() {
modalInstance.dismiss('cancel');
});
modalInstance.result.finally(function() {
$rootScope.modalOpened = false;
disableCloseModal();
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutRight);
$ionicModal.fromTemplateUrl('views/modals/coinbase-tx-details.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.coinbaseTxDetailsModal = modal;
$scope.coinbaseTxDetailsModal.show();
});
};

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $rootScope, $timeout, $log, $modal, profileService, go, notification, platformInfo, gettext, gettextCatalog, animationService) {
function($scope, $rootScope, $timeout, $log, $modal, $ionicModal, profileService, go, notification, platformInfo, gettext, gettextCatalog) {
var self = this;
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
@ -27,35 +27,19 @@ angular.module('copayApp.controllers').controller('copayersController',
};
var _modalDeleteWallet = function() {
var ModalInstanceCtrl = function($scope, $modalInstance, gettext) {
$scope.title = delete_msg;
$scope.loading = false;
$scope.title = delete_msg;
$scope.accept_msg = accept_msg;
$scope.cancel_msg = cancel_msg;
$scope.confirm_msg = confirm_msg;
$scope.okAction = doDeleteWallet;
$scope.loading = false;
$scope.ok = function() {
$scope.loading = true;
$modalInstance.close(accept_msg);
};
$scope.cancel = function() {
$modalInstance.dismiss(cancel_msg);
};
};
var modalInstance = $modal.open({
templateUrl: 'views/modals/confirmation.html',
windowClass: animationService.modalAnimated.slideUp,
controller: ModalInstanceCtrl
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutDown);
});
modalInstance.result.then(function(ok) {
if (ok) {
doDeleteWallet();
}
$ionicModal.fromTemplateUrl('views/modals/confirmation.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.confirmationModal = modal;
$scope.confirmationModal.show();
});
};

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('glideraController',
function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, glideraService, animationService, lodash) {
angular.module('copayApp.controllers').controller('glideraController',
function($rootScope, $scope, $timeout, $modal, $ionicModal, profileService, configService, storageService, glideraService, lodash) {
this.getAuthenticateUrl = function() {
return glideraService.getOauthCodeUrl();
@ -19,10 +19,9 @@ angular.module('copayApp.controllers').controller('glideraController',
if (err) {
self.error = err;
$timeout(function() {
$scope.$apply();
}, 100);
}
else if (data && data.access_token) {
$scope.$apply();
}, 100);
} else if (data && data.access_token) {
storageService.setGlideraToken(network, data.access_token, function() {
$scope.$emit('Local/GlideraUpdated', data.access_token);
$timeout(function() {
@ -35,41 +34,23 @@ angular.module('copayApp.controllers').controller('glideraController',
};
this.openTxModal = function(token, tx) {
$rootScope.modalOpened = true;
var self = this;
var config = configService.getSync().wallet.settings;
var fc = profileService.focusedClient;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.self = self;
$scope.tx = tx;
glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) {
$scope.tx = tx;
$scope.settings = config;
$scope.color = fc.backgroundColor;
$scope.noColor = true;
glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) {
$scope.tx = tx;
});
$scope.cancel = lodash.debounce(function() {
$modalInstance.dismiss('cancel');
}, 0, 1000);
};
var modalInstance = $modal.open({
templateUrl: 'views/modals/glidera-tx-details.html',
windowClass: animationService.modalAnimated.slideRight,
controller: ModalInstanceCtrl,
});
var disableCloseModal = $rootScope.$on('closeModal', function() {
modalInstance.dismiss('cancel');
});
modalInstance.result.finally(function() {
$rootScope.modalOpened = false;
disableCloseModal();
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutRight);
$ionicModal.fromTemplateUrl('views/modals/glidera-tx-details.html', {
scope: $scope,
backdropClickToClose: false,
hardwareBackButtonClose: false,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.glideraTxDetailsModal = modal;
$scope.glideraTxDetailsModal.show();
});
};

View file

@ -0,0 +1,20 @@
'use strict';
angular.module('copayApp.controllers').controller('coinbaseConfirmationController', function($scope, $timeout, coinbaseService, applicationService) {
$scope.ok = function() {
coinbaseService.logout($scope.network, function() {
$timeout(function() {
applicationService.restart();
}, 1000);
});
$scope.cancel();
};
$scope.cancel = function() {
$scope.coinbaseConfirmationModal.hide();
};
});

View file

@ -0,0 +1,18 @@
'use strict';
angular.module('copayApp.controllers').controller('coinbaseTxDetailsController', function($scope, coinbaseService) {
$scope.remove = function() {
coinbaseService.savePendingTransaction($scope.tx, {
remove: true
}, function(err) {
$rootScope.$emit('Local/CoinbaseTx');
$scope.cancel();
});
};
$scope.cancel = function() {
$scope.coinbaseTxDetailsModal.hide();
};
});

View file

@ -0,0 +1,15 @@
'use strict';
angular.module('copayApp.controllers').controller('confirmationController', function($scope) {
$scope.ok = function() {
$scope.loading = true;
$scope.okAction();
$scope.cancel();
};
$scope.cancel = function() {
$scope.confirmationModal.hide();
};
});

View file

@ -0,0 +1,18 @@
'use strict';
angular.module('copayApp.controllers').controller('glideraConfirmationController', function($scope, $timeout, storageService, applicationService) {
$scope.ok = function() {
storageService.removeGlideraToken($scope.network, function() {
$timeout(function() {
applicationService.restart();
}, 100);
});
$scope.cancel();
};
$scope.cancel = function() {
$scope.glideraConfirmationModal.hide();
};
});

View file

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

View file

@ -0,0 +1,30 @@
'use strict';
angular.module('copayApp.controllers').controller('walletsController', function($scope, bwsError, profileService) {
var self = $scope.self;
$scope.selectWallet = function(walletId, walletName) {
if (!profileService.getClient(walletId).isComplete()) {
self.error = bwsError.msg({
'code': 'WALLET_NOT_COMPLETE'
}, 'Could not choose the wallet');
self.error = {
errors: [{
message: 'The Wallet could not be selected'
}]
};
$scope.cancel();
return;
}
self.selectedWalletId = walletId;
self.selectedWalletName = walletName;
self.fc = profileService.getClient(self.selectedWalletId);
$scope.cancel();
};
$scope.cancel = function() {
$scope.walletsModal.hide();
};
});

View file

@ -1,38 +1,17 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesCoinbaseController',
function($scope, $modal, $timeout, applicationService, coinbaseService, animationService) {
angular.module('copayApp.controllers').controller('preferencesCoinbaseController',
function($scope, $modal, $timeout, $ionicModal, applicationService, coinbaseService) {
this.revokeToken = function(testnet) {
var network = testnet ? 'testnet' : 'livenet';
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close(true);
};
$scope.cancel = function() {
$modalInstance.dismiss();
};
};
$scope.network = testnet ? 'testnet' : 'livenet';
var modalInstance = $modal.open({
templateUrl: 'views/modals/coinbase-confirmation.html',
windowClass: animationService.modalAnimated.slideRight,
controller: ModalInstanceCtrl
});
modalInstance.result.then(function(ok) {
if (ok) {
coinbaseService.logout(network, function() {
$timeout(function() {
applicationService.restart();
}, 1000);
});
}
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutRight);
$ionicModal.fromTemplateUrl('views/modals/coinbase-confirmation.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.coinbaseConfirmationModal = modal;
$scope.coinbaseConfirmationModal.show();
});
};

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $rootScope, $filter, $timeout, $modal, $log, storageService, notification, profileService, platformInfo, go, gettext, gettextCatalog, animationService, applicationService) {
function($scope, $rootScope, $filter, $timeout, $modal, $log, $ionicModal, storageService, notification, profileService, platformInfo, go, gettext, gettextCatalog, applicationService) {
var isCordova = platformInfo.isCordova;
this.isCordova = isCordova;
this.error = null;
@ -13,35 +13,19 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
var confirm_msg = gettextCatalog.getString('Confirm');
var _modalDeleteWallet = function() {
var ModalInstanceCtrl = function($scope, $modalInstance, gettext) {
$scope.title = delete_msg;
$scope.loading = false;
$scope.title = delete_msg;
$scope.accept_msg = accept_msg;
$scope.cancel_msg = cancel_msg;
$scope.confirm_msg = confirm_msg;
$scope.okAction = doDeleteWallet;
$scope.loading = false;
$scope.ok = function() {
$scope.loading = true;
$modalInstance.close(accept_msg);
};
$scope.cancel = function() {
$modalInstance.dismiss(cancel_msg);
};
};
var modalInstance = $modal.open({
templateUrl: 'views/modals/confirmation.html',
windowClass: animationService.modalAnimated.slideUp,
controller: ModalInstanceCtrl
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutDown);
});
modalInstance.result.then(function(ok) {
if (ok) {
doDeleteWallet();
}
$ionicModal.fromTemplateUrl('views/modals/confirmation.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.confirmationModal = modal;
$scope.confirmationModal.show();
});
};

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesGlideraController',
function($scope, $modal, $timeout, profileService, applicationService, glideraService, storageService, animationService) {
angular.module('copayApp.controllers').controller('preferencesGlideraController',
function($scope, $modal, $timeout, $ionicModal, profileService, applicationService, glideraService, storageService) {
this.getEmail = function(token) {
var self = this;
@ -32,35 +32,15 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
};
this.revokeToken = function(testnet) {
var network = testnet ? 'testnet' : 'livenet';
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close(true);
};
$scope.cancel = function() {
$modalInstance.dismiss();
};
};
$scope.network = testnet ? 'testnet' : 'livenet';
$scope.loading = false;
var modalInstance = $modal.open({
templateUrl: 'views/modals/glidera-confirmation.html',
windowClass: animationService.modalAnimated.slideRight,
controller: ModalInstanceCtrl
});
modalInstance.result.then(function(ok) {
if (ok) {
storageService.removeGlideraToken(network, function() {
$timeout(function() {
applicationService.restart();
}, 100);
});
}
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutRight);
$ionicModal.fromTemplateUrl('views/modals/glidera-confirmation.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.glideraConfirmationModal = modal;
$scope.glideraConfirmationModal.show();
});
};

View file

@ -1,31 +1,31 @@
'use strict';
angular.module('copayApp.controllers').controller('sellCoinbaseController',
function($rootScope, $scope, $modal, $log, $timeout, lodash, profileService, coinbaseService, animationService, bwsError, configService, walletService, fingerprintService) {
angular.module('copayApp.controllers').controller('sellCoinbaseController',
function($rootScope, $scope, $modal, $log, $timeout, $ionicModal, lodash, profileService, coinbaseService, bwsError, configService, walletService, fingerprintService) {
window.ignoreMobilePause = true;
var self = this;
var fc;
$scope.priceSensitivity = [
{
value : 0.5,
value: 0.5,
name: '0.5%'
},
{
value : 1,
value: 1,
name: '1%'
},
{
value : 2,
value: 2,
name: '2%'
},
{
value : 5,
value: 5,
name: '5%'
},
{
value : 10,
value: 10,
name: '10%'
}
];
@ -63,7 +63,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
});
} catch (e) {
$log.debug(e);
};
};
};
this.getPaymentMethods = function(token) {
@ -94,47 +94,20 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
$scope.openWalletsModal = function(wallets) {
self.error = null;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.type = 'SELL';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
self.selectedWalletId = null;
self.selectedWalletName = null;
$scope.selectWallet = function(walletId, walletName) {
if (!profileService.getClient(walletId).isComplete()) {
self.error = bwsError.msg({
'code': 'WALLET_NOT_COMPLETE'
}, 'Could not choose the wallet');
$modalInstance.dismiss('cancel');
return;
}
$modalInstance.close({
'walletId': walletId,
'walletName': walletName,
});
};
};
$scope.type = 'SELL';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.self = self;
var modalInstance = $modal.open({
templateUrl: 'views/modals/wallets.html',
windowClass: animationService.modalAnimated.slideUp,
controller: ModalInstanceCtrl,
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutDown);
});
modalInstance.result.then(function(obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
fc = profileService.getClient(obj.walletId);
$scope.$apply();
}, 100);
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.walletsModal = modal;
$scope.walletsModal.show();
});
};
@ -185,7 +158,9 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
self.error = null;
var accountId = account.id;
var dataSrc = { name : 'Received from Copay: ' + self.selectedWalletName };
var dataSrc = {
name: 'Received from Copay: ' + self.selectedWalletName
};
var outputs = [];
var config = configService.getSync();
var configWallet = config.wallet;
@ -213,7 +188,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
'amount': amount,
'message': comment
});
var txp = {
toAddress: address,
amount: amount,
@ -228,16 +203,24 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
if (err) {
$log.debug(err);
self.loading = null;
self.error = {errors: [{ message: 'Could not create transaction: ' + err.message }]};
self.error = {
errors: [{
message: 'Could not create transaction: ' + err.message
}]
};
$scope.$apply();
return;
}
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
self.loading = null;
if (accept) {
if (accept) {
self.confirmTx(createdTxp, function(err, tx) {
if (err) {
self.error = {errors: [{ message: 'Could not create transaction: ' + err.message }]};
if (err) {
self.error = {
errors: [{
message: 'Could not create transaction: ' + err.message
}]
};
return;
}
self.loading = 'Checking transaction...';
@ -296,7 +279,11 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
if (err) {
self.loading = null;
$log.debug(err);
return cb({errors: [{ message: 'Transaction could not be published: ' + err.message }]});
return cb({
errors: [{
message: 'Transaction could not be published: ' + err.message
}]
});
}
walletService.signTx(fc, publishedTxp, function(err, signedTxp) {
@ -307,7 +294,11 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
walletService.removeTx(fc, signedTxp, function(err) {
if (err) $log.debug(err);
});
return cb({errors: [{ message: 'The payment was created but could not be completed: ' + err.message }]});
return cb({
errors: [{
message: 'The payment was created but could not be completed: ' + err.message
}]
});
}
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
@ -317,7 +308,11 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController',
walletService.removeTx(fc, broadcastedTxp, function(err) {
if (err) $log.debug(err);
});
return cb({errors: [{ message: 'The payment was created but could not be broadcasted: ' + err.message }]});
return cb({
errors: [{
message: 'The payment was created but could not be broadcasted: ' + err.message
}]
});
}
$timeout(function() {
self.loading = null;

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('sellGlideraController',
function($rootScope, $scope, $timeout, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, animationService, walletService, fingerprintService) {
function($rootScope, $scope, $timeout, $ionicModal, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, walletService, fingerprintService) {
var self = this;
var config = configService.getSync();
@ -53,47 +53,18 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
self.error = null;
self.selectedWalletId = null;
self.selectedWalletName = null;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.type = 'SELL';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
$scope.selectWallet = function(walletId, walletName) {
if (!profileService.getClient(walletId).isComplete()) {
self.error = bwsError.msg({
'code': 'WALLET_NOT_COMPLETE'
}, 'Could not choose the wallet');
$modalInstance.dismiss('cancel');
return;
}
$modalInstance.close({
'walletId': walletId,
'walletName': walletName,
});
};
};
$scope.type = 'SELL';
$scope.wallets = wallets;
$scope.noColor = true;
$scope.self = self;
var modalInstance = $modal.open({
templateUrl: 'views/modals/wallets.html',
windowClass: animationService.modalAnimated.slideUp,
controller: ModalInstanceCtrl,
});
modalInstance.result.finally(function() {
var m = angular.element(document.getElementsByClassName('reveal-modal'));
m.addClass(animationService.modalAnimated.slideOutDown);
});
modalInstance.result.then(function(obj) {
$timeout(function() {
self.selectedWalletId = obj.walletId;
self.selectedWalletName = obj.walletName;
fc = profileService.getClient(obj.walletId);
$scope.$apply();
}, 100);
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.walletsModal = modal;
$scope.walletsModal.show();
});
};
@ -136,7 +107,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
var outputs = [];
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
addressService.getAddress(fc.credentials.walletId, null, function(err, refundAddress) {
if (!refundAddress) {
self.loading = null;
@ -157,7 +128,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
'amount': amount,
'message': comment
});
var txp = {
toAddress: sellAddress,
amount: amount,
@ -175,20 +146,20 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
walletService.createTx(fc, txp, function(err, createdTxp) {
self.loading = null;
if (err) {
self.error = err.message || bwsError.msg(err);
self.error = err.message ||  bwsError.msg(err);
return;
}
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
if (accept) {
fingerprintService.check(fc, function(err) {
if (err) {
self.error = err.message || bwsError.msg(err);
self.error = err.message ||  bwsError.msg(err);
return;
}
handleEncryptedWallet(fc, function(err) {
if (err) {
self.error = err.message || bwsError.msg(err);
self.error = err.message ||  bwsError.msg(err);
return;
}
@ -197,7 +168,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
walletService.publishTx(fc, createdTxp, function(err, publishedTxp) {
if (err) {
self.loading = null;
self.error = err.message || bwsError.msg(err);
self.error = err.message ||  bwsError.msg(err);
}
walletService.signTx(fc, publishedTxp, function(err, signedTxp) {
@ -207,7 +178,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
});
if (err) {
self.loading = null;
self.error = err.message || bwsError.msg(err);
self.error = err.message ||  bwsError.msg(err);
return;
}
var rawTx = signedTxp.raw;
@ -222,7 +193,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
glideraService.sell(token, twoFaCode, data, function(err, data) {
self.loading = null;
if (err) {
self.error = err.message || bwsError.msg(err);
self.error = err.message ||  bwsError.msg(err);
$timeout(function() {
$scope.$emit('Local/GlideraError');
}, 100);

View file

@ -1,75 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('txController',
function($rootScope, $scope, $timeout, $filter, lodash, profileService, platformInfo, nodeWebkit, configService, animationService, gettextCatalog) {
var isCordova = platformInfo.isCordova;
var fc = profileService.focusedClient;
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
var m = angular.element(document.getElementsByClassName('txModal'));
m.addClass(animationService.modalAnimated.slideRight);
this.alternativeIsoCode = walletSettings.alternativeIsoCode;
this.color = fc.backgroundColor;
this.copayerId = fc.credentials.copayerId;
this.isShared = fc.credentials.n > 1;
if (isCordova) {
$rootScope.modalOpened = true;
var self = this;
var disableCloseModal = $rootScope.$on('closeModal', function() {
self.cancel();
});
}
this.getAlternativeAmount = function(btx) {
var self = this;
var satToBtc = 1 / 100000000;
fc.getFiatRate({
code: self.alternativeIsoCode,
ts: btx.time * 1000
}, function(err, res) {
if (err) {
$log.debug('Could not get historic rate');
return;
}
if (res && res.rate) {
var alternativeAmountBtc = (btx.amount * satToBtc).toFixed(8);
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + self.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + self.alternativeIsoCode;
$scope.$apply();
}
});
};
this.getShortNetworkName = function() {
var n = fc.credentials.network;
return n.substring(0, 4);
};
this.copyToClipboard = function(value) {
if (isCordova) {
window.cordova.plugins.clipboard.copy(value);
window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
} else if (platformInfo.isNW) {
nodeWebkit.writeToClipboard(value);
}
};
this.cancel = lodash.debounce(function() {
m.addClass(animationService.modalAnimated.slideOutRight);
if (isCordova) {
$rootScope.modalOpened = false;
disableCloseModal();
$timeout(function() {
$rootScope.$emit('Local/TxModal', null);
}, 350);
} else {
$rootScope.$emit('Local/TxModal', null);
}
}, 0, 1000);
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, $ionicModal, notification, txStatus, profileService, lodash, configService, rateService, storageService, bitcore, gettext, gettextCatalog, platformInfo, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, walletService, fingerprintService, nodeWebkit) {
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, $ionicModal, notification, txStatus, profileService, lodash, configService, rateService, storageService, bitcore, gettext, gettextCatalog, platformInfo, addressService, ledger, bwsError, confirmDialog, txFormatService, addressbookService, go, feeService, walletService, fingerprintService, nodeWebkit) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;

View file

@ -630,6 +630,10 @@ ul.manage li {
margin-top: 20px;
}
.m20ti {
margin-top: 20px !important;
}
.m20tp {
margin-top: 20%;
}