copay/js/controllers/profile.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

'use strict';
2014-11-30 18:08:16 -08:00
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, backupService, identityService) {
2014-11-12 19:07:33 -08:00
$scope.username = $rootScope.iden.getName();
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$rootScope.title = 'Profile';
2014-10-27 12:13:06 -07:00
$scope.downloadProfileBackup = function() {
backupService.profileDownload($rootScope.iden);
};
$scope.viewProfileBackup = function() {
$scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden);
$scope.hideViewProfileBackup = true;
};
2014-11-10 11:41:07 -08:00
$scope.deleteWallet = function(w) {
if (!w) return;
2014-11-30 18:08:16 -08:00
identityService.deleteWallet(w, function(err) {
2014-11-10 11:41:07 -08:00
$scope.loading = false;
2014-11-30 18:08:16 -08:00
if (err) {
2014-12-01 10:33:16 -08:00
copay.logger.warn(err);
2014-11-30 18:08:16 -08:00
}
2014-12-01 10:33:16 -08:00
$scope.setWallets();
2014-11-10 11:41:07 -08:00
});
};
2014-11-29 23:03:23 -08:00
$scope.setWallets = function() {
if (!$rootScope.iden) return;
$scope.wallets=$rootScope.iden.listWallets();
};
$scope.downloadWalletBackup = function(w) {
if (!w) return;
backupService.walletDownload(w);
}
$scope.viewWalletBackup = function(w) {
var ModalInstanceCtrl = function($scope, $modalInstance) {
if (!w) return;
$scope.backupWalletPlainText = backupService.walletEncrypted(w);
$scope.hideViewWalletBackup = true;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
$modal.open({
templateUrl: 'views/modals/backup-text.html',
windowClass: 'tiny',
controller: ModalInstanceCtrl
});
};
});