Wallet/js/controllers/profile.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict';
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova) {
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();
$scope.isCordova = isCordova;
$rootScope.title = 'Profile';
2014-12-01 12:13:11 -03:00
$scope.hideAdv = true;
2014-10-27 16:13:06 -03:00
$scope.downloadProfileBackup = function() {
backupService.profileDownload($rootScope.iden);
};
$scope.viewProfileBackup = function() {
$scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden);
$scope.hideViewProfileBackup = true;
2014-12-09 12:48:03 -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() {
identityService.deleteProfile(function(err, res) {
2014-12-01 14:44:36 -03:00
if (err) {
log.warn(err);
notification.error('Error', 'Could not delete profile');
return;
}
2014-11-26 12:08:26 -03:00
$location.path('/');
2014-12-30 16:20:18 -03:00
$timeout(function() {
2014-12-01 14:44:36 -03:00
notification.error('Success', 'Profile successfully deleted');
2014-12-30 16:20:18 -03:00
});
2014-12-01 14:44:36 -03:00
});
2014-12-01 12:13:11 -03:00
};
});