mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #3280 from cmgustavo/bug/glidera-12
Fixes choose wallet on buy page
This commit is contained in:
commit
fc57514d9e
|
@ -52,8 +52,8 @@
|
||||||
ng-submit="buy.get2faCode(index.glideraToken)" novalidate>
|
ng-submit="buy.get2faCode(index.glideraToken)" novalidate>
|
||||||
|
|
||||||
<div ng-if="index.glideraToken"
|
<div ng-if="index.glideraToken"
|
||||||
ng-init="otherWallets = buy.otherWallets(index.glideraTestnet)"
|
ng-init="buy.init(index.glideraTestnet)"
|
||||||
ng-click="openWalletsModal(otherWallets)">
|
ng-click="openWalletsModal(buy.otherWallets)">
|
||||||
<label>Wallet</label>
|
<label>Wallet</label>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="text" id="address" name="address" ng-disabled="buy.selectedWalletId"
|
<input type="text" id="address" name="address" ng-disabled="buy.selectedWalletId"
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
ng-style="{'background-color':index.backgroundColor}"
|
ng-style="{'background-color':index.backgroundColor}"
|
||||||
type="submit" value="{{'Continue'}}"
|
type="submit" value="{{'Continue'}}"
|
||||||
ng-disabled="index.glideraLimits.transactDisabledPendingFirstTransaction || !buy.buyPrice.qty ||
|
ng-disabled="index.glideraLimits.transactDisabledPendingFirstTransaction || !buy.buyPrice.qty ||
|
||||||
!buy.selectedWalletAddr || buy.loading">
|
!buy.selectedWalletId || buy.loading">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,18 +9,36 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||||
this.success = null;
|
this.success = null;
|
||||||
this.loading = null;
|
this.loading = null;
|
||||||
|
|
||||||
this.otherWallets = function(testnet) {
|
var otherWallets = function(testnet) {
|
||||||
var network = testnet ? 'testnet' : 'livenet';
|
var network = testnet ? 'testnet' : 'livenet';
|
||||||
return lodash.filter(profileService.getWallets(network), function(w) {
|
return lodash.filter(profileService.getWallets(network), function(w) {
|
||||||
return w.network == network;
|
return w.network == network;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.init = function(testnet) {
|
||||||
|
self.otherWallets = otherWallets(testnet);
|
||||||
|
// Choose focused wallet
|
||||||
|
try {
|
||||||
|
var currentWalletId = profileService.focusedClient.credentials.walletId;
|
||||||
|
lodash.find(self.otherWallets, function(w) {
|
||||||
|
if (w.id == currentWalletId) {
|
||||||
|
$timeout(function() {
|
||||||
|
self.selectedWalletId = w.id;
|
||||||
|
self.selectedWalletName = w.name;
|
||||||
|
$scope.$apply();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
$log.debug(e);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
$scope.openWalletsModal = function(wallets) {
|
$scope.openWalletsModal = function(wallets) {
|
||||||
self.error = null;
|
self.error = null;
|
||||||
self.selectedWalletId = null;
|
self.selectedWalletId = null;
|
||||||
self.selectedWalletName = null;
|
self.selectedWalletName = null;
|
||||||
self.selectedWalletAddr = null;
|
|
||||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||||
$scope.type = 'BUY';
|
$scope.type = 'BUY';
|
||||||
$scope.wallets = wallets;
|
$scope.wallets = wallets;
|
||||||
|
@ -34,17 +52,9 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||||
$modalInstance.dismiss('cancel');
|
$modalInstance.dismiss('cancel');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addressService.getAddress(walletId, false, function(err, walletAddr) {
|
$modalInstance.close({
|
||||||
if (err) {
|
'walletId': walletId,
|
||||||
self.error = bwsError.cb(err, 'Could not create address');
|
'walletName': walletName,
|
||||||
$modalInstance.dismiss('cancel');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$modalInstance.close({
|
|
||||||
'walletId': walletId,
|
|
||||||
'walletName': walletName,
|
|
||||||
'walletAddr': walletAddr
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -64,7 +74,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
self.selectedWalletId = obj.walletId;
|
self.selectedWalletId = obj.walletId;
|
||||||
self.selectedWalletName = obj.walletName;
|
self.selectedWalletName = obj.walletName;
|
||||||
self.selectedWalletAddr = obj.walletAddr;
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
@ -110,23 +119,29 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||||
var self = this;
|
var self = this;
|
||||||
self.error = null;
|
self.error = null;
|
||||||
self.loading = 'Buying bitcoin...';
|
self.loading = 'Buying bitcoin...';
|
||||||
var data = {
|
|
||||||
destinationAddress: self.selectedWalletAddr,
|
|
||||||
qty: self.buyPrice.qty,
|
|
||||||
priceUuid: self.buyPrice.priceUuid,
|
|
||||||
useCurrentPrice: false,
|
|
||||||
ip: null
|
|
||||||
};
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
glideraService.buy(token, twoFaCode, data, function(err, data) {
|
addressService.getAddress(self.selectedWalletId, false, function(err, walletAddr) {
|
||||||
self.loading = null;
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err;
|
self.error = bwsError.cb(err, 'Could not create address');
|
||||||
}
|
return;
|
||||||
else {
|
|
||||||
self.success = data;
|
|
||||||
$scope.$emit('Local/GlideraTx');
|
|
||||||
}
|
}
|
||||||
|
var data = {
|
||||||
|
destinationAddress: walletAddr,
|
||||||
|
qty: self.buyPrice.qty,
|
||||||
|
priceUuid: self.buyPrice.priceUuid,
|
||||||
|
useCurrentPrice: false,
|
||||||
|
ip: null
|
||||||
|
};
|
||||||
|
glideraService.buy(token, twoFaCode, data, function(err, data) {
|
||||||
|
self.loading = null;
|
||||||
|
if (err) {
|
||||||
|
self.error = err;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.success = data;
|
||||||
|
$scope.$emit('Local/GlideraTx');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue