Select Git revision
autocompletion.md
-
* Fix a few Typos
* Fix a few Typos
common-controllers.js 12.65 KiB
angular.module('cesium.graph.common.controllers', ['cesium.services'])
.controller('GpCurrencyAbstractCtrl', GpCurrencyAbstractController)
;
function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHistory, $state, csSettings, csCurrency, esHttp, UIUtils) {
'ngInject';
$scope.loading = true;
$scope.formData = $scope.formData || {
useRelative: csSettings.data.useRelative,
timePct: 100,
rangeDuration: 'day',
maxAge: undefined, // forever
firstBlockTime: 0,
scale: 'linear',
hide: [],
beginAtZero: true
};
$scope.scale = 'linear';
$scope.height = undefined;
$scope.width = undefined;
$scope.maintainAspectRatio = true;
$scope.times = [];
function _truncDate(time) {
return moment.unix(time).utc().startOf($scope.formData.rangeDuration).unix();
}
$scope.enter = function (e, state) {
if ($scope.loading) {
// Make sure there is currency, or load it not
if (!$scope.formData.currency) {
return csCurrency.get()
.then(function (currency) {
$scope.formData.currency = currency ? currency.name : null;
$scope.formData.firstBlockTime = currency ? _truncDate(currency.firstBlockTime) : 0;
if (!$scope.formData.firstBlockTime){
console.warn('[graph] currency.firstBlockTime not loaded ! Should have been loaded by currrency service!');
}
$scope.formData.currencyAge = _truncDate(moment().utc().unix()) - $scope.formData.firstBlockTime;
return $scope.enter(e, state); // Loop
});
}
if (state && state.stateParams) {
// remember state, to be able to refresh location
$scope.stateName = state && state.stateName;
$scope.stateParams = angular.copy(state && state.stateParams||{});
if (!$scope.formData.currency && state && state.stateParams && state.stateParams.currency) { // Currency parameter
$scope.formData.currency = state.stateParams.currency;
}
if (state.stateParams.t) {
$scope.formData.timePct = state.stateParams.t;
}
else if (state.stateParams.timePct) {
$scope.formData.timePct = state.stateParams.timePct;
}
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) {