add wallet alias
This commit is contained in:
parent
63a488e630
commit
d851f62c7f
12 changed files with 118 additions and 17 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
32
src/js/controllers/preferencesAlias.js
Normal file
32
src/js/controllers/preferencesAlias.js
Normal 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);
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
|
@ -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}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue