Browse Source

Panel: added search typeahead for dashboard links, #1041

Torkel Ödegaard 11 years ago
parent
commit
c12d830162

+ 2 - 0
src/app/app.js

@@ -78,6 +78,8 @@ function (angular, $, _, appLevelRequire, config) {
   });
 
   var preBootRequires = [
+    'services/all',
+    'features/all',
     'controllers/all',
     'directives/all',
     'filters/all',

+ 0 - 1
src/app/controllers/dashboardCtrl.js

@@ -3,7 +3,6 @@ define([
   'jquery',
   'config',
   'lodash',
-  'services/all',
 ],
 function (angular, $, config, _) {
   "use strict";

+ 0 - 1
src/app/directives/all.js

@@ -19,6 +19,5 @@ define([
   './graphiteSegment',
   './grafanaVersionCheck',
   './dropdown.typeahead',
-  'components/panellinkeditor/module',
   './influxdbFuncEditor'
 ], function () {});

+ 3 - 0
src/app/features/all.js

@@ -0,0 +1,3 @@
+define([
+  './panellinkeditor/module',
+], function () {});

+ 0 - 0
src/app/components/panellinkeditor/linkSrv.js → src/app/features/panellinkeditor/linkSrv.js


+ 4 - 1
src/app/components/panellinkeditor/module.html → src/app/features/panellinkeditor/module.html

@@ -21,7 +21,10 @@
 
 					<li class="grafana-target-segment" ng-show="link.type === 'dashboard'">dashboard</li>
 					<li ng-show="link.type === 'dashboard'">
-						<input type="text" ng-model="link.dashboard" class="input-large grafana-target-segment-input">
+						<input type="text"
+						       ng-model="link.dashboard"
+									 bs-typeahead="searchDashboards"
+									 class="input-large grafana-target-segment-input">
 					</li>
 
 					<li class="grafana-target-segment" ng-show="link.type === 'absolute'">url</li>

+ 15 - 2
src/app/components/panellinkeditor/module.js → src/app/features/panellinkeditor/module.js

@@ -15,11 +15,11 @@ function (angular, _) {
         },
         restrict: 'E',
         controller: 'PanelLinkEditorCtrl',
-        templateUrl: 'app/components/panellinkeditor/module.html',
+        templateUrl: 'app/features/panellinkeditor/module.html',
         link: function() {
         }
       };
-    }).controller('PanelLinkEditorCtrl', function($scope) {
+    }).controller('PanelLinkEditorCtrl', function($scope, datasourceSrv) {
 
       $scope.panel.links = $scope.panel.links || [];
 
@@ -30,6 +30,19 @@ function (angular, _) {
         });
       };
 
+      $scope.searchDashboards = function(query, callback) {
+        var ds = datasourceSrv.getGrafanaDB();
+        if (ds === null) { return; }
+
+        ds.searchDashboards(query).then(function(result) {
+          var dashboards = _.map(result.dashboards, function(dash) {
+            return dash.title;
+          });
+
+          callback(dashboards);
+        });
+      };
+
       $scope.deleteLink = function(link) {
         $scope.panel.links = _.without($scope.panel.links, link);
       };

+ 0 - 1
src/app/services/dashboard/dashboardKeyBindings.js

@@ -1,7 +1,6 @@
 define([
   'angular',
   'jquery',
-  'services/all'
 ],
 function(angular, $) {
   "use strict";

+ 4 - 3
tasks/options/requirejs.js

@@ -54,12 +54,13 @@ module.exports = function(config,grunt) {
         'timepicker',
         'datepicker',
         'lodash',
-        'filters/all',
         'jquery.flot',
-        'services/all',
         'angular-strap',
-        'directives/all',
         'angular-dragdrop',
+        'services/all',
+        'features/all',
+        'directives/all',
+        'filters/all',
         'controllers/all',
         'routes/all',
         'components/partials',