display paypro timer on confirm view
This commit is contained in:
parent
55af18de09
commit
c8330b4cd4
2 changed files with 59 additions and 15 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig) {
|
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig) {
|
||||||
var cachedTxp = {};
|
var cachedTxp = {};
|
||||||
var isChromeApp = platformInfo.isChromeApp;
|
var isChromeApp = platformInfo.isChromeApp;
|
||||||
|
var countDown = null;
|
||||||
$ionicConfig.views.swipeBackEnabled(false);
|
$ionicConfig.views.swipeBackEnabled(false);
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
|
|
@ -15,6 +15,12 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
$scope.toEmail = data.stateParams.toEmail;
|
$scope.toEmail = data.stateParams.toEmail;
|
||||||
$scope.description = data.stateParams.description;
|
$scope.description = data.stateParams.description;
|
||||||
$scope.paypro = data.stateParams.paypro;
|
$scope.paypro = data.stateParams.paypro;
|
||||||
|
$scope.paymentExpired = {
|
||||||
|
value: false
|
||||||
|
};
|
||||||
|
$scope.remainingTimeStr = {
|
||||||
|
value: null
|
||||||
|
};
|
||||||
initConfirm();
|
initConfirm();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -28,7 +34,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
}
|
}
|
||||||
// TODO (URL , etc)
|
// TODO (URL , etc)
|
||||||
if (!$scope.toAddress || !$scope.toAmount) {
|
if (!$scope.toAddress || !$scope.toAmount) {
|
||||||
$log.error('Bad params at amount')
|
$log.error('Bad params at amount');
|
||||||
throw ('bad params');
|
throw ('bad params');
|
||||||
}
|
}
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
|
|
@ -188,11 +194,45 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
$scope.paypro = null;
|
$scope.paypro = null;
|
||||||
|
|
||||||
$scope._paypro = paypro;
|
$scope._paypro = paypro;
|
||||||
|
_paymentTimeControl(paypro.expires);
|
||||||
return initConfirm();
|
return initConfirm();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function _paymentTimeControl(expirationTime) {
|
||||||
|
$scope.paymentExpired.value = false;
|
||||||
|
setExpirationTime();
|
||||||
|
|
||||||
|
countDown = $interval(function() {
|
||||||
|
setExpirationTime();
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
function setExpirationTime() {
|
||||||
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
if ($scope.paymentExpired.value)
|
||||||
|
popupService.showAlert(null, gettextCatalog.getString('The payment request has expired'));
|
||||||
|
|
||||||
|
if (now > expirationTime) {
|
||||||
|
setExpiredValues();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalSecs = expirationTime - now;
|
||||||
|
var m = Math.floor(totalSecs / 60);
|
||||||
|
var s = totalSecs % 60;
|
||||||
|
$scope.remainingTimeStr.value = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
|
||||||
|
};
|
||||||
|
|
||||||
|
function setExpiredValues() {
|
||||||
|
$scope.paymentExpired.value = true;
|
||||||
|
$scope.remainingTimeStr.value = gettextCatalog.getString('Expired');
|
||||||
|
if (countDown) $interval.cancel(countDown);
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
function setWallet(wallet, delayed) {
|
function setWallet(wallet, delayed) {
|
||||||
var stop;
|
var stop;
|
||||||
$scope.wallet = wallet;
|
$scope.wallet = wallet;
|
||||||
|
|
@ -299,12 +339,16 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.approve = function(onSendStatusChange) {
|
$scope.approve = function(onSendStatusChange) {
|
||||||
|
if ($scope._paypro && $scope.paymentExpired.value) {
|
||||||
|
popupService.showAlert(null, gettextCatalog.getString('The payment request has expired'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var wallet = $scope.wallet;
|
var wallet = $scope.wallet;
|
||||||
if (!wallet) {
|
if (!wallet) {
|
||||||
return setSendError(gettextCatalog.getString('No wallet selected'));
|
return setSendError(gettextCatalog.getString('No wallet selected'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||||
$log.info('No signing proposal: No private key');
|
$log.info('No signing proposal: No private key');
|
||||||
|
|
||||||
|
|
@ -343,10 +387,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
}
|
}
|
||||||
publishAndSign(wallet, txp, onSendStatusChange);
|
publishAndSign(wallet, txp, onSendStatusChange);
|
||||||
});
|
});
|
||||||
}
|
} else publishAndSign(wallet, txp, onSendStatusChange);
|
||||||
else publishAndSign(wallet, txp, onSendStatusChange);
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
$scope.sendStatus = '';
|
$scope.sendStatus = '';
|
||||||
|
|
@ -355,8 +397,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
publishAndSign(wallet, txp, onSendStatusChange);
|
publishAndSign(wallet, txp, onSendStatusChange);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
} else publishAndSign(wallet, txp, onSendStatusChange);
|
||||||
else publishAndSign(wallet, txp, onSendStatusChange);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
|
<div class="item single-line" ng-if="_paypro">
|
||||||
|
<span class="label" translate>Payment Expires:</span>
|
||||||
|
<span class="item-note" ng-if="!paymentExpired.value">{{remainingTimeStr.value}}</span>
|
||||||
|
<span class="item-note" ng-if="paymentExpired.value" ng-style="{'color': 'red'}" translate>Expired</span>
|
||||||
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<span class="label" translate>To</span>
|
<span class="label" translate>To</span>
|
||||||
<span class="payment-proposal-to">
|
<span class="payment-proposal-to">
|
||||||
|
|
@ -85,8 +90,7 @@
|
||||||
<slide-to-accept-success
|
<slide-to-accept-success
|
||||||
slide-success-show="sendStatus === 'success'"
|
slide-success-show="sendStatus === 'success'"
|
||||||
slide-success-on-confirm="onSuccessConfirm()"
|
slide-success-on-confirm="onSuccessConfirm()"
|
||||||
slide-success-hide-on-confirm="true"
|
slide-success-hide-on-confirm="true">
|
||||||
>
|
|
||||||
<span ng-hide="wallet.m > 1">Payment Sent</span>
|
<span ng-hide="wallet.m > 1">Payment Sent</span>
|
||||||
<span ng-show="wallet.m > 1">Proposal Created</span>
|
<span ng-show="wallet.m > 1">Proposal Created</span>
|
||||||
</slide-to-accept-success>
|
</slide-to-accept-success>
|
||||||
|
|
@ -95,8 +99,7 @@
|
||||||
wallet-selector-wallets="wallets"
|
wallet-selector-wallets="wallets"
|
||||||
wallet-selector-selected-wallet="wallet"
|
wallet-selector-selected-wallet="wallet"
|
||||||
wallet-selector-show="showWallets"
|
wallet-selector-show="showWallets"
|
||||||
wallet-selector-on-select="onWalletSelect"
|
wallet-selector-on-select="onWalletSelect">
|
||||||
>
|
|
||||||
</wallet-selector>
|
</wallet-selector>
|
||||||
|
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue