add wallet alias

This commit is contained in:
Matias Alejo Garcia 2015-05-14 10:39:22 -03:00
parent 63a488e630
commit d851f62c7f
12 changed files with 118 additions and 17 deletions

View File

@ -21,7 +21,7 @@
<section class="middle tab-bar-section">
<h1 class="title ellipsis" ng-style="{'color': noColor ? '#7A8C9E' : index.backgroundColor}">
{{(titleSection|translate) || index.walletName}}
{{(titleSection|translate) || (index.alias || index.walletName)}}
</h1>
</section>
</nav>

View File

@ -9,7 +9,16 @@
<div class="content preferences" ng-controller="preferencesController as preferences">
<ul class="no-bullet m0 size-14" ng-show="!index.noFocusedWallet">
<h4 class="title m0" translate>{{index.walletName}} settings</h4>
<h4 class="title m0">{{index.alias}} [{{index.walletName}}] <span translate>settings</span></h4>
<li class="line-b p20" ng-click="$root.go('preferencesAlias')">
<span translate>Wallet Alias</span>
<span class="right text-gray">
<i class="icon-arrow-right3 size-24 right"></i>
{{index.alias||index.walletName}}
</span>
</li>
<li class="line-b p20" ng-click="$root.go('preferencesColor')">
<span translate>Color</span>

View File

@ -0,0 +1,18 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Wallet Alias'; goBackToState = 'preferences'">
</div>
<div class="content preferences p20v" ng-controller="preferencesAliasController as prefAlias">
<form name="settingsAliasForm" ng-submit="prefAlias.save()" class="columns">
<label>Alias for <i>{{index.walletName}}</i></label>
<input type="text" id="alias2" type="text" name="alias2" ng-model="prefAlias.alias">
<input type="submit" class="button expand black radius" value="{{'Save'|translate}}"
ng-style="{'background-color':index.backgroundColor}">
</form>
<p class="text-gray text-center columns size-14"> Changing wallet alias only afects the local wallet name.
</div>
<div class="extra-margin-bottom"></div>

View File

@ -1,4 +1,3 @@
'use strict';
angular.module('copayApp.controllers').controller('backupController',
@ -45,6 +44,9 @@ angular.module('copayApp.controllers').controller('backupController',
}
window.plugins.toast.showShortCenter('Preparing backup...');
var name = (fc.credentials.walletName || fc.credentials.walletId);
if (fc.alias) {
name = fc.alias + ' [' + name + ']';
}
var ew = this.getBackup();
var properties = {
subject: 'Copay Wallet Backup: ' + name,

View File

@ -102,6 +102,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.txps = [];
self.copayers = [];
self.updateColor();
self.updateAlias();
storageService.getBackupFlag(self.walletId, function(err, val) {
self.needsBackup = self.network == 'testnet' ? false : !val;
@ -344,6 +345,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
};
self.updateAlias = function() {
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
self.alias = config.aliasFor[self.walletId];
var fc = profileService.focusedClient;
fc.alias = self.alias;
};
self.updateColor = function() {
var config = configService.getSync();
config.colorFor = config.colorFor || {};
@ -552,6 +561,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
});
$rootScope.$on('Local/AliasUpdated', function(event) {
self.updateAlias();
$timeout(function() {
$rootScope.$apply();
});
});
$rootScope.$on('Local/UnitSettingUpdated', function(event) {
self.updateAll();
self.updateTxHistory();

View File

@ -39,11 +39,12 @@ angular.module('copayApp.controllers').controller('paymentUriController',
if (!profileService.profile) return;
var config = configService.getSync();
config.colorFor = config.colorFor || {};
config.aliasFor = config.aliasFor || {};
var ret = lodash.map(profileService.profile.credentials, function(c) {
return {
m: c.m,
n: c.n,
name: c.walletName,
name: config.aliasFor[c.walletId] || c.walletName,
id: c.walletId,
network: c.network,
color: config.colorFor[c.walletId] || '#2C3E50'
@ -52,7 +53,7 @@ angular.module('copayApp.controllers').controller('paymentUriController',
ret = lodash.filter(ret, function(w) {
return (w.network == network);
});
return lodash.sortBy(ret, 'walletName');
return lodash.sortBy(ret, 'name');
};
this.selectWallet = function(wid) {

View File

@ -0,0 +1,32 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAliasController',
function($scope, $timeout, configService, profileService, go) {
var config = configService.getSync();
var fc = profileService.focusedClient;
var walletId = fc.credentials.walletId;
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
this.alias = config.aliasFor[walletId] || fc.credentials.walletName;
this.save = function() {
var self = this;
var opts = {
aliasFor: {}
};
opts.aliasFor[walletId] = self.alias;
configService.set(opts, function(err) {
if (err) {
$scope.$emit('Local/DeviceError', err);
return;
}
$scope.$emit('Local/AliasUpdated');
$timeout(function(){
go.path('preferences');
}, 50);
});
};
});

View File

@ -34,14 +34,15 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
var _deleteWallet = function() {
var fc = profileService.focusedClient;
var walletName = fc.credentials.walletName;
var name = fc.credentials.walletName;
var walletName = (fc.alias||'') + ' [' + name + ']';
var self = this;
profileService.deleteWalletFC({}, function(err) {
if (err) {
self.error = err.message || err;
} else {
notification.success(gettext('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', {walletName: walletName}));
notification.success(gettext('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', {walletName: name}));
}
});
};

View File

@ -15,6 +15,11 @@ angular.module('copayApp.controllers').controller('sidebarController',
self.setWallets();
});
$rootScope.$on('Local/AliasUpdated', function(event) {
self.setWallets();
});
self.signout = function() {
profileService.signout();
};
@ -35,16 +40,17 @@ angular.module('copayApp.controllers').controller('sidebarController',
if (!profileService.profile) return;
var config = configService.getSync();
config.colorFor = config.colorFor || {};
config.aliasFor = config.aliasFor || {};
var ret = lodash.map(profileService.profile.credentials, function(c) {
return {
m: c.m,
n: c.n,
name: c.walletName,
name: config.aliasFor[c.walletId] || c.walletName,
id: c.walletId,
color: config.colorFor[c.walletId] || '#7A8C9E',
};
});
self.wallets = lodash.sortBy(ret, 'walletName');
self.wallets = lodash.sortBy(ret, 'name');
};
self.setWallets();

View File

@ -245,6 +245,19 @@ angular
},
}
})
.state('preferencesAlias', {
url: '/preferencesAlias',
templateUrl: 'views/preferencesAlias.html',
walletShouldBeComplete: true,
needProfile: true,
views: {
'main': {
templateUrl: 'views/preferencesAlias.html'
},
}
})
.state('preferencesBwsUrl', {
url: '/preferencesBwsUrl',
templateUrl: 'views/preferencesBwsUrl.html',
@ -378,6 +391,7 @@ angular
preferencesUnit: 12,
preferencesAltCurrency: 12,
preferencesBwsUrl: 12,
preferencesAlias: 12,
about: 12,
logs: 13,
add: 11,

View File

@ -75,7 +75,7 @@ angular.module('copayApp.services')
var ew = root.walletExport(password);
if (!ew) return cb('Could not create backup');
var walletName = fc.credentials.walletName;
var walletName = (fc.alias || '') + (fc.alias ? '-' : '') + fc.credentials.walletName;
var filename = walletName + '-Copaybackup.aes.json';
_download(ew, filename, cb)
};

View File

@ -53,35 +53,36 @@ angular.module('copayApp.services')
var config = configService.getSync();
config.colorFor = config.colorFor || {};
var color = config.colorFor[walletId] || '#2C3E50';
var name = config.aliasFor[walletId] || walletName;
switch (notificationData.type) {
case 'NewTxProposal':
notification.new(gettext('New Transaction'),
walletName, {color: color} );
name, {color: color} );
break;
case 'TxProposalAcceptedBy':
notification.success(gettext('Transaction Signed'),
walletName, {color: color} );
name, {color: color} );
break;
case 'TxProposalRejectedBy':
notification.error(gettext('Transaction Rejected'),
walletName, {color: color} );
name, {color: color} );
break;
case 'TxProposalFinallyRejected':
notification.error(gettext('A transaction was finally rejected'),
walletName, {color: color} );
name, {color: color} );
break;
case 'NewOutgoingTx':
notification.sent(gettext('Transaction Sent'),
walletName, {color: color} );
name, {color: color} );
break;
case 'NewIncomingTx':
notification.funds(gettext('Funds received'),
walletName, {color: color} );
name, {color: color} );
break;
case 'ScanFinished':
notification.success(gettext('Scan Finished'),
walletName, {color: color} );
name, {color: color} );
break;
case 'NewCopayer':