copay/js/controllers/signin.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
angular.module('copay.signin').controller('SigninController',
2014-04-17 07:46:49 -07:00
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
$scope.loading = false;
$scope.wallets = walletFactory.getWallets();
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : 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);
};
2014-04-20 08:41:28 -07:00
$scope.join = function(secret) {
if (!secret || secret.length !==66 || !secret.match(/^[0-9a-f]*$/) ) {
$rootScope.flashMessage = { message: 'Bad secret secret string', type: 'error'};
return;
}
$scope.loading = true;
2014-04-20 08:41:28 -07:00
walletFactory.network.on('joinError', function() {
controllerUtils.onErrorDigest($scope);
});
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
});
};
});