From 6c4950151a6a61f23ace01bc512d6b7d9110a376 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Thu, 16 Aug 2018 09:13:17 +0200 Subject: [PATCH] [fix] Device: Show/loading indocator when scanning WIF/EWIF QRCode [enh] TX history: Auto refresh history when received new block --- www/i18n/locale-en-GB.json | 11 ++++++++ www/i18n/locale-en.json | 11 ++++++++ www/i18n/locale-fr-FR.json | 5 +++- www/i18n/locale-it-IT.json | 2 +- www/js/controllers/app-controllers.js | 5 +++- www/js/controllers/transfer-controllers.js | 1 + www/js/controllers/wallet-controllers.js | 32 +++++++++++++++++++++- www/js/services/http-services.js | 2 +- www/js/services/settings-services.js | 3 +- www/js/services/wallet-services.js | 15 +--------- www/templates/join/modal_join_member.html | 2 +- www/templates/settings/settings.html | 10 +++++++ www/templates/wallet/item_tx.html | 3 +- www/templates/wallet/new_transfer.html | 4 +-- www/templates/wallet/transfer_form.html | 8 ++++-- www/templates/wallet/view_wallet_tx.html | 3 +- 16 files changed, 88 insertions(+), 29 deletions(-) diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json index 1cf2efc69..adc1ddb8b 100644 --- a/www/i18n/locale-en-GB.json +++ b/www/i18n/locale-en-GB.json @@ -146,6 +146,13 @@ "BTN_RESET": "Restore default values", "EXPERT_MODE": "Enable expert mode", "EXPERT_MODE_HELP": "Allow to see more details", + "BLOCK_VALIDITY_WINDOW": "Block uncertainty time", + "BLOCK_VALIDITY_WINDOW_SHORT": "Time of uncertainty", + "BLOCK_VALIDITY_WINDOW_HELP": "Time to wait before considering an information is validated", + "BLOCK_VALIDITY_OPTION": { + "NONE": "No delay", + "N": "{{time | formatDuration}} ({{count}} blocks)" + }, "POPUP_PEER": { "TITLE" : "Duniter peer", "HOST" : "Address", @@ -442,6 +449,7 @@ "SHOW_ALL_TX": "Show all", "TX_FROM_DATE": "(current limit to {{fromTime|formatFromNowShort}})", "PENDING_TX": "Pending transactions", + "VALIDATING_TX": "Transactions being validated", "ERROR_TX": "Transaction not executed", "ERROR_TX_SENT": "Sent transactions", "PENDING_TX_RECEIVED": "Transactions awaiting receipt", @@ -595,6 +603,8 @@ "COMMENT_HELP": "Comment (optional)", "BTN_SEND": "Send", "BTN_ADD_COMMENT": "Add a comment", + "REST": "Rest of account", + "REST_TO": "to", "WARN_COMMENT_IS_PUBLIC": "Please note that <b>comments are public</b> (not encrypted).", "MODAL": { "TITLE": "Transfer" @@ -719,6 +729,7 @@ "CERTIFY_RULES_TITLE_UID": "Certify {{uid}}", "CERTIFY_RULES": "<b class=\"assertive\">Don't certify an account</b> if you believe that: <ul><li>1.) the issuers identity might be faked.<li>2.) the issuer already has another certified account.<li>3.) the issuer purposely or carelessly violates rule 1 or 2 (he certifies faked or double accounts).</ul></small><br/>Are you sure you want to certify this identity?", "TRANSFER": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li></ul><br/><b>Are-you sure you want to do this transfer?</b>", + "TRANSFER_ALL": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li><br/><li> - Rest : <b>{{restAmount}} {{unit}}</b> to <b>{{restTo}}</b></li></ul><br/><b>Are-you sure you want to do this transfer?</b>", "MEMBERSHIP_OUT": "This operation is <b>irreversible</b>.<br/></br/><b>Are you sure you want to terminate your membership?</b>", "MEMBERSHIP_OUT_2": "This operation is <b>irreversible</b>!<br/><br/>Are you sure you want to <b>terminate your membership</b>?", "LOGIN_UNUSED_WALLET_TITLE": "Typing error?", diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index 48f0eee6a..9f26d374d 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -146,6 +146,13 @@ "BTN_RESET": "Restore default values", "EXPERT_MODE": "Enable expert mode", "EXPERT_MODE_HELP": "Allow to see more details", + "BLOCK_VALIDITY_WINDOW": "Block uncertainty time", + "BLOCK_VALIDITY_WINDOW_SHORT": "Time of uncertainty", + "BLOCK_VALIDITY_WINDOW_HELP": "Time to wait before considering an information is validated", + "BLOCK_VALIDITY_OPTION": { + "NONE": "No delay", + "N": "{{time | formatDuration}} ({{count}} blocks)" + }, "POPUP_PEER": { "TITLE" : "Duniter peer", "HOST" : "Address", @@ -442,6 +449,7 @@ "SHOW_ALL_TX": "Show all", "TX_FROM_DATE": "(current limit to {{fromTime|formatFromNowShort}})", "PENDING_TX": "Pending transactions", + "VALIDATING_TX": "Transactions being validated", "ERROR_TX": "Transaction not executed", "ERROR_TX_SENT": "Sent transactions", "PENDING_TX_RECEIVED": "Transactions awaiting receipt", @@ -595,6 +603,8 @@ "COMMENT_HELP": "Comment (optional)", "BTN_SEND": "Send", "BTN_ADD_COMMENT": "Add a comment", + "REST": "Rest of account", + "REST_TO": "to", "WARN_COMMENT_IS_PUBLIC": "Please note that <b>comments are public</b> (not encrypted).", "MODAL": { "TITLE": "Transfer" @@ -719,6 +729,7 @@ "CERTIFY_RULES_TITLE_UID": "Certify {{uid}}", "CERTIFY_RULES": "<b class=\"assertive\">Don't certify an account</b> if you believe that: <ul><li>1.) the issuers identity might be faked.<li>2.) the issuer already has another certified account.<li>3.) the issuer purposely or carelessly violates rule 1 or 2 (he certifies faked or double accounts).</ul></small><br/>Are you sure you want to certify this identity?", "TRANSFER": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li></ul><br/><b>Are-you sure you want to do this transfer?</b>", + "TRANSFER_ALL": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li><br/><li> - Rest : <b>{{restAmount}} {{unit}}</b> to <b>{{restTo}}</b></li></ul><br/><b>Are-you sure you want to do this transfer?</b>", "MEMBERSHIP_OUT": "This operation is <b>irreversible</b>.<br/></br/><b>Are you sure you want to terminate your membership?</b>", "MEMBERSHIP_OUT_2": "This operation is <b>irreversible</b>!<br/><br/>Are you sure you want to <b>terminate your membership</b>?", "LOGIN_UNUSED_WALLET_TITLE": "Typing error?", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 826fcac21..a35a28af4 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -129,6 +129,8 @@ "ENABLE_UI_EFFECTS": "Activer les effets visuels", "HISTORY_SETTINGS": "Liste des opérations", "DISPLAY_UD_HISTORY": "Afficher les dividendes produits ?", + "TX_HISTORY_AUTO_REFRESH": "Activer le rafraichissement automatique ?", + "TX_HISTORY_AUTO_REFRESH_HELP": "Met à jour la liste des opérations à chaque nouveau bloc.", "AUTHENTICATION_SETTINGS": "Authentification", "KEEP_AUTH": "Expiration de l'authentification", "KEEP_AUTH_HELP": "Défini le moment où l'authentification est nettoyée de la mémoire", @@ -148,7 +150,7 @@ "EXPERT_MODE_HELP": "Permet un affichage plus détaillé", "BLOCK_VALIDITY_WINDOW": "Délai d'incertitude des blocs", "BLOCK_VALIDITY_WINDOW_SHORT": "Délai d'incertitude", - "BLOCK_VALIDITY_WINDOW_HELP": "Nombre de blocs à attentre, avant de considérer qu'une information est validée", + "BLOCK_VALIDITY_WINDOW_HELP": "Délai avant de considérer qu'une information est validée", "BLOCK_VALIDITY_OPTION": { "NONE": "Aucun délai", "N": "{{time | formatDuration}} ({{count}} blocs)" @@ -595,6 +597,7 @@ "TRANSFER": { "TITLE": "Virement", "SUB_TITLE": "Faire un virement", + "SUB_TITLE_ALL": "Vider le compte", "FROM": "De", "TO": "À", "AMOUNT": "Montant", diff --git a/www/i18n/locale-it-IT.json b/www/i18n/locale-it-IT.json index ae1c3365f..9fbd02943 100644 --- a/www/i18n/locale-it-IT.json +++ b/www/i18n/locale-it-IT.json @@ -1,6 +1,6 @@ { "COMMON": { - "APP_NAME": "ğ<b>change</b>", + "APP_NAME": "Cesium", "APP_VERSION": "v{{version}}", "APP_BUILD": "build {{build}}", "PUBKEY": "Chiave privata", diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index 6ff04549a..324281a83 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -90,6 +90,7 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ options = options || {}; options.withSecret = angular.isDefined(options.withSecret) && options.withSecret || true; options.password = function() { + UIUtils.loading.hide(); return Modals.showPassword({ title: 'ACCOUNT.SECURITY.KEYFILE.PASSWORD_POPUP.TITLE', subTitle: 'ACCOUNT.SECURITY.KEYFILE.PASSWORD_POPUP.HELP', @@ -97,14 +98,16 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ scope: $scope }) .then(function(password) { - if (password) UIUtils.loading.show(); // Timeout is need to force popup to be hide return $timeout(function() { + if (password) UIUtils.loading.show(); return password; }, 150); }); }; + UIUtils.loading.show(); + return CryptoUtils.parseWIF_or_EWIF(data, options) .catch(function(err) { if (err && err == 'CANCELLED') return; diff --git a/www/js/controllers/transfer-controllers.js b/www/js/controllers/transfer-controllers.js index 71bc10baa..4e74bf516 100644 --- a/www/js/controllers/transfer-controllers.js +++ b/www/js/controllers/transfer-controllers.js @@ -74,6 +74,7 @@ function TransferController($scope, $controller, UIUtils, csWot, csWallet) { } else if (state.stateParams.all) { parameters.all = state.stateParams.all; + $scope.formData.all = state.stateParams.all; } } diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index 205e3bd5f..a2bd0e330 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -572,11 +572,38 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state, function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, - UIUtils, Modals, BMA, csSettings, csWallet, csTx) { + UIUtils, Modals, BMA, csSettings, csCurrency, csWallet, csTx) { 'ngInject'; $scope.loading = true; $scope.settings = csSettings.data; + $scope.listeners = []; + + $scope.addListeners = function() { + if ($scope.settings.walletHistoryAutoRefresh) { + + $scope.listeners = [ + // Update on new block + csCurrency.api.data.on.newBlock($scope, function(block) { + if ($scope.loading) return; + console.debug("[wallet] Received new block. Will reload history."); + $timeout(function() { + $scope.doUpdate(true); + }, 300/*waiting for node cache propagation*/); + }) + ]; + } + else { + $scope.listeners = []; + } + }; + + $scope.removeListeners = function() { + _.forEach($scope.listeners, function(remove){ + remove(); + }); + $scope.listeners = []; + }; $scope.$on('$ionicView.enter', function(e, state) { $scope.loading = $scope.loading || (state.stateParams && state.stateParams.refresh); @@ -588,6 +615,7 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, $scope.updateView(); $scope.showFab('fab-transfer'); $scope.showHelpTip(); + $scope.addListeners(); UIUtils.loading.hide(); // loading could have be open (e.g. new account) // remove the stateParams @@ -627,7 +655,9 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, $scope.doUpdate = function(silent) { console.debug('[wallet] TX history reloading...'); return (silent ? + // If silent: just refresh csWallet.refreshData() : + // If not silent: show/hide loading indicator UIUtils.loading.show() .then(csWallet.refreshData) .then(UIUtils.loading.hide) diff --git a/www/js/services/http-services.js b/www/js/services/http-services.js index 71832c998..da79aa395 100644 --- a/www/js/services/http-services.js +++ b/www/js/services/http-services.js @@ -267,7 +267,7 @@ angular.module('cesium.http.services', ['cesium.cache.services']) var self = this; return _waitOpen(self) .then(function(){ - self.delegate && self.delegate.send(data); + if (self.delegate) self.delegate.send(data); }); }, close: function() { diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js index 5c9755996..d6571c640 100644 --- a/www/js/services/settings-services.js +++ b/www/js/services/settings-services.js @@ -60,6 +60,7 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) useLocalStorage: true, // override to false if no device walletHistoryTimeSecond: 30 * 24 * 60 * 60 /*30 days*/, walletHistorySliceSecond: 5 * 24 * 60 * 60 /*download using 5 days slice*/, + walletHistoryAutoRefresh: true, rememberMe: true, keepAuthIdle: 10 * 60, // 10min - override to false if no device showUDHistory: true, @@ -72,7 +73,7 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) userForumUrl: "https://forum.monnaie-libre.fr", latestReleaseUrl: "https://api.github.com/repos/duniter/cesium/releases/latest", duniterLatestReleaseUrl: "https://api.github.com/repos/duniter/duniter/releases/latest", - blockValidityWindow: 0, + blockValidityWindow: 6, helptip: { enable: true, installDocUrl: "https://duniter.org/en/wiki/duniter/install/", diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index d69916a2c..f297709a6 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -980,29 +980,16 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se .then(function(block) { console.debug("[wallet] Using last valid block as TX reference (to avoid network fork): ", block); - data.sources.forEach(function(src) { - console.log(src); - }); - return transfer(destPub, amount, comments, useRelative, restPub, block) .then(function() { - - // If more money: transfer all to restPub if (data.balance > 0 && restPub) { - - console.debug("Sending the rest amount to {" + restPub + '}...'); - data.sources.forEach(function(src) { - console.debug(src); - }); - console.debug("[wallet] Wallet has some more money: transfering fund to [{0}]".format(restPub.substring(0,6))); return transfer(restPub, data.balance, undefined/*comments*/, false/*useRelative*/, restPub, block); } }); - }) - + }); }, diff --git a/www/templates/join/modal_join_member.html b/www/templates/join/modal_join_member.html index 12ea52553..8fbde9841 100644 --- a/www/templates/join/modal_join_member.html +++ b/www/templates/join/modal_join_member.html @@ -41,7 +41,7 @@ </ion-header-bar> - <ion-slides options="slides.options" slider="slides.slider" ng-init="console.log('START SLIDE');"> + <ion-slides options="slides.options" slider="slides.slider"> <!-- STEP 1: license --> <ion-slide-page ng-if="licenseFileUrl"> diff --git a/www/templates/settings/settings.html b/www/templates/settings/settings.html index 3638125de..b581e5ab1 100644 --- a/www/templates/settings/settings.html +++ b/www/templates/settings/settings.html @@ -130,6 +130,16 @@ </label> </div> + <div class="item item-toggle dark"> + <div class="input-label" translate>SETTINGS.TX_HISTORY_AUTO_REFRESH</div> + <label class="toggle toggle-royal"> + <input type="checkbox" ng-model="formData.walletHistoryAutoRefresh" > + <div class="track"> + <div class="handle"></div> + </div> + </label> + </div> + <!-- Allow extension here --> <cs-extension-point name="history"></cs-extension-point> diff --git a/www/templates/wallet/item_tx.html b/www/templates/wallet/item_tx.html index a1cfe6521..cd56e4d5d 100644 --- a/www/templates/wallet/item_tx.html +++ b/www/templates/wallet/item_tx.html @@ -5,7 +5,8 @@ <div class="row no-padding"> <div class="col no-padding"> - <b class="ion-clock" ng-if="::(pending||validating)"> </b> + <b class="ion-clock" ng-if="::pending"> </b> + <b class="ion-clock" ng-if="::validating"> </b> <a class="" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="tx.uid"> {{::tx.name||tx.uid}} </a> diff --git a/www/templates/wallet/new_transfer.html b/www/templates/wallet/new_transfer.html index 13632341a..d1a6fc1d4 100644 --- a/www/templates/wallet/new_transfer.html +++ b/www/templates/wallet/new_transfer.html @@ -13,8 +13,8 @@ <div class="row no-padding-xs"> <div class="col col-20 hidden-xs hidden-sm"> </div> <div class="col no-padding-xs"> - <h2 class="hidden-xs hidden-sm"> - {{'TRANSFER.SUB_TITLE'|translate}} + <h2 class="hidden-xs hidden-sm" ng-if="formData"> + {{(formData.all ? 'TRANSFER.SUB_TITLE_ALL' : 'TRANSFER.SUB_TITLE')|translate}} </h2> <h4 class="hidden-xs hidden-sm"> </h4> <ng-include src="'templates/wallet/transfer_form.html'"></ng-include> diff --git a/www/templates/wallet/transfer_form.html b/www/templates/wallet/transfer_form.html index 7c187d2c9..fedf8ae7c 100644 --- a/www/templates/wallet/transfer_form.html +++ b/www/templates/wallet/transfer_form.html @@ -96,7 +96,7 @@ <a class="item item-icon-right gray ink" ng-class="{'item-input-error': form.$submitted && !formData.destPub}" ng-click="showWotLookupModal('restPub')" - ng-if="formData.all && formData.restAmount > 0"> + ng-if="formData.all && formData.restAmount"> <span class="gray"> <i translate>TRANSFER.REST</i> <ng-if ng-if="formData.restAmount">(<i ng-bind-html="formData.restAmount|formatAmount:{useRelative: formData.useRelative, currency:currency}"></i>)</ng-if> @@ -181,8 +181,10 @@ <button class="button button-clear button-dark ink" ng-click="cancel()" type="button" translate>COMMON.BTN_CANCEL </button> - <button class="button button-positive ink" type="submit"> - {{'TRANSFER.BTN_SEND' | translate}} + <button class="button ink" + ng-class="{'button-assertive': formData.all, 'button-positive': !formData.all}" + type="submit" translate> + TRANSFER.BTN_SEND </button> </div> </form> diff --git a/www/templates/wallet/view_wallet_tx.html b/www/templates/wallet/view_wallet_tx.html index 9e424f8a4..995d810d1 100644 --- a/www/templates/wallet/view_wallet_tx.html +++ b/www/templates/wallet/view_wallet_tx.html @@ -96,6 +96,7 @@ <div class="item item-pending item-tx item-icon-left" ng-repeat="tx in formData.tx.validating" + ng-init="validating=true;" ng-include="'templates/wallet/item_tx.html'"> </div> @@ -109,8 +110,6 @@ <span class="gray">{{:locale:'ACCOUNT.NO_TX'|translate}}</span> </span> - - <div ng-repeat="tx in formData.tx.history" class="item item-tx item-icon-left" ng-include="::!tx.isUD ? 'templates/wallet/item_tx.html' : 'templates/wallet/item_ud.html'"> -- GitLab