Explorar el Código

load all metrics now works

Torkel Ödegaard hace 12 años
padre
commit
16b0d797a9
Se han modificado 2 ficheros con 26 adiciones y 92 borrados
  1. 1 89
      grafana.sublime-workspace
  2. 25 3
      src/app/controllers/metricKeys.js

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 89
grafana.sublime-workspace


+ 25 - 3
src/app/controllers/metricKeys.js

@@ -44,15 +44,37 @@ function (angular, _, config) {
     };
     };
 
 
     $scope.loadAll = function() {
     $scope.loadAll = function() {
-      return $http.get(config.graphiteUrl + "/metrics/index.json")
-        .then(function (data) {
+      $scope.infoText = "Fetching all metrics from graphite...";
 
 
+      return $http.get(config.graphiteUrl + "/metrics/index.json")
+        .then(saveMetricsArray)
+        .then(function () {
+          $scope.infoText = "Indexing complete!";
         })
         })
         .then(null, function(err) {
         .then(null, function(err) {
-          $scope.errorText = "Failed to fetch index.json metrics file from graphite: " + err;
+          $scope.errorText = err;
+          deferred.reject(err);
         });
         });
     };
     };
 
 
+    function saveMetricsArray(data, currentIndex)
+    {
+      if (!data && !data.data && !data.data.length == 0) {
+        return $q.reject('No metrics from graphite');
+      }
+
+      if (data.data.length === currentIndex) {
+        return $q.when('done');
+      }
+
+      currentIndex = currentIndex || 0;
+
+      return saveMetricKey(data.data[currentIndex])
+        .then(function() {
+          return saveMetricsArray(data, currentIndex + 1);
+        });
+    }
+
     function deleteIndex()
     function deleteIndex()
     {
     {
       var deferred = $q.defer();
       var deferred = $q.defer();

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio