Wallet/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 11:46:49 -03: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 17:50:10 -03:00
$scope.create = function() {
2014-04-24 22:43:19 -03:00
$scope.loading = true;
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-18 18:25:51 -03:00
$scope.open = function(walletId, opts) {
2014-04-16 17:50:10 -03:00
$scope.loading = true;
2014-04-18 18:25:51 -03:00
var w = walletFactory.open(walletId, opts);
2014-04-17 11:46:49 -03:00
controllerUtils.setupUxHandlers(w);
};
2014-04-20 12:41:28 -03: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 12:41:28 -03:00
walletFactory.network.on('joinError', function() {
controllerUtils.onErrorDigest($scope);
});
2014-04-20 12:41:28 -03:00
walletFactory.joinCreateSession(secret, function(w) {
console.log('[signin.js.33] joinCreateSession RETURN', w); //TODO
2014-04-17 11:46:49 -03:00
controllerUtils.setupUxHandlers(w);
2014-04-16 20:58:57 -03:00
});
};
});