2015-08-31 18:12:04 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-06-10 15:16:02 -03:00
|
|
|
angular.module('copayApp.controllers').controller('glideraController',
|
|
|
|
|
function($rootScope, $scope, $timeout, $modal, $ionicModal, profileService, configService, storageService, glideraService, lodash) {
|
2015-08-31 18:12:04 -03:00
|
|
|
|
2015-09-07 19:45:03 -03:00
|
|
|
this.getAuthenticateUrl = function() {
|
|
|
|
|
return glideraService.getOauthCodeUrl();
|
|
|
|
|
};
|
|
|
|
|
|
2015-09-08 10:17:59 -03:00
|
|
|
this.submitOauthCode = function(code) {
|
2015-09-02 16:02:40 -03:00
|
|
|
var self = this;
|
2015-11-05 18:57:59 -03:00
|
|
|
var glideraTestnet = configService.getSync().glidera.testnet;
|
|
|
|
|
var network = glideraTestnet ? 'testnet' : 'livenet';
|
2015-09-02 16:02:40 -03:00
|
|
|
this.loading = true;
|
2015-09-09 00:02:12 -03:00
|
|
|
this.error = null;
|
2015-09-02 16:02:40 -03:00
|
|
|
$timeout(function() {
|
2015-09-08 10:17:59 -03:00
|
|
|
glideraService.getToken(code, function(err, data) {
|
|
|
|
|
self.loading = null;
|
|
|
|
|
if (err) {
|
|
|
|
|
self.error = err;
|
|
|
|
|
$timeout(function() {
|
2016-06-10 15:16:02 -03:00
|
|
|
$scope.$apply();
|
|
|
|
|
}, 100);
|
|
|
|
|
} else if (data && data.access_token) {
|
2015-11-05 18:57:59 -03:00
|
|
|
storageService.setGlideraToken(network, data.access_token, function() {
|
2015-09-11 13:11:41 -03:00
|
|
|
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
2015-09-02 16:02:40 -03:00
|
|
|
$timeout(function() {
|
|
|
|
|
$scope.$apply();
|
|
|
|
|
}, 100);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, 100);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.openTxModal = function(token, tx) {
|
|
|
|
|
var self = this;
|
|
|
|
|
|
2016-06-10 15:16:02 -03:00
|
|
|
$scope.self = self;
|
|
|
|
|
$scope.tx = tx;
|
2015-09-02 16:02:40 -03:00
|
|
|
|
2016-06-10 15:16:02 -03:00
|
|
|
glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) {
|
|
|
|
|
$scope.tx = tx;
|
2016-01-11 17:07:39 -03:00
|
|
|
});
|
|
|
|
|
|
2016-06-10 15:16:02 -03:00
|
|
|
$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();
|
2015-09-02 16:02:40 -03:00
|
|
|
});
|
2015-08-31 18:12:04 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|