[Groonga-commit] groonga/grafana-datasource-plugin-groonga at 743b31e [master] Choose existing table that has time column

Back to archive index

Masafumi Yokoyama null+****@clear*****
Mon Feb 15 21:14:16 JST 2016


Masafumi Yokoyama	2016-02-15 21:14:16 +0900 (Mon, 15 Feb 2016)

  New Revision: 743b31ee20ff8190dd67a7affda0c6a67a994654
  https://github.com/groonga/grafana-datasource-plugin-groonga/commit/743b31ee20ff8190dd67a7affda0c6a67a994654

  Message:
    Choose existing table that has time column

  Modified files:
    partials/query.editor.html
    query_ctrl.js

  Modified: partials/query.editor.html (+8 -7)
===================================================================
--- partials/query.editor.html    2016-02-15 21:00:01 +0900 (74d3340)
+++ partials/query.editor.html    2016-02-15 21:14:16 +0900 (a1a4f87)
@@ -5,13 +5,14 @@
       TABLE
     </li>
     <li>
-      <input type="text"
-             class="tight-form-input input-medium"
-             ng-model="table"
-             ng-model-onblur
-             ng-change="update()"
-             spellcheck='false'
-             placeholder="Logs">
+      <select class="tight-form-input input-medium"
+              ng-model="table"
+              ng-change="update()">
+        <option ng-repeat="name in availableTables"
+                value="{{name}}">
+          {{name}}
+        </option>
+      </select>
     </li>
     <li class="tight-form-item query-keyword"
         style="width: 75px">

  Modified: query_ctrl.js (+21 -3)
===================================================================
--- query_ctrl.js    2016-02-15 21:00:01 +0900 (3e407b3)
+++ query_ctrl.js    2016-02-15 21:14:16 +0900 (b8c50c3)
@@ -6,11 +6,28 @@ function (angular) {
 
   var module = angular.module('grafana.controllers');
 
-  module.controller('GroongaQueryCtrl', function ($scope) {
+  module.controller('GroongaQueryCtrl', function ($scope, backendSrv) {
 
     $scope.init = function () {
-      console.log('init');
-      $scope.target.table = 'Logs';
+      var options = {
+        url: $scope.datasource.datasource.url + '/d/schema'
+      };
+      return backendSrv.datasourceRequest(options).then(function(response) {
+        var tables = response.data[1].tables;
+        angular.forEach(tables, function(table, tableName) {
+          var hasTimeColumn = false;
+          var columnName;
+          for (columnName in table.columns) {
+            if (table.columns[columnName].value_type.name === 'Time') {
+              hasTimeColumn = true;
+              break;
+            }
+          }
+          if (hasTimeColumn) {
+            $scope.availableTables.push(tableName);
+          }
+        });
+      });
     };
 
     $scope.update = function () {
@@ -20,6 +37,7 @@ function (angular) {
       $scope.get_data();
     }
 
+    $scope.availableTables = [];
     $scope.init();
 
   });
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index