<commit_before>angular.module('dashES.controllers',[])

  // Primary App controller which takes care of default requests and
  // top navigation bar behavior
  .controller('DashESCtrl',
    ['$scope', 'appConfigService', 'clusterHealthService', 
    function($scope, appConfigService, clusterHealthService) {
  
      $scope.app_config = appConfigService;
      $scope.app_config.es_host = 'http://localhost:9200';
      $scope.cluster = clusterHealthService.get();

      //$scope.refresh = function() {
      //  this.clusterHealthService.get(function(data){
      //    $scope.clusterHealthService.data = data;
      //  });
      //};

  }])

  // Cluster Status
  .controller('ClusterStatusCtrl',
    ['$scope', '$http', '$filter', 'appConfigService', 'clusterHealthService',
    function($scope, $http, $filter, appConfigService, clusterHealthService) {

      $scope.app_config = appConfigService;
      $scope.cluster = clusterHealthService.get();

      // Timed Out Label
      alert(JSON.stringify($scope.cluster))
      if ($scope.cluster.timed_out) {
        $scope.cluster.timed_out_label = "important"
      } else if (!$scope.cluster.timed_out) {
        $scope.cluster.timed_out_label = "success"
      }

      // Status Label
      if ($scope.cluster.status == "green") {
        $scope.cluster.status_label = "success"
      } else if ($scope.cluster.status == "red") {
        $scope.cluster.status_label = "important"
      } else if ($scope.cluster.status == "yellow") {
        $scope.cluster.status_label = "warning"
      }

      // Relocating Shards Label
      if ($scope.cluster.relocating_shards > 0) {
        $scope.cluster.relocating_shards_label = "warning"
      } else {
        $scope.cluster.relocating_shards_label = "success"
      }

      // Initializing Shards Label
      if ($scope.cluster.initializing_shards > 0) {
        $scope.cluster.initializing_shards_label = "important"
      } else {
        $scope.cluster.initializing_shards_label = "success"
      }

      // Unassigned Shards Label
      if ($scope.cluster.unassigned_shards > 0) {
        $scope.cluster.unassigned_shards_label = "important"
      } else {
        $scope.cluster.unassigned_shards_label = "success"
      }

      // I need to split out these into services still:
      $http.get('http://localhost:9200/_stats?clear=true&docs=true&store=true&indexing=true').success(function(data) {
        $scope.indices = data.indices;

        $http.get('http://localhost:9200/_cluster/state?filter_indices=true&filter_blocks=true&filter_metadata=true&filter_nodes=true').success(function(data) {
          $scope.routing_nodes = data.routing_nodes.nodes;
          // Turning the Index info into an array so Angualar can sort it
          var indices = $.map(data.routing_table.indices, function(k, v) {<commit_msg>Set up $watcher for the cluster health promise for label coloring<commit_after>angular.module('dashES.controllers',[])

  // Primary App controller which takes care of default requests and
  // top navigation bar behavior
  .controller('DashESCtrl',
    ['$scope', 'appConfigService', 'clusterHealthService', 
    function($scope, appConfigService, clusterHealthService) {
  
      $scope.app_config = appConfigService;
      $scope.app_config.es_host = 'http://localhost:9200';
      $scope.cluster = clusterHealthService.get();

  }])

  // Cluster Status
  .controller('ClusterStatusCtrl',
    ['$scope', '$http', '$filter', 'appConfigService', 'clusterHealthService',
    function($scope, $http, $filter, appConfigService, clusterHealthService) {

      $scope.app_config = appConfigService;
      $scope.cluster = clusterHealthService.get();

      $scope.$watch('cluster', function(cluster) {
        if (angular.isDefined(cluster)) {
          // Timed Out Label
          if (cluster.timed_out) {
            cluster.timed_out_label = "important";
          } else {
            cluster.timed_out_label = "success";
          }
          // Status Label
          if (cluster.status == "green") {
            cluster.status_label = "success";
          } else if (cluster.status == "red") {
            cluster.status_label = "important";
          } else if (cluster.status == "yellow") {
            cluster.status_label = "warning";
          }

          // Relocating Shards Label
          if (cluster.relocating_shards > 0) {
            cluster.relocating_shards_label = "warning";
          } else {
            cluster.relocating_shards_label = "success";
          }

          // Initializing Shards Label
          if (cluster.initializing_shards > 0) {
            cluster.initializing_shards_label = "important";
          } else {
            cluster.initializing_shards_label = "success";
          }

          // Unassigned Shards Label
          if (cluster.unassigned_shards > 0) {
            cluster.unassigned_shards_label = "important";
          } else {
            cluster.unassigned_shards_label = "success";
          }
        }
        else {
          
        }
      });


      // I need to split out these into services still:
      $http.get('http://localhost:9200/_stats?clear=true&docs=true&store=true&indexing=true').success(function(data) {
        $scope.indices = data.indices;

        $http.get('http://localhost:9200/_cluster/state?filter_indices=true&filter_blocks=true&filter_metadata=true&filter_nodes=true').success(function(data) {
          $scope.routing_nodes = data.routing_nodes.nodes;
          // Turning the Index info into an array so Angualar can sort it
          var indices = $.map(data.routing_table.indices, function(k, v) {
{'fraction_non_alphanumeric': 0.12624289772727273, 'fraction_numerical': 0.005326704545454545, 'mean_word_length': 2.6673177083333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2437433', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1608, 'n_words': 301}