integrate new name and header. Signin/signout flow
This commit is contained in:
parent
28247a87c6
commit
4cd48b7bb2
12 changed files with 130 additions and 74 deletions
|
|
@ -1,10 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.header').controller('HeaderController',
|
||||
function($scope, $rootScope, $location) {
|
||||
function($scope, $rootScope, $location, Network) {
|
||||
$scope.menu = [{
|
||||
'title': 'Home',
|
||||
'link': '#/'
|
||||
'link': '#/home'
|
||||
}, {
|
||||
'title': 'Transactions',
|
||||
'link': '#/transactions'
|
||||
|
|
@ -16,6 +16,10 @@ angular.module('copay.header').controller('HeaderController',
|
|||
'link': '#/backup'
|
||||
}];
|
||||
|
||||
if (!$rootScope.peerId) {
|
||||
$location.path('signin');
|
||||
}
|
||||
|
||||
$scope.isActive = function(item) {
|
||||
if (item.link.replace('#','') == $location.path()) {
|
||||
return true;
|
||||
|
|
@ -29,7 +33,7 @@ angular.module('copay.header').controller('HeaderController',
|
|||
|
||||
$scope.signout = function() {
|
||||
$rootScope.isLogged = false;
|
||||
|
||||
Network.disconnect();
|
||||
$location.path('signin');
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ angular.module('copay.home').controller('HomeController',
|
|||
|
||||
$scope.oneAtATime = true;
|
||||
|
||||
if (!$rootScope.peerId) {
|
||||
$location.path('signin');
|
||||
}
|
||||
|
||||
$scope.addrs = [
|
||||
{ addrStr: 'n3zUqNR7Bbbc4zJhPVj1vG2Lx66K3Xhzvb'},
|
||||
{ addrStr: 'my9wnLwwUrwpNfEgSrWY62ymEGf1edKf4J'}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.join').controller('JoinController',
|
||||
function($scope, $rootScope, $routeParams, Network) {
|
||||
|
||||
$scope.connectionId = $routeParams.id;
|
||||
$scope.copayers = [];
|
||||
|
||||
$scope.init = function() {
|
||||
console.log('-------- init --------');
|
||||
console.log($rootScope.peerId);
|
||||
$scope.copayers.push($rootScope.peerId);
|
||||
|
||||
Network.connect($scope.connectionId, function(copayer) {
|
||||
console.log('----- join connect --------');
|
||||
console.log(copayer);
|
||||
$scope.copayers.push(copayer);
|
||||
$scope.$digest();
|
||||
});
|
||||
};
|
||||
});
|
||||
13
js/controllers/peer.js
Normal file
13
js/controllers/peer.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.peer').controller('PeerController',
|
||||
function($scope, $rootScope, $location, $routeParams, Network) {
|
||||
|
||||
$scope.init = function() {
|
||||
Network.connect($rootScope.connectionId, function(copayer) {
|
||||
console.log(copayer);
|
||||
console.log($rootScope.copayers);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -3,4 +3,9 @@
|
|||
angular.module('copay.send').controller('SendController',
|
||||
function($scope, $rootScope, $location) {
|
||||
$scope.title = 'Send';
|
||||
|
||||
if (!$rootScope.peerId) {
|
||||
$location.path('signin');
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,23 +2,36 @@
|
|||
|
||||
angular.module('copay.signin').controller('SigninController',
|
||||
function($scope, $rootScope, $location, Network) {
|
||||
$scope.loading = false;
|
||||
$rootScope.peerId = null;
|
||||
$scope.peerReady = false;
|
||||
|
||||
// Init peer
|
||||
Network.init(function(pid) {
|
||||
$rootScope.peerId = pid;
|
||||
$rootScope.$digest();
|
||||
|
||||
$scope.peerReady = true;
|
||||
$scope.$digest();
|
||||
});
|
||||
$rootScope.copayers = [];
|
||||
|
||||
$scope.create = function() {
|
||||
$scope.loading = true;
|
||||
Network.init(function(pid) {
|
||||
$rootScope.copayers.push(pid);
|
||||
$location.path('peer');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.join = function(cid) {
|
||||
console.log('------- join --------');
|
||||
console.log(cid);
|
||||
$scope.loading = true;
|
||||
$rootScope.connectionId = cid;
|
||||
Network.init(function(pid) {
|
||||
|
||||
console.log('------- join --------');
|
||||
console.log(pid);
|
||||
|
||||
$rootScope.copayers.push(pid);
|
||||
|
||||
Network.connect(cid, function(copayer) {
|
||||
console.log('----- join master --------');
|
||||
console.log(copayer);
|
||||
$rootScope.copayers.push(copayer);
|
||||
|
||||
$location.path('peer');
|
||||
});
|
||||
});
|
||||
|
||||
var pid = cid || $rootScope.peerId;
|
||||
$location.path('join/' + pid);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
|
||||
$scope.oneAtATime = true;
|
||||
|
||||
if (!$rootScope.peerId) {
|
||||
$location.path('signin');
|
||||
}
|
||||
|
||||
$scope.txsinput = [
|
||||
{
|
||||
fromAddr: "n3zUqNR7Bbbc4zJhPVj1vG2Lx66K3Xhzvb",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue