2015-08-28 18:23:24 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-06-10 15:16:02 -03:00
|
|
|
angular.module('copayApp.controllers').controller('preferencesGlideraController',
|
2017-02-14 12:36:28 -03:00
|
|
|
function($scope, $timeout, $state, $ionicHistory, glideraService, popupService) {
|
2016-06-10 15:16:02 -03:00
|
|
|
|
2016-08-24 11:33:43 -03:00
|
|
|
$scope.revokeToken = function() {
|
2016-09-12 13:58:36 -03:00
|
|
|
popupService.showConfirm('Glidera', 'Are you sure you would like to log out of your Glidera account?', null, null, function(res) {
|
2016-08-31 16:43:52 -03:00
|
|
|
if (res) {
|
2017-02-14 12:36:28 -03:00
|
|
|
glideraService.remove(function() {
|
2016-11-22 12:35:51 -03:00
|
|
|
$ionicHistory.clearHistory();
|
2016-08-31 16:43:52 -03:00
|
|
|
$timeout(function() {
|
2016-11-22 12:35:51 -03:00
|
|
|
$state.go('tabs.home');
|
2016-08-31 16:43:52 -03:00
|
|
|
}, 100);
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-09-10 14:58:06 -03:00
|
|
|
});
|
2015-08-28 18:23:24 -03:00
|
|
|
};
|
|
|
|
|
|
2017-02-14 12:36:28 -03:00
|
|
|
$scope.$on("$ionicView.afterEnter", function(event, data){
|
|
|
|
|
glideraService.updateStatus($scope.account);
|
|
|
|
|
});
|
2016-09-22 11:55:23 -03:00
|
|
|
|
2017-02-14 12:36:28 -03:00
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data){
|
|
|
|
|
$scope.account = {};
|
|
|
|
|
glideraService.init(function(err, glidera) {
|
2016-09-22 11:55:23 -03:00
|
|
|
if (err || !glidera) {
|
2017-02-14 12:36:28 -03:00
|
|
|
if (err) popupService.showAlert('Error connecting Glidera', err);
|
2016-09-22 11:55:23 -03:00
|
|
|
return;
|
|
|
|
|
}
|
2017-02-14 12:36:28 -03:00
|
|
|
$scope.account['token'] = glidera.token;
|
|
|
|
|
$scope.account['permissions'] = glidera.permissions;
|
|
|
|
|
$scope.account['status'] = glidera.status;
|
2016-09-22 11:55:23 -03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-08-28 18:23:24 -03:00
|
|
|
});
|