copay/js/controllers/signin.js

62 lines
1.7 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();
2014-04-17 08:58:54 -07:00
$scope.selectedWalletId = $scope.walletIds.length ? $scope.walletIds[0]: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-18 14:25:51 -07:00
$scope.open = function(walletId, opts) {
2014-04-16 13:50:10 -07:00
$scope.loading = true;
2014-04-18 14:25:51 -07:00
var w = walletFactory.open(walletId, opts);
2014-04-17 07:46:49 -07:00
controllerUtils.setupUxHandlers(w);
};
$scope.join = function(cid) {
$scope.loading = true;
walletFactory.network.on('openError', function() {
controllerUtils.onError($scope);
$rootScope.$digest();
});
2014-04-18 14:25:51 -07:00
walletFactory.connectTo(cid, function(data) {
$scope.open(data.walletId, data.opts);
});
2014-04-16 16:58:57 -07:00
};
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