2014-10-11 17:26:10 -03:00
|
|
|
'use strict';
|
2015-01-14 15:33:19 -03:00
|
|
|
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova, notification) {
|
2014-11-13 00:07:33 -03:00
|
|
|
$scope.username = $rootScope.iden.getName();
|
2014-12-09 12:48:03 -03:00
|
|
|
$scope.isSafari = isMobile.Safari();
|
2014-12-15 12:09:57 -03:00
|
|
|
$scope.isCordova = isCordova;
|
2014-10-16 10:18:37 -03:00
|
|
|
|
2014-11-11 16:01:33 -03:00
|
|
|
$rootScope.title = 'Profile';
|
2014-12-01 12:13:11 -03:00
|
|
|
$scope.hideAdv = true;
|
2014-10-27 16:13:06 -03:00
|
|
|
|
2014-11-11 16:53:57 -03:00
|
|
|
$scope.downloadProfileBackup = function() {
|
2014-10-16 10:18:37 -03:00
|
|
|
backupService.profileDownload($rootScope.iden);
|
|
|
|
|
};
|
2014-10-21 15:11:04 -03:00
|
|
|
|
2014-11-11 16:53:57 -03:00
|
|
|
$scope.viewProfileBackup = function() {
|
|
|
|
|
$scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden);
|
|
|
|
|
$scope.hideViewProfileBackup = true;
|
2014-12-09 12:48:03 -03:00
|
|
|
};
|
2014-11-11 16:53:57 -03:00
|
|
|
|
2014-12-02 16:53:24 -03:00
|
|
|
|
2014-12-01 17:21:39 -03:00
|
|
|
$scope.init = function() {
|
|
|
|
|
if ($rootScope.quotaPerItem) {
|
2014-11-26 12:08:26 -03:00
|
|
|
$scope.perItem = $filter('noFractionNumber')($rootScope.quotaPerItem / 1000, 1);
|
|
|
|
|
$scope.nrWallets = parseInt($rootScope.quotaItems) - 1;
|
2014-12-01 17:21:39 -03:00
|
|
|
}
|
2014-12-02 16:53:24 -03:00
|
|
|
// no need to add event handlers here. Wallet deletion is handle by callback.
|
2014-12-01 17:21:39 -03:00
|
|
|
};
|
|
|
|
|
|
2014-11-26 12:08:26 -03:00
|
|
|
$scope.deleteProfile = function() {
|
2015-01-14 15:33:19 -03:00
|
|
|
$scope.loading = true;
|
2014-11-26 12:08:26 -03:00
|
|
|
identityService.deleteProfile(function(err, res) {
|
2015-01-14 15:33:19 -03:00
|
|
|
$scope.loading = false;
|
2014-12-01 14:44:36 -03:00
|
|
|
if (err) {
|
|
|
|
|
log.warn(err);
|
|
|
|
|
notification.error('Error', 'Could not delete profile');
|
2015-01-14 15:33:19 -03:00
|
|
|
$timeout(function () { $scope.$digest(); });
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$location.path('/');
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
notification.success('Success', 'Profile successfully deleted');
|
|
|
|
|
});
|
2014-12-01 14:44:36 -03:00
|
|
|
}
|
|
|
|
|
});
|
2014-12-01 12:13:11 -03:00
|
|
|
};
|
2014-10-11 17:26:10 -03:00
|
|
|
});
|