Skip to content
Snippets Groups Projects
Select Git revision
  • 4010a9e40db1b3beeebb06151fdf3c008496d4a3
  • master default protected
  • json-output
  • nostr
  • 48-error-base-58-requirement-is-violated
  • no-rename
  • hugo/tx-comments
  • poka/dev
  • hugo/dev
  • tuxmain/mail
  • 0.4.3-RC2
  • 0.4.3-RC1
  • 0.4.2
  • 0.4.1
  • 0.4.0
  • 0.3.0
  • 0.2.17
  • 0.2.16
  • 0.2.15
  • 0.2.14
  • 0.2.13
  • 0.2.12
  • 0.2.10
  • 0.2.9
  • 0.2.8
  • 0.2.7
  • 0.2.6
  • 0.2.5
  • 0.2.4
  • 0.2.3
30 results

ud.rs

Blame
  • 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) {