From 50599b09316a932b695514b0fad7e27a359a1cdc Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Fri, 16 Jun 2017 18:13:24 +0200 Subject: [PATCH] [fix] Graph must not starts before currency starts - fix #483 [fix] Graph: keep hidden datasets and scale in the browser URL [enh] add SSL icon on peer info, in top bar [enh] Peer info: show current block and SSL [enh] Format block number using integer formatter --- scss/ionic.app.scss | 2 +- 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/app-controllers.js | 4 +- www/js/services/settings-services.js | 1 - www/js/vendor/numeral.fr.js | 8 +- .../es/templates/message/compose_form.html | 2 + .../js/controllers/account-controllers.js | 19 +-- .../js/controllers/blockchain-controllers.js | 62 ++++++---- .../js/controllers/common-controllers.js | 116 +++++++++++++++--- .../js/controllers/currency-controllers.js | 76 +++++++----- .../graph/js/services/color-services.js | 4 + .../graph/js/services/data-services.js | 23 ++-- .../graph/templates/account/view_stats.html | 31 +++-- .../templates/blockchain/view_stats.html | 44 ++++--- .../common/popover_range_actions.html | 2 +- .../currency/graph_monetary_mass.html | 3 +- .../templates/currency/view_stats_lg.html | 30 +++-- .../templates/currency/view_wot_stats.html | 4 +- www/templates/blockchain/item_block.html | 2 +- .../blockchain/item_block_empty_lg.html | 2 +- www/templates/menu.html | 5 +- www/templates/network/items_peers.html | 2 +- www/templates/network/popover_peer_info.html | 23 +++- www/templates/network/view_peer.html | 2 +- 28 files changed, 321 insertions(+), 156 deletions(-) diff --git a/scss/ionic.app.scss b/scss/ionic.app.scss index e8df662ed..da11386b3 100644 --- a/scss/ionic.app.scss +++ b/scss/ionic.app.scss @@ -1043,6 +1043,7 @@ $screen-menu: 845px; } .card-footer { padding-left: 88px; + overflow: hidden; .pull-right { a { @@ -1344,7 +1345,6 @@ $ionicon-var-badge-editable: $ionicon-var-edit + "\00a0"; **********/ .modal.modal-full-height { - //height: 100% !important; bottom: 0px; } diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json index ee4450053..c4924543d 100644 --- a/www/i18n/locale-en-GB.json +++ b/www/i18n/locale-en-GB.json @@ -156,7 +156,7 @@ "VIEW": { "HEADER_TITLE": "Block #{{number}}-{{hash|formatHash}}", "TITLE_CURRENT": "Current block", - "TITLE": "Block #{{number}}", + "TITLE": "Block #{{number|formatInteger}}", "COMPUTED_BY": "Computed by", "SHOW_RAW": "Show raw data", "TECHNICAL_DIVIDER": "Technical informations", diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index 3ea592fb9..98836cf88 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -156,7 +156,7 @@ "VIEW": { "HEADER_TITLE": "Block #{{number}}-{{hash|formatHash}}", "TITLE_CURRENT": "Current block", - "TITLE": "Block #{{number}}", + "TITLE": "Block #{{number|formatInteger}}", "COMPUTED_BY": "Computed by", "SHOW_RAW": "Show raw data", "TECHNICAL_DIVIDER": "Technical informations", diff --git a/www/i18n/locale-es-ES.json b/www/i18n/locale-es-ES.json index 57429cd20..4bfefa465 100644 --- a/www/i18n/locale-es-ES.json +++ b/www/i18n/locale-es-ES.json @@ -156,7 +156,7 @@ "VIEW": { "HEADER_TITLE": "Bloque #{{number}}-{{hash|formatHash}}", "TITLE_CURRENT": "Bloque corriente", - "TITLE": "Bloque #{{number}}", + "TITLE": "Bloque #{{number|formatInteger}}", "COMPUTED_BY": "Calculado por el nodo de", "SHOW_RAW": "Ver el fichero en bruto", "TECHNICAL_DIVIDER": "Informaciónes técnicas", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 30c995aa8..d711f0571 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -157,7 +157,7 @@ "VIEW": { "HEADER_TITLE": "Bloc #{{number}}-{{hash|formatHash}}", "TITLE_CURRENT": "Bloc courant", - "TITLE": "Bloc #{{number}}", + "TITLE": "Bloc #{{number|formatInteger}}", "COMPUTED_BY": "Calculé par le noeud de", "SHOW_RAW": "Voir le fichier brut", "TECHNICAL_DIVIDER": "Informations techniques", diff --git a/www/i18n/locale-nl-NL.json b/www/i18n/locale-nl-NL.json index 7cc873b26..ad2d1a383 100644 --- a/www/i18n/locale-nl-NL.json +++ b/www/i18n/locale-nl-NL.json @@ -146,7 +146,7 @@ "VIEW": { "HEADER_TITLE": "Blok #{{number}}-{{hash|formatHash}}", "TITLE_CURRENT": "Huidige blok", - "TITLE": "Blok #{{number}}", + "TITLE": "Blok #{{number|formatInteger}}", "COMPUTED_BY": "Berekend door het knooppunt", "SHOW_RAW": "Bekijk RAW-bestand", "TECHNICAL_DIVIDER": "Technische informatie", diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index 4c8e26490..7c059aa87 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -433,12 +433,10 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ //////////////////////////////////////// $scope.showNodeListPopover = function(event) { - UIUtils.popover.show(event, { + return UIUtils.popover.show(event, { templateUrl: 'templates/network/popover_peer_info.html', autoremove: true, scope: $scope.$new(true) - }).then(function(res) { - console.log(res); }); }; diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js index e4fb89690..210875804 100644 --- a/www/js/services/settings-services.js +++ b/www/js/services/settings-services.js @@ -65,7 +65,6 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) httpsMode: false, expertMode: false, decimalCount: 4, - forceNetworkViewToHttp: false, uiEffects: true, minVersion: csConfig.compatProtocol_0_80 ? '0.80.0' : '0.90.0', // TODO update this if need newIssueUrl: "https://github.com/duniter/cesium/issues/new?labels=bug", diff --git a/www/js/vendor/numeral.fr.js b/www/js/vendor/numeral.fr.js index 47a9950b4..89679d859 100644 --- a/www/js/vendor/numeral.fr.js +++ b/www/js/vendor/numeral.fr.js @@ -14,10 +14,10 @@ "decimal": "," }, "abbreviations": { - "thousand": "<small>x10<sup>3</sup></small>", - "million": "<small>x10<sup>6</sup></small>", - "billion": "<small>x10<sup>9</sup></small>", - "trillion": "<small>x10<sup>12</sup></small>" + "thousand": "x10^3", + "million": "x10^6", + "billion": "x10^9", + "trillion": "x10^12" }, "ordinal": function (number) { return (number === 1) ? 'er' : 'ième'; diff --git a/www/plugins/es/templates/message/compose_form.html b/www/plugins/es/templates/message/compose_form.html index 1b1b70220..ab00ec8bc 100644 --- a/www/plugins/es/templates/message/compose_form.html +++ b/www/plugins/es/templates/message/compose_form.html @@ -2,6 +2,8 @@ <div class="list" ng-init="setForm(messageForm)"> + <!-- TODO: allow multi dest ? + Do IT with a ion-scroll - see https://stackoverflow.com/a/38308803 --> <a class="item item-icon-right gray ink" ng-class="{'item-input-error': form.$submitted && !formData.destPub}" ng-click="showWotLookupModal()"> diff --git a/www/plugins/graph/js/controllers/account-controllers.js b/www/plugins/graph/js/controllers/account-controllers.js index c3e9d9af8..923db559a 100644 --- a/www/plugins/graph/js/controllers/account-controllers.js +++ b/www/plugins/graph/js/controllers/account-controllers.js @@ -29,7 +29,7 @@ angular.module('cesium.graph.account.controllers', ['chart.js', 'cesium.graph.se $stateProvider .state('app.view_wallet_stats', { - url: "/wallet/stats?t&stepUnit", + url: "/wallet/stats?t&stepUnit&hide&scale", views: { 'menuContent': { templateUrl: "plugins/graph/templates/account/view_stats.html" @@ -41,7 +41,7 @@ angular.module('cesium.graph.account.controllers', ['chart.js', 'cesium.graph.se }) .state('app.wot_identity_stats', { - url: "/wot/:pubkey/stats?t&stepUnit", + url: "/wot/:pubkey/stats?t&stepUnit&hide&scale", views: { 'menuContent': { templateUrl: "plugins/graph/templates/account/view_stats.html" @@ -100,7 +100,7 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t }; - $scope.inheritedSetScale = $scope.setScale; + var defaultSetScale = $scope.setScale; $scope.setScale = function(scale) { // linear scale: sent values as negative if (scale === 'linear') { @@ -115,7 +115,8 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t }); } - $scope.inheritedSetScale(scale); + // call default implementation + defaultSetScale(scale); }; $scope.load = function(updateTimePct) { @@ -168,15 +169,15 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t result.balance ]; - var displayFormats = { + var datePatterns = { hour: translations['COMMON.DATE_PATTERN'], day: translations['COMMON.DATE_SHORT_PATTERN'], month: translations['COMMON.DATE_MONTH_YEAR_PATTERN'] }; - var displayFormat = displayFormats[$scope.formData.rangeDuration]; // Labels + var labelPattern = datePatterns[$scope.formData.rangeDuration]; $scope.labels = result.times.reduce(function(res, time) { - return res.concat(moment.unix(time).local().format(displayFormat)); + return res.concat(moment.unix(time).local().format(labelPattern)); }, []); // Colors @@ -204,7 +205,8 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t ] }, legend: { - display: true + display: true, + onClick: $scope.onLegendClick }, tooltips: { enabled: true, @@ -219,7 +221,6 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t } } }; - $scope.setScale($scope.scale); $scope.datasetOverride = [ { diff --git a/www/plugins/graph/js/controllers/blockchain-controllers.js b/www/plugins/graph/js/controllers/blockchain-controllers.js index 165d0fe0a..ab7af7934 100644 --- a/www/plugins/graph/js/controllers/blockchain-controllers.js +++ b/www/plugins/graph/js/controllers/blockchain-controllers.js @@ -7,7 +7,7 @@ angular.module('cesium.graph.blockchain.controllers', ['chart.js', 'cesium.servi $stateProvider .state('app.blockchain_stats', { - url: "/blockchain/stats?currency", + url: "/blockchain/stats?currency&stepUnit&t&hide&scale", views: { 'menuContent': { templateUrl: "plugins/graph/templates/blockchain/view_stats.html" @@ -37,6 +37,8 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, // Initialize the super class and extend it. angular.extend(this, $controller('GpCurrencyAbstractCtrl', {$scope: $scope})); + $scope.displayRightAxis = true; + $scope.init = function(e, state) { if (state && state.stateParams) { @@ -44,12 +46,18 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, if (!$scope.formData.issuer && state && state.stateParams && state.stateParams.pubkey) { // Currency parameter $scope.formData.issuer = state.stateParams.pubkey; } + + // get the pubkey + if (!$scope.formData.issuer && state && state.stateParams && state.stateParams.pubkey) { // Currency parameter + $scope.formData.issuer = state.stateParams.pubkey; + } } }; $scope.load = function(updateTimePct) { var formData = $scope.formData; + console.log(angular.copy($scope.formData)); return $q.all([ @@ -73,6 +81,12 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, var title = result[0]; var translations = result[1]; + var datePatterns = { + hour: translations['COMMON.DATE_PATTERN'], + day: translations['COMMON.DATE_SHORT_PATTERN'], + month: translations['COMMON.DATE_MONTH_YEAR_PATTERN'] + }; + result = result[2]; if (!result || !result.times) return; // no data @@ -86,8 +100,8 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, if ($scope.formData.rangeDuration != 'hour') { $scope.data = [ result.amount, - result.count, - result.avgByBlock + result.count/*, + result.avgByBlock*/ ]; } else { @@ -98,17 +112,9 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, } // Labels - $scope.labels = result.labels; - - var displayFormats = { - hour: translations['COMMON.DATE_PATTERN'], - day: translations['COMMON.DATE_SHORT_PATTERN'], - month: translations['COMMON.DATE_MONTH_YEAR_PATTERN'] - }; - var displayFormat = displayFormats[$scope.formData.rangeDuration]; - // Labels + var labelPattern = datePatterns[$scope.formData.rangeDuration]; $scope.labels = result.times.reduce(function(res, time) { - return res.concat(moment.unix(time).local().format(displayFormat)); + return res.concat(moment.unix(time).local().format(labelPattern)); }, []); // Colors @@ -129,23 +135,27 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, yAxes: [ { id: 'y-axis-amount', - type: 'linear', position: 'left' }, { id: 'y-axis-count', - display: false, - type: 'linear', - position: 'right' - }, + display: $scope.displayRightAxis, + position: 'right', + gridLines: { + drawOnChartArea: false + } + }/*, { id: 'y-axis-avg', display: false, - type: 'linear', position: 'right' - } + }*/ ] }, + legend: { + display: $scope.displayRightAxis, + onClick: $scope.onLegendClick + }, tooltips: { enabled: true, mode: 'index', @@ -163,8 +173,7 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, } }; - $scope.setScale($scope.scale); - + // Override dataset config $scope.datasetOverride = [ { yAxisID: 'y-axis-amount', @@ -179,24 +188,25 @@ function GpBlockchainTxCountController($scope, $controller, $q, $state, $filter, fill: false, borderColor: gpColor.rgba.gray(0.5), borderWidth: 2, + backgroundColor: gpColor.rgba.gray(0.5), pointBackgroundColor: gpColor.rgba.gray(0.5), pointBorderColor: gpColor.rgba.white(), pointHoverBackgroundColor: gpColor.rgba.gray(1), - pointHoverBorderColor: 'rgba(0,0,0,0)', + pointHoverBorderColor: gpColor.rgba.translucent(), pointRadius: 3 - }, + }/*, { yAxisID: 'y-axis-avg', type: 'line', label: translations['GRAPH.BLOCKCHAIN.TX_AVG_BY_BLOCK'], fill: false, - showLine: false, + showLine: true, borderColor: 'rgba(0,0,0,0)', pointBackgroundColor: 'rgba(0,0,0,0)', pointBorderColor: 'rgba(0,0,0,0)', pointHoverBackgroundColor: 'rgba(0,0,0,0)', pointHoverBorderColor: 'rgba(0,0,0,0)' - } + }*/ ]; }); }; diff --git a/www/plugins/graph/js/controllers/common-controllers.js b/www/plugins/graph/js/controllers/common-controllers.js index 69c80fd5b..95fb03db8 100644 --- a/www/plugins/graph/js/controllers/common-controllers.js +++ b/www/plugins/graph/js/controllers/common-controllers.js @@ -12,7 +12,9 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist useRelative: csSettings.data.useRelative, timePct: 100, rangeDuration: 'day', - firstBlockTime: 0 + firstBlockTime: 0, + scale: 'linear', + hide: [] }; $scope.formData.useRelative = false; /*angular.isDefined($scope.formData.useRelative) ? $scope.formData.useRelative : csSettings.data.useRelative;*/ @@ -37,14 +39,27 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist if (!$scope.formData.currency && state && state.stateParams && state.stateParams.currency) { // Currency parameter $scope.formData.currency = state.stateParams.currency; } - if (state.stateParams.timePct) { + if (state.stateParams.t) { + $scope.formData.timePct = state.stateParams.t; + } + else if (state.stateParams.timePct) { $scope.formData.timePct = state.stateParams.timePct; } - if (state.stateParams.group) { - $scope.formData.rangeDuration = state.stateParams.group; + if (state.stateParams.stepUnit) { + $scope.formData.rangeDuration = state.stateParams.stepUnit; + } + if (state.stateParams.scale) { + $scope.formData.scale = state.stateParams.scale; + } + // Allow to hide some dataset + if (state.stateParams.hide) { + $scope.formData.hide = state.stateParams.hide.split(',').reduce(function(res, index){ + return res.concat(parseInt(index)); + }, []); } } + // Should be override by subclasses $scope.init(e, state); // Make sure there is currency, or load it not @@ -61,8 +76,13 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist }); } - $scope.load() + $scope.load() // Should be override by subclasses .then(function () { + // Update scale + $scope.setScale($scope.formData.scale); + // Hide some dataset by index (read from state params) + $scope.updateHiddenDataset(); + $scope.loading = false; }); } @@ -78,8 +98,10 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist }); $scope.stateParams = $scope.stateParams || {}; - $scope.stateParams.t = $scope.formData.timePct < 100 || $scope.formData.timePct >= 0 ? $scope.formData.timePct : undefined; + $scope.stateParams.t = ($scope.formData.timePct >= 0 && $scope.formData.timePct < 100) ? $scope.formData.timePct : undefined; $scope.stateParams.stepUnit = $scope.formData.rangeDuration != 'day' ? $scope.formData.rangeDuration : undefined; + $scope.stateParams.hide = $scope.formData.hide && $scope.formData.hide.length ? $scope.formData.hide.join(',') : undefined; + $scope.stateParams.scale = $scope.formData.scale != 'linear' ?$scope.formData.scale : undefined; $state.go($scope.stateName, $scope.stateParams, { reload: false, @@ -102,7 +124,7 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist } }); - $scope.init = function(stateParams) { + $scope.init = function(e, state) { // Should be override by subclasses }; @@ -111,16 +133,19 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist }; $scope.toggleScale = function() { - $scope.setScale($scope.scale === 'linear' ? 'logarithmic' : 'linear'); + $scope.setScale($scope.formData.scale === 'linear' ? 'logarithmic' : 'linear'); + $scope.updateLocation(); }; $scope.setScale = function(scale) { $scope.hideActionsPopover(); - $scope.scale = scale; + $scope.formData.scale = scale; + + if (!$scope.options || !$scope.options.scales || !$scope.options.scales.yAxes) return; var format = $filter('formatInteger'); - _.forEach($scope.options.scales.yAxes, function(yAxe) { + _.forEach($scope.options.scales.yAxes, function(yAxe, index) { yAxe.type = scale; yAxe.ticks = yAxe.ticks || {}; if (scale == 'linear') { @@ -163,9 +188,62 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist $scope.updateLocation(); }; + $scope.updateHiddenDataset = function(datasetOverride) { + datasetOverride = datasetOverride || $scope.datasetOverride || {}; + + _.forEach($scope.formData.hide||[], function(index) { + if (!datasetOverride[index]) return; // skip invalid index + + // Hide the dataset (stroke the legend) + datasetOverride[index].hidden = true; + + // If this dataset has an yAxis, hide it (if not used elsewhere) + var yAxisID = datasetOverride[index].yAxisID; + var yAxe = yAxisID && $scope.options && $scope.options.scales && _.findWhere($scope.options.scales.yAxes||[], {id: yAxisID}); + if (yAxisID && yAxe) { + var yAxisDatasetCount = _.filter(datasetOverride, function(dataset) { + return dataset.yAxisID === yAxisID; + }).length; + if (yAxisDatasetCount == 1) { + yAxe.display = false; + } + } + + }); + }; + + $scope.onLegendClick = function(e, legendItem) { + var index = legendItem.datasetIndex; + var ci = this.chart; + var meta = ci.getDatasetMeta(index); + + // Hide/show the dataset + meta.hidden = meta.hidden === null? !ci.data.datasets[index].hidden : null; + + // Update yAxis display (if used by only ONE dataset) + if (ci.config && ci.config.data && ci.config.data.datasets) { + var yAxisDatasetCount = _.filter(ci.config.data.datasets, function(dataset) { + return dataset.yAxisID && dataset.yAxisID === meta.yAxisID; + }).length; + if (yAxisDatasetCount === 1) { + ci.scales[meta.yAxisID].options.display = !(meta.hidden === true); + } + } + + // We hid a dataset ... rerender the chart + ci.update(); + + // Update window location + $scope.formData.hide = $scope.formData.hide||[]; + $scope.formData.hide = meta.hidden ? + _.union($scope.formData.hide, [index]) : + _.difference($scope.formData.hide, [index]); + $scope.updateLocation(); + }; + $scope.goPreviousRange = function() { - if ($scope.loading) return; - $scope.loading = true; + if ($scope.loadingRange) return; + $scope.loadingRange = true; $scope.formData.startTime -= $scope.times.length * $scope.formData.rangeDurationSec; if ($scope.formData.startTime < $scope.formData.firstBlockTime) { @@ -178,13 +256,13 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist // Update location $scope.updateLocation(); - $scope.loading = false; + $scope.loadingRange = false; }); }; $scope.goNextRange = function() { - if ($scope.loading) return; - $scope.loading = true; + if ($scope.loadingRange) return; + $scope.loadingRange = true; $scope.formData.startTime += $scope.times.length * $scope.formData.rangeDurationSec; if ($scope.formData.startTime > $scope.formData.firstBlockTime + $scope.formData.currencyAge - $scope.formData.timeWindow) { $scope.formData.startTime = $scope.formData.firstBlockTime + $scope.formData.currencyAge - $scope.formData.timeWindow; @@ -196,13 +274,13 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist // Update location $scope.updateLocation(); - $scope.loading = false; + $scope.loadingRange = false; }); }; $scope.onRangeChanged = function() { - if ($scope.loading) return; - $scope.loading = true; + if ($scope.loadingRange) return; + $scope.loadingRange = true; $scope.formData.startTime = $scope.formData.firstBlockTime + (parseFloat($scope.formData.timePct) / 100) * ($scope.formData.currencyAge - $scope.formData.timeWindow) ; $scope.formData.endTime = $scope.formData.startTime + $scope.times.length * $scope.formData.rangeDurationSec; @@ -212,7 +290,7 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist // Update location $scope.updateLocation(); - $scope.loading = false; + $scope.loadingRange = false; }); }; diff --git a/www/plugins/graph/js/controllers/currency-controllers.js b/www/plugins/graph/js/controllers/currency-controllers.js index af172d4f3..992353e9c 100644 --- a/www/plugins/graph/js/controllers/currency-controllers.js +++ b/www/plugins/graph/js/controllers/currency-controllers.js @@ -40,7 +40,7 @@ angular.module('cesium.graph.currency.controllers', ['chart.js', 'cesium.graph.s } }) .state('app.currency_stats_lg', { - url: "/currency/stats/lg", + url: "/currency/stats/lg?hide&scale", views: { 'menuContent': { templateUrl: "plugins/graph/templates/currency/view_stats_lg.html" @@ -111,6 +111,11 @@ function GpCurrencyMonetaryMassController($scope, $controller, $q, $state, $tran $scope.formData.useRelative : csSettings.data.useRelative; $scope.displayShareAxis = true; + $scope.hiddenDatasets = []; + + $scope.init = function(e, state) { + // nothing to do here + }; $scope.onUseRelativeChanged = function() { if (!$scope.loading) { @@ -145,7 +150,7 @@ function GpCurrencyMonetaryMassController($scope, $controller, $q, $state, $tran // Choose a date formatter, depending on the blocks period var blocksPeriod = result.times[result.times.length-1] - result.times[0]; var formatDate; - if (blocksPeriod < 15778800/* less than 6 months*/) { + if (blocksPeriod < 31557600/* less than 1 year */) { formatDate = $filter('formatDateShort'); } else { @@ -205,7 +210,8 @@ function GpCurrencyMonetaryMassController($scope, $controller, $q, $state, $tran text: translations['GRAPH.CURRENCY.MONETARY_MASS_TITLE'] }, legend: { - display: $scope.displayShareAxis + display: $scope.displayShareAxis, + onClick: $scope.onLegendClick }, scales: { yAxes: [ @@ -215,7 +221,10 @@ function GpCurrencyMonetaryMassController($scope, $controller, $q, $state, $tran { id: 'y-axis-mn', display: $scope.displayShareAxis, - position: 'right' + position: 'right', + gridLines: { + drawOnChartArea: false + } } ] }, @@ -231,15 +240,16 @@ function GpCurrencyMonetaryMassController($scope, $controller, $q, $state, $tran } } }; - $scope.setScale($scope.scale); $scope.datasetOverride = [ { yAxisID: 'y-axis-mass', type: 'line', label: translations['GRAPH.CURRENCY.MONETARY_MASS_LABEL'], - hoverBackgroundColor: gpColor.rgba.calm(0.6), - borderWidth: 1 + borderWidth: 2, + pointRadius: 0, + pointHitRadius: 4, + pointHoverRadius: 3 }, { yAxisID: 'y-axis-mn', @@ -247,16 +257,20 @@ function GpCurrencyMonetaryMassController($scope, $controller, $q, $state, $tran label: translations['GRAPH.CURRENCY.MONETARY_MASS_SHARE_LABEL'], fill: false, showLine: true, - borderColor: 'rgba(255,201,0,1)', - borderWidth: 2, - backgroundColor: 'rgba(255,201,0,1)', - pointBackgroundColor: 'rgba(255,201,0,1)', - pointBorderColor: 'rgba(255,255,255,1)', - pointHoverBackgroundColor: 'rgba(255,201,0,1)', - pointHoverBorderColor: 'rgba(0,0,0,0)', - pointRadius: 3 + borderColor: gpColor.rgba.energized(), + borderWidth: 1, + backgroundColor: gpColor.rgba.energized(), + pointBackgroundColor: gpColor.rgba.energized(), + pointBorderColor: gpColor.rgba.energized(), + pointHoverBackgroundColor: gpColor.rgba.energized(), + pointHoverBorderColor: gpColor.rgba.energized(), + pointRadius: 0, + pointHitRadius: 4, + pointHoverRadius: 3 }]; + $scope.setScale($scope.scale); + // Keep only block number (need for click) $scope.blocks = result.blocks.reduce(function(res, block) { return res.concat(block.number); @@ -295,7 +309,7 @@ function GpCurrencyMonetaryMassController($scope, $controller, $q, $state, $tran } -function GpCurrencyDUController($scope, $q, $controller, $translate, gpData, $filter) { +function GpCurrencyDUController($scope, $q, $controller, $translate, gpColor, gpData, $filter) { 'ngInject'; // Initialize the super class and extend it. angular.extend(this, $controller('GpCurrencyMonetaryMassCtrl', {$scope: $scope})); @@ -322,7 +336,7 @@ function GpCurrencyDUController($scope, $q, $controller, $translate, gpData, $fi // Choose a date formatter, depending on the blocks period var blocksPeriod = result.times[result.times.length-1] - result.times[0]; var dateFilter; - if (blocksPeriod < 15778800/* less than 6 months*/) { + if (blocksPeriod < 31557600/* less than 1 year */) { dateFilter = $filter('formatDateShort'); } else { @@ -346,7 +360,7 @@ function GpCurrencyDUController($scope, $q, $controller, $translate, gpData, $fi // Colors $scope.colors = result.blocks.reduce(function(res) { - return res.concat('rgba(17,193,243,0.5)'); + return res.concat(gpColor.rgba.calm(0.5)); }, []); // Options @@ -362,7 +376,7 @@ function GpCurrencyDUController($scope, $q, $controller, $translate, gpData, $fi { id: 'y-axis-ud', ticks: { - beginAtZero: true + beginAtZero: false } } ] @@ -384,9 +398,12 @@ function GpCurrencyDUController($scope, $q, $controller, $translate, gpData, $fi $scope.datasetOverride = [ { yAxisID: 'y-axis-ud', - type: 'bar', + type: 'line', label: translations['COMMON.UNIVERSAL_DIVIDEND'], - hoverBackgroundColor: 'rgba(17,193,243,0.6)' + borderWidth: 2, + pointRadius: 0, + pointHitRadius: 4, + pointHoverRadius: 3 }]; // Keep only block number (need for click) @@ -425,18 +442,18 @@ function GpCurrencyMembersCountController($scope, $controller, $q, $state, $tran $scope.times = result.times; // Choose a date formatter, depending on the blocks period - var blocksPeriod = result.times[result.blocks.length-1]- result.times[0]; - var dateFormat; - if (blocksPeriod < 15778800/* less than 6 months*/) { - dateFormat = $filter('formatDateShort'); + var blocksPeriod = result.times[result.blocks.length-1] - result.times[0]; + var dateFilter; + if (blocksPeriod < 31557600/* less than 1 year*/) { + dateFilter = $filter('formatDateShort'); } else { - dateFormat = $filter('formatDateMonth'); + dateFilter = $filter('formatDateMonth'); } // Format time $scope.labels = result.times.reduce(function(res, time) { - return res.concat(dateFormat(time)); + return res.concat(dateFilter(time)); }, []); // Members count graph: ------------------------- @@ -463,7 +480,10 @@ function GpCurrencyMembersCountController($scope, $controller, $q, $state, $tran yAxisID: 'y-axis-1', type: 'line', label: translations['GRAPH.CURRENCY.MEMBERS_COUNT_LABEL'], - hoverBackgroundColor: 'rgba(17,193,243,0.7)' + borderWidth: 2, + pointRadius: 0, + pointHitRadius: 4, + pointHoverRadius: 3 }]; // Data diff --git a/www/plugins/graph/js/services/color-services.js b/www/plugins/graph/js/services/color-services.js index 8995ec27e..5f7029d56 100644 --- a/www/plugins/graph/js/services/color-services.js +++ b/www/plugins/graph/js/services/color-services.js @@ -132,6 +132,10 @@ angular.module('cesium.graph.color.services', []) }; }); + exports.rgba.translucent = function() { + return 'rgb(0,0,0,0)'; + }; + return exports; }) diff --git a/www/plugins/graph/js/services/data-services.js b/www/plugins/graph/js/services/data-services.js index b2c6677bb..12c8bf7fc 100644 --- a/www/plugins/graph/js/services/data-services.js +++ b/www/plugins/graph/js/services/data-services.js @@ -65,6 +65,10 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es. options.endTime = options.endTime || moment().utc().add(1, options.rangeDuration).unix(); options.startTime = options.startTime || moment.unix(options.endTime).utc().subtract(options.defaultTotalRangeCount, options.rangeDuration).unix(); + // Make to sure startTime is never before the currency starts - fix #483 + if (options.firstBlockTime && options.startTime < options.firstBlockTime) { + options.startTime = options.firstBlockTime; + } return options; } @@ -229,7 +233,7 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es. var jobs = []; var from = moment.unix(options.startTime).utc().startOf(options.rangeDuration); - var to = moment.unix(options.endTime).utc(); + var to = moment.unix(options.endTime).utc().startOf(options.rangeDuration); var ranges = []; while(from.isBefore(to)) { @@ -238,8 +242,9 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es. to: from.add(1, options.rangeDuration).unix() }); - // Do not exceed max range count - if (ranges.length == options.maxRangeSize) { + // Flush if max range count, or just before loop condition end (fix #483) + var flush = (ranges.length === options.maxRangeSize) || !from.isBefore(to); + if (flush) { var request = { size: 0, aggs: { @@ -296,7 +301,7 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es. ); } } - } + } // loop return $q.all(jobs) .then(function(res) { @@ -468,7 +473,7 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es. } var from = moment.unix(options.startTime).utc().startOf(options.rangeDuration); - var to = moment.unix(options.endTime).utc(); + var to = moment.unix(options.endTime).utc().startOf(options.rangeDuration); var ranges = []; var udRanges = []; @@ -505,9 +510,11 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es. to: from.add(1, options.rangeDuration).unix() }); - // Do not exceed max range count - if ((!jobs.length && ranges.length == options.maxRangeSize+1) || (jobs.length && ranges.length == options.maxRangeSize)) { - + // Flush if max range count, or just before loop condition end (fix #483) + var flush = (!jobs.length && ranges.length == options.maxRangeSize+1) || + (jobs.length && ranges.length == options.maxRangeSize) || + !from.isBefore(to); + if (flush) { if (udRanges.length) { jobs.push($q.all([ exports.raw.movement.getUds(currency, udRanges, udFromMapping), diff --git a/www/plugins/graph/templates/account/view_stats.html b/www/plugins/graph/templates/account/view_stats.html index 8b21f2ddc..b3617f58d 100644 --- a/www/plugins/graph/templates/account/view_stats.html +++ b/www/plugins/graph/templates/account/view_stats.html @@ -6,22 +6,27 @@ <ion-content scroll="true" class="no-padding"> - <div class="center padding" ng-if="loading"> - <ion-spinner icon="android"></ion-spinner> - </div> - <div class="list" ng-if="!loading"> - <!-- - - - - Balance - - - - --> - <div class="item item-divider" translate> - GRAPH.ACCOUNT.BALANCE_DIVIDER - </div> + <div class="list" > - <div class="item no-padding-xs" - ng-include="'plugins/graph/templates/account/graph_balance.html'" - ng-controller="GpAccountBalanceCtrl" - ng-init="setSize(350, 1000)"> - </div> + <!-- - - - - Balance - - - - --> + <ng-controller ng-controller="GpAccountBalanceCtrl"> + <div class="center padding" ng-if="loading"> + <ion-spinner icon="android"></ion-spinner> + </div> + + <div class="item item-divider" ng-if="!loading" > + {{'GRAPH.ACCOUNT.BALANCE_DIVIDER'|translate}} + <ion-spinner ng-if="loadingRange" class="ion-spinner-small" icon="android"></ion-spinner> + </div> + + <div class="item no-padding-xs" + ng-if="!loading" + ng-include="'plugins/graph/templates/account/graph_balance.html'" + ng-init="setSize(350, 1000)"> + </div> + </ng-controller> <!-- - - - - WOT - - - - --> <!--<div class="item item-divider" translate> diff --git a/www/plugins/graph/templates/blockchain/view_stats.html b/www/plugins/graph/templates/blockchain/view_stats.html index e7887857f..4c66ade43 100644 --- a/www/plugins/graph/templates/blockchain/view_stats.html +++ b/www/plugins/graph/templates/blockchain/view_stats.html @@ -12,28 +12,38 @@ <div class="list" ng-if="!loading"> - <!-- - - - - TX divider - - - - --> - <div class="item item-divider" translate> - GRAPH.BLOCKCHAIN.TX_DIVIDER - </div> - <div class="item no-padding-xs" - ng-include="'plugins/graph/templates/blockchain/graph_tx_count.html'" - ng-controller="GpBlockchainTxCountCtrl" - ng-init="setSize(350, 1000)"> - </div> + <!-- TX count --> + <ng-controller ng-controller="GpBlockchainTxCountCtrl"> + <div class="center padding" ng-if="loading"> + <ion-spinner icon="android"></ion-spinner> + </div> + + <div class="item item-divider" ng-if="!loading" > + {{'GRAPH.BLOCKCHAIN.TX_DIVIDER'|translate}} + <ion-spinner ng-if="loadingRange" class="ion-spinner-small" icon="android"></ion-spinner> + </div> + + <div class="item no-padding-xs" + ng-if="!loading" + ng-include="'plugins/graph/templates/blockchain/graph_tx_count.html'" + ng-init="setSize(350, 1000)"> + </div> + </ng-controller> + <!-- Blocks issuer --> - <div class="item item-divider" translate> - GRAPH.BLOCKCHAIN.BLOCKS_ISSUERS_DIVIDER - </div> + <ng-controller ng-controller="GpBlockchainIssuersCtrl"> + + <div class="item item-divider" ng-if="!loading" translate>GRAPH.BLOCKCHAIN.BLOCKS_ISSUERS_DIVIDER</div> - <div class="item no-padding-xs" - ng-include="'plugins/graph/templates/blockchain/graph_block_issuers.html'" - ng-controller="GpBlockchainIssuersCtrl" - ng-init="setSize(300, 750)"> - </div> + <div class="item no-padding-xs" + ng-if="!loading" + ng-include="'plugins/graph/templates/blockchain/graph_block_issuers.html'" + ng-init="setSize(300, 750)"> + </div> + </ng-controller> </ion-content> diff --git a/www/plugins/graph/templates/common/popover_range_actions.html b/www/plugins/graph/templates/common/popover_range_actions.html index 31745aa69..8342186d4 100644 --- a/www/plugins/graph/templates/common/popover_range_actions.html +++ b/www/plugins/graph/templates/common/popover_range_actions.html @@ -8,7 +8,7 @@ <!-- scale --> <a class="item item-icon-left ink" ng-click="toggleScale()"> - <i class="icon ion-ios-checkmark-empty" ng-show="scale=='logarithmic'"></i> + <i class="icon ion-ios-checkmark-empty" ng-show="formData.scale=='logarithmic'"></i> <span ng-bind-html="'GRAPH.COMMON.LOGARITHMIC_SCALE' | translate"></span> </a> diff --git a/www/plugins/graph/templates/currency/graph_monetary_mass.html b/www/plugins/graph/templates/currency/graph_monetary_mass.html index 894e82b84..8091257b5 100644 --- a/www/plugins/graph/templates/currency/graph_monetary_mass.html +++ b/www/plugins/graph/templates/currency/graph_monetary_mass.html @@ -9,7 +9,8 @@ </button> </div> - <canvas id="monetaryMass-bar" class="chart-bar" + <canvas id="monetaryMass-bar" + class="chart-bar" height="{{height}}" width="{{width}}" chart-data="data" diff --git a/www/plugins/graph/templates/currency/view_stats_lg.html b/www/plugins/graph/templates/currency/view_stats_lg.html index 15d0dd788..03abfb8bc 100644 --- a/www/plugins/graph/templates/currency/view_stats_lg.html +++ b/www/plugins/graph/templates/currency/view_stats_lg.html @@ -6,16 +6,24 @@ <ion-content scroll="true" class="padding" > + + <div class="list" > <!-- Monetary mass --> - <ng-controller ng-controller="GpCurrencyMonetaryMassCtrl"> - <div class="item no-padding-xs" + <ng-controller ng-controller="GpCurrencyMonetaryMassCtrl" > + + <div class="center padding" ng-if="loading"> + <ion-spinner icon="android"></ion-spinner> + </div> + + <div class="item no-padding-xs" ng-if="!loading" ng-include="'plugins/graph/templates/currency/graph_monetary_mass.html'" ng-init="setSize(250, 1000)"> </div> - <div class="item item-toggle dark no-border text-right"> + <div ng-if="!loading" + class="item item-toggle dark no-border text-right"> <span class="" translate>COMMON.BTN_RELATIVE_UNIT</span> <label class="toggle toggle-royal" id="helptip-currency-change-unit"> <input type="checkbox" ng-model="formData.useRelative"> @@ -27,15 +35,19 @@ </ng-controller> <!-- DU --> - <div class="item no-padding-xs" - ng-include="'plugins/graph/templates/currency/graph_du.html'" - ng-controller="GpCurrencyDUCtrl" - ng-init="setSize(250, 1000)"> - </div> + <ng-controller ng-controller="GpCurrencyDUCtrl" > + <div class="item no-padding-xs" + ng-if="!loading" + ng-include="'plugins/graph/templates/currency/graph_du.html'" + ng-init="setSize(250, 1000)"> + </div> + </ng-controller> + <!-- Member count --> + <ng-controller ng-controller="GpCurrencyMembersCountCtrl" > <div class="item no-padding-xs" + ng-if="!loading" ng-include="'plugins/graph/templates/currency/graph_members_count.html'" - ng-controller="GpCurrencyMembersCountCtrl" ng-init="setSize(250, 1000)"> </div> diff --git a/www/plugins/graph/templates/currency/view_wot_stats.html b/www/plugins/graph/templates/currency/view_wot_stats.html index 41c583327..594cad02b 100644 --- a/www/plugins/graph/templates/currency/view_wot_stats.html +++ b/www/plugins/graph/templates/currency/view_wot_stats.html @@ -7,6 +7,8 @@ <ion-spinner icon="android"></ion-spinner> </div> - <ng-include src="'plugins/graph/templates/currency/graph_members_count.html'" ></ng-include> + <ng-include + ng-if="!loading" + src="'plugins/graph/templates/currency/graph_members_count.html'" ></ng-include> </ion-content> </ion-view> diff --git a/www/templates/blockchain/item_block.html b/www/templates/blockchain/item_block.html index d567db6cd..bb6cdc204 100644 --- a/www/templates/blockchain/item_block.html +++ b/www/templates/blockchain/item_block.html @@ -33,7 +33,7 @@ </div> <div class="col col-20"> - <span class="badge " ng-class="{'badge-balanced': !$index , 'badge-calm': $index && !block.compacted && !block.empty}">{{:rebind:block.number}}</span> + <span class="badge " ng-class="{'badge-balanced': !$index , 'badge-calm': $index && !block.compacted && !block.empty}">{{:rebind:block.number|formatInteger}}</span> </div> </div> diff --git a/www/templates/blockchain/item_block_empty_lg.html b/www/templates/blockchain/item_block_empty_lg.html index 01a5a178f..1fecc3172 100644 --- a/www/templates/blockchain/item_block_empty_lg.html +++ b/www/templates/blockchain/item_block_empty_lg.html @@ -26,7 +26,7 @@ <div class="col col-20"></div> <div class="col col-20"> - <span class="badge" ng-class="{'badge-balanced': !$index && search.type=='last'}">{{block.number}}</span> + <span class="badge" ng-class="{'badge-balanced': !$index && search.type=='last'}">{{block.number|formatInteger}}</span> </div> </div> diff --git a/www/templates/menu.html b/www/templates/menu.html index 97bfcdd5f..abca5bb7e 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -13,11 +13,12 @@ <ion-nav-buttons side="right" > <!-- current node info --> - <button class="button button-clear hidden-xs hidden-sm gray" + <button class="button button-clear hidden-xs hidden-sm gray icon-left" ng-if="$root.settings.expertMode" style="max-width: 450px !important;" ng-click="showNodeListPopover($event)"> - {{$root.currency.node.server}} + <small class="ion-locked" ng-if="$root.currency.node.useSsl"></small> + {{$root.currency.node.host}}{{$root.currency.node.port != 80 && $root.currency.node.port != 443 ? ':'+$root.currency.node.port : ''}} <small class="ion-arrow-down-b"></small> </button> diff --git a/www/templates/network/items_peers.html b/www/templates/network/items_peers.html index 59c2decdd..07a762059 100644 --- a/www/templates/network/items_peers.html +++ b/www/templates/network/items_peers.html @@ -78,7 +78,7 @@ </div> <div class="col col-20 no-padding text-center"> <span id="helptip-network-peer-{{$index}}-block" - class="badge" ng-class="{'badge-balanced': peer.hasMainConsensusBlock, 'badge-energized': peer.hasConsensusBlock }">{{:rebind:peer.currentNumber}}</span> + class="badge" ng-class="{'badge-balanced': peer.hasMainConsensusBlock, 'badge-energized': peer.hasConsensusBlock }">{{:rebind:peer.currentNumber|formatInteger}}</span> </div> </div> </div> diff --git a/www/templates/network/popover_peer_info.html b/www/templates/network/popover_peer_info.html index 031e11281..f778fb512 100644 --- a/www/templates/network/popover_peer_info.html +++ b/www/templates/network/popover_peer_info.html @@ -2,19 +2,34 @@ ng-controller="PeerInfoPopoverCtrl"> <ion-header-bar class="stable-bg block"> <div class="title"> - {{'MENU.NETWORK'|translate}} + {{'PEER.VIEW.TITLE'|translate}} </div> </ion-header-bar> - <ion-content scroll="true"> + <ion-content scroll="false"> <div class="center" ng-if="loading"> <ion-spinner icon="android"></ion-spinner> </div> <div class="list no-padding"> + <div class="item"> + <i class="ion-locked"></i> + {{'NETWORK.VIEW.ENDPOINTS.BMAS'|translate}} + <div class="badge badge-balanced" ng-if="$root.settings.node.useSsl" translate>COMMON.BTN_YES</div> + <div class="badge badge-assertive" ng-if="!$root.settings.node.useSsl" translate>COMMON.BTN_NO</div> + </div> + + <div class="item"> + <i class="ion-cube"></i> + {{'BLOCKCHAIN.VIEW.TITLE_CURRENT'|translate}} + <div class="badge badge-balanced"> + {{formData.number | formatInteger}} + </div> + </div> + <div class="item"> <i class="ion-clock"></i> {{'CURRENCY.VIEW.MEDIAN_TIME'|translate}} - <div class="badge"> + <div class="badge dark"> {{formData.medianTime | formatDate}} </div> </div> @@ -22,7 +37,7 @@ <div class="item"> <i class="ion-lock-combination"></i> {{'CURRENCY.VIEW.POW_MIN'|translate}} - <div class="badge"> + <div class="badge dark"> {{formData.powMin | formatInteger}} </div> </div> diff --git a/www/templates/network/view_peer.html b/www/templates/network/view_peer.html index 2f52296f5..677ebd8af 100644 --- a/www/templates/network/view_peer.html +++ b/www/templates/network/view_peer.html @@ -72,7 +72,7 @@ <i class="icon ion-cube"></i> <span translate>BLOCKCHAIN.VIEW.TITLE_CURRENT</span> <div class="badge badge-calm" ng-if="!loading"> - {{current.number}} + {{current.number|formatInteger}} </div> </a> -- GitLab