display payment expiry time

This commit is contained in:
Javier 2016-02-04 10:33:41 -03:00
commit 1402eea43e
2 changed files with 29 additions and 7 deletions

View file

@ -367,6 +367,7 @@
class="p10" class="p10"
translate> Send All translate> Send All
</a> </a>
<time ng-show="!home.paymentExpired" translate>Payment expires: {{home.timeToExpire * 1000 | amTimeAgo}}</time>
</h4> </h4>
<div class="camera-icon" ng-show="index.isComplete"> <div class="camera-icon" ng-show="index.isComplete">
<qr-scanner on-scan="home.onQrCodeScanned(data)"></qr-scanner> <qr-scanner on-scan="home.onQrCodeScanned(data)"></qr-scanner>
@ -475,7 +476,7 @@
<a ng-click="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a> <a ng-click="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
</div> </div>
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}"> <div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}">
<button type="submit" class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline" <button type="submit" class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline || home.paymentExpired"
ng-style="{'background-color':index.backgroundColor}" translate> ng-style="{'background-color':index.backgroundColor}" translate>
Send Send
</button> </button>

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, txService) { angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, txSignService) {
var self = this; var self = this;
window.ignoreMobilePause = false; window.ignoreMobilePause = false;
@ -27,6 +27,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.showScanner = false; this.showScanner = false;
this.addr = {}; this.addr = {};
this.lockedCurrentFeePerKb = null; this.lockedCurrentFeePerKb = null;
self.paymentExpired = true;
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) { var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
self.setForm(data); self.setForm(data);
@ -37,6 +38,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.resetForm(); self.resetForm();
self.error = gettext('Could not recognize a valid Bitcoin QR Code'); self.error = gettext('Could not recognize a valid Bitcoin QR Code');
} }
$timeout(function () {
$rootScope.$appply();
}, 10);
}); });
var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) { var disablePaymentUriListener = $rootScope.$on('paymentUri', function(event, uri) {
@ -618,7 +623,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}); });
}; };
// Send // Send
this.canShowAlternative = function() { this.canShowAlternative = function() {
return $scope.showAlternative; return $scope.showAlternative;
@ -673,7 +678,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (isCordova && !this.isWindowsPhoneApp) { if (isCordova && !this.isWindowsPhoneApp) {
this.hideMenuBar(what); this.hideMenuBar(what);
} }
var self = this; var self = this;
if (isCordova && !this.isWindowsPhoneApp && what == 'address') { if (isCordova && !this.isWindowsPhoneApp && what == 'address') {
getClipboard(function(value) { getClipboard(function(value) {
@ -877,7 +882,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}); });
}, 100); }, 100);
}; };
this.acceptTx = function(txp) { this.acceptTx = function(txp) {
var self = this; var self = this;
@ -975,7 +980,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$timeout(function() { $timeout(function() {
$rootScope.$digest(); $rootScope.$digest();
}, 1); }, 1);
}; };
this.openPPModal = function(paypro) { this.openPPModal = function(paypro) {
$rootScope.modalOpened = true; $rootScope.modalOpened = true;
@ -1059,11 +1064,27 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self._paypro = paypro; self._paypro = paypro;
self.setForm(paypro.toAddress, (paypro.amount * satToUnit).toFixed(self.unitDecimals), paypro.memo); self.setForm(paypro.toAddress, (paypro.amount * satToUnit).toFixed(self.unitDecimals), paypro.memo);
_countDownPaymentTime(paypro.expires);
return cb(); return cb();
}); });
}, 1); }, 1);
}; };
function _countDownPaymentTime(time){
self.paymentExpired = false;
// self.timeToExpire = time;
self.timeToExpire = (Math.floor(Date.now()/1000) + 10);
var countDown = $interval(function(){
self.timeToExpire--;
if(self.timeToExpire <= Math.floor(Date.now() / 1000)){
self.paymentExpired = true;
self.timeToExpire = null;
self.error = gettext('Cannot send the payment: time to sign expired');
$interval.cancel(countDown);
}
}, 1000);
};
this.setFromUri = function(uri) { this.setFromUri = function(uri) {
var self = this; var self = this;
@ -1135,7 +1156,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
} }
}; };
// History // History
function strip(number) { function strip(number) {
return (parseFloat(number.toPrecision(12))); return (parseFloat(number.toPrecision(12)));