Wallet/src/js/controllers/preferencesAlias.js
2016-08-17 15:53:17 -03:00

26 lines
817 B
JavaScript

'use strict';
angular.module('copayApp.controllers').controller('preferencesAliasController',
function($scope, $timeout, $stateParams, $state, configService, profileService, walletService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.wallet = wallet;
var walletId = wallet.credentials.walletId;
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
$scope.walletName = wallet.credentials.walletName;
$scope.alias = config.aliasFor[walletId] || wallet.walletName;
$scope.save = function() {
var opts = {
aliasFor: {}
};
opts.aliasFor[walletId] = $scope.alias;
configService.set(opts, function(err) {
if (err) $log.warn(err);
$state.go('wallet.preferences')
});
};
});