diff --git a/public/views/buyAndSell.html b/public/views/buyAndSell.html deleted file mode 100644 index 03e1e09c9..000000000 --- a/public/views/buyAndSell.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - Buy and sell - - - - - - - - - - - - - - - - diff --git a/public/views/buyGlidera.html b/public/views/buyGlidera.html index f2754e627..a447eff9b 100644 --- a/public/views/buyGlidera.html +++ b/public/views/buyGlidera.html @@ -1,123 +1,145 @@ -
-
+ + + + + + Buy + + -
+
+ + Testnet wallets only work with Glidera Sandbox Accounts +
-
-

+

Daily buy limit: - {{index.glideraLimits.dailyBuy|currency:'':2}} {{index.glideraLimits.currency}} - (remaining {{index.glideraLimits.dailyBuyRemaining|currency:'':2}} {{index.glideraLimits.currency}}) + {{limits.dailyBuy|currency:'':2}} {{limits.currency}} + (remaining {{limits.dailyBuyRemaining|currency:'':2}} {{limits.currency}})
Monthly buy limit: - {{index.glideraLimits.monthlyBuy|currency:'':2}} {{index.glideraLimits.currency}} - (remaining {{index.glideraLimits.monthlyBuyRemaining|currency:'':2}} {{index.glideraLimits.currency}}) -
-
+ {{limits.monthlyBuy|currency:'':2}} {{limits.currency}} + (remaining {{limits.monthlyBuyRemaining|currency:'':2}} {{limits.currency}}) + -
-
+
+ + This operation was disabled because you have a pending first transaction + +
-
- - This operation was disabled because you have a pending first transaction - -
+
-
+
- +
-
- -
- - - - -
-
+ - -
- - +
- -
-
-
- {{buy.buyPrice.subtotal|currency:'':2}} {{buy.buyPrice.currency}} → {{buy.buyPrice.qty}} BTC -

- A SMS containing a confirmation code was sent to your phone.
- Please, enter the code below -

-
- - -
-

- Fiat will be immediately withdrawn from your bank account. The bitcoins will be purchased and deposited to your wallet ({{index.walletName}}) in 2-4 business days. -

+ BTC + USD +
-
-
- - {{buy.error}} - -
-
-

Purchase initiated

-

- A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business days. -

- +
+ Buy + {{buy.buyPrice.subtotal|currency:'':2}} {{buy.buyPrice.currency}} in Bitcoin + {{buy.buyPrice.qty}} BTC + at {{buy.buyPrice.price}} {{buy.buyPrice.currency}}/BTC +
+
+ (Enter the amount to get the exchange rate) +
+ +
+ ... +
+ + + +
+
+
+{{buy.buyPrice.subtotal|currency:'':2}} {{buy.buyPrice.currency}} → {{buy.buyPrice.qty}} BTC +

+ A SMS containing a confirmation code was sent to your phone.
+ Please, enter the code below +

+
+
+ +
+ +
+

+ Fiat will be immediately withdrawn from your bank account. The bitcoins will be purchased and deposited to your wallet in 2-4 business days. +

-
-
-
+
+ + {{buy.error}} + +
+
+

Purchase initiated

+

+ A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business days. +

+ + +
+ + diff --git a/public/views/confirm.html b/public/views/confirm.html index dac9298d6..d6669bbc3 100644 --- a/public/views/confirm.html +++ b/public/views/confirm.html @@ -23,7 +23,7 @@
-
Fee: {{feeLevel}} +
Fee: {{feeLevel}} {{fee || '...'}} @@ -49,7 +49,7 @@
  • - {{item.name || item.id}} + {{item.name || item.id}} {{item.availableBalanceStr}} @@ -61,9 +61,11 @@
-
- Add Description (not yet working...) - +
+ Add Description + {{description}} + +
diff --git a/public/views/glidera.html b/public/views/glidera.html index 020bbb832..b626ad29d 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -1,201 +1,187 @@ - -
-
- - -
- -
-
-
- {{index.glideraError}} -
-
-
- -
- - -
-
-
+ + Glidera + -
-
+ + +
Testnet wallets only work with Glidera Sandbox Accounts
-
-
- +
+
+ {{error}}
-
-

You can buy and sell Bitcoin with a US bank account directly in Copay.

+
+
+ +
+ + +
+
-

- DISCLOSURE.
- Glidera Inc. (Glidera) is providing the service of buying or selling bitcoins to Copay users. To enable this - service, Glidera has registered with US Treasury Department’s FinCEN as a Money Service Business - (#31000042625755). Users of Copay must agree to the service agreement presented by Glidera prior to obtaining - Glidera’s service of buying or selling bitcoins. Service available in U.S. and Canada only. In U.S. (buy & sell) CA, GA, IL, KS, - MA, MD, MO, MT, MN, SC, TX, AZ, CO, DE, ME, NJ, PA, TN, UT, NV, WI. In Canada (buy & sell) AB, BC, MB, NB, NL, NS, NT, NU, - ON, PE, SK, YT. -

+
-

Connect your Glidera account to get started

+
+
+ +
+ +
+
+ {{error}} +
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+
+ + -
- -
-
- -
-
-
-
- Preferences -
-
- - {{index.glideraPersonalInfo.firstName}} {{index.glideraPersonalInfo.lastName}} - -
-
- {{index.glideraEmail}} -
-
-
-
- - - - -
-
-
-
-
-

Complete Setup

-
Your Glidera account is not ready to transact. Please, verify it at Glidera.io
- - Go to Glidera - -
-
-
- -
    -
  • - buy bitcoin - Buy Bitcoin - - - -
  • -
  • - buy bitcoin - Sell Bitcoin - - - -
  • -
- -
-

Activity

-
- No activity in your account -
-
-
- bought - bought - bought - bought -
- -
-
- Bought - Sold - {{tx.qty}} BTC -
- - {{tx.subtotal|currency:'':2}} {{tx.currency}} - -
-
-
-
- -
-
- Processing -
-
-
-
- -
-
-
- -
-
-
+
+ diff --git a/public/views/includes/note.html b/public/views/includes/note.html index a4af02532..e52beba85 100644 --- a/public/views/includes/note.html +++ b/public/views/includes/note.html @@ -1,15 +1,11 @@ -
- +
-
-
- +
+
+
-
- +
+
diff --git a/public/views/modals/glidera-confirmation.html b/public/views/modals/glidera-confirmation.html index 2d58612af..1a8f5622b 100644 --- a/public/views/modals/glidera-confirmation.html +++ b/public/views/modals/glidera-confirmation.html @@ -1,18 +1,14 @@ - -
-
-

Are you sure you would like to log out of your Glidera account?

-

You will need to log back in to buy or sell bitcoin in Copay.

-
- +
-
- -
-
-
+
diff --git a/public/views/modals/glidera-tx-details.html b/public/views/modals/glidera-tx-details.html index e072f9ddc..8696edc71 100644 --- a/public/views/modals/glidera-tx-details.html +++ b/public/views/modals/glidera-tx-details.html @@ -1,12 +1,10 @@ - -

Details

+ +

Details

diff --git a/public/views/preferencesGlidera.html b/public/views/preferencesGlidera.html index 7336059b5..dedea52b0 100644 --- a/public/views/preferencesGlidera.html +++ b/public/views/preferencesGlidera.html @@ -1,266 +1,278 @@ -
-
+ + + + + + Preferences + -
+ -
    -

    Permissions

    -
  • - Email - - {{index.glideraPermissions.view_email_address}} - -
  • -
  • - Personal Information - - {{index.glideraPermissions.personal_info}} - -
  • -
  • - Buy/Sell - - {{index.glideraPermissions.transact}} - -
  • -
  • - Transaction History - - {{index.glideraPermissions.transaction_history}} - -
  • -
+
    +
    + Permissions +
    +
  • + Email + + {{permissions.view_email_address}} + +
  • +
  • + Personal Information + + {{permissions.personal_info}} + +
  • +
  • + Buy/Sell + + {{permissions.transact}} + +
  • +
  • + Transaction History + + {{permissions.transaction_history}} + +
  • +
-
    -

    Email

    -
  • - Email - - {{glidera.email.email}} - -
  • -
  • - Active - - {{glidera.email.userEmailIsSetup}} - -
  • -
+
    +
    + Email +
    +
  • + Email + + {{email.email}} + +
  • +
  • + Active + + {{email.userEmailIsSetup}} + +
  • +
-
    -

    Personal Information

    +
      +
      + Personal Information +
      -
    • - First Name - - {{glidera.personalInfo.firstName}} - -
    • -
    • - Middle Name - - {{glidera.personalInfo.middleName}} - -
    • -
    • - Last Name - - {{glidera.personalInfo.lastName}} - -
    • -
    • - Birth Date - - {{glidera.personalInfo.birthDate}} - -
    • -
    • - Address 1 - - {{glidera.personalInfo.address1}} - -
    • -
    • - Address 2 - - {{glidera.personalInfo.address2}} - -
    • -
    • - City - - {{glidera.personalInfo.city}} - -
    • -
    • - State - - {{glidera.personalInfo.state}} - -
    • -
    • - ZIP Code - - {{glidera.personalInfo.zipCode}} - -
    • -
    • - Country - - {{glidera.personalInfo.countryCode}} - -
    • -
    • - Occupation - - {{glidera.personalInfo.occupation}} - -
    • -
    • - Basic Information State - - {{glidera.personalInfo.basicInfoState}} - -
    • -
    +
  • + First Name + + {{personalInfo.firstName}} + +
  • +
  • + Middle Name + + {{personalInfo.middleName}} + +
  • +
  • + Last Name + + {{personalInfo.lastName}} + +
  • +
  • + Birth Date + + {{personalInfo.birthDate}} + +
  • +
  • + Address 1 + + {{personalInfo.address1}} + +
  • +
  • + Address 2 + + {{personalInfo.address2}} + +
  • +
  • + City + + {{personalInfo.city}} + +
  • +
  • + State + + {{personalInfo.state}} + +
  • +
  • + ZIP Code + + {{personalInfo.zipCode}} + +
  • +
  • + Country + + {{personalInfo.countryCode}} + +
  • +
  • + Occupation + + {{personalInfo.occupation}} + +
  • +
  • + Basic Information State + + {{personalInfo.basicInfoState}} + +
  • +
-
    -

    Status

    +
      +
      + Status +
      -
    • - Buy/Sell - - {{glidera.status.userCanTransact}} - -
    • +
    • + Buy/Sell + + {{status.userCanTransact}} + +
    • -
    • - Buy - - {{glidera.status.userCanBuy}} - -
    • -
    • - Sell - - {{glidera.status.userCanSell}} - -
    • -
    • - Email Is Setup - - {{glidera.status.userEmailIsSetup}} - -
    • -
    • - Phone Is Setup - - {{glidera.status.userPhoneIsSetup}} - -
    • -
    • - Bank Account Is Setup - - {{glidera.status.userBankAccountIsSetup}} - -
    • -
    • - Personal Information State - - {{glidera.status.personalInfoState}} - -
    • -
    • - Bank Account State - - {{glidera.status.bankAccountState}} - -
    • -
    • - Country - - {{glidera.status.country}} - -
    • -
    +
  • + Buy + + {{status.userCanBuy}} + +
  • +
  • + Sell + + {{status.userCanSell}} + +
  • +
  • + Email Is Setup + + {{status.userEmailIsSetup}} + +
  • +
  • + Phone Is Setup + + {{status.userPhoneIsSetup}} + +
  • +
  • + Bank Account Is Setup + + {{status.userBankAccountIsSetup}} + +
  • +
  • + Personal Information State + + {{status.personalInfoState}} + +
  • +
  • + Bank Account State + + {{status.bankAccountState}} + +
  • +
  • + Country + + {{status.country}} + +
  • +
-
    -

    Limits

    +
      +
      + Limits +
      -
    • - Daily Buy - - {{glidera.limits.dailyBuy|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Daily Sell - - {{glidera.limits.dailySell|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Monthly Buy - - {{glidera.limits.monthlyBuy|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Monthly Sell - - {{glidera.limits.monthlySell|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Daily Buy Remaining - - {{glidera.limits.dailyBuyRemaining|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Daily Sell Remaining - - {{glidera.limits.dailySellRemaining|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Monthly Buy Remaining - - {{glidera.limits.monthlyBuyRemaining|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Monthly Sell Remaining - - {{glidera.limits.monthlySellRemaining|currency:'':2}} {{glidera.limits.currency}} - -
    • -
    • - Buy/Sell Disabled (pending first transaction) - - {{glidera.limits.transactDisabledPendingFirstTransaction}} - -
    • -
    +
  • + Daily Buy + + {{limits.dailyBuy|currency:'':2}} {{limits.currency}} + +
  • +
  • + Daily Sell + + {{limits.dailySell|currency:'':2}} {{limits.currency}} + +
  • +
  • + Monthly Buy + + {{limits.monthlyBuy|currency:'':2}} {{limits.currency}} + +
  • +
  • + Monthly Sell + + {{limits.monthlySell|currency:'':2}} {{limits.currency}} + +
  • +
  • + Daily Buy Remaining + + {{limits.dailyBuyRemaining|currency:'':2}} {{limits.currency}} + +
  • +
  • + Daily Sell Remaining + + {{limits.dailySellRemaining|currency:'':2}} {{limits.currency}} + +
  • +
  • + Monthly Buy Remaining + + {{limits.monthlyBuyRemaining|currency:'':2}} {{limits.currency}} + +
  • +
  • + Monthly Sell Remaining + + {{limits.monthlySellRemaining|currency:'':2}} {{limits.currency}} + +
  • +
  • + Buy/Sell Disabled (pending first transaction) + + {{limits.transactDisabledPendingFirstTransaction}} + +
  • +
-
    -

    Account

    +
      +
      + Account +
      -
    • - - Log out -
    • -
    -

    +
  • + Log out +
  • +
+
+ -
-
diff --git a/public/views/sellGlidera.html b/public/views/sellGlidera.html index 160e33656..f5a7796e8 100644 --- a/public/views/sellGlidera.html +++ b/public/views/sellGlidera.html @@ -1,123 +1,140 @@ -
-
+ + + + + + Sell + + -
- -
-

+

Daily sell limit: - {{index.glideraLimits.dailySell|currency:'':2}} {{index.glideraLimits.currency}} - (remaining {{index.glideraLimits.dailySellRemaining|currency:'':2}} {{index.glideraLimits.currency}}) + {{limits.dailySell|currency:'':2}} {{limits.currency}} + (remaining {{limits.dailySellRemaining|currency:'':2}} {{limits.currency}})
Monthly sell limit: - {{index.glideraLimits.monthlySell|currency:'':2}} {{index.glideraLimits.currency}} - (remaining {{index.glideraLimits.monthlySellRemaining|currency:'':2}} {{index.glideraLimits.currency}}) + {{limits.monthlySell|currency:'':2}} {{limits.currency}} + (remaining {{limits.monthlySellRemaining|currency:'':2}} {{limits.currency}})

-
-
-
+
+ + This operation was disabled because you have a pending first transaction + +
-
- - This operation was disabled because you have a pending first transaction - -
+
+
-
- +
+ -
- -
- - - - -
-
+
-
-
-{{sell.sellPrice.qty}} BTC → {{sell.sellPrice.subtotal|currency:'':2}} {{sell.sellPrice.currency}} -

- A SMS containing a confirmation code was sent to your phone.
- Please, enter the code below -

-
- - -
-

- Bitcoins will be immediately sent from your wallet to Glidera. Fiat will be deposited in your bank account in 4-6 business days. -

+ BTC + USD +
-
-
- - {{sell.error}} - -
-
-

Sale initiated

-

- A transfer has been initiated to your bank account and should arrive in 4-6 business days. -

- +
+ Sell + {{sell.sellPrice.subtotal|currency:'':2}} {{sell.sellPrice.currency}} in Bitcoin + {{sell.sellPrice.qty}} BTC + at {{sell.sellPrice.price|currency:'':2}} {{sell.sellPrice.currency}}/BTC + +
+
+ (Enter the amount to get the exchange rate) +
+ +
+ ... +
+ + + +
+
+
+{{sell.sellPrice.qty}} BTC → {{sell.sellPrice.subtotal|currency:'':2}} {{sell.sellPrice.currency}} +

+ A SMS containing a confirmation code was sent to your phone.
+ Please, enter the code below +

+
+
+ +
+ +
+

+ Bitcoins will be immediately sent from your wallet to Glidera. Fiat will be deposited in your bank account in 4-6 business days. +

-
-
-
+
+
+ + {{sell.error}} + +
+
+

Sale initiated

+

+ A transfer has been initiated to your bank account and should arrive in 4-6 business days. +

+ + +
+ + + diff --git a/public/views/tab-home.html b/public/views/tab-home.html index a4d5b572f..8b8c8a426 100644 --- a/public/views/tab-home.html +++ b/public/views/tab-home.html @@ -66,6 +66,18 @@
+
+

Buy & Sell Bitcoin

+
+
+ +
+
+ +
+
+
+

Next steps

    @@ -73,10 +85,6 @@ BitPay Card -
  • - - Buy and Sell -
  • Gift Cards diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index a0eff911c..0c92b3adc 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -1,26 +1,89 @@ 'use strict'; angular.module('copayApp.controllers').controller('buyGlideraController', - function($scope, $timeout, $ionicModal, profileService, addressService, glideraService, bwcError, lodash, ongoingProcess) { + function($scope, $timeout, $log, $ionicModal, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess) { + var wallet; var self = this; this.show2faCodeInput = null; this.error = null; this.success = null; - this.init = function(testnet) { - self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet'); + $scope.init = function(accessToken) { + $scope.network = glideraService.getEnvironment(); - var client = profileService.focusedClient; - if (client) { + $scope.token = accessToken; + $scope.error = null; + $scope.permissions = null; + $scope.email = null; + $scope.personalInfo = null; + $scope.txs = null; + $scope.status = null; + $scope.limits = null; + + ongoingProcess.set('connectingGlidera', true); + glideraService.init($scope.token, function(err, glidera) { + ongoingProcess.set('connectingGlidera'); + if (err || !glidera) { + $scope.error = err; + return; + } + $scope.token = glidera.token; + $scope.permissions = glidera.permissions; + $scope.update({fullUpdate: true}); + }); + + self.allWallets = profileService.getWallets({ + network: $scope.network, + n: 1, + onlyComplete: true + }); + if (lodash.isEmpty(self.allWallets)) return; + + wallet = self.allWallets[0]; + if (wallet) { $timeout(function() { - self.selectedWalletId = client.credentials.walletId; - self.selectedWalletName = client.credentials.walletName; + self.selectedWalletId = wallet.credentials.walletId; + self.selectedWalletName = wallet.credentials.walletName; $scope.$apply(); }, 100); } }; + $scope.update = function(opts) { + if (!$scope.token || !$scope.permissions) return; + $log.debug('Updating Glidera Account...'); + var accessToken = $scope.token; + var permissions = $scope.permissions; + + opts = opts || {}; + + glideraService.getStatus(accessToken, function(err, data) { + $scope.status = data; + }); + + glideraService.getLimits(accessToken, function(err, limits) { + $scope.limits = limits; + }); + + if (permissions.transaction_history) { + glideraService.getTransactions(accessToken, function(err, data) { + $scope.txs = data; + }); + } + + if (permissions.view_email_address && opts.fullUpdate) { + glideraService.getEmail(accessToken, function(err, data) { + $scope.email = data.email; + }); + } + if (permissions.personal_info && opts.fullUpdate) { + glideraService.getPersonalInfo(accessToken, function(err, data) { + $scope.personalInfo = data; + }); + } + }; + $scope.openWalletsModal = function(wallets) { self.error = null; @@ -39,9 +102,9 @@ angular.module('copayApp.controllers').controller('buyGlideraController', $scope.$on('walletSelected', function(ev, walletId) { $timeout(function() { - var client = profileService.getClient(walletId); + wallet = profileService.getClient(walletId); self.selectedWalletId = walletId; - self.selectedWalletName = client.credentials.walletName; + self.selectedWalletName = wallet.credentials.walletName; $scope.$apply(); }, 100); $scope.walletsModal.hide(); @@ -87,7 +150,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', self.error = null; ongoingProcess.set('Buying Bitcoin...', true); $timeout(function() { - addressService.getAddress(self.selectedWalletId, false, function(err, walletAddr) { + walletService.getAddress(wallet, false, function(err, walletAddr) { if (err) { ongoingProcess.set('Buying Bitcoin...', false); self.error = bwcError.cb(err, 'Could not create address'); diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index e793c2709..383a7ba56 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -1,12 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService) { +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, txStatus, gettext, txFormatService) { var cachedTxp = {}; // An alert dialog var showAlert = function(title, msg, cb) { - $log.warn(title + ":" + msg); + $log.warn(title + ": " + msg); var alertPopup = $ionicPopup.alert({ title: title, template: msg @@ -17,6 +17,29 @@ angular.module('copayApp.controllers').controller('confirmController', function( alertPopup.then(cb); }; + $scope.showDescriptionPopup = function() { + var commentPopup = $ionicPopup.show({ + templateUrl: "views/includes/note.html", + title: gettextCatalog.getString('Set description'), + scope: $scope, + }); + $scope.commentPopupClose = function() { + commentPopup.close(); + }; + $scope.commentPopupSave = function() { + $log.debug('Saving description: ' + $scope.data.comment); + $scope.description = $scope.data.comment; + $scope.txp = null; + + createTx($scope.wallet, $scope.toAddress, $scope.toAmount, $scope.data.comment, function(err, txp) { + if (err) return; + cachedTxp[$scope.wallet.id] = txp; + apply(txp); + }); + commentPopup.close(); + }; + }; + $scope.init = function() { // TODO (URL , etc) @@ -67,17 +90,11 @@ angular.module('copayApp.controllers').controller('confirmController', function( stop = null; } - function apply(txp) { - $scope.fee = txFormatService.formatAmountStr(txp.fee); - $scope.txp = txp; - $scope.$apply(); - }; - if (cachedTxp[wallet.id]) { apply(cachedTxp[wallet.id]); } else { stop = $timeout(function() { - createTx(wallet, $scope.toAddress, $scope.toAmount, $scope.comment, function(err, txp) { + createTx(wallet, $scope.toAddress, $scope.toAmount, $scope.description, function(err, txp) { if (err) return; cachedTxp[wallet.id] = txp; apply(txp); @@ -106,7 +123,13 @@ angular.module('copayApp.controllers').controller('confirmController', function( showAlert(gettext('Error creating transaction'), msg); }; - var createTx = function(wallet, toAddress, toAmount, comment, cb) { + function apply(txp) { + $scope.fee = txFormatService.formatAmountStr(txp.fee); + $scope.txp = txp; + $scope.$apply(); + }; + + var createTx = function(wallet, toAddress, toAmount, description, cb) { var config = configService.getSync().wallet; // @@ -117,7 +140,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( var paypro = $scope.paypro; // ToDo: use a credential's (or fc's) function for this - if (comment && !wallet.credentials.sharedEncryptingKey) { + if (description && !wallet.credentials.sharedEncryptingKey) { var msg = 'Could not add message to imported wallet without shared encrypting key'; $log.warn(msg); return setSendError(gettext(msg)); @@ -132,7 +155,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( outputs.push({ 'toAddress': toAddress, 'amount': toAmount, - 'message': comment + 'message': description }); var txp = {}; @@ -145,7 +168,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( } txp.outputs = outputs; - txp.message = comment; + txp.message = description; txp.payProUrl = paypro ? paypro.url : null; txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true; txp.feeLevel = config.settings.feeLevel || 'normal'; diff --git a/src/js/controllers/glidera.js b/src/js/controllers/glidera.js index f72a6c5f6..db9fb51a9 100644 --- a/src/js/controllers/glidera.js +++ b/src/js/controllers/glidera.js @@ -1,33 +1,98 @@ 'use strict'; angular.module('copayApp.controllers').controller('glideraController', - function($rootScope, $scope, $timeout, $ionicModal, profileService, configService, storageService, glideraService, lodash, ongoingProcess, platformInfo) { + function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, storageService, glideraService, lodash, ongoingProcess, platformInfo, nodeWebkit) { if (platformInfo.isCordova && StatusBar.isVisible) { StatusBar.backgroundColorByHexString("#4B6178"); } + $scope.openExternalLink = function(url, target) { + if (platformInfo.isNW) { + nodeWebkit.openExternalLink(url); + } else { + target = target || '_blank'; + var ref = window.open(url, target, 'location=no'); + } + }; + + $scope.init = function(accessToken) { + $scope.network = glideraService.getEnvironment(); + + $scope.token = null; + $scope.error = null; + $scope.permissions = null; + $scope.email = null; + $scope.personalInfo = null; + $scope.txs = null; + $scope.status = null; + $scope.limits = null; + + ongoingProcess.set('connectingGlidera', true); + glideraService.init($scope.token, function(err, glidera) { + ongoingProcess.set('connectingGlidera'); + if (err || !glidera) { + $scope.error = err; + return; + } + $scope.token = glidera.token; + $scope.permissions = glidera.permissions; + $scope.update({fullUpdate: true}); + }); + }; + + $scope.update = function(opts) { + if (!$scope.token || !$scope.permissions) return; + $log.debug('Updating Glidera Account...'); + var accessToken = $scope.token; + var permissions = $scope.permissions; + + opts = opts || {}; + + glideraService.getStatus(accessToken, function(err, data) { + $scope.status = data; + }); + + glideraService.getLimits(accessToken, function(err, limits) { + $scope.limits = limits; + }); + + if (permissions.transaction_history) { + glideraService.getTransactions(accessToken, function(err, data) { + $scope.txs = data; + }); + } + + if (permissions.view_email_address && opts.fullUpdate) { + glideraService.getEmail(accessToken, function(err, data) { + $scope.email = data.email; + }); + } + if (permissions.personal_info && opts.fullUpdate) { + glideraService.getPersonalInfo(accessToken, function(err, data) { + $scope.personalInfo = data; + }); + } + }; + this.getAuthenticateUrl = function() { return glideraService.getOauthCodeUrl(); }; this.submitOauthCode = function(code) { - var self = this; - var glideraTestnet = configService.getSync().glidera.testnet; - var network = glideraTestnet ? 'testnet' : 'livenet'; ongoingProcess.set('connectingGlidera', true); - this.error = null; + $scope.error = null; $timeout(function() { glideraService.getToken(code, function(err, data) { ongoingProcess.set('connectingGlidera', false); if (err) { - self.error = err; + $scope.error = err; $timeout(function() { $scope.$apply(); }, 100); } else if (data && data.access_token) { - storageService.setGlideraToken(network, data.access_token, function() { - $scope.$emit('Local/GlideraUpdated', data.access_token); + storageService.setGlideraToken($scope.network, data.access_token, function() { + $scope.init(data.access_token); $timeout(function() { $scope.$apply(); }, 100); diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 4dcfad174..3aad8690f 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('importController', - function($scope, $rootScope, $timeout, $log, profileService, configService, notification, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) { + function($scope, $rootScope, $timeout, $log, $state, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -110,7 +110,6 @@ angular.module('copayApp.controllers').controller('importController', }); $rootScope.$emit('Local/WalletImported', client.credentials.walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $state.go('tabs.home'); }); }, 100); @@ -138,7 +137,6 @@ angular.module('copayApp.controllers').controller('importController', }); $rootScope.$emit('Local/WalletImported', client.credentials.walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $state.go('tabs.home'); }); }, 100); @@ -159,7 +157,6 @@ angular.module('copayApp.controllers').controller('importController', }); } $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $state.go('tabs.home'); }); }, 100); @@ -189,7 +186,6 @@ angular.module('copayApp.controllers').controller('importController', }); $rootScope.$emit('Local/WalletImported', client.credentials.walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $state.go('tabs.home'); }); }, 100); @@ -324,7 +320,6 @@ angular.module('copayApp.controllers').controller('importController', $log.debug('Remote preferences saved for:' + wallet.walletId) }); $rootScope.$emit('Local/WalletImported', wallet.walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $state.go('tabs.home'); }); }, 100); @@ -402,7 +397,6 @@ angular.module('copayApp.controllers').controller('importController', $log.debug('Remote preferences saved for:' + wallet.walletId) }); $rootScope.$emit('Local/WalletImported', wallet.walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); $state.go('tabs.home'); }); }, 100); diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index 45535318e..3c1650d83 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('joinController', - function($scope, $rootScope, $timeout, $state, notification, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log) { + function($scope, $rootScope, $timeout, $state, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; diff --git a/src/js/controllers/modals/glideraConfirmation.js b/src/js/controllers/modals/glideraConfirmation.js index eb83a0615..8a1b846ef 100644 --- a/src/js/controllers/modals/glideraConfirmation.js +++ b/src/js/controllers/modals/glideraConfirmation.js @@ -1,11 +1,11 @@ 'use strict'; -angular.module('copayApp.controllers').controller('glideraConfirmationController', function($scope, $timeout, storageService, applicationService) { +angular.module('copayApp.controllers').controller('glideraConfirmationController', function($scope, $timeout, $state, glideraService) { $scope.ok = function() { - storageService.removeGlideraToken($scope.network, function() { + glideraService.removeToken(function() { $timeout(function() { - applicationService.restart(); + $state.go('glidera.main'); }, 100); }); $scope.cancel(); diff --git a/src/js/controllers/preferencesGlidera.js b/src/js/controllers/preferencesGlidera.js index 1428ca933..e47c24c3b 100644 --- a/src/js/controllers/preferencesGlidera.js +++ b/src/js/controllers/preferencesGlidera.js @@ -1,43 +1,70 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesGlideraController', - function($scope, $timeout, $ionicModal, profileService, applicationService, glideraService, storageService) { + function($scope, $log, $ionicModal, ongoingProcess, glideraService) { - this.getEmail = function(token) { - var self = this; - glideraService.getEmail(token, function(error, data) { - self.email = data; + $scope.init = function(accessToken) { + $scope.network = glideraService.getEnvironment(); + + $scope.token = accessToken; + $scope.error = null; + $scope.permissions = null; + $scope.email = null; + $scope.personalInfo = null; + $scope.txs = null; + $scope.status = null; + $scope.limits = null; + + ongoingProcess.set('connectingGlidera', true); + glideraService.init($scope.token, function(err, glidera) { + ongoingProcess.set('connectingGlidera'); + if (err || !glidera) { + $scope.error = err; + return; + } + $scope.token = glidera.token; + $scope.permissions = glidera.permissions; + $scope.update({fullUpdate: true}); }); }; - this.getPersonalInfo = function(token) { - var self = this; - glideraService.getPersonalInfo(token, function(error, info) { - self.personalInfo = info; + $scope.update = function(opts) { + if (!$scope.token || !$scope.permissions) return; + $log.debug('Updating Glidera Account...'); + var accessToken = $scope.token; + var permissions = $scope.permissions; + + opts = opts || {}; + + glideraService.getStatus(accessToken, function(err, data) { + $scope.status = data; }); + + glideraService.getLimits(accessToken, function(err, limits) { + $scope.limits = limits; + }); + + if (permissions.transaction_history) { + glideraService.getTransactions(accessToken, function(err, data) { + $scope.txs = data; + }); + } + + if (permissions.view_email_address && opts.fullUpdate) { + glideraService.getEmail(accessToken, function(err, data) { + $scope.email = data.email; + }); + } + if (permissions.personal_info && opts.fullUpdate) { + glideraService.getPersonalInfo(accessToken, function(err, data) { + $scope.personalInfo = data; + }); + } }; - this.getStatus = function(token) { - var self = this; - glideraService.getStatus(token, function(error, data) { - self.status = data; - }); - }; - - this.getLimits = function(token) { - var self = this; - glideraService.getLimits(token, function(error, limits) { - self.limits = limits; - }); - }; - - this.revokeToken = function(testnet) { - $scope.network = testnet ? 'testnet' : 'livenet'; - $scope.loading = false; - + $scope.revokeToken = function() { $ionicModal.fromTemplateUrl('views/modals/glidera-confirmation.html', { - scope: $scope, - animation: 'slide-in-up' + scope: $scope }).then(function(modal) { $scope.glideraConfirmationModal = modal; $scope.glideraConfirmationModal.show(); diff --git a/src/js/controllers/sellGlidera.js b/src/js/controllers/sellGlidera.js index 59cad402c..ab9e3be9f 100644 --- a/src/js/controllers/sellGlidera.js +++ b/src/js/controllers/sellGlidera.js @@ -1,38 +1,97 @@ 'use strict'; angular.module('copayApp.controllers').controller('sellGlideraController', - function($rootScope, $scope, $timeout, $ionicModal, $log, configService, profileService, addressService, feeService, glideraService, bwcError, lodash, walletService, fingerprintService, ongoingProcess, go) { + function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, glideraService, bwcError, lodash, walletService, fingerprintService, configService, ongoingProcess) { var self = this; - var config = configService.getSync(); this.data = {}; this.show2faCodeInput = null; this.success = null; this.error = null; - var client; + var wallet; - var handleEncryptedWallet = function(client, cb) { - if (!walletService.isEncrypted(client)) return cb(); + var handleEncryptedWallet = function(wallet, cb) { + if (!walletService.isEncrypted(wallet)) return cb(); $rootScope.$emit('Local/NeedsPassword', false, function(err, password) { if (err) return cb(err); - return cb(walletService.unlock(client, password)); + return cb(walletService.unlock(wallet, password)); }); }; - this.init = function(testnet) { - self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1); + $scope.init = function(accessToken) { + $scope.network = glideraService.getEnvironment(); - client = profileService.focusedClient; - if (client && client.credentials.m == 1) { + $scope.token = accessToken; + $scope.error = null; + $scope.permissions = null; + $scope.email = null; + $scope.personalInfo = null; + $scope.txs = null; + $scope.status = null; + $scope.limits = null; + + ongoingProcess.set('connectingGlidera', true); + glideraService.init($scope.token, function(err, glidera) { + ongoingProcess.set('connectingGlidera'); + if (err || !glidera) { + $scope.error = err; + return; + } + $scope.token = glidera.token; + $scope.permissions = glidera.permissions; + $scope.update({fullUpdate: true}); + }); + + self.allWallets = profileService.getWallets({ + network: $scope.network, + n: 1, + onlyComplete: true + }); + if (lodash.isEmpty(self.allWallets)) return; + + wallet = self.allWallets[0]; + if (wallet) { $timeout(function() { - self.selectedWalletId = client.credentials.walletId; - self.selectedWalletName = client.credentials.walletName; + self.selectedWalletId = wallet.credentials.walletId; + self.selectedWalletName = wallet.credentials.walletName; $scope.$apply(); }, 100); } }; + $scope.update = function(opts) { + if (!$scope.token || !$scope.permissions) return; + $log.debug('Updating Glidera Account...'); + var accessToken = $scope.token; + var permissions = $scope.permissions; + opts = opts || {}; + + glideraService.getStatus(accessToken, function(err, data) { + $scope.status = data; + }); + + glideraService.getLimits(accessToken, function(err, limits) { + $scope.limits = limits; + }); + + if (permissions.transaction_history) { + glideraService.getTransactions(accessToken, function(err, data) { + $scope.txs = data; + }); + } + + if (permissions.view_email_address && opts.fullUpdate) { + glideraService.getEmail(accessToken, function(err, data) { + $scope.email = data.email; + }); + } + if (permissions.personal_info && opts.fullUpdate) { + glideraService.getPersonalInfo(accessToken, function(err, data) { + $scope.personalInfo = data; + }); + } + }; $scope.openWalletsModal = function(wallets) { self.error = null; @@ -52,9 +111,9 @@ angular.module('copayApp.controllers').controller('sellGlideraController', $scope.$on('walletSelected', function(ev, walletId) { $timeout(function() { - client = profileService.getClient(walletId); + wallet = profileService.getClient(walletId); self.selectedWalletId = walletId; - self.selectedWalletName = client.credentials.walletName; + self.selectedWalletName = wallet.credentials.walletName; $scope.$apply(); }, 100); $scope.walletsModal.hide(); @@ -98,16 +157,17 @@ angular.module('copayApp.controllers').controller('sellGlideraController', var self = this; self.error = null; var outputs = []; + var config = configService.getSync(); var configWallet = config.wallet; var walletSettings = configWallet.settings; - if (!client) { + if (!wallet) { self.error = 'No wallet selected'; return; } ongoingProcess.set('creatingTx', true); - addressService.getAddress(client.credentials.walletId, null, function(err, refundAddress) { + walletService.getAddress(wallet, null, function(err, refundAddress) { if (!refundAddress) { ongoingProcess.clear(); @@ -142,71 +202,62 @@ angular.module('copayApp.controllers').controller('sellGlideraController', } }; - walletService.createTx(client, txp, function(err, createdTxp) { + walletService.createTx(wallet, txp, function(err, createdTxp) { ongoingProcess.clear(); if (err) { self.error = err.message ||  bwcError.msg(err); return; } - $scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) { - if (accept) { - fingerprintService.check(client, function(err) { + fingerprintService.check(wallet, function(err) { + if (err) { + self.error = err.message ||  bwcError.msg(err); + return; + } + + handleEncryptedWallet(wallet, function(err) { + if (err) { + self.error = err.message ||  bwcError.msg(err); + return; + } + + ongoingProcess.set('signingTx', true); + walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) { if (err) { + ongoingProcess.clear(); self.error = err.message ||  bwcError.msg(err); - return; } - handleEncryptedWallet(client, function(err) { + walletService.signTx(wallet, publishedTxp, function(err, signedTxp) { + walletService.lock(wallet); + walletService.removeTx(wallet, signedTxp, function(err) { + if (err) $log.debug(err); + }); + ongoingProcess.clear(); if (err) { self.error = err.message ||  bwcError.msg(err); return; } - - ongoingProcess.set('signingTx', true); - walletService.publishTx(client, createdTxp, function(err, publishedTxp) { + var rawTx = signedTxp.raw; + var data = { + refundAddress: refundAddress, + signedTransaction: rawTx, + priceUuid: self.sellPrice.priceUuid, + useCurrentPrice: self.sellPrice.priceUuid ? false : true, + ip: null + }; + ongoingProcess.set('Seling Bitcoin', true); + glideraService.sell(token, twoFaCode, data, function(err, data) { + ongoingProcess.clear(); if (err) { - ongoingProcess.clear(); self.error = err.message ||  bwcError.msg(err); + return; } - - walletService.signTx(client, publishedTxp, function(err, signedTxp) { - walletService.lock(client); - walletService.removeTx(client, signedTxp, function(err) { - if (err) $log.debug(err); - }); - ongoingProcess.clear(); - if (err) { - self.error = err.message ||  bwcError.msg(err); - return; - } - var rawTx = signedTxp.raw; - var data = { - refundAddress: refundAddress, - signedTransaction: rawTx, - priceUuid: self.sellPrice.priceUuid, - useCurrentPrice: self.sellPrice.priceUuid ? false : true, - ip: null - }; - ongoingProcess.set('Seling Bitcoin', true); - glideraService.sell(token, twoFaCode, data, function(err, data) { - ongoingProcess.clear(); - if (err) { - self.error = err.message ||  bwcError.msg(err); - $timeout(function() { - $scope.$emit('Local/GlideraError'); - }, 100); - return; - } - self.success = data; - $scope.$emit('Local/GlideraTx'); - }); - }); + self.success = data; + $scope.update(); }); }); }); - } else { - go.path('glidera'); - } + }); }); }); }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 614b5976b..3c925b8d7 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -93,10 +93,9 @@ angular.module('copayApp.controllers').controller('tabHomeController', configService.whenAvailable(function() { var config = configService.getSync(); - var glideraEnabled = config.glidera.enabled; - var coinbaseEnabled = config.coinbase.enabled; var isWindowsPhoneApp = platformInfo.isWP && isCordova; - $scope.buyAndSellEnabled = !isWindowsPhoneApp && (glideraEnabled || coinbaseEnabled); + $scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp; + $scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp; }); }); diff --git a/src/js/routes.js b/src/js/routes.js index b5907cce0..588c6851b 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -85,7 +85,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr * */ - .state('disclaimer', { + .state('disclaimer', { url: '/disclaimer', templateUrl: 'views/disclaimer.html', }) @@ -104,22 +104,19 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr .state('uri', { url: '/uri/:url', - needProfile: true, - views: { - 'main': { - templateUrl: 'views/uri.html' - } - } + templateUrl: 'views/uri.html' }) .state('uripayment', { url: '/uri-payment/:url', - templateUrl: 'views/paymentUri.html', - views: { - 'main': { - templateUrl: 'views/paymentUri.html', - }, - }, - needProfile: true + templateUrl: 'views/paymentUri.html' + }) + .state('uriglidera', { + url: '/uri-glidera/:url', + templateUrl: 'views/glideraUri.html' + }) + .state('uricoinbase', { + url: '/uri-coinbase/:url', + templateUrl: 'views/coinbaseUri.html' }) .state('activity', { url: '/activity', @@ -537,53 +534,43 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr * * Glidera * + * */ - .state('uriglidera', { - url: '/uri-glidera/:url', - templateUrl: 'views/glideraUri.html' - }) - .state('glidera', { + .state('glidera', { url: '/glidera', - templateUrl: 'views/glidera.html' - }) - .state('buyGlidera', { - url: '/buy', - templateUrl: 'views/buyGlidera.html' - }) - .state('sellGlidera', { - url: '/sell', - templateUrl: 'views/sellGlidera.html' - }) - .state('preferencesGlidera', { - url: '/preferencesGlidera', - templateUrl: 'views/preferencesGlidera.html' - }) - - /* - * - * BitPay Card - * - */ - - .state('bitpayCard', { - url: '/bitpayCard', abstract: true, - template: '' + template: '' }) - .state('bitpayCard.main', { + .state('glidera.main', { url: '/main', views: { - 'bitpayCard': { - templateUrl: 'views/bitpayCard.html' + 'glidera': { + templateUrl: 'views/glidera.html' } } }) - .state('bitpayCard.preferences', { + .state('glidera.buy', { + url: '/buy', + views: { + 'glidera': { + templateUrl: 'views/buyGlidera.html' + } + } + }) + .state('glidera.sell', { + url: '/sell', + views: { + 'glidera': { + templateUrl: 'views/sellGlidera.html' + } + } + }) + .state('glidera.preferences', { url: '/preferences', views: { - 'bitpayCard': { - templateUrl: 'views/preferencesBitpayCard.html' + 'glidera': { + templateUrl: 'views/preferencesGlidera.html' } } }) @@ -602,10 +589,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr url: '/preferencesCoinbase', templateUrl: 'views/preferencesCoinbase.html' }) - .state('uricoinbase', { - url: '/uri-coinbase/:url', - templateUrl: 'views/coinbaseUri.html' - }) .state('buyCoinbase', { url: '/buycoinbase', templateUrl: 'views/buyCoinbase.html' @@ -614,15 +597,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr url: '/sellcoinbase', templateUrl: 'views/sellCoinbase.html' }) - .state('buyandsell', { - url: '/buyandsell', - templateUrl: 'views/buyAndSell.html', - controller: function(platformInfo) { - if (platformInfo.isCordova && StatusBar.isVisible) { - StatusBar.backgroundColorByHexString("#4B6178"); - } - } - }) + /* * @@ -650,6 +625,34 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr templateUrl: 'views/buyAmazon.html' } } + }) + + /* + * + * BitPay Card + * + */ + + .state('bitpayCard', { + url: '/bitpayCard', + abstract: true, + template: '' + }) + .state('bitpayCard.main', { + url: '/main', + views: { + 'bitpayCard': { + templateUrl: 'views/bitpayCard.html' + } + } + }) + .state('bitpayCard.preferences', { + url: '/preferences', + views: { + 'bitpayCard': { + templateUrl: 'views/preferencesBitpayCard.html' + } + } }); }) .run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog) { @@ -707,12 +710,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr if ($rootScope.backButtonPressedOnceToExit || fromDisclaimer) { ionic.Platform.exitApp(); - } - - else if ($ionicHistory.backView() && !fromTabs) { + } else if ($ionicHistory.backView() && !fromTabs) { $ionicHistory.goBack(); - } - else { + } else { $rootScope.backButtonPressedOnceToExit = true; window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit')); setInterval(function() { diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 5f0ebe92c..53bb686e9 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -123,11 +123,6 @@ angular.module('copayApp.services').factory('configService', function(storageSer configCache.colorFor = configCache.colorFor || {}; configCache.aliasFor = configCache.aliasFor || {}; - - // Glidera - // Disabled for testnet - configCache.glidera.testnet = false; - // Coinbase // Disabled for testnet configCache.coinbase.testnet = false; diff --git a/src/js/services/glideraService.js b/src/js/services/glideraService.js index 6f96ee2cb..31b373105 100644 --- a/src/js/services/glideraService.js +++ b/src/js/services/glideraService.js @@ -4,11 +4,15 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l var root = {}; var credentials = {}; var isCordova = platformInfo.isCordova; - // - // - root.setCredentials = function(network) { - if (network == 'testnet') { + var _setCredentials = function() { + /* + * Development: 'testnet' + * Production: 'livenet' + */ + credentials.NETWORK = 'livenet'; + + if (credentials.NETWORK == 'testnet') { credentials.HOST = 'https://sandbox.glidera.io'; if (isCordova) { credentials.REDIRECT_URI = 'copay://glidera'; @@ -33,11 +37,25 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l }; }; + root.getEnvironment = function() { + _setCredentials(); + return credentials.NETWORK; + }; + root.getOauthCodeUrl = function() { + _setCredentials(); return credentials.HOST + '/oauth2/auth?response_type=code&client_id=' + credentials.CLIENT_ID + '&redirect_uri=' + credentials.REDIRECT_URI; }; + root.removeToken = function(cb) { + _setCredentials(); + storageService.removeGlideraToken(credentials.NETWORK, function() { + return cb(); + }); + }; + root.getToken = function(code, cb) { + _setCredentials(); var req = { method: 'POST', url: credentials.HOST + '/api/v1/oauth/token', @@ -64,6 +82,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l }; var _get = function(endpoint, token) { + _setCredentials(); return { method: 'GET', url: credentials.HOST + '/api/v1' + endpoint, @@ -176,6 +195,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l }; var _post = function(endpoint, token, twoFaCode, data) { + _setCredentials(); return { method: 'POST', url: credentials.HOST + '/api/v1' + endpoint, @@ -251,91 +271,39 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l }); }; - root.init = function(accessToken) { - root.glideraEnabled = configService.getSync().glidera.enabled; - root.glideraTestnet = configService.getSync().glidera.testnet; - var network = root.glideraTestnet ? 'testnet' : 'livenet'; + root.init = function(accessToken, cb) { + _setCredentials(); + $log.debug('Init Glidera...'); - root.glideraToken = null; - root.glideraError = null; - root.glideraPermissions = null; - root.glideraEmail = null; - root.glideraPersonalInfo = null; - root.glideraTxs = null; - root.glideraStatus = null; - - if (!root.glideraEnabled) return; - - root.setCredentials(network); + var glidera = { + token: null, + permissions: null + } var getToken = function(cb) { if (accessToken) { cb(null, accessToken); } else { - storageService.getGlideraToken(network, cb); + storageService.getGlideraToken(credentials.NETWORK, cb); } }; getToken(function(err, accessToken) { - if (err || !accessToken) return; + if (err || !accessToken) return cb(); else { root.getAccessTokenPermissions(accessToken, function(err, p) { if (err) { - root.glideraError = err; + return cb(err); } else { - root.glideraToken = accessToken; - root.glideraPermissions = p; - root.update({ - fullUpdate: true - }); + glidera.token = accessToken; + glidera.permissions = p; + return cb(null, glidera); } }); } }); }; - root.update = function(opts) { - if (!root.glideraToken || !root.glideraPermissions) return; - var accessToken = root.glideraToken; - var permissions = root.glideraPermissions; - - opts = opts || {}; - - root.getStatus(accessToken, function(err, data) { - root.glideraStatus = data; - }); - - root.getLimits(accessToken, function(err, limits) { - root.glideraLimits = limits; - }); - - if (permissions.transaction_history) { - root.getTransactions(accessToken, function(err, data) { - root.glideraTxs = data; - }); - } - - if (permissions.view_email_address && opts.fullUpdate) { - root.getEmail(accessToken, function(err, data) { - root.glideraEmail = data.email; - }); - } - if (permissions.personal_info && opts.fullUpdate) { - root.getPersonalInfo(accessToken, function(err, data) { - root.glideraPersonalInfo = data; - }); - } - }; - - configService.whenAvailable(function() { - $log.debug('Init Glidera Service...'); - root.init(); - }); - - $rootScope.$on('NewBlock', function() {     - root.update();    - }); - return root; }); diff --git a/src/js/services/onGoingProcess.js b/src/js/services/onGoingProcess.js index 3738519b6..2c433a4af 100644 --- a/src/js/services/onGoingProcess.js +++ b/src/js/services/onGoingProcess.js @@ -67,7 +67,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti window.plugins.spinnerDialog.show(null, showName, true); } else { - var tmpl = '' + showName; + var tmpl = '
    ' + showName + '
    '; $ionicLoading.show({ template: tmpl }); diff --git a/src/sass/main.scss b/src/sass/main.scss index 411e2a4e9..af6c7ab3e 100644 --- a/src/sass/main.scss +++ b/src/sass/main.scss @@ -965,3 +965,14 @@ input[type=number] { } } +/* Spinner */ + +.item-icon-left ion-spinner { + float: left; + margin-left: -3.2em; + margin-right: 1em; + margin-top: -0.2em; + height: 24px; +} + +