copay/js/controllers/signin.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

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