diff --git a/www/plugins/es/js/services/subscription-services.js b/www/plugins/es/js/services/subscription-services.js index ad98dcdc175f970fb7be6ca13a46949ce9fc8536..dbde1240a6b850b4a2be96099f8bee8844d0f516 100644 --- a/www/plugins/es/js/services/subscription-services.js +++ b/www/plugins/es/js/services/subscription-services.js @@ -2,7 +2,7 @@ angular.module('cesium.es.subscription.services', ['cesium.services', 'cesium.es .config(function(PluginServiceProvider, csConfig) { 'ngInject'; - var enable = false; // csConfig.plugins && csConfig.plugins.es; + var enable = csConfig.plugins && csConfig.plugins.es; if (enable) { // Will force to load this service PluginServiceProvider.registerEagerLoadingService('esSubscription'); diff --git a/www/plugins/es/templates/wallet/view_wallet_extend.html b/www/plugins/es/templates/wallet/view_wallet_extend.html index a829dfb2687ca278164ffb847921b470e66097ae..ea8e02f0c1007789bcadcf6b18f9d740a31192e6 100644 --- a/www/plugins/es/templates/wallet/view_wallet_extend.html +++ b/www/plugins/es/templates/wallet/view_wallet_extend.html @@ -13,7 +13,7 @@ <ng-include src="'plugins/es/templates/user/items_profile.html'" ng-init="showName=true;"></ng-include> </div> -<!-- subscriptions +<!-- subscriptions --> <div class="item item-divider item-divider-top-border"> {{'SUBSCRIPTION.SUBSCRIPTION_DIVIDER' | translate}} <a class="badge button button-text button-small button-small-padding " @@ -35,4 +35,3 @@ <i class="gray icon ion-ios-arrow-right"></i> </a> ---> diff --git a/www/plugins/graph/i18n/locale-en.json b/www/plugins/graph/i18n/locale-en.json index 4e05eac5bc51a36b5a74d36ac40880695f4790cc..071dfbbb36febb021eed9a760bfe6ff9809db378 100644 --- a/www/plugins/graph/i18n/locale-en.json +++ b/www/plugins/graph/i18n/locale-en.json @@ -8,7 +8,8 @@ "BLOCKCHAIN": { "TITLE": "Statistics", "BLOCKS_ISSUERS_DIVIDER": "Written blocks by members", - "BLOCKS_ISSUERS_TITLE": "{{issuerCount}} members has written {{blockCount}} blocks" + "BLOCKS_ISSUERS_TITLE": "{{issuerCount}} members has written {{blockCount}} blocks", + "TX_COUNT_TITLE": "Number of written transactions" }, "CURRENCY": { "MEMBERS_COUNT_TITLE": "Evolution of the number of members", diff --git a/www/plugins/graph/i18n/locale-fr-FR.json b/www/plugins/graph/i18n/locale-fr-FR.json index 86ee0f7daaa7258400d0c82dbc2a998360516b8f..32b2ddcee275ea3247df7329b7c3d9e76f95cc3d 100644 --- a/www/plugins/graph/i18n/locale-fr-FR.json +++ b/www/plugins/graph/i18n/locale-fr-FR.json @@ -8,7 +8,8 @@ "BLOCKCHAIN": { "TITLE": "Statistiques", "BLOCKS_ISSUERS_DIVIDER": "Répartition du calcul des blocs par membre", - "BLOCKS_ISSUERS_TITLE": "{{issuerCount}} membres ont calculé {{blockCount}} blocs" + "BLOCKS_ISSUERS_TITLE": "{{issuerCount}} membres ont calculé {{blockCount}} blocs", + "TX_COUNT_TITLE": "Nombre de transactions écrites" }, "CURRENCY": { "MEMBERS_COUNT_TITLE": "Evolution du nombre de membres", diff --git a/www/plugins/graph/js/controllers/blockchain-controllers.js b/www/plugins/graph/js/controllers/blockchain-controllers.js index c4981aba2e5b84342adcba61fabc45731c1ceb9f..ccd604529384cc193f24162234bc02be7361d29e 100644 --- a/www/plugins/graph/js/controllers/blockchain-controllers.js +++ b/www/plugins/graph/js/controllers/blockchain-controllers.js @@ -68,10 +68,10 @@ function GpBlockchainController($scope, $q, $state, $translate, csCurrency, gpDa .then(function(res) { $scope.blocksByIssuer = res; }) - /*, $scope.loadMonetaryMass() + , $scope.loadTxCount() .then(function(res) { - $scope.monetaryMass = res; - })*/ + $scope.txCount = res; + }) ]) .then(function() { $scope.loading = false; @@ -117,12 +117,12 @@ function GpBlockchainController($scope, $q, $state, $translate, csCurrency, gpDa }); }; -/* - $scope.loadMonetaryMass = function(from, size) { + + $scope.loadTxCount = function(from, size) { from = from || 0; size = size || 10000; - return gpData.block.monetaryMass($scope.currency, { + return gpData.blockchain.txCount($scope.currency, { from: from, size: size }) @@ -131,18 +131,16 @@ function GpBlockchainController($scope, $q, $state, $translate, csCurrency, gpDa if (!result || !result.data) return; // Block by issuer - result.line = { - options: { - title: { - display: true - }, - scales: { - yAxes: [{ - ticks: { - beginAtZero:true - } - }] - } + result.options = { + title: { + display: true + }, + scales: { + yAxes: [{ + ticks: { + beginAtZero:true + } + }] } }; @@ -152,23 +150,23 @@ function GpBlockchainController($scope, $q, $state, $translate, csCurrency, gpDa return res.concat(formDateFilter(time)); }, []); - // Compute color - if (result.data.length) { - result.colors = gpData.util.colors.custom(result.data.length); - } + result.colors = result.labels.reduce(function(res) { + return res.concat('rgba(17,193,243,0.5)'); + }, []); + // Compute graph title - return $translate('GRAPH.BLOCKCHAIN.BLOCKS_ISSUERS_TITLE', { + return $translate('GRAPH.BLOCKCHAIN.TX_COUNT_TITLE', { issuerCount: result.data.length, blockCount: result.blockCount }) .then(function(title) { - result.line.options.title.text = title; + result.options.title.text = title; return result; }); }); - };*/ + }; $scope.showBlockIssuer = function(data, e, item) { if (!item) return diff --git a/www/plugins/graph/js/controllers/currency-controllers.js b/www/plugins/graph/js/controllers/currency-controllers.js index 8c0b1d13761727dc2b1ce9283c21fc3d4e3496d0..4a98e1a3af0034a110c5c96d9b51c00f694317cd 100644 --- a/www/plugins/graph/js/controllers/currency-controllers.js +++ b/www/plugins/graph/js/controllers/currency-controllers.js @@ -60,9 +60,6 @@ function GpGraphMonetaryMassController($scope, $q, $state, $translate, csCurrenc $scope.formData.useRelative = angular.isDefined($scope.formData.useRelative) ? $scope.formData.useRelative : csSettings.data.useRelative; - $scope.defaultLineColors = ['rgba(178,224,255,0.65)']; - $scope.defaultLineColors = ['rgba(17,193,243,0.75)']; - $scope.enter = function(e, state) { if ($scope.loading) { @@ -134,7 +131,7 @@ function GpGraphMonetaryMassController($scope, $q, $state, $translate, csCurrenc }] } }, - colors: ['rgba(17,193,243,0.5)']/*$scope.defaultLineColors*/ + colors: ['rgba(17,193,243,0.5)'] }; membersCount.data = result.blocks.reduce(function(res, block) { return res.concat(block.membersCount); @@ -154,7 +151,7 @@ function GpGraphMonetaryMassController($scope, $q, $state, $translate, csCurrenc }] } }, - colors: ['rgba(255,201,0,0.5)']/*$scope.defaultLineColors*/ + colors: ['rgba(255,201,0,0.5)'] }; if($scope.formData.useRelative) { // If relative, divide by UD diff --git a/www/plugins/graph/js/services/data-services.js b/www/plugins/graph/js/services/data-services.js index d45622efd43a53ddf0659573c10a978b259f51b1..b3a32870d1627ddee41455a234ac5539758a4d04 100644 --- a/www/plugins/graph/js/services/data-services.js +++ b/www/plugins/graph/js/services/data-services.js @@ -229,6 +229,67 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es. return promise; }; + /** + * Graph: "tx count" + * @param currency + * @returns {*} + */ + exports.blockchain.txCount = function(currency, options) { + var ranges = []; + var sliceSize = 24*60*60*2; + var now = esHttp.date.now(); + var start = now - (30.4375 * sliceSize); + for (var i = start; i <= now; i=i+sliceSize) { + ranges.push({ + from: i, + to: i + sliceSize + }); + } + + var request = { + size: 0, + aggs: { + txCount: { + range: { + field: "medianTime", + ranges: ranges + }, + aggs: { + tx_stats : { + stats: { + script : { + inline: "txcount", + lang: "native" + } + } + } + } + + } + } + }; + + + return exports.raw.block.search(request, {currency: currency}) + .then(function(res) { + var aggs = res.aggregations; + if (!aggs.txCount || !aggs.txCount.buckets || !aggs.txCount.buckets.length) return; + + var result = {}; + var started = false; + result.data = (aggs.txCount.buckets || []).reduce(function(res, agg) { + if (!started) { + started = agg.tx_stats.count > 0; + } + return started ? res.concat(agg.tx_stats.sum) : res; + }, []); + result.labels = (aggs.txCount.buckets || []).reduce(function(res, agg) { + return res.concat(agg.to); + }, []); + return result; + }); + }; + return exports; }) diff --git a/www/plugins/graph/templates/blockchain/view_stats.html b/www/plugins/graph/templates/blockchain/view_stats.html index ff2d70bbad1d7d091eda556344675b4f8df9a868..730515cd9aae196e26b81c86a24910f760861245 100644 --- a/www/plugins/graph/templates/blockchain/view_stats.html +++ b/www/plugins/graph/templates/blockchain/view_stats.html @@ -4,7 +4,7 @@ {{'GRAPH.BLOCKCHAIN.TITLE' | translate}}{{id}} </ion-nav-title> - <ion-content scroll="true" class="list no-padding"> + <ion-content scroll="true" class="no-padding"> <!-- Blocks per issuer --> <div class="item item-divider" translate> @@ -39,22 +39,18 @@ </div> </div> - <!-- monetary mass --> + <!-- tx count --> <div class="row responsive-lg" ng-if="!loading"> <!-- bar --> - <div class="col col-50"> - <canvas id="monetaryMass-line" class="chart chart-line" - chart-data="monetaryMass.data" - chart-labels="monetaryMass.labels" - chart-click="showBlock"> + <div class="col col-75"> + <canvas id="txCount-line" class="chart chart-bar" + chart-data="txCount.data" + chart-colors="txCount.colors" + chart-options="txCount.options" + chart-labels="txCount.labels"> </canvas> </div> - - <!-- bar --> - <div class="col col-50"> - - </div> </div> </ion-content>