diff --git a/public/img/glidera-logo.png b/public/img/glidera-logo.png new file mode 100644 index 000000000..930cdf4a9 Binary files /dev/null and b/public/img/glidera-logo.png differ diff --git a/public/views/glidera.html b/public/views/glidera.html index 4ef91bcb6..7f574b866 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -6,43 +6,105 @@ -
-
-
+
- - Connect to Glidera +
+
+
+
+
+
+
+
+
+ Connecting to Glidera... +
+
+ +
+ +
+
+
+ +
+ {{index.glideraEmail}}
+ + Preferences +
-
- Connected to Glidera - Preferences - -
- - -
- -

Transactions

-
    -
  • - transactionUuid: {{tx.transactionUuid}}
    - transactionDate: {{tx.transactionDate}}
    - type: {{tx.type}}
    - price: {{tx.price}}
    - subtotal: {{tx.subtotal}}
    - fees: {{tx.fees}}
    - total: {{tx.total}}
    - currency: {{tx.currency}}
    - estimatedDeliveryDate: {{tx.estimatedDeliveryDate}}
    - transactionHash: {{tx.transactionHash}}
    - status: {{tx.status}}
    -
  • -
- +

Connected

+
    +
  • + Buy + + + +
  • +
  • + Sell + + + +
  • +
+

Activity

+
+
+ Bought + Sold
+
+ + {{tx.subtotal}} {{tx.currency}} + +
+
+
+ +
+
+
+ +
+
+ Completed + Pending + Error +
+
diff --git a/public/views/modals/glidera-tx-details.html b/public/views/modals/glidera-tx-details.html new file mode 100644 index 000000000..02135444a --- /dev/null +++ b/public/views/modals/glidera-tx-details.html @@ -0,0 +1,60 @@ + + + diff --git a/public/views/preferencesGlidera.html b/public/views/preferencesGlidera.html index 58b2dcc58..31b8467a9 100644 --- a/public/views/preferencesGlidera.html +++ b/public/views/preferencesGlidera.html @@ -9,21 +9,6 @@
-
- - Get OAuth Code - - -
- - -
-
-
- - Glidera + + Glidera diff --git a/src/js/controllers/glidera.js b/src/js/controllers/glidera.js index 202f5490e..c55429de5 100644 --- a/src/js/controllers/glidera.js +++ b/src/js/controllers/glidera.js @@ -1,13 +1,68 @@ 'use strict'; angular.module('copayApp.controllers').controller('glideraController', - function(glideraService) { + function($scope, $timeout, $modal, profileService, configService, storageService, glideraService) { + + var config = configService.getSync().wallet.settings; + this.authenticateUrl = glideraService.getOauthCodeUrl(); - this.init = function(token) { + this.update = function(token) { var self = this; glideraService.getTransactions(token, function(error, txs) { self.txs = txs; }); + glideraService.getEmail(token, function(error, data) { + self.email = data.email; + }); + }; + + this.submitOauthCode = function(code) { + var fc = profileService.focusedClient; + var self = this; + this.loading = true; + $timeout(function() { + glideraService.getToken(code, function(error, data) { + if (data && data.access_token) { + storageService.setGlideraToken(fc.credentials.network, data.access_token, function() { + $scope.$emit('Local/GlideraTokenUpdated'); + $timeout(function() { + self.loading = false; + $scope.$apply(); + }, 100); + }); + } + }); + }, 100); + }; + + this.openTxModal = function(token, tx) { + var self = this; + var fc = profileService.focusedClient; + var ModalInstanceCtrl = function($scope, $modalInstance) { + $scope.tx = tx; + $scope.settings = config; + $scope.color = fc.backgroundColor; + + glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) { + $scope.tx = tx; + }); + + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + + }; + + var modalInstance = $modal.open({ + templateUrl: 'views/modals/glidera-tx-details.html', + windowClass: 'full animated slideInRight', + controller: ModalInstanceCtrl, + }); + + modalInstance.result.finally(function() { + var m = angular.element(document.getElementsByClassName('reveal-modal')); + m.addClass('slideOutRight'); + }); }; }); diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index bde992c7b..fe5b1e86a 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, utilService, $state) { +angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, utilService, $state, glideraService) { var self = this; self.isCordova = isCordova; self.onGoingProcess = {}; @@ -114,6 +114,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.setSpendUnconfirmed(); self.glideraToken = null; + self.glideraTxs = null; + self.glideraEmail = null; $timeout(function() { self.hasProfile = true; @@ -847,9 +849,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r }; self.initGlidera = function() { + if (self.isShared) return; storageService.getGlideraToken(self.network, function(err, val) { if (err) return; - self.glideraToken = val; + else { + self.glideraToken = val; + glideraService.getTransactions(val, function(error, txs) { + self.glideraTxs = txs; + }); + glideraService.getEmail(val, function(error, data) { + self.glideraEmail = data.email; + }); + } }); }; diff --git a/src/js/controllers/preferencesGlidera.js b/src/js/controllers/preferencesGlidera.js index 5234f9b1a..0c2a73e9b 100644 --- a/src/js/controllers/preferencesGlidera.js +++ b/src/js/controllers/preferencesGlidera.js @@ -3,8 +3,6 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController', function($scope, $timeout, profileService, go, glideraService, storageService) { - this.authenticateUrl = glideraService.getOauthCodeUrl(); - this.init = function(token) { var self = this; glideraService.getPermissions(token, function(error, permission) { @@ -26,21 +24,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController' glideraService.getLimits(token, function(error, limits) { self.limits = limits; }); - }; - - this.submit = function(code) { - var fc = profileService.focusedClient; - glideraService.getToken(code, function(error, data) { - if (data && data.status == 200) { - storageService.setGlideraToken(fc.credentials.network, data.data.access_token, function() { - $scope.$emit('Local/GlideraTokenUpdated'); - $timeout(function() { - go.walletHome(); - }, 100); - }); - } - }); - }; + }; this.revokeToken = function() { var fc = profileService.focusedClient; diff --git a/src/js/services/glideraService.js b/src/js/services/glideraService.js index d1943ef64..478909423 100644 --- a/src/js/services/glideraService.js +++ b/src/js/services/glideraService.js @@ -34,7 +34,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l $http(req).then(function(data) { $log.info('Glidera Authorization Access Token: SUCCESS'); - return cb(null, data); + return cb(null, data.data); }, function(data) { $log.error('Glidera Authorization Access Token: ERROR ' + data.statusText); return cb(data.statusText); @@ -111,8 +111,20 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l root.getTransactions = function(token, cb) { if (!token) return cb('Invalid Token'); $http(_get('/transaction', token)).then(function(data) { - $log.info('Glidera Transaction: SUCCESS'); + $log.info('Glidera Transactions: SUCCESS'); return cb(null, data.data.transactions); + }, function(data) { + $log.error('Glidera Transactions: ERROR ' + data.statusText); + return cb(data.statusText); + }); + }; + + root.getTransaction = function(token, txid, cb) { + if (!token) return cb('Invalid Token'); + if (!txid) return cb('TxId required'); + $http(_get('/transaction/' + txid, token)).then(function(data) { + $log.info('Glidera Transaction: SUCCESS'); + return cb(null, data.data); }, function(data) { $log.error('Glidera Transaction: ERROR ' + data.statusText); return cb(data.statusText);