Fixed Conflicts:

bower.json
	js/directives.js
	views/includes/sidebar.html
This commit is contained in:
Gustavo Maximiliano Cortez 2014-08-01 11:12:35 -03:00
commit b94f66f32e
17 changed files with 79 additions and 40 deletions

View File

@ -22,6 +22,7 @@
"angular-moment": "~0.7.1", "angular-moment": "~0.7.1",
"socket.io-client": ">=1.0.0", "socket.io-client": ">=1.0.0",
"mousetrap": "1.4.6", "mousetrap": "1.4.6",
"zeroclipboard": "~2.1.6" "zeroclipboard": "~2.1.6",
"ng-idle": "*"
} }
} }

View File

@ -62,6 +62,7 @@
<script src="lib/angular-moment/angular-moment.js"></script> <script src="lib/angular-moment/angular-moment.js"></script>
<script src="lib/qrcode-generator/js/qrcode.js"></script> <script src="lib/qrcode-generator/js/qrcode.js"></script>
<script src="lib/angular-qrcode/qrcode.js"></script> <script src="lib/angular-qrcode/qrcode.js"></script>
<script src="lib/ng-idle/angular-idle.min.js"></script>
<script src="lib/angular-foundation/mm-foundation.min.js"></script> <script src="lib/angular-foundation/mm-foundation.min.js"></script>
<script src="lib/angular-foundation/mm-foundation-tpls.min.js"></script> <script src="lib/angular-foundation/mm-foundation-tpls.min.js"></script>
<script src="lib/peer.js"></script> <!-- TODO Change this on PeerJS version 0.3.9 --> <script src="lib/peer.js"></script> <!-- TODO Change this on PeerJS version 0.3.9 -->

View File

@ -27,6 +27,7 @@ var copayApp = window.copayApp = angular.module('copayApp', [
'angularMoment', 'angularMoment',
'mm.foundation', 'mm.foundation',
'monospaced.qrcode', 'monospaced.qrcode',
'ngIdle',
'copayApp.filters', 'copayApp.filters',
'copayApp.services', 'copayApp.services',
'copayApp.controllers', 'copayApp.controllers',
@ -40,6 +41,7 @@ copayApp.config(function($sceDelegateProvider) {
]); ]);
}); });
angular.module('copayApp.filters', []); angular.module('copayApp.filters', []);
angular.module('copayApp.services', []); angular.module('copayApp.services', []);
angular.module('copayApp.controllers', []); angular.module('copayApp.controllers', []);

View File

@ -20,13 +20,6 @@ angular.module('copayApp.controllers').controller('AddressesController',
var ModalInstanceCtrl = function ($scope, $modalInstance, address) { var ModalInstanceCtrl = function ($scope, $modalInstance, address) {
$scope.address = address; $scope.address = address;
$scope.openExternal = function(address) {
var url = 'bitcoin:' + address;
if (window.cordova) return window.open(url, '_blank');
window.location = url;
}
$scope.cancel = function () { $scope.cancel = function () {
$modalInstance.dismiss('cancel'); $modalInstance.dismiss('cancel');
}; };

View File

@ -82,4 +82,15 @@ angular.module('copayApp.controllers').controller('SidebarController',
// Init socket handlers (with no wallet yet) // Init socket handlers (with no wallet yet)
controllerUtils.setSocketHandlers(); controllerUtils.setSocketHandlers();
if ($rootScope.wallet) {
$scope.$on('$idleStart', function(a) {
notification.warning('Session will be closed', 'Your session is about to expire due to inactivity');
});
$scope.$on('$idleTimeout', function() {
$scope.signout();
notification.warning('Session closed', 'Session closed because a long time of inactivity');
});
}
}); });

View File

@ -198,10 +198,18 @@ angular.module('copayApp.directives')
} }
}; };
}) })
// From https://gist.github.com/asafge/7430497 .directive('openExternal', function() {
.directive('ngReallyClick', [ return {
restrict: 'A',
function() { link: function(scope, element, attrs) {
element.bind('click', function() {
window.open('bitcoin:'+attrs.address, '_blank');
});
}
}
})
// From https://gist.github.com/asafge/7430497
.directive('ngReallyClick', [function() {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
@ -214,8 +222,7 @@ angular.module('copayApp.directives')
} }
} }
} }
]) ])
.directive('match', function () { .directive('match', function () {
return { return {
require: 'ngModel', require: 'ngModel',
@ -265,5 +272,4 @@ angular.module('copayApp.directives')
}); });
} }
}; };
}) });
;

View File

@ -18,7 +18,7 @@ function HDParams(opts) {
HDParams.init = function(totalCopayers) { HDParams.init = function(totalCopayers) {
preconditions.shouldBeNumber(totalCopayers); preconditions.shouldBeNumber(totalCopayers);
var ret = [new HDParams()]; var ret = [new HDParams({receiveIndex: 1})];
for (var i = 0 ; i < totalCopayers ; i++) { for (var i = 0 ; i < totalCopayers ; i++) {
ret.push(new HDParams({copayerIndex: i})); ret.push(new HDParams({copayerIndex: i}));
} }

View File

@ -65,17 +65,22 @@ angular
//Setting HTML5 Location Mode //Setting HTML5 Location Mode
angular angular
.module('copayApp') .module('copayApp')
.config(function($locationProvider) { .config(function($locationProvider, $idleProvider) {
$locationProvider $locationProvider
.html5Mode(false) .html5Mode(false)
.hashPrefix('!'); .hashPrefix('!');
// IDLE timeout
$idleProvider.idleDuration(15 * 60); // in seconds
$idleProvider.warningDuration(10); // in seconds
}) })
.run(function($rootScope, $location) { .run(function($rootScope, $location, $idle) {
$idle.watch();
$rootScope.$on('$routeChangeStart', function(event, next, current) { $rootScope.$on('$routeChangeStart', function(event, next, current) {
if (!util.supports.data) { if (!util.supports.data) {
$location.path('unsupported'); $location.path('unsupported');
} else { } else {
if ((!$rootScope.wallet || !$rootScope.wallet.id) && next.validate) { if ((!$rootScope.wallet || !$rootScope.wallet.id) && next.validate) {
$idle.unwatch();
$location.path('/'); $location.path('/');
} }
if ($rootScope.wallet && !$rootScope.wallet.isReady()) { if ($rootScope.wallet && !$rootScope.wallet.isReady()) {

View File

@ -185,13 +185,14 @@ angular.module('copayApp.services')
root.updateAddressList = function() { root.updateAddressList = function() {
var w = $rootScope.wallet; var w = $rootScope.wallet;
if (w) if (w && w.isReady())
$rootScope.addrInfos = w.getAddressesInfo(); $rootScope.addrInfos = w.getAddressesInfo();
}; };
root.updateBalance = function(cb) { root.updateBalance = function(cb) {
var w = $rootScope.wallet; var w = $rootScope.wallet;
if (!w) return root.onErrorDigest(); if (!w) return root.onErrorDigest();
if (!w.isReady()) return;
$rootScope.balanceByAddr = {}; $rootScope.balanceByAddr = {};
$rootScope.updatingBalance = true; $rootScope.updatingBalance = true;
@ -212,6 +213,10 @@ angular.module('copayApp.services')
$rootScope.totalBalanceBTC = (balanceSat / COIN); $rootScope.totalBalanceBTC = (balanceSat / COIN);
$rootScope.availableBalance = safeBalanceSat * satToUnit; $rootScope.availableBalance = safeBalanceSat * satToUnit;
$rootScope.availableBalanceBTC = (safeBalanceSat / COIN); $rootScope.availableBalanceBTC = (safeBalanceSat / COIN);
$rootScope.lockedBalance = (balanceSat - safeBalanceSat) * satToUnit;
$rootScope.lockedBalanceBTC = (balanceSat - safeBalanceSat) / COIN;
var balanceByAddr = {}; var balanceByAddr = {};
for (var ii in balanceByAddrSat) { for (var ii in balanceByAddrSat) {
balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit; balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit;

View File

@ -21,6 +21,7 @@ module.exports = function(config) {
'lib/angular/angular.min.js', 'lib/angular/angular.min.js',
'lib/angular-mocks/angular-mocks.js', 'lib/angular-mocks/angular-mocks.js',
'lib/moment/moment.js', 'lib/moment/moment.js',
'lib/ng-idle/angular-idle.min.js',
'lib/angular-moment/angular-moment.js', 'lib/angular-moment/angular-moment.js',
'lib/qrcode-generator/js/qrcode.js', 'lib/qrcode-generator/js/qrcode.js',
'lib/angular-qrcode/qrcode.js', 'lib/angular-qrcode/qrcode.js',

View File

@ -46,6 +46,10 @@ FakeWallet.prototype.getAddressesInfo = function() {
return ret; return ret;
}; };
FakeWallet.prototype.isReady = function() {
return true;
}
FakeWallet.prototype.getBalance = function(cb) { FakeWallet.prototype.getBalance = function(cb) {
return cb(null, this.balance, this.balanceByAddr, this.safeBalance); return cb(null, this.balance, this.balanceByAddr, this.safeBalance);

View File

@ -145,9 +145,8 @@ describe('PublicKeyRing model', function() {
var k = createW(); var k = createW();
var w = k.w; var w = k.w;
var a = w.getAddresses(); var a = w.getAddresses();
a.length.should.equal(0); a.length.should.equal(1);
[true, false].forEach(function(isChange){ [true, false].forEach(function(isChange){
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
@ -156,15 +155,22 @@ describe('PublicKeyRing model', function() {
}); });
var as = w.getAddressesInfo(); var as = w.getAddressesInfo();
as.length.should.equal(4); as.length.should.equal(5); // include pre-generated shared one
for (var j in as) { for (var j in as) {
var a = as[j]; var a = as[j];
a.address.isValid().should.equal(true); a.address.isValid().should.equal(true);
a.addressStr.should.equal(a.address.toString()); a.addressStr.should.equal(a.address.toString());
a.isChange.should.equal([false, false, true, true][j]); a.isChange.should.equal([false, false, false, true, true][j]);
} }
}); });
it('should start with one shared address', function() {
var k = createW();
var a = k.w.getAddresses();
a.length.should.equal(1);
});
it('should count generation indexes', function() { it('should count generation indexes', function() {
var k = createW(); var k = createW();
var w = k.w; var w = k.w;

View File

@ -594,7 +594,7 @@ describe('Wallet model', function() {
it('should get balance', function(done) { it('should get balance', function(done) {
var w = createW(); var w = createW2();
var spy = sinon.spy(w.blockchain, 'getUnspent'); var spy = sinon.spy(w.blockchain, 'getUnspent');
w.blockchain.fixUnspent([]); w.blockchain.fixUnspent([]);
w.getBalance(function(err, balance, balanceByAddr, safeBalance) { w.getBalance(function(err, balance, balanceByAddr, safeBalance) {

View File

@ -93,8 +93,12 @@ describe("Unit: controllerUtils", function() {
controllerUtils.updateBalance(function() { controllerUtils.updateBalance(function() {
expect($rootScope.totalBalanceBTC).to.be.equal(1.00000001); expect($rootScope.totalBalanceBTC).to.be.equal(1.00000001);
expect($rootScope.availableBalanceBTC).to.be.equal(0.90000002); expect($rootScope.availableBalanceBTC).to.be.equal(0.90000002);
expect($rootScope.lockedBalanceBTC).to.be.equal(0.09999999);
expect($rootScope.totalBalance).to.be.equal(1000000.01); expect($rootScope.totalBalance).to.be.equal(1000000.01);
expect($rootScope.availableBalance).to.be.equal(900000.02); expect($rootScope.availableBalance).to.be.equal(900000.02);
expect($rootScope.lockedBalance).to.be.equal(99999.99);
expect($rootScope.addrInfos).not.to.equal(null); expect($rootScope.addrInfos).not.to.equal(null);
expect($rootScope.addrInfos[0].address).to.equal(Waddr); expect($rootScope.addrInfos[0].address).to.equal(Waddr);
}); });

View File

@ -24,16 +24,16 @@
</span> </span>
</div> </div>
<div> <div>
Available Locked
<span ng-if="$root.updatingBalance"> <span ng-if="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i> <i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span> </span>
<span ng-show="!$root.updatingBalance" <span ng-show="!$root.updatingBalance"
data-options="disable_for_touch:true" data-options="disable_for_touch:true"
tooltip="{{availableBalanceBTC || 0 |noFractionNumber:8}} BTC" tooltip="{{lockedBalanceBTC || 0 |noFractionNumber:8}} BTC"
tooltip-trigger="mouseenter" tooltip-trigger="mouseenter"
tooltip-placement="bottom">{{availableBalance || 0|noFractionNumber}} {{$root.unitName}} tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.unitName}}
</span> </span> &nbsp;<i class="fi-info medium" tooltip="Balance locked in pending transaction proposals" tooltip-placement="bottom"></i>
</div> </div>
<div class="line-sidebar-b"></div> <div class="line-sidebar-b"></div>
</div> </div>

View File

@ -34,7 +34,7 @@
|noFractionNumber}} {{$root.unitName}} |noFractionNumber}} {{$root.unitName}}
</span> </span>
<br> <br>
Available Locked &nbsp;
<span ng-if="$root.updatingBalance"> <span ng-if="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i> <i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span> </span>
@ -42,10 +42,10 @@
class="has-tip" class="has-tip"
data-options="disable_for_touch:true" data-options="disable_for_touch:true"
tooltip-popup-delay='500' tooltip-popup-delay='500'
tooltip="{{availableBalanceBTC || 0 |noFractionNumber:8}} BTC" tooltip="{{lockedBalanceBTC || 0 |noFractionNumber:8}} BTC"
tooltip-trigger="mouseenter" tooltip-trigger="mouseenter"
tooltip-placement="bottom">{{availableBalance || 0|noFractionNumber}} {{$root.unitName}} tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.unitName}}
</span> </span> &nbsp;<i class="fi-info medium" tooltip="Balance locked in pending transaction proposals" tooltip-placement="bottom"></i>
</div> </div>
<div class="line-sidebar"></div> <div class="line-sidebar"></div>
</header> </header>

View File

@ -10,8 +10,8 @@
{{address.balance || 0|noFractionNumber}} {{$root.unitName}} {{address.balance || 0|noFractionNumber}} {{$root.unitName}}
</span> </span>
<div style="margin-top:10px;"> <div style="margin-top:10px;">
<span class="label pointer" ng-click="openExternal(address.address)"> <span class="label pointer" open-external address="{{address.address}}">
<i class="fi-link">&nbsp;</i> Open in external aplication <i class="fi-link">&nbsp;</i> Open in external application
</span> </span>
</div> </div>
</div> </div>