Browse Source

updated grafana datasource

Torkel Ödegaard 11 years ago
parent
commit
91a6ae756f
1 changed files with 20 additions and 0 deletions
  1. 20 0
      src/app/services/grafana/grafanaDatasource.js

+ 20 - 0
src/app/services/grafana/grafanaDatasource.js

@@ -41,6 +41,26 @@ function (angular, _, $, config, kbn, moment) {
         });
     };
 
+    GrafanaDatasource.prototype.saveDashboard = function(dashboard) {
+      return $http.post('/api/dashboard/', { dashboard: dashboard })
+        .then(function() {
+            return { title: dashboard.title, url: '/dashboard/db/' + dashboard.title };
+        }, function(data) {
+          throw "Failed to search: " + data;
+        });
+    };
+
+    GrafanaDatasource.prototype.searchDashboards = function(query) {
+      return $http.get('/api/search/', { params: { q: query } })
+        .then(function(results) {
+          var hits = { dashboards: [], tags: [] };
+          hits.dashboards = results.data;
+          return hits;
+        }, function(data) {
+          throw "Failed to search: " + data;
+        });
+    };
+
     return GrafanaDatasource;
 
   });