<commit_before>'use strict';

(function() {
  angular.module('ncsaas')
    .directive('customerBalance', ['currentStateService', 'ncUtils', 'ENV', detailsView]);

  function detailsView(currentStateService, ncUtils, ENV) {
    return {
      restrict: 'E',
      templateUrl: "views/directives/customer-balance.html",
      replace: true,
      scope: {
        type: '@customerBalanceType',
        addCredit: '=customerAddCredit',
        chartData: '=customerChartData',
        showChart: '=customerShowChart'
      },
      link: function(scope) {
        var refresh = function() {

          scope.enablePurchaseCostDisplay = ENV.enablePurchaseCostDisplay;

          scope.currency = ENV.currency;
          scope.chartOptions = {
            responsive: true,
            bezierCurve: false,
            scaleShowGridLines: false
          };

          scope.currency = ENV.currency;

          scope.graphTooltip = false;

          scope.toggleChart = function() {
            scope.graphTooltip = !scope.graphTooltip;
            scope.amountTooltip = false;
            scope.quotasTooltip = false;
          };

          scope.toggleBalance = function() {
            scope.amountTooltip = !scope.amountTooltip;
            scope.graphTooltip = false;
            scope.quotasTooltip = false;
          };

          currentStateService.getCustomer().then(function(customer) {
            scope.model = customer;

            if (customer.plan) {
              scope.currentPlan = customer.plan.name;

              var usage = {};
              for (var i = 0; i < customer.quotas.length; i++) {
                var quota = customer.quotas[i];
                usage[quota.name] = quota.usage;
              }

              scope.currentPlanQuotas = customer.plan.quotas.map(function(quota) {
                var name = ncUtils.getPrettyQuotaName(quota.name);
                return {
                  name: name + (quota.value > 1 || quota.value == -1 ? 's' : ''),
                  limit: quota.value < 0 ? '∞' : quota.value,
                  usage: usage[quota.name]
                };
              });
            } else {
              scope.currentPlan = 'Default';
              scope.currentPlanQuotas = customer.quotas.map(function(quota) {
                var name = ncUtils.getPrettyQuotaName(quota.name);
                return {
                  name: name + (quota.value > 1 || quota.value == -1 ? 's' : ''),
                  limit: quota.limit < 0 ? '∞' : quota.limit,
                  usage: quota.usage
                };
              });
            }
          });

        };

        refresh();
        scope.$on('customerBalance:refresh', function() {
          refresh();
        });

      }
    };
  }
})();<commit_msg>Fix typo (SAAS-913)<commit_after>'use strict';

(function() {
  angular.module('ncsaas')
    .directive('customerBalance', ['currentStateService', 'ncUtils', 'ENV', detailsView]);

  function detailsView(currentStateService, ncUtils, ENV) {
    return {
      restrict: 'E',
      templateUrl: "views/directives/customer-balance.html",
      replace: true,
      scope: {
        type: '@customerBalanceType',
        addCredit: '=customerAddCredit',
        chartData: '=customerChartData',
        showChart: '=customerShowChart'
      },
      link: function(scope) {
        var refresh = function() {

          scope.enablePurchaseCostDisplay = ENV.enablePurchaseCostDisplay;

          scope.currency = ENV.currency;
          scope.chartOptions = {
            responsive: true,
            bezierCurve: false,
            scaleShowGridLines: false
          };

          scope.currency = ENV.currency;

          scope.graphTooltip = false;

          scope.toggleChart = function() {
            scope.graphTooltip = !scope.graphTooltip;
            scope.amountTooltip = false;
            scope.quotasTooltip = false;
          };

          scope.toggleBalance = function() {
            scope.amountTooltip = !scope.amountTooltip;
            scope.graphTooltip = false;
            scope.quotasTooltip = false;
          };

          currentStateService.getCustomer().then(function(customer) {
            scope.model = customer;

            if (customer.plan) {
              scope.currentPlan = customer.plan.name;

              var usage = {};
              for (var i = 0; i < customer.quotas.length; i++) {
                var quota = customer.quotas[i];
                usage[quota.name] = quota.usage;
              }

              scope.currentPlanQuotas = customer.plan.quotas.map(function(quota) {
                var name = ncUtils.getPrettyQuotaName(quota.name);
                return {
                  name: name + (quota.value > 1 || quota.value == -1 ? 's' : ''),
                  limit: quota.value < 0 ? '∞' : quota.value,
                  usage: usage[quota.name]
                };
              });
            } else {
              scope.currentPlan = 'Default';
              scope.currentPlanQuotas = customer.quotas.map(function(quota) {
                var name = ncUtils.getPrettyQuotaName(quota.name);
                return {
                  name: name + (quota.limit > 1 || quota.limit == -1 ? 's' : ''),
                  limit: quota.limit < 0 ? '∞' : quota.limit,
                  usage: quota.usage
                };
              });
            }
          });

        };

        refresh();
        scope.$on('customerBalance:refresh', function() {
          refresh();
        });

      }
    };
  }
})();
{'fraction_non_alphanumeric': 0.12251894622879826, 'fraction_numerical': 0.003067484662576687, 'mean_word_length': 1.5829450139794967, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3942318', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1488, 'n_words': 268}