Glidera Integration

This commit is contained in:
Gustavo Maximiliano Cortez 2015-08-28 18:23:24 -03:00
commit 4ed39a22d4
8 changed files with 314 additions and 0 deletions

View file

@ -113,6 +113,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.pendingTxProposalsCountForUs = null;
self.setSpendUnconfirmed();
self.glideraToken = null;
$timeout(function() {
self.hasProfile = true;
self.noFocusedWallet = false;
@ -134,6 +136,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.copayers = [];
self.updateColor();
self.updateAlias();
self.initGlidera();
storageService.getBackupFlag(self.walletId, function(err, val) {
self.needsBackup = self.network == 'testnet' ? false : !val;
@ -843,6 +846,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}), 'name');
};
self.initGlidera = function() {
storageService.getGlideraToken(self.network, function(err, val) {
if (err) return;
self.glideraToken = val;
});
};
// UX event handlers
$rootScope.$on('Local/ColorUpdated', function(event) {
self.updateColor();
@ -892,6 +902,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
});
$rootScope.$on('Local/GlideraTokenUpdated', function() {
self.initGlidera();
});
$rootScope.$on('Local/UnitSettingUpdated', function(event) {
self.updateAll();
self.updateTxHistory();

View file

@ -0,0 +1,55 @@
'use strict';
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) {
self.permission = permission;
});
glideraService.getEmail(token, function(error, email) {
self.email = email;
});
glideraService.getPersonalInfo(token, function(error, info) {
self.personalInfo = info;
});
glideraService.getStatus(token, function(error, status) {
self.status = status;
});
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;
storageService.removeGlideraToken(fc.credentials.network, function() {
$scope.$emit('Local/GlideraTokenUpdated');
$timeout(function() {
go.walletHome();
}, 100);
});
};
});