mirror of https://github.com/BTCPrivate/copay.git
fix angular
This commit is contained in:
parent
5f21f2e80d
commit
f8b4f8e4c9
3
copay.js
3
copay.js
|
@ -10,13 +10,12 @@ var Insight = module.exports.Insight = require('./js/models/blockchain/Insight')
|
|||
var StorageLocalPlain = module.exports.StorageLocalPlain = require('./js/models/storage/LocalPlain');
|
||||
var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('./js/models/storage/LocalEncrypted');
|
||||
|
||||
var WalletFactory = require('soop').load('./js/models/core/WalletFactory',{
|
||||
var WalletFactory = require('soop').load('./js/models/core/WalletFactory.js',{
|
||||
Network: WebRTC,
|
||||
Blockchain: Insight,
|
||||
Storage: StorageLocalPlain,
|
||||
});
|
||||
module.exports.WalletFactory = WalletFactory;
|
||||
//var walletFactory = new WalletFactory(config);
|
||||
|
||||
|
||||
module.exports.API = require('./API');
|
||||
|
|
|
@ -290,7 +290,7 @@
|
|||
<script src="js/routes.js"></script>
|
||||
<script src="js/directives.js"></script>
|
||||
<script src="js/filters.js"></script>
|
||||
<script src="js/services/network.js"></script>
|
||||
<script src="js/services/walletFactory.js"></script>
|
||||
|
||||
<script src="js/controllers/header.js"></script>
|
||||
<script src="js/controllers/home.js"></script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.header').controller('HeaderController',
|
||||
function($scope, $rootScope, $location, Network) {
|
||||
function($scope, $rootScope, $location, walletFactory) {
|
||||
$scope.menu = [{
|
||||
'title': 'Home',
|
||||
'icon': 'fi-home',
|
||||
|
@ -35,15 +35,14 @@ angular.module('copay.header').controller('HeaderController',
|
|||
return false;
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
$rootScope.isLogged = false;
|
||||
};
|
||||
|
||||
$scope.signout = function() {
|
||||
Network.disconnect(function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (w) {
|
||||
w.disconnect();
|
||||
delete $rootScope['wallet'];
|
||||
$location.path('signin');
|
||||
$rootScope.$digest();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.clearFlashMessage = function() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.peer').controller('PeerController',
|
||||
function($scope, $rootScope, $location, $routeParams, Network) {
|
||||
function($scope, $rootScope, $location, $routeParams) {
|
||||
|
||||
$scope.init = function() {
|
||||
//Network.connect($rootScope.masterId);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.send').controller('SendController',
|
||||
function($scope, $rootScope, $location, Network) {
|
||||
function($scope, $rootScope, $location) {
|
||||
$scope.title = 'Send';
|
||||
|
||||
if (!$rootScope.wallet.id) {
|
||||
|
@ -11,8 +11,6 @@ angular.module('copay.send').controller('SendController',
|
|||
|
||||
$scope.sendTest = function() {
|
||||
var w = $rootScope.wallet;
|
||||
var pkr = w.publicKeyRing;
|
||||
var txp = w.txProposals;
|
||||
w.createTx( '15q6HKjWHAksHcH91JW23BJEuzZgFwydBt', '12345',function() {
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
|
|
@ -46,20 +46,22 @@ console.log('[signin.js.42:create:]'); //TODO
|
|||
$scope.join = function(cid) {
|
||||
console.log('[signin.js.42:join:]'); //TODO
|
||||
$scope.loading = true;
|
||||
|
||||
if (cid) {
|
||||
Network.init(null, function() {
|
||||
Network.connect(cid,
|
||||
function() {
|
||||
$location.path('peer');
|
||||
$rootScope.$digest();
|
||||
}, function() {
|
||||
$rootScope.flashMessage = { message: 'Connection refussed', type: 'error'};
|
||||
$location.path('home');
|
||||
$rootScope.$digest();
|
||||
});
|
||||
});
|
||||
}
|
||||
//
|
||||
// if (cid) {
|
||||
// var w = walletFactory.(walletId);
|
||||
//TODO
|
||||
// Network.init(null, function() {
|
||||
// Network.connect(cid,
|
||||
// function() {
|
||||
// $location.path('peer');
|
||||
// $rootScope.$digest();
|
||||
// }, function() {
|
||||
// $rootScope.flashMessage = { message: 'Connection refussed', type: 'error'};
|
||||
// $location.path('home');
|
||||
// $rootScope.$digest();
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
// if (peerData && peerData.peerId && peerData.connectedPeers.length > 0) {
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.network')
|
||||
.factory('Network', function($rootScope) {
|
||||
var peer;
|
||||
|
||||
var _refreshUx = function() {
|
||||
var net = $rootScope.wallet.network;
|
||||
log('*** UPDATING UX'); //TODO
|
||||
$rootScope.peedId = net.peerId;
|
||||
$rootScope.connectedPeers = net.connectedPeers;
|
||||
$rootScope.$digest();
|
||||
};
|
||||
|
||||
var closeWallet = function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (w && w.id) w.store();
|
||||
|
||||
log('### CLOSING WALLET');
|
||||
delete $rootScope['wallet'];
|
||||
};
|
||||
|
||||
// public methods
|
||||
var init = function(walletId, cb) {
|
||||
if (!$rootScope.wallet) {
|
||||
// create an empty Wallet
|
||||
$rootScope.wallet = new copay.Wallet(config);
|
||||
}
|
||||
var w = $rootScope.wallet;
|
||||
console.log('[network.js.30:walletId:]',walletId); //TODO
|
||||
if (!walletId) w.openWalletId();
|
||||
w.on('created', _refreshUx);
|
||||
w.on('txProposals', _refreshUx);
|
||||
w.on('publicKeyRing', _refreshUx);
|
||||
w.on('abort', function() {
|
||||
disconnect();
|
||||
_refreshUx();
|
||||
});
|
||||
w.netStart(cb);
|
||||
};
|
||||
|
||||
var disconnect = function() {
|
||||
var w = $rootScope.wallet;
|
||||
var net = w.network;
|
||||
|
||||
if (net) {
|
||||
net.disconnect();
|
||||
}
|
||||
closeWallet();
|
||||
};
|
||||
|
||||
var connect = function(peerId, openCallback, failCallback) {
|
||||
$rootScope.wallet.connectTo(peerId);
|
||||
$rootScope.wallet.on('open', openCallback);
|
||||
$rootScope.wallet.on('close', failCallback);
|
||||
};
|
||||
|
||||
var sendTxProposals = function(recipients) {
|
||||
var w = $rootScope.wallet;
|
||||
w.sendTxProposals(recipients);
|
||||
};
|
||||
|
||||
return {
|
||||
init: init,
|
||||
connect: connect,
|
||||
disconnect: disconnect,
|
||||
sendTxProposals: sendTxProposals,
|
||||
}
|
||||
});
|
||||
|
|
@ -42,7 +42,8 @@ var createBundle = function(opts) {
|
|||
b.require('./copay', {
|
||||
expose: 'copay'
|
||||
});
|
||||
b.require('./js/models/core/Wallet');
|
||||
b.require('./js/models/core/WalletFactory.js');
|
||||
|
||||
|
||||
if (!opts.dontminify) {
|
||||
b.transform({
|
||||
|
|
Loading…
Reference in New Issue