Skip to content
Snippets Groups Projects
Commit ed49eb54 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Account stats: Remove UD data, as this is not working yet

parent c2c84271
No related branches found
No related tags found
No related merge requests found
......@@ -203,7 +203,7 @@
"TAB_WOT": "Toile de confiance",
"TAB_NETWORK": "Réseau",
"TAB_BLOCKS": "Blocs",
"CURRENCY_SHORT_DESCRIPTION": "{{currency|capitalize}} est une <b>monnaie libre</b>, démarrée {{firstBlockTime|formatFromNow}}. Elle compte actuellement <b>{{N}} membres</b>, qui produisent et perçoivent un <a ng-click=\"showHelpModal('ud')\">Dividende Universel</a> (DU), chaque {{dt|formatPeriod}}.",
"CURRENCY_SHORT_DESCRIPTION": "{{currency|abbreviate}} est une <b>monnaie libre</b>, démarrée {{firstBlockTime|formatFromNow}}. Elle compte actuellement <b>{{N}} membres</b>, qui produisent et perçoivent un <a ng-click=\"showHelpModal('ud')\">Dividende Universel</a> (DU), chaque {{dt|formatPeriod}}.",
"NETWORK_RULES_DIVIDER": "Règles du réseau",
"CURRENCY_NAME": "Nom de la monnaie",
"MEMBERS": "Nombre de membres",
......
......@@ -225,21 +225,32 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht
})
.filter('abbreviate', function() {
var _cache = {};
return function(input) {
var currency = input || '';
if (_cache[currency]) return _cache[currency];
if (currency.length > 3) {
var unit = '', sepChars = ['-', '_', ' '];
for (var i = 0; i < currency.length; i++) {
var c = currency[i];
if (i === 0 || (i > 0 && sepChars.indexOf(currency[i-1]) != -1)) {
if (i === 0) {
unit = (c === 'g' || c === 'G') ? 'Ğ' : c ;
}
else if (i > 0 && sepChars.indexOf(currency[i-1]) != -1) {
unit += c;
}
}
return unit.toUpperCase();
currency = unit.toUpperCase();
}
else {
return currency.toUpperCase();
currency = currency.toUpperCase();
if (currency.charAt(0) === 'G') {
currency = 'Ğ' + (currency.length > 1 ? currency.substr(1) : '');
}
}
_cache[input] = currency;
return currency;
};
})
......
......@@ -618,7 +618,7 @@ function ESMarketRecordEditController($scope, $q, $timeout, $state, $ionicPopove
$scope.formData.type=state.stateParams.type;
}
// Set the default currency
csCurrency.default()
csCurrency.get()
.then(function(currency){
$scope.formData.currency = currency.name;
$scope.loading = false;
......
......@@ -191,7 +191,7 @@ angular.module('cesium.es.market.services', ['ngResource', 'cesium.services', 'c
// Make sure currency if present (fix old data)
if (!record.currency) {
return csCurrency.default()
return csCurrency.get()
.then(function (currency) {
record.currency = currency.name;
return data;
......
......@@ -110,16 +110,19 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t
var translations = result[1];
result = result[2];
if (!result || !result.times) return; // no data
if (!result || !result.times) {
console.log('No DATA');
return; // no data
}
$scope.times = result.times;
var formatInteger = $filter('formatInteger');
var formatAmount = $filter('formatDecimal');
$scope.currencySymbol = $filter('currencySymbolNoHtml')($scope.currency, $scope.formData.useRelative);
$scope.currencySymbol = $filter('currencySymbolNoHtml')($scope.formData.currency, $scope.formData.useRelative);
// Data
$scope.data = [
result.ud,
//result.ud,
result.received,
result.sent,
result.udSum,
......@@ -196,7 +199,7 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t
&& tooltipItems.yLabel > 0;
return data.datasets[tooltipItems.datasetIndex].label +
': ' +
(tooltipItems.yLabel === 0 ? '0' :
(!tooltipItems.yLabel ? '0' :
((addPlus ? '+' : '') + formatAmount(tooltipItems.yLabel) + ' ' + $scope.currencySymbol));
}
}
......@@ -204,14 +207,14 @@ function GpAccountBalanceController($scope, $controller, $q, $state, $filter, $t
};
$scope.datasetOverride = [
{
/*{
yAxisID: 'y-axis-right',
type: 'bar',
label: translations['GRAPH.ACCOUNT.UD_LABEL'],
backgroundColor: gpColor.rgba.energized(0.3),
hoverBackgroundColor: gpColor.rgba.energized(0.5),
borderWidth: 1
},
},*/
{
yAxisID: 'y-axis-right',
type: 'bar',
......@@ -336,7 +339,10 @@ function GpAccountCertificationController($scope, $controller, $q, $state, $filt
var translations = result[1];
result = result[2];
if (!result || !result.times) return; // no data
if (!result || !result.times) {
console.log('No DATA');
return; // no data
}
$scope.times = result.times;
var formatInteger = $filter('formatInteger');
......@@ -405,7 +411,7 @@ function GpAccountCertificationController($scope, $controller, $q, $state, $filt
return data.datasets[tooltipItems.datasetIndex].label +
': ' +
(addPlus ? '+' : '') +
formatInteger(tooltipItems.yLabel);
!tooltipItems.yLabel ? '0' : formatInteger(tooltipItems.yLabel);
}
}
}
......
......@@ -49,7 +49,7 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist
// Make sure there is currency, or load it not
if (!$scope.formData.currency) {
return csCurrency.default()
return csCurrency.get()
.then(function (currency) {
$scope.formData.currency = currency ? currency.name : null;
$scope.formData.firstBlockTime = currency ? _truncDate(currency.firstBlockTime) : 0;
......
......@@ -59,7 +59,7 @@ function GpNetworkViewExtendController($scope, PluginService, esSettings) {
});
}
function GpPeerViewExtendController($scope, $q, $timeout, PluginService, esSettings, csCurrency, gpData) {
function GpPeerViewExtendController($scope, $timeout, PluginService, esSettings, csCurrency, gpData) {
'ngInject';
$scope.extensionPoint = PluginService.extensions.points.current.get();
......@@ -84,7 +84,7 @@ function GpPeerViewExtendController($scope, $q, $timeout, PluginService, esSetti
// Make sure there is currency, or load if not
if (!$scope.node.currency) {
return csCurrency.default()
return csCurrency.get()
.then(function(currency) {
$scope.node.currency = currency ? currency.name : null;
return $scope.enter(e, state);
......@@ -133,7 +133,7 @@ function GpPeerStatsController($scope, $controller, csCurrency) {
// Make sure there is currency, or load it not
if (!$scope.currency) {
return csCurrency.default()
return csCurrency.get()
.then(function(currency) {
$scope.currency = currency ? currency.name : null;
return $scope.enter(e, state);
......
......@@ -541,6 +541,8 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es.
return res.concat(hits);
}, []);
if (!res.length) return;
// Sort by 'from' field
res = _.sortBy(res, 'from');
......@@ -548,7 +550,7 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es.
var history = res.splice(0,1)[0];
var txSum = history.delta||0;
var udSum = history.ud||0;
var balance = history.delta+history.ud||0;
var balance = history.delta+(history.ud||0);
return {
times: _.pluck(res, 'from'),
......@@ -565,7 +567,7 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es.
return res.concat(udSum);
}, []),
balance: res.reduce(function(res, hit){
balance += hit.delta+hit.ud||0;
balance += hit.delta+(hit.ud||0);
return res.concat(balance);
}, []),
count: _.pluck(res, 'count')
......@@ -585,6 +587,7 @@ angular.module('cesium.graph.data.services', ['cesium.wot.services', 'cesium.es.
return csWot.load(options.pubkey)
.then(function(idty) {
if (!idty) return;
var res = {};
_.forEach(idty.given_cert||[], function(cert){
var truncTime = moment.unix(cert.time).utc().startOf(options.rangeDuration).unix();
......
<ion-view left-buttons="leftButtons"
cache-view="false">
<ion-nav-title bind-notifier="{ rebind:formData.useRelative }">
<span>
{{'CURRENCY.VIEW.TITLE' | translate}}
</span>
<span ng-if="!loading">
{{formData.currency|capitalize}}
{{'CURRENCY.VIEW.TITLE' | translate}} {{formData.currency|abbreviate}}
</span>
</ion-nav-title>
......@@ -21,6 +18,8 @@
<!-- Buttons bar-->
<div class="hidden-xs hidden-sm padding text-center">
<button class="button button-stable icon-right ink"
ng-if="formData.licenseUrl"
ng-click="showLicenseModal()">
......@@ -39,7 +38,7 @@
</div>
<div class="item item-text-wrap no-border no-padding"
<div class="item item-text-wrap no-border no-padding pull-left"
ng-if="!loading">
<div class="item-icon-left card padding stable-900-bg">
<i class="icon ion-help-circled calm"></i>
......@@ -53,9 +52,6 @@
<div class="col list">
<div class="item item-divider">
<span translate>CURRENCY.VIEW.MONEY_DIVIDER</span>
<span ng-if="!loading">
{{formData.currency|capitalize}}
</span>
</div>
<ng-include src="'templates/currency/items_parameters.html'"></ng-include>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment