controllers refactor to handle identities
This commit is contained in:
parent
622c3da68c
commit
0b7e9be611
14 changed files with 190 additions and 227 deletions
|
|
@ -112,6 +112,18 @@ header {
|
||||||
padding: 15px 20px 5px;
|
padding: 15px 20px 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
header .wfooter {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
header .creation {
|
||||||
|
color: white;
|
||||||
|
background: red;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.off-canvas-wrap, .inner-wrap{
|
.off-canvas-wrap, .inner-wrap{
|
||||||
height:100%;
|
height:100%;
|
||||||
}
|
}
|
||||||
|
|
@ -211,6 +223,7 @@ a:hover {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.button.small.side-bar {
|
.button.small.side-bar {
|
||||||
padding: 0rem 0.4rem;
|
padding: 0rem 0.4rem;
|
||||||
}
|
}
|
||||||
|
|
@ -1046,12 +1059,12 @@ input.ng-invalid-match, input.ng-invalid-match:focus {
|
||||||
.copayers {
|
.copayers {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: #213140;
|
background-color: #213140;
|
||||||
position: absolute;
|
/* position: absolute; */
|
||||||
bottom: 0;
|
/* bottom: 0; */
|
||||||
left: 0;
|
/* left: 0; */
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-top: 1px solid #475065;
|
border-top: 1px solid #475065;
|
||||||
overflow-y: hidden;
|
/* overflow-y: hidden; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.copayers i {
|
.copayers i {
|
||||||
|
|
@ -1246,4 +1259,6 @@ fieldset legend {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------*/
|
/*-----------------------------------------------------------------*/
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ angular.module('copayApp.controllers').controller('CreateController',
|
||||||
};
|
};
|
||||||
$rootScope.iden.createWallet(opts, function(err, w) {
|
$rootScope.iden.createWallet(opts, function(err, w) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$rootScope.wallet = w;
|
controllerUtils.installWalletHandlers($scope, w);
|
||||||
controllerUtils.bindWallet(w, $scope);
|
controllerUtils.setFocusedWallet(w);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,8 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
networkName: config.networkName,
|
networkName: config.networkName,
|
||||||
walletDefaults: config.wallet,
|
walletDefaults: config.wallet,
|
||||||
passphrase: config.passphrase,
|
passphrase: config.passphrase,
|
||||||
}, function(err, iden ,w) {
|
}, function(err, iden , firstWallet) {
|
||||||
$rootScope.iden = iden;
|
controllerUtils.bindProfile($scope, iden, firstWallet);
|
||||||
$rootScope.wallet = w;
|
|
||||||
controllerUtils.bindWallet(w, $scope);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,13 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
networkName: config.networkName,
|
networkName: config.networkName,
|
||||||
walletDefaults: config.wallet,
|
walletDefaults: config.wallet,
|
||||||
passphrase: config.passphrase,
|
passphrase: config.passphrase,
|
||||||
}, function(err, iden, w) {
|
}, function(err, iden, firstWallet) {
|
||||||
if (err && !w) {
|
if (err && !iden) {
|
||||||
console.log('Error:' + err)
|
console.log('Error:' + err)
|
||||||
controllerUtils.onErrorDigest(
|
controllerUtils.onErrorDigest(
|
||||||
$scope, (err.toString()||'').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
|
$scope, (err.toString()||'').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
|
||||||
} else {
|
} else {
|
||||||
$rootScope.iden = iden;
|
controllerUtils.bindProfile($scope, iden, firstWallet);
|
||||||
$rootScope.wallet = w;
|
|
||||||
controllerUtils.bindWallet(w, $scope);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('OpenController', function($scope, $rootScope, $location, controllerUtils, Passphrase, notification) {
|
|
||||||
controllerUtils.redirIfLogged();
|
|
||||||
|
|
||||||
if ($rootScope.pendingPayment) {
|
|
||||||
notification.info('Login Required', 'Please open wallet to complete payment');
|
|
||||||
}
|
|
||||||
|
|
||||||
var cmp = function(o1, o2) {
|
|
||||||
var v1 = o1.show.toLowerCase(),
|
|
||||||
v2 = o2.show.toLowerCase();
|
|
||||||
return v1 > v2 ? 1 : (v1 < v2) ? -1 : 0;
|
|
||||||
};
|
|
||||||
$rootScope.fromSetup = false;
|
|
||||||
$scope.loading = false;
|
|
||||||
$scope.retreiving = true;
|
|
||||||
|
|
||||||
identity.getWallets(function(err, wallets) {
|
|
||||||
|
|
||||||
if (err || !wallets || !wallets.length) {
|
|
||||||
$location.path('/');
|
|
||||||
} else {
|
|
||||||
$scope.retreiving = false;
|
|
||||||
$scope.wallets = wallets.sort(cmp);
|
|
||||||
var lastOpened = _.findWhere($scope.wallets, {
|
|
||||||
lastOpened: true
|
|
||||||
});
|
|
||||||
$scope.selectedWalletId = lastOpened ? lastOpened.id : ($scope.wallets[0] && $scope.wallets[0].id);
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
$rootScope.$digest();
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.openPassword = '';
|
|
||||||
$scope.isMobile = !!window.cordova;
|
|
||||||
|
|
||||||
$scope.open = function(form) {
|
|
||||||
if (form && form.$invalid) {
|
|
||||||
notification.error('Error', 'Please enter the required fields');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.loading = true;
|
|
||||||
var password = form.openPassword.$modelValue;
|
|
||||||
|
|
||||||
Passphrase.getBase64Async(password, function(passphrase) {
|
|
||||||
var w, errMsg;
|
|
||||||
identity.open($scope.selectedWalletId, passphrase, function(err, w) {
|
|
||||||
if (!w) {
|
|
||||||
$scope.loading = false;
|
|
||||||
notification.error('Error', err.errMsg || 'Wrong password');
|
|
||||||
$rootScope.$digest();
|
|
||||||
} else {
|
|
||||||
$rootScope.updatingBalance = true;
|
|
||||||
controllerUtils.startNetwork(w, $scope);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -57,6 +57,8 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
||||||
return new Array(num);
|
return new Array(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($rootScope.wallet) {
|
if ($rootScope.wallet) {
|
||||||
$scope.$on('$idleWarn', function(a, countdown) {
|
$scope.$on('$idleWarn', function(a, countdown) {
|
||||||
if (!(countdown % 5))
|
if (!(countdown % 5))
|
||||||
|
|
@ -72,18 +74,7 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.switchWallet = function(id) {
|
$scope.switchWallet = function(wid) {
|
||||||
var iden = $rootScope.iden;
|
controllerUtils.setFocusedWallet(wid);
|
||||||
controllerUtils.unbindWallet($scope);
|
|
||||||
|
|
||||||
iden.openWallet(id, null, function(err, w) {
|
|
||||||
if (err) {
|
|
||||||
notification.warning('Could not open wallet');
|
|
||||||
} else {
|
|
||||||
$scope.loading = false;
|
|
||||||
$rootScope.wallet = w;
|
|
||||||
controllerUtils.bindWallet(w, $scope);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -173,20 +173,25 @@ Identity.open = function(email, password, opts, cb) {
|
||||||
|
|
||||||
var wids = _.pluck(iden.listWallets(), 'id');
|
var wids = _.pluck(iden.listWallets(), 'id');
|
||||||
|
|
||||||
|
if (!wids || !wids.length)
|
||||||
|
return new Error('Could not open any wallet from profile');
|
||||||
|
|
||||||
while (1) {
|
// Open All wallets from profile
|
||||||
var wid = wids.shift();
|
//This could be optional, or opts.onlyOpen = wid
|
||||||
if (!wid)
|
var firstWallet;
|
||||||
return new Error('Could not open any wallet from profile');
|
_.each(wids, function(wid) {
|
||||||
|
iden.openWallet(wid, function(err, w) {
|
||||||
iden.openWallet(wid, password, function(err, w) {
|
|
||||||
if (err)
|
if (err)
|
||||||
log.info('Cound not open wallet id:' + wid + '. Skipping')
|
log.error('Cound not open wallet id:' + wid + '. Skipping')
|
||||||
else
|
else {
|
||||||
return cb(err, iden, w);
|
log.info('Open wallet id:' + wid + ' opened');
|
||||||
|
if (!firstWallet)
|
||||||
|
firstWallet = w;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
});
|
||||||
|
|
||||||
|
return cb(err, iden, firstWallet);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -288,10 +293,8 @@ Identity.prototype.importWallet = function(base64, password, skipFields, cb) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Identity.prototype.closeWallet = function(wid, cb) {
|
Identity.prototype.closeWallet = function(wid, cb) {
|
||||||
var w = _.findWhere(this.openWallets, function(w) {
|
var w = this.getOpenWallet(wid);
|
||||||
w.id === wid;
|
preconditions.checkState(w, 'Wallet not found');
|
||||||
});
|
|
||||||
preconditions.checkState(w);
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
w.close(function(err) {
|
w.close(function(err) {
|
||||||
|
|
@ -433,24 +436,21 @@ Identity.prototype._checkVersion = function(inVersion) {
|
||||||
/**
|
/**
|
||||||
* @desc Retrieve a wallet from the storage
|
* @desc Retrieve a wallet from the storage
|
||||||
* @param {string} walletId - the id of the wallet
|
* @param {string} walletId - the id of the wallet
|
||||||
* @param {string} password - the password to decode it
|
|
||||||
* @param {function} callback (err, {Wallet})
|
* @param {function} callback (err, {Wallet})
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Identity.prototype.openWallet = function(walletId, password, cb) {
|
Identity.prototype.openWallet = function(walletId, cb) {
|
||||||
preconditions.checkArgument(cb);
|
preconditions.checkArgument(cb);
|
||||||
|
preconditions.checkState(this.storage.hasPassphrase());
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (password && !this.storage.hasPassphrase())
|
|
||||||
self.storage.setPassword(password);
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// self.migrateWallet(walletId, password, function() {
|
// self.migrateWallet(walletId, password, function() {
|
||||||
//
|
//
|
||||||
|
|
||||||
Identity._walletRead(walletId, {
|
Identity._walletRead(walletId, {
|
||||||
storage: self.storage,
|
storage: self.storage,
|
||||||
networkOpts: this.networkOpts,
|
networkOpts: this.networkOpts,
|
||||||
blockchainOpts: this.blockchainOpts
|
blockchainOpts: this.blockchainOpts
|
||||||
}, function(err, w) {
|
}, function(err, w) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
@ -466,6 +466,13 @@ Identity.prototype.openWallet = function(walletId, password, cb) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Identity.prototype.getOpenWallet = function(id) {
|
||||||
|
return _.findWhere(this.openWallets, {
|
||||||
|
id: id,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Identity.prototype.listWallets = function(a) {
|
Identity.prototype.listWallets = function(a) {
|
||||||
var ret = this.profile.listWallets();
|
var ret = this.profile.listWallets();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -564,7 +571,6 @@ Identity.prototype.joinWallet = function(opts, cb) {
|
||||||
return cb('joinError');
|
return cb('joinError');
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('[Identity.js.566:joinOpts:]',joinOpts); //TODO
|
|
||||||
joinNetwork.start(joinOpts, function() {
|
joinNetwork.start(joinOpts, function() {
|
||||||
|
|
||||||
joinNetwork.greet(decodedSecret.pubKey, joinOpts.secretNumber);
|
joinNetwork.greet(decodedSecret.pubKey, joinOpts.secretNumber);
|
||||||
|
|
|
||||||
|
|
@ -743,6 +743,16 @@ Wallet.prototype.getNetworkName = function() {
|
||||||
return this.publicKeyRing.network.name;
|
return this.publicKeyRing.network.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc
|
||||||
|
* @return {bool}
|
||||||
|
*/
|
||||||
|
Wallet.prototype.isTestnet = function() {
|
||||||
|
return this.publicKeyRing.network.name === 'testnet';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc Serialize options into an object
|
* @desc Serialize options into an object
|
||||||
* @return {Object} with keys <tt>id</tt>, <tt>spendUnconfirmed</tt>,
|
* @return {Object} with keys <tt>id</tt>, <tt>spendUnconfirmed</tt>,
|
||||||
|
|
@ -855,6 +865,9 @@ Wallet.prototype._setBlockchainListeners = function() {
|
||||||
this.blockchain.on('reconnect', function(attempts) {
|
this.blockchain.on('reconnect', function(attempts) {
|
||||||
log.debug('Wallet:' + this.id +'blockchain reconnect event');
|
log.debug('Wallet:' + this.id +'blockchain reconnect event');
|
||||||
self.emit('insightReconnected');
|
self.emit('insightReconnected');
|
||||||
|
|
||||||
|
// Subscription should persist? TODO
|
||||||
|
//self.subscribeToAddresses();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.blockchain.on('disconnect', function() {
|
this.blockchain.on('disconnect', function() {
|
||||||
|
|
@ -928,6 +941,7 @@ Wallet.prototype.netStart = function() {
|
||||||
net.start(startOpts, function() {
|
net.start(startOpts, function() {
|
||||||
log.debug('Wallet:' + self.id + ' Networking ready:', net.copayerId);
|
log.debug('Wallet:' + self.id + ' Networking ready:', net.copayerId);
|
||||||
self._setBlockchainListeners();
|
self._setBlockchainListeners();
|
||||||
|
self.subscribeToAddresses();
|
||||||
self.emit('ready', net.getPeer());
|
self.emit('ready', net.getPeer());
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
self.emit('publicKeyRingUpdated', true);
|
self.emit('publicKeyRingUpdated', true);
|
||||||
|
|
@ -1048,9 +1062,11 @@ Wallet.prototype.toObj = function() {
|
||||||
* @param {number} o.lastTimestamp - last time this wallet object was deserialized
|
* @param {number} o.lastTimestamp - last time this wallet object was deserialized
|
||||||
* @param {Object} o.txProposals - TxProposals to be deserialized by {@link TxProposals#fromObj}
|
* @param {Object} o.txProposals - TxProposals to be deserialized by {@link TxProposals#fromObj}
|
||||||
* @param {string} o.nickname - user's nickname
|
* @param {string} o.nickname - user's nickname
|
||||||
|
*
|
||||||
* @param readOpts.storage
|
* @param readOpts.storage
|
||||||
* @param readOpts.network
|
* @param readOpts.network
|
||||||
* @param readOpts.blockchain
|
* @param readOpts.blockchain
|
||||||
|
* @param readOpts.isImported {boolean} - tag wallet as 'imported' (skip forced backup step)
|
||||||
* @param readOpts.{string[]} skipFields - parameters to ignore when importing
|
* @param readOpts.{string[]} skipFields - parameters to ignore when importing
|
||||||
*/
|
*/
|
||||||
Wallet.fromObj = function(o, readOpts) {
|
Wallet.fromObj = function(o, readOpts) {
|
||||||
|
|
@ -1120,9 +1136,9 @@ Wallet.fromObj = function(o, readOpts) {
|
||||||
opts.lastTimestamp = o.lastTimestamp || 0;
|
opts.lastTimestamp = o.lastTimestamp || 0;
|
||||||
|
|
||||||
opts.storage = storage;
|
opts.storage = storage;
|
||||||
opts.isImported = true;
|
|
||||||
opts.blockchainOpts = readOpts.blockchainOpts;
|
opts.blockchainOpts = readOpts.blockchainOpts;
|
||||||
opts.networkOpts = readOpts.networkOpts;
|
opts.networkOpts = readOpts.networkOpts;
|
||||||
|
opts.isImported = readOpts.isImported || false;
|
||||||
|
|
||||||
return new Wallet(opts);
|
return new Wallet(opts);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -94,11 +94,6 @@ angular
|
||||||
$idle.unwatch();
|
$idle.unwatch();
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// In creation?
|
|
||||||
if ($rootScope.wallet && !$rootScope.wallet.isReady()) {
|
|
||||||
$location.path('/copayers');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,13 @@ angular.module('copayApp.services')
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
root.redirIfLogged = function() {
|
root.redirIfLogged = function() {
|
||||||
if ($rootScope.wallet) {
|
var w = $rootScope.wallet;
|
||||||
$location.path('receive');
|
if (w) {
|
||||||
|
if (!w.isReady()) {
|
||||||
|
$location.path('/copayers');
|
||||||
|
} else {
|
||||||
|
$location.path('receive');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,7 +50,8 @@ angular.module('copayApp.services')
|
||||||
return wid === $rootScope.wallet.getId();
|
return wid === $rootScope.wallet.getId();
|
||||||
};
|
};
|
||||||
|
|
||||||
root.installWalletHandlers = function(w, $scope) {
|
root.installWalletHandlers = function($scope, w) {
|
||||||
|
w.removeAllListeners();
|
||||||
|
|
||||||
var wid = w.getId();
|
var wid = w.getId();
|
||||||
w.on('connectionError', function() {
|
w.on('connectionError', function() {
|
||||||
|
|
@ -69,7 +75,7 @@ angular.module('copayApp.services')
|
||||||
if ($rootScope.pendingPayment) {
|
if ($rootScope.pendingPayment) {
|
||||||
$location.path('send');
|
$location.path('send');
|
||||||
} else {
|
} else {
|
||||||
$location.path('receive');
|
root.redirIfLogged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -163,41 +169,63 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
root.setupRootVariables = function() {
|
root.setupGlobalVariables = function(iden) {
|
||||||
|
notification.enableHtml5Mode(); // for chrome: if support, enable it
|
||||||
uriHandler.register();
|
uriHandler.register();
|
||||||
$rootScope.unitName = config.unitName;
|
$rootScope.unitName = config.unitName;
|
||||||
$rootScope.txAlertCount = 0;
|
$rootScope.txAlertCount = 0;
|
||||||
$rootScope.initialConnection = true;
|
$rootScope.initialConnection = true;
|
||||||
$rootScope.reconnecting = false;
|
$rootScope.reconnecting = false;
|
||||||
$rootScope.isCollapsed = true;
|
$rootScope.isCollapsed = true;
|
||||||
$rootScope.$watch('txAlertCount', function(txAlertCount) {
|
|
||||||
if (txAlertCount && txAlertCount > 0) {
|
|
||||||
|
|
||||||
notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : $filter('translate')('You have') + ' ' + $rootScope.txAlertCount + ' ' + $filter('translate')('pending transaction proposals'), txAlertCount);
|
$rootScope.iden = iden;
|
||||||
}
|
|
||||||
|
// TODO
|
||||||
|
// $rootScope.$watch('txAlertCount', function(txAlertCount) {
|
||||||
|
// if (txAlertCount && txAlertCount > 0) {
|
||||||
|
//
|
||||||
|
// notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : $filter('translate')('You have') + ' ' + $rootScope.txAlertCount + ' ' + $filter('translate')('pending transaction proposals'), txAlertCount);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
root.rebindWallets = function($scope, iden) {
|
||||||
|
_.each(iden.listWallets(), function(winfo) {
|
||||||
|
var w = iden.getOpenWallet(winfo.id);
|
||||||
|
preconditions.checkState(w);
|
||||||
|
root.installWalletHandlers($scope, w);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.setFocusedWallet = function(w) {
|
||||||
|
if (!_.isObject(w) )
|
||||||
|
w = $rootScope.iden.getOpenWallet(w);
|
||||||
|
preconditions.checkState(w && _.isObject(w));
|
||||||
|
|
||||||
root.unbindWallet = function($scope) {
|
$rootScope.wallet = w;
|
||||||
var w = $rootScope.wallet;
|
|
||||||
w.removeAllListeners();
|
|
||||||
};
|
|
||||||
|
|
||||||
root.bindWallet = function(w, $scope) {
|
|
||||||
root.setupRootVariables();
|
|
||||||
root.unbindWallet(w);
|
|
||||||
root.installWalletHandlers(w, $scope);
|
|
||||||
root.updateAddressList();
|
root.updateAddressList();
|
||||||
notification.enableHtml5Mode(); // for chrome: if support, enable it
|
|
||||||
|
root.redirIfLogged();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO movie this to wallet
|
root.bindProfile = function($scope, iden, w) {
|
||||||
root.updateAddressList = function() {
|
|
||||||
var w = $rootScope.wallet;
|
root.setupGlobalVariables(iden);
|
||||||
if (w && w.isReady()) {
|
root.rebindWallets($scope, iden);
|
||||||
w.subscribeToAddresses();
|
root.setFocusedWallet(w);
|
||||||
$rootScope.addrInfos = w.getAddressesInfo();
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// On the focused wallet
|
||||||
|
root.updateAddressList = function(wid) {
|
||||||
|
|
||||||
|
if (!wid || root.isFocusedWallet(wid)) {
|
||||||
|
var w = $rootScope.wallet;
|
||||||
|
|
||||||
|
if (w && w.isReady()) {
|
||||||
|
$rootScope.addrInfos = w.getAddressesInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -237,21 +237,9 @@ describe('Identity model', function() {
|
||||||
Identity._walletRead = sinon.stub().callsArgWith(5, null, wallet);
|
Identity._walletRead = sinon.stub().callsArgWith(5, null, wallet);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call setPassword', function(done) {
|
|
||||||
|
|
||||||
var s1 = sinon.stub();
|
|
||||||
s1.store = sinon.stub().yields(null);
|
|
||||||
|
|
||||||
iden.openWallet('id123', 'xxx', function(err, w) {
|
|
||||||
iden.storage.setPassword.calledOnce.should.equal(true);
|
|
||||||
iden.storage.setPassword.getCall(0).args[0].should.equal('xxx');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return wallet and call .store, .setLastOpenedTs & .migrateWallet', function(done) {
|
it('should return wallet and call .store, .setLastOpenedTs & .migrateWallet', function(done) {
|
||||||
|
|
||||||
iden.openWallet('dummy', 'xxx', function(err, w) {
|
iden.openWallet('dummy', function(err, w) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
w.store.calledOnce.should.equal(true);
|
w.store.calledOnce.should.equal(true);
|
||||||
iden.profile.setLastOpenedTs.calledTwice.should.equal(true);
|
iden.profile.setLastOpenedTs.calledTwice.should.equal(true);
|
||||||
|
|
@ -279,7 +267,7 @@ describe('Identity model', function() {
|
||||||
Identity._walletFromObj = sinon.stub().returns(wallet);
|
Identity._walletFromObj = sinon.stub().returns(wallet);
|
||||||
|
|
||||||
iden.importWallet("encrypted object", "xxx", [], function(err) {
|
iden.importWallet("encrypted object", "xxx", [], function(err) {
|
||||||
iden.openWallet('ID123', 'xxx', function(err, w) {
|
iden.openWallet('ID123', function(err, w) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(w);
|
should.exist(w);
|
||||||
done();
|
done();
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
<h1 class="text-white line-sidebar-b" translate >Login </h1>
|
<h1 class="text-white line-sidebar-b" translate >Login </h1>
|
||||||
<form name="loginForm" ng-submit="openProfile(loginForm)" novalidate>
|
<form name="loginForm" ng-submit="openProfile(loginForm)" novalidate>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="insight-livenet">Email</label>
|
<label for="email">Email</label>
|
||||||
<input type="text" ng-model="email" class="form-control" name="email">
|
<input type="text" ng-model="email" class="form-control" name="email">
|
||||||
<label for="insight-testnet">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="text" ng-model="password" class="form-control" name="password">
|
<input type="text" ng-model="password" class="form-control" name="password">
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
|
|
|
||||||
|
|
@ -1,85 +1,78 @@
|
||||||
<div ng-controller="SidebarController">
|
<div ng-controller="SidebarController">
|
||||||
<header>
|
<header>
|
||||||
|
<!-- <div ng-show="$root.wallet.isShared()" ng-include="'views/includes/peer-list.html'"></div> -->
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<a href="#!/receive" class="db">
|
<a href="#" class="db">
|
||||||
<img src="img/logo-negative-beta.svg" alt="" width="100">
|
<img src="img/logo-negative-beta.svg" alt="" width="100">
|
||||||
</a>
|
</a>
|
||||||
<div ng-include="'views/includes/version.html'"></div>
|
<div ng-include="'views/includes/version.html'"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="line-sidebar"></div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
Available wallets
|
|
||||||
<ul class="side-nav">
|
|
||||||
<li data-ng-repeat="item in $root.iden.listWallets() track by $index" class="nav-item">
|
|
||||||
<a ng-click="switchWallet(item.id)">
|
|
||||||
{{item.name || item.id}}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item" ui-route="{{create}}">
|
|
||||||
<a href="#!/create">+ {{'Create ' | translate }} </a> <a href="#!/join">+ {{'Join' | translate }} </a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="#!/" class="db p20h" title="Close"
|
|
||||||
ng-click="signout()"><i class="size-21 m20r fi-power"></i> {{'Close'|translate}}</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="line-sidebar"></div>
|
<ul class="side-nav">
|
||||||
<div>
|
|
||||||
<a href="#!/receive" class="name-wallet" tooltip-placement="bottom" tooltip="ID: {{$root.wallet.id}}">
|
<li data-ng-repeat="item in $root.iden.listWallets() track by $index" class="nav-item db p20h">
|
||||||
<span>{{$root.wallet.getName()}}</span>
|
<a ng-click="switchWallet(item.id)" ng-if="item.id != $root.wallet.id "> <i class="size-21 m20r fi-bitcoin-circle"></i> {{item.name || item.id}}</a>
|
||||||
</a>
|
<div ng-if="item.id == $root.wallet.id ">
|
||||||
<a class="button gray small side-bar right" title="{{'Manual Update'|translate}}"
|
<div class="line-sidebar"></div>
|
||||||
ng-disabled="$root.loading"
|
<div>
|
||||||
ng-click="refresh()"><i class="size-16 fi-refresh"></i></a>
|
<a href="#!/receive" class="name-wallet" tooltip-placement="bottom" tooltip="ID: {{$root.wallet.id}}">
|
||||||
</div>
|
<span>{{$root.wallet.getName()}}</span>
|
||||||
<div class="founds size-14 m10v">
|
</a>
|
||||||
{{'Balance'|translate}}
|
<a class="button gray small side-bar right" title="{{'Manual Update'|translate}}" ng-disabled="$root.loading" ng-click="refresh()"><i class="size-16 fi-refresh"></i></a>
|
||||||
<span ng-if="$root.updatingBalance">
|
</div>
|
||||||
|
<div class="founds size-14 m10v">
|
||||||
|
{{'Balance'|translate}}
|
||||||
|
<span ng-if="$root.updatingBalance">
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="$root.wallet && !$root.updatingBalance"
|
<span ng-if="$root.wallet && !$root.updatingBalance" class="has-tip size-16" data-options="disable_for_touch:true" tooltip-popup-delay='500' tooltip="{{totalBalanceAlternative |noFractionNumber:2}} {{alternativeIsoCode}}" tooltip-trigger="mouseenter" tooltip-placement="bottom">{{totalBalance || 0 |noFractionNumber}} {{$root.wallet.settings.unitName}}
|
||||||
class="has-tip size-16"
|
|
||||||
data-options="disable_for_touch:true"
|
|
||||||
tooltip-popup-delay='500'
|
|
||||||
tooltip="{{totalBalanceAlternative |noFractionNumber:2}} {{alternativeIsoCode}}"
|
|
||||||
tooltip-trigger="mouseenter"
|
|
||||||
tooltip-placement="bottom">{{totalBalance || 0 |noFractionNumber}} {{$root.wallet.settings.unitName}}
|
|
||||||
</span>
|
</span>
|
||||||
<div class="m10t" ng-show="lockedBalance">
|
<div class="m10t" ng-show="lockedBalance">
|
||||||
{{'Locked'|translate}}
|
{{'Locked'|translate}}
|
||||||
<span ng-if="$root.updatingBalance">
|
<span ng-if="$root.updatingBalance">
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="$root.wallet && !$root.updatingBalance"
|
<span ng-if="$root.wallet && !$root.updatingBalance" class="has-tip" data-options="disable_for_touch:true" tooltip-popup-delay='500' tooltip="{{lockedBalanceAlternative |noFractionNumber:2}} {{alternativeIsoCode}}" tooltip-trigger="mouseenter" tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.wallet.settings.unitName}}
|
||||||
class="has-tip"
|
|
||||||
data-options="disable_for_touch:true"
|
|
||||||
tooltip-popup-delay='500'
|
|
||||||
tooltip="{{lockedBalanceAlternative |noFractionNumber:2}} {{alternativeIsoCode}}"
|
|
||||||
tooltip-trigger="mouseenter"
|
|
||||||
tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.wallet.settings.unitName}}
|
|
||||||
</span> <i class="fi-info medium" tooltip="{{'Balance locked in pending transaction proposals'|translate}}" tooltip-placement="bottom"></i>
|
</span> <i class="fi-info medium" tooltip="{{'Balance locked in pending transaction proposals'|translate}}" tooltip-placement="bottom"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="line-sidebar"></div>
|
<div class="wfooter">
|
||||||
</header>
|
<span ng-if="$root.wallet.isShared()">
|
||||||
<ul class="side-nav">
|
{{$root.wallet.requiredCopayers}} <span translate>of</span> {{$root.wallet.totalCopayers}} wallet
|
||||||
<li data-ng-repeat="item in menu" ui-route="{{item.link}}" class="nav-item" data-ng-class="{active: isActive(item)}">
|
<span ng-if="!$root.wallet.isReady()">
|
||||||
<a href="#!/{{item.link}}" ng-click="toggleCollapse()" class="db p20h">
|
<span class="creation"> in creation </span>
|
||||||
<i class="size-21 m20r {{item.icon}}"></i> {{item.title|translate}}
|
</span>
|
||||||
<span class="right">
|
</span>
|
||||||
<span class="label alert" ng-if="item.link=='send' && $root.pendingTxCount > 0">{{$root.pendingTxCount}}</span>
|
<span ng-if="$root.wallet.isTestnet()" [TESTNET]</span>
|
||||||
</span>
|
</div>
|
||||||
</a>
|
<ul class="side-nav" ng-if="$root.wallet.isReady()">
|
||||||
</li>
|
<li data-ng-repeat="item in menu" ui-route="{{item.link}}" class="nav-item" data-ng-class="{active: isActive(item)}">
|
||||||
</ul>
|
<a href="#!/{{item.link}}" ng-click="toggleCollapse()" class="db p20h">
|
||||||
|
<i class="size-21 m20r {{item.icon}}"></i> {{item.title|translate}}
|
||||||
|
<span class="right">
|
||||||
|
<span class="label alert" ng-if="item.link=='send' && $root.pendingTxCount > 0">{{$root.pendingTxCount}}</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<li class="nav-item" ui-route="{{create}}">
|
||||||
|
<a href="#!/create" class="db p20h" title="Create"><i class="size-21 m20r fi-plus"></i> {{'Create' | translate }} </a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item" ui-route="{{create}}">
|
||||||
|
<a href="#!/join" class="db p20h" title="Join"><i class="size-21 m20r fi-torsos-all"></i> {{'Join' | translate }} </a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="#!/" class="db p20h" title="Close" ng-click="signout()"><i class="size-21 m20r fi-power"></i> {{'Close'|translate}}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</header>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-show="$root.wallet.isShared()" ng-include="'views/includes/peer-list.html'"></div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<div ng-controller="VersionController">
|
<div ng-controller="VersionController">
|
||||||
<small>v{{version}}</small>
|
<small>v{{version}}</small>
|
||||||
<small>#{{commitHash}}</small>
|
<small>#{{commitHash}}</small>
|
||||||
<small ng-if="networkName ==='testnet' || networkName ==='livenet'">[ {{networkName}} ]</small>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue