Split signin.html in home, join and open files. Signin process with responsive support
This commit is contained in:
parent
f4d4f819de
commit
9875e9d643
21 changed files with 329 additions and 288 deletions
10
js/controllers/home.js
Normal file
10
js/controllers/home.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HomeController',
|
||||
function($scope, $rootScope, walletFactory, notification) {
|
||||
$scope.loading = false;
|
||||
if ($rootScope.pendingPayment) {
|
||||
notification.info('Login Required', 'Please open wallet to complete payment');
|
||||
}
|
||||
$scope.hasWallets = walletFactory.getWallets().length > 0 ? true : false;
|
||||
});
|
||||
37
js/controllers/join.js
Normal file
37
js/controllers/join.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('JoinController',
|
||||
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase, notification) {
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.join = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
walletFactory.network.on('badSecret', function() {});
|
||||
|
||||
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
|
||||
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, function(err, w) {
|
||||
$scope.loading = false;
|
||||
if (err || !w) {
|
||||
if (err === 'joinError')
|
||||
notification.error('Can\'t find peer.');
|
||||
else if (err === 'walletFull')
|
||||
notification.error('The wallet is full');
|
||||
else if (err === 'badNetwork')
|
||||
notification.error('Network Error', 'The wallet your are trying to join uses a different Bitcoin Network. Check your settings.');
|
||||
else if (err === 'badSecret')
|
||||
notification.error('Bad secret', 'The secret string you entered is invalid');
|
||||
else
|
||||
notification.error('Unknown error');
|
||||
controllerUtils.onErrorDigest();
|
||||
} else {
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
43
js/controllers/open.js
Normal file
43
js/controllers/open.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('OpenController',
|
||||
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase, notification) {
|
||||
var cmp = function(o1, o2) {
|
||||
var v1 = o1.show.toLowerCase(),
|
||||
v2 = o2.show.toLowerCase();
|
||||
return v1 > v2 ? 1 : (v1 < v2) ? -1 : 0;
|
||||
};
|
||||
$scope.loading = false;
|
||||
$scope.wallets = walletFactory.getWallets().sort(cmp);
|
||||
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
|
||||
$scope.openPassword = '';
|
||||
|
||||
$scope.open = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
var password = form.openPassword.$modelValue;
|
||||
|
||||
Passphrase.getBase64Async(password, function(passphrase) {
|
||||
var w, errMsg;
|
||||
try {
|
||||
var w = walletFactory.open($scope.selectedWalletId, {
|
||||
passphrase: passphrase
|
||||
});
|
||||
} catch (e) {
|
||||
errMsg = e.message;
|
||||
};
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', errMsg || 'Wrong password');
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -74,7 +74,7 @@ angular.module('copayApp.controllers').controller('SettingsController',
|
|||
unitToSatoshi: $scope.selectedUnit.value,
|
||||
}));
|
||||
|
||||
var target = ($window.location.origin !== 'null' ? $window.location.origin : '') + '/signin';
|
||||
var target = ($window.location.origin !== 'null' ? $window.location.origin : '');
|
||||
|
||||
$window.location.href = target;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,100 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('SigninController',
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase, backupService, notification) {
|
||||
var cmp = function(o1, o2) {
|
||||
var v1 = o1.show.toLowerCase(),
|
||||
v2 = o2.show.toLowerCase();
|
||||
return v1 > v2 ? 1 : (v1 < v2) ? -1 : 0;
|
||||
};
|
||||
$rootScope.videoInfo = {};
|
||||
$scope.loading = false;
|
||||
$scope.wallets = walletFactory.getWallets().sort(cmp);
|
||||
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
|
||||
$scope.openPassword = '';
|
||||
|
||||
if ($rootScope.pendingPayment) {
|
||||
notification.info('Login Required', 'Please open wallet to complete payment');
|
||||
}
|
||||
|
||||
$scope.open = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
var password = form.openPassword.$modelValue;
|
||||
|
||||
Passphrase.getBase64Async(password, function(passphrase) {
|
||||
var w, errMsg;
|
||||
try {
|
||||
var w = walletFactory.open($scope.selectedWalletId, {
|
||||
passphrase: passphrase
|
||||
});
|
||||
} catch (e) {
|
||||
errMsg = e.message;
|
||||
};
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', errMsg || 'Wrong password');
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.join = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
walletFactory.network.on('badSecret', function() {});
|
||||
|
||||
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
|
||||
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, function(err, w) {
|
||||
$scope.loading = false;
|
||||
if (err || !w) {
|
||||
if (err === 'joinError')
|
||||
notification.error('Can\'t find peer.');
|
||||
else if (err === 'walletFull')
|
||||
notification.error('The wallet is full');
|
||||
else if (err === 'badNetwork')
|
||||
notification.error('Network Error', 'The wallet your are trying to join uses a different Bitcoin Network. Check your settings.');
|
||||
else if (err === 'badSecret')
|
||||
notification.error('Bad secret', 'The secret string you entered is invalid');
|
||||
else
|
||||
notification.error('Unknown error');
|
||||
controllerUtils.onErrorDigest();
|
||||
} else {
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.isHome = 1;
|
||||
$scope.isJoin = 0;
|
||||
$scope.isOpen = 0;
|
||||
|
||||
$scope.backWallet = function() {
|
||||
$scope.isHome = 1;
|
||||
$scope.isJoin = 0;
|
||||
$scope.isOpen = 0;
|
||||
};
|
||||
|
||||
$scope.openWallet = function() {
|
||||
$scope.isHome = 0;
|
||||
$scope.isJoin = 0;
|
||||
$scope.isOpen = 1;
|
||||
};
|
||||
|
||||
$scope.joinWallet = function() {
|
||||
$scope.isHome = 0;
|
||||
$scope.isOpen = 0;
|
||||
$scope.isJoin = 1;
|
||||
};
|
||||
});
|
||||
|
|
@ -10,7 +10,7 @@ angular.module('copayApp.controllers').controller('UriPaymentController', functi
|
|||
$scope.message = $rootScope.pendingPayment.message;
|
||||
|
||||
$timeout(function() {
|
||||
$location.path('signin');
|
||||
$location.path('/');
|
||||
}, 1000);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
angular.module('copayApp.controllers').controller('VideoController',
|
||||
function($scope, $rootScope, $sce) {
|
||||
|
||||
$rootScope.videoInfo = {};
|
||||
|
||||
// Cached list of copayers
|
||||
$scope.copayers = $rootScope.wallet.getRegisteredPeerIds();
|
||||
|
||||
|
|
|
|||
12
js/routes.js
12
js/routes.js
|
|
@ -7,11 +7,15 @@ angular
|
|||
|
||||
$routeProvider
|
||||
.when('/', {
|
||||
templateUrl: 'views/signin.html',
|
||||
templateUrl: 'views/home.html',
|
||||
validate: false
|
||||
})
|
||||
.when('/signin', {
|
||||
templateUrl: 'views/signin.html',
|
||||
.when('/open', {
|
||||
templateUrl: 'views/open.html',
|
||||
validate: false
|
||||
})
|
||||
.when('/join', {
|
||||
templateUrl: 'views/join.html',
|
||||
validate: false
|
||||
})
|
||||
.when('/import', {
|
||||
|
|
@ -68,7 +72,7 @@ angular
|
|||
$location.path('unsupported');
|
||||
} else {
|
||||
if ((!$rootScope.wallet || !$rootScope.wallet.id) && next.validate) {
|
||||
$location.path('signin');
|
||||
$location.path('/');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ angular.module('copayApp.services')
|
|||
}
|
||||
}
|
||||
|
||||
$location.path('signin');
|
||||
$location.path('/');
|
||||
};
|
||||
|
||||
root.onError = function(scope) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue