fix conflicts

This commit is contained in:
Mario Colque 2014-03-31 18:05:35 -03:00
commit 92f4422841
26 changed files with 1811 additions and 331 deletions

View file

@ -1,25 +1,25 @@
'use strict';
angular.module('cosign',[
angular.module('copay',[
'ngRoute',
'mm.foundation',
'monospaced.qrcode',
'cosign.header',
'cosign.home',
'cosign.transactions',
'cosign.send',
'cosign.backup',
'cosign.network',
'cosign.signin',
'cosign.join'
'copay.header',
'copay.home',
'copay.transactions',
'copay.send',
'copay.backup',
'copay.network',
'copay.signin',
'copay.peer'
]);
angular.module('cosign.header', []);
angular.module('cosign.home', []);
angular.module('cosign.transactions', []);
angular.module('cosign.send', []);
angular.module('cosign.backup', []);
angular.module('cosign.network', []);
angular.module('cosign.signin', []);
angular.module('cosign.join', []);
angular.module('copay.header', []);
angular.module('copay.home', []);
angular.module('copay.transactions', []);
angular.module('copay.send', []);
angular.module('copay.backup', []);
angular.module('copay.network', []);
angular.module('copay.signin', []);
angular.module('copay.peer', []);

View file

@ -2,7 +2,7 @@
//Setting up route
angular
.module('cosign')
.module('copay')
.config(function($routeProvider) {
$routeProvider
@ -18,6 +18,9 @@ angular
.when('/join/:id', {
templateUrl: 'join.html'
})
.when('/peer', {
templateUrl: 'peer.html'
})
.when('/transactions', {
templateUrl: 'transactions.html'
})
@ -34,7 +37,7 @@ angular
//Setting HTML5 Location Mode
angular
.module('cosign')
.module('copay')
.config(function($locationProvider) {
$locationProvider
.html5Mode(false);

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('cosign.backup').controller('BackupController',
angular.module('copay.backup').controller('BackupController',
function($scope, $rootScope, $location) {
$scope.title = 'Backup';
});

View file

@ -1,10 +1,10 @@
'use strict';
angular.module('cosign.header').controller('HeaderController',
function($scope, $rootScope, $location) {
angular.module('copay.header').controller('HeaderController',
function($scope, $rootScope, $location, Network) {
$scope.menu = [{
'title': 'Home',
'link': '#/'
'link': '#/home'
}, {
'title': 'Transactions',
'link': '#/transactions'
@ -16,6 +16,10 @@ angular.module('cosign.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('cosign.header').controller('HeaderController',
$scope.signout = function() {
$rootScope.isLogged = false;
Network.disconnect();
$location.path('signin');
};
});

View file

@ -1,11 +1,15 @@
'use strict';
angular.module('cosign.home').controller('HomeController',
angular.module('copay.home').controller('HomeController',
function($scope, $rootScope, $location) {
$scope.title = 'Home';
$scope.oneAtATime = true;
if (!$rootScope.peerId) {
$location.path('signin');
}
$scope.addrs = [
{ addrStr: 'n3zUqNR7Bbbc4zJhPVj1vG2Lx66K3Xhzvb'},
{ addrStr: 'my9wnLwwUrwpNfEgSrWY62ymEGf1edKf4J'}

View file

@ -1,13 +0,0 @@
'use strict';
angular.module('cosign.join').controller('JoinController',
function($scope, $rootScope, $routeParams, Network) {
$rootScope.masterId = $routeParams.id;
$scope.init = function() {
console.log('-------- init --------');
console.log($rootScope.peerId);
Network.connect($rootScope.masterId);
};
});

11
js/controllers/peer.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
angular.module('copay.peer').controller('PeerController',
function($scope, $rootScope, $location, $routeParams, Network) {
$scope.init = function() {
console.log('connecting peer init');
//Network.connect($rootScope.masterId);
};
});

View file

@ -1,6 +1,11 @@
'use strict';
angular.module('cosign.send').controller('SendController',
angular.module('copay.send').controller('SendController',
function($scope, $rootScope, $location) {
$scope.title = 'Send';
if (!$rootScope.peerId) {
$location.path('signin');
}
});

View file

@ -1,15 +1,28 @@
'use strict';
angular.module('cosign.signin').controller('SigninController',
angular.module('copay.signin').controller('SigninController',
function($scope, $rootScope, $location, Network) {
$scope.loading = false;
$rootScope.peerId = null;
// Init peer
Network.init();
$scope.create = function() {
$scope.loading = true;
Network.init(function(pid) {
$rootScope.masterId = pid;
$location.path('peer');
});
};
$scope.join = function(cid) {
console.log('------- joining to ' + cid + ' --------');
$scope.loading = true;
Network.init(function() {
Network.connect(cid, function() {
$rootScope.masterId = cid;
$location.path('peer');
});
});
var pid = cid || $rootScope.peerId;
$location.path('join/' + pid);
};
});

View file

@ -1,11 +1,15 @@
'use strict';
angular.module('cosign.transactions').controller('TransactionsController',
angular.module('copay.transactions').controller('TransactionsController',
function($scope, $rootScope, $location) {
$scope.title = 'Transactions';
$scope.oneAtATime = true;
if (!$rootScope.peerId) {
$location.path('signin');
}
$scope.txsinput = [
{
fromAddr: "n3zUqNR7Bbbc4zJhPVj1vG2Lx66K3Xhzvb",

View file

@ -2,5 +2,5 @@
angular.element(document).ready(function() {
// Init the app
angular.bootstrap(document, ['cosign']);
angular.bootstrap(document, ['copay']);
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('cosign.network')
angular.module('copay.network')
.factory('Network', function($rootScope) {
var peer;
$rootScope.connectedPeers = [];
@ -59,17 +59,19 @@ angular.module('cosign.network')
});
};
var _init = function() {
var _init = function(cb) {
peer = new Peer($rootScope.peerId, {
key: 'lwjd5qra8257b9', // TODO: we need our own PeerServer KEY (http://peerjs.com/peerserver)
debug: 3
});
peer.on('open', function(pid) {
$rootScope.$apply(function() {
$rootScope.peerId = pid;
$rootScope.connectedPeers.push(pid);
});
$rootScope.peerId = pid;
$rootScope.connectedPeers.push(pid);
cb(pid);
$rootScope.$digest();
});
peer.on('connection', function(conn) {
@ -77,7 +79,11 @@ angular.module('cosign.network')
conn.on('open', function() {
console.log('-------- ' + conn.peer + ' conected to me --------');
console.log($rootScope.masterId);
console.log($rootScope.peerId);
if ($rootScope.masterId === $rootScope.peerId) {
console.log('-------- I am the master --------');
var c = peer.connect(conn.peer, {
label: 'wallet',
serialization: 'none',
@ -86,12 +92,12 @@ angular.module('cosign.network')
});
c.on('open', function() {
$rootScope.$apply(function() {
$rootScope.connectedPeers.push(conn.peer);
$rootScope.connectedTo.push(conn.peer);
});
$rootScope.connectedPeers.push(conn.peer);
$rootScope.connectedTo.push(conn.peer);
_send($rootScope.connectedPeers, { peers: $rootScope.connectedPeers });
$rootScope.$digest();
});
}
});
@ -103,7 +109,7 @@ angular.module('cosign.network')
});
};
var _connect = function(pid) {
var _connect = function(pid, cb) {
if (pid !== $rootScope.peerId) {
console.log('------- conecting to ' + pid + ' ------');
var c = peer.connect(pid, {
@ -118,10 +124,13 @@ angular.module('cosign.network')
console.log($rootScope.connectedPeers);
console.log($rootScope.connectedTo);
$rootScope.$apply(function() {
$rootScope.connectedPeers.push(pid);
$rootScope.connectedTo.push(pid);
});
$rootScope.connectedPeers.push(pid);
$rootScope.connectedTo.push(pid);
if (typeof cb === 'function')
cb();
$rootScope.$digest();
console.log($rootScope.connectedPeers);
console.log($rootScope.connectedTo);
@ -145,10 +154,17 @@ angular.module('cosign.network')
}
};
var _disconnect = function() {
peer.disconnect();
peer.destroy();
console.log('Disconnected and destroyed connection');
}
return {
init: _init,
connect: _connect,
send: _send
send: _send,
disconnect: _disconnect
}
});