2014-03-27 12:31:42 -07:00
|
|
|
'use strict';
|
|
|
|
|
2014-03-28 11:08:14 -07:00
|
|
|
angular.module('copay.signin').controller('SigninController',
|
2014-04-17 07:46:49 -07:00
|
|
|
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
|
2014-03-31 08:48:35 -07:00
|
|
|
$scope.loading = false;
|
2014-04-24 12:35:52 -07:00
|
|
|
$scope.wallets = walletFactory.getWallets();
|
|
|
|
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
|
2014-04-08 22:20:28 -07:00
|
|
|
|
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);
|
2014-04-08 22:20:28 -07:00
|
|
|
};
|
|
|
|
|
2014-04-20 08:41:28 -07:00
|
|
|
$scope.join = function(secret) {
|
2014-04-24 12:35:52 -07:00
|
|
|
if (!secret || secret.length !==66 || !secret.match(/^[0-9a-f]*$/) ) {
|
|
|
|
$rootScope.flashMessage = { message: 'Bad secret secret string', type: 'error'};
|
2014-04-21 08:10:34 -07:00
|
|
|
return;
|
|
|
|
}
|
2014-03-31 08:48:35 -07:00
|
|
|
$scope.loading = true;
|
2014-04-20 08:41:28 -07:00
|
|
|
|
|
|
|
walletFactory.network.on('joinError', function() {
|
|
|
|
controllerUtils.onErrorDigest($scope);
|
2014-04-17 12:27:15 -07:00
|
|
|
});
|
2014-04-20 08:41:28 -07:00
|
|
|
|
|
|
|
walletFactory.joinCreateSession(secret, function(w) {
|
|
|
|
console.log('[signin.js.33] joinCreateSession RETURN', w); //TODO
|
2014-04-17 07:46:49 -07:00
|
|
|
controllerUtils.setupUxHandlers(w);
|
2014-04-16 16:58:57 -07:00
|
|
|
});
|
|
|
|
};
|
2014-03-27 12:31:42 -07:00
|
|
|
});
|