Wallet/js/controllers/signin.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

'use strict';
2014-04-17 11:46:49 -03:00
angular.module('copay.signin').controller('SigninController',
2014-04-17 11:46:49 -03:00
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
2014-04-01 18:22:07 -03:00
2014-04-15 12:17:28 -03:00
// var peerData = Storage.get($rootScope.walletId, 'peerData');
// $rootScope.peerId = peerData ? peerData.peerId : null;
$scope.loading = false;
2014-04-15 15:25:55 -03:00
$scope.selectedWalletId = false;
$scope.listWalletIds = function() {
2014-04-16 17:50:10 -03:00
return walletFactory.getWalletIds();
};
2014-04-16 17:50:10 -03:00
$scope.create = function() {
2014-04-16 19:45:22 -03:00
$location.path('setup');
2014-04-16 17:50:10 -03:00
};
2014-04-15 15:25:55 -03:00
2014-04-16 17:50:10 -03:00
$scope.open = function(walletId) {
$scope.loading = true;
var w = walletFactory.open(walletId);
2014-04-17 11:46:49 -03:00
controllerUtils.setupUxHandlers(w);
2014-04-16 17:50:10 -03:00
w.netStart();
};
$scope.join = function(cid) {
2014-04-16 17:50:10 -03:00
console.log('[signin.js.42:join:]'); //TODO
$scope.loading = true;
2014-04-16 20:58:57 -03:00
walletFactory.connectTo(cid, function(w) {
console.log('[signin.js.50]'); //TODO
2014-04-17 11:46:49 -03:00
controllerUtils.setupUxHandlers(w);
2014-04-16 20:58:57 -03:00
w.netStart();
});
};
2014-04-16 19:14:58 -03:00
//
// 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();
// });
// });
// }
2014-04-01 18:22:07 -03:00
2014-04-15 12:17:28 -03:00
// if (peerData && peerData.peerId && peerData.connectedPeers.length > 0) {
// $rootScope.peerId = peerData.peerId;
// $scope.join(peerData.connectedPeers);
// }
});
2014-04-01 18:22:07 -03:00