From 67bc8e7056f5a606239f0502b11df06b5fcf5b7f Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Tue, 13 Jun 2017 12:53:01 +0200 Subject: [PATCH] [enh] TX export: add currency in file name [fix] TX view: add special style for pending TX [fix] refactore service TX download history --- www/i18n/locale-en-GB.json | 2 +- www/i18n/locale-en.json | 2 +- www/i18n/locale-es-ES.json | 2 +- www/i18n/locale-fr-FR.json | 2 +- www/i18n/locale-nl-NL.json | 2 +- www/js/controllers/wallet-controllers.js | 7 ++-- www/js/services/tx-services.js | 38 +++++++++++-------- .../wallet/{view_tx.html => item_tx.html} | 8 ++-- www/templates/wallet/view_wallet_tx.html | 16 ++++---- 9 files changed, 44 insertions(+), 35 deletions(-) rename www/templates/wallet/{view_tx.html => item_tx.html} (85%) diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json index fdcb25ada..ee4450053 100644 --- a/www/i18n/locale-en-GB.json +++ b/www/i18n/locale-en-GB.json @@ -479,7 +479,7 @@ "STRONG_LEVEL": "Strong <span class=\"hidden-xs \">(6 questions minimum)</span>", "TITLE": "Sign-in and security" }, - "FILE_NAME": "Account statement {{pubkey|formatPubkey}} to {{currentTime|formatDateForFile}}.csv", + "FILE_NAME": "{{currency}} - Account statement {{pubkey|formatPubkey}} to {{currentTime|formatDateForFile}}.csv", "HEADERS": { "TIME": "Date", "AMOUNT": "Amount", diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index a6fb16a84..3ea592fb9 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -479,7 +479,7 @@ "STRONG_LEVEL": "Strong <span class=\"hidden-xs \">(6 questions minimum)</span>", "TITLE": "Sign-in and security" }, - "FILE_NAME": "Account statement {{pubkey|formatPubkey}} to {{currentTime|formatDateForFile}}.csv", + "FILE_NAME": "{{currency}} - Account statement {{pubkey|formatPubkey}} to {{currentTime|formatDateForFile}}.csv", "HEADERS": { "TIME": "Date", "AMOUNT": "Amount", diff --git a/www/i18n/locale-es-ES.json b/www/i18n/locale-es-ES.json index 35c567a21..57429cd20 100644 --- a/www/i18n/locale-es-ES.json +++ b/www/i18n/locale-es-ES.json @@ -479,7 +479,7 @@ "STRONG_LEVEL": "Alto <span class=\"hidden-xs \">(6 preguntas mÃnimo)</span>", "TITLE": "Cuenta y seguridad" }, - "FILE_NAME": "Encuesta cuenta {{pubkey|formatPubkey}} a {{currentTime|formatDateForFile}}.csv", + "FILE_NAME": "{{currency}} - Encuesta cuenta {{pubkey|formatPubkey}} a {{currentTime|formatDateForFile}}.csv", "HEADERS": { "TIME": "Fecha", "AMOUNT": "Cantidad", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 1b69134ec..30c995aa8 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -480,7 +480,7 @@ "STRONG_LEVEL": "Fort <span class=\"hidden-xs \">(6 questions minimum)</span>", "TITLE": "Compte et sécurité" }, - "FILE_NAME": "Relevé du compte {{pubkey|formatPubkey}} au {{currentTime|formatDateForFile}}.csv", + "FILE_NAME": "{{currency}} - Relevé du compte {{pubkey|formatPubkey}} au {{currentTime|formatDateForFile}}.csv", "HEADERS": { "TIME": "Date", "AMOUNT": "Montant", diff --git a/www/i18n/locale-nl-NL.json b/www/i18n/locale-nl-NL.json index 0aa917f0a..7cc873b26 100644 --- a/www/i18n/locale-nl-NL.json +++ b/www/i18n/locale-nl-NL.json @@ -387,7 +387,7 @@ "TITLE": "Voer een pseudoniem in", "HELP": "Een pseudoniem is nodig voor anderen om je te kunnen vinden." }, - "FILE_NAME": "Rekeningafschrift {{pubkey|formatPubkey}} {{currentTime|formatDateForFile}}.csv", + "FILE_NAME": "{{currency}} - Rekeningafschrift {{pubkey|formatPubkey}} {{currentTime|formatDateForFile}}.csv", "HEADERS": { "TIME": "Datum", "AMOUNT": "Bedrag", diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index e3c8ebc21..38846e96c 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -575,10 +575,11 @@ function WalletTxController($scope, $filter, $ionicPopover, $state, UIUtils, csW $scope.motion.show({ink: false}); }; - $scope.getDataForAccountStatement = function(options) { - options = options || -1;// all TX (full history) + $scope.downloadHistoryFile = function(options) { + options = options || {}; + options.fromTime = options.fromTime || -1; // default: full history var pubkey = $scope.formData.pubkey; - csTx.downloadAccountStatement(pubkey, options); + csTx.downloadHistoryFile(pubkey, options); }; // Updating wallet data diff --git a/www/js/services/tx-services.js b/www/js/services/tx-services.js index 3ee923007..bb1b9692e 100644 --- a/www/js/services/tx-services.js +++ b/www/js/services/tx-services.js @@ -83,7 +83,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', lockedOutput.amount = outputAmount; lockedOutputs = lockedOutputs || []; lockedOutputs.push(lockedOutput); - console.debug('[BMA] [TX] has locked output:', lockedOutput); + console.debug('[tx] has locked output:', lockedOutput); return sum + outputAmount; } @@ -337,13 +337,13 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', }); }; - // Download transactions history on current wallet - downloadAccountStatement = function(pubkey, options) { + // Download TX history file + downloadHistoryFile = function(pubkey, options) { - // Load account TX data - fromTime = options; + options = options || {}; + options.fromTime = options.fromTime || -1; - console.debug("[TX] Download transactions history on pubkey: " + pubkey); + console.debug("[tx] Exporting TX history for pubkey [{0}]".format(pubkey.substr(0,8))); return $q.all([ $translate(['ACCOUNT.HEADERS.TIME', @@ -351,16 +351,19 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', 'COMMON.PUBKEY', 'ACCOUNT.HEADERS.AMOUNT', 'ACCOUNT.HEADERS.COMMENT']), + //TODO : Utiliser plutôt csCurency pour avoir le bloc courant BMA.blockchain.current(), - loadData(pubkey, fromTime) + loadData(pubkey, options.fromTime) ]) .then(function(result){ var translations = result[0]; - //TODO : Utiliser plutôt csCurency - var currentTime = (result[1] && result[1].medianTime) || moment().utc().unix(); - result = result[2]; + var currentBlock = result[1]; + var currentTime = (currentBlock && currentBlock.medianTime) || moment().utc().unix(); + var currency = currentBlock && currentBlock.currency; + + result = result[2]; if (!result || !result.tx || !result.tx.history) return; // no TX @@ -368,12 +371,15 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', var formatPubkey = $filter('formatPubkey'); var formatDate = $filter('formatDate'); var formatDateForFile = $filter('formatDateForFile'); + var formatSymbol = $filter('currencySymbolNoHtml'); - var headers = [translations['ACCOUNT.HEADERS.TIME'], + var headers = [ + translations['ACCOUNT.HEADERS.TIME'], translations['COMMON.UID'], translations['COMMON.PUBKEY'], - translations['ACCOUNT.HEADERS.AMOUNT'], - translations['ACCOUNT.HEADERS.COMMENT']]; + translations['ACCOUNT.HEADERS.AMOUNT'] + ' (' + formatSymbol(currency) + ')', + translations['ACCOUNT.HEADERS.COMMENT'] + ]; var content = result.tx.history.reduce(function(res, tx){ return res.concat([ formatDate(tx.time), @@ -385,7 +391,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', }, [headers.join(';') + '\n']); var file = new Blob(content, {type: 'text/plain; charset=utf-8'}); - $translate('ACCOUNT.FILE_NAME', {pubkey: pubkey, currentTime : currentTime}) + $translate('ACCOUNT.FILE_NAME', {currency: currency, pubkey: pubkey, currentTime : currentTime}) .then(function(result){ FileSaver.saveAs(file, result); }) @@ -396,9 +402,9 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', return { id: id, load: loadData, - downloadAccountStatement: downloadAccountStatement, + downloadHistoryFile: downloadHistoryFile, // api extension - api: api, + api: api }; } diff --git a/www/templates/wallet/view_tx.html b/www/templates/wallet/item_tx.html similarity index 85% rename from www/templates/wallet/view_tx.html rename to www/templates/wallet/item_tx.html index 43edb8464..96dcdbea5 100644 --- a/www/templates/wallet/view_tx.html +++ b/www/templates/wallet/item_tx.html @@ -1,14 +1,15 @@ <i class="icon item-image " ng-if="::!tx.avatar" - ng-class="::{'ion-arrow-up-c': tx.isUD, 'ion-person': tx.uid, 'ion-card': !tx.uid && !tx.isUD}"></i> + ng-class="::{'ion-arrow-up-c': tx.isUD, 'ion-person dark': tx.uid, 'ion-card dark': !tx.uid && !tx.isUD}"></i> <i class="avatar" ng-if="::tx.avatar" style="background-image: url({{::tx.avatar.src}})"></i> <div class="row no-padding"> <div class="col no-padding"> - <a class="positive" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="tx.uid"> + <b class="ion-clock" ng-if="pending"> </b> + <a class="" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="tx.uid"> {{::tx.name||tx.uid}} </a> - <a class="dark" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="!tx.uid"> + <a class="gray" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="!tx.uid"> <i class="ion-key gray"></i> {{::tx.pubkey | formatPubkey}} </a> @@ -30,6 +31,7 @@ title="{{::tx.comment}}">{{::tx.comment}}</p> </div> <div class="col col-10 no-padding"> + <!-- not locked TX --> <span ng-if="::!tx.lockedOutputs" class="badge item-note" ng-class="{'badge-balanced': tx.amount > 0}"> <span ng-bind-html=":rebind:tx.amount| formatAmount"></span> diff --git a/www/templates/wallet/view_wallet_tx.html b/www/templates/wallet/view_wallet_tx.html index e72076efd..e0346fe38 100644 --- a/www/templates/wallet/view_wallet_tx.html +++ b/www/templates/wallet/view_wallet_tx.html @@ -43,7 +43,7 @@ </button> <button class="button button-stable button-small-padding icon ion-android-download ink" - ng-click="getDataForAccountStatement()" + ng-click="downloadHistoryFile()" title="{{'COMMON.BTN_DOWNLOAD_ACCOUNT_STATEMENT' | translate}}"> </button> @@ -59,7 +59,7 @@ <div class="row no-padding"> - <div class="col col-15 no-padding hidden-xs hidden-sm"></div> + <div class="col col-15 hidden-xs hidden-sm"> </div> <div class="col"> @@ -80,9 +80,10 @@ {{:locale:'ACCOUNT.PENDING_TX'|translate}} </span> - <div class="item item-tx item-icon-left" - ng-repeat="tx in formData.tx.pendings" - ng-include="'templates/wallet/view_tx.html'"> + <div class="item item-pending item-tx item-icon-left" + ng-repeat="tx in formData.tx.pendings" + ng-init="pending=true;" + ng-include="'templates/wallet/item_tx.html'"> </div> <!-- Last Transactions --> @@ -99,8 +100,7 @@ <div ng-repeat="tx in formData.tx.history" class="item item-tx item-icon-left" - ng-class="::ionItemClass" - ng-include="'templates/wallet/view_tx.html'"> + ng-include="'templates/wallet/item_tx.html'"> </div> <div class="item item-text-wrap text-center" ng-if="formData.tx.fromTime > 0"> <p> @@ -113,7 +113,7 @@ </div> </div> - <div class="col col-15 no-padding hidden-xs hidden-sm"></div> + <div class="col col-15 hidden-xs hidden-sm"> </div> </div> -- GitLab