From c12d830162ab428e27f508279aeacb12d93ca80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Nov 2014 13:38:27 +0100 Subject: [PATCH] Panel: added search typeahead for dashboard links, #1041 --- src/app/app.js | 2 ++ src/app/controllers/dashboardCtrl.js | 1 - src/app/directives/all.js | 1 - src/app/features/all.js | 3 +++ .../panellinkeditor/linkSrv.js | 0 .../panellinkeditor/module.html | 5 ++++- .../panellinkeditor/module.js | 17 +++++++++++++++-- .../services/dashboard/dashboardKeyBindings.js | 1 - tasks/options/requirejs.js | 7 ++++--- 9 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/app/features/all.js rename src/app/{components => features}/panellinkeditor/linkSrv.js (100%) rename src/app/{components => features}/panellinkeditor/module.html (90%) rename src/app/{components => features}/panellinkeditor/module.js (57%) diff --git a/src/app/app.js b/src/app/app.js index 0b75d459435..bb03d47686d 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -78,6 +78,8 @@ function (angular, $, _, appLevelRequire, config) { }); var preBootRequires = [ + 'services/all', + 'features/all', 'controllers/all', 'directives/all', 'filters/all', diff --git a/src/app/controllers/dashboardCtrl.js b/src/app/controllers/dashboardCtrl.js index d69978dcdea..0aee19d82e4 100644 --- a/src/app/controllers/dashboardCtrl.js +++ b/src/app/controllers/dashboardCtrl.js @@ -3,7 +3,6 @@ define([ 'jquery', 'config', 'lodash', - 'services/all', ], function (angular, $, config, _) { "use strict"; diff --git a/src/app/directives/all.js b/src/app/directives/all.js index 15c2a5c80f7..7f7836728a6 100644 --- a/src/app/directives/all.js +++ b/src/app/directives/all.js @@ -19,6 +19,5 @@ define([ './graphiteSegment', './grafanaVersionCheck', './dropdown.typeahead', - 'components/panellinkeditor/module', './influxdbFuncEditor' ], function () {}); diff --git a/src/app/features/all.js b/src/app/features/all.js new file mode 100644 index 00000000000..5e11ae038f6 --- /dev/null +++ b/src/app/features/all.js @@ -0,0 +1,3 @@ +define([ + './panellinkeditor/module', +], function () {}); diff --git a/src/app/components/panellinkeditor/linkSrv.js b/src/app/features/panellinkeditor/linkSrv.js similarity index 100% rename from src/app/components/panellinkeditor/linkSrv.js rename to src/app/features/panellinkeditor/linkSrv.js diff --git a/src/app/components/panellinkeditor/module.html b/src/app/features/panellinkeditor/module.html similarity index 90% rename from src/app/components/panellinkeditor/module.html rename to src/app/features/panellinkeditor/module.html index 2cbdc50e49b..11558f7c90c 100644 --- a/src/app/components/panellinkeditor/module.html +++ b/src/app/features/panellinkeditor/module.html @@ -21,7 +21,10 @@
  • dashboard
  • - +
  • url
  • diff --git a/src/app/components/panellinkeditor/module.js b/src/app/features/panellinkeditor/module.js similarity index 57% rename from src/app/components/panellinkeditor/module.js rename to src/app/features/panellinkeditor/module.js index fe6f9684f7f..3052466d1d1 100644 --- a/src/app/components/panellinkeditor/module.js +++ b/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); }; diff --git a/src/app/services/dashboard/dashboardKeyBindings.js b/src/app/services/dashboard/dashboardKeyBindings.js index 95e61dbea8d..1557a3848d3 100644 --- a/src/app/services/dashboard/dashboardKeyBindings.js +++ b/src/app/services/dashboard/dashboardKeyBindings.js @@ -1,7 +1,6 @@ define([ 'angular', 'jquery', - 'services/all' ], function(angular, $) { "use strict"; diff --git a/tasks/options/requirejs.js b/tasks/options/requirejs.js index a5e9008ac3c..a889b9fd154 100644 --- a/tasks/options/requirejs.js +++ b/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',