diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index d501f01a81f..0cd2a3d0db3 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -18,7 +18,6 @@ function (angular, _, config, $) { $scope.query = { query: 'title:' }; $scope.db = datasourceSrv.getGrafanaDB(); $scope.currentSearchId = 0; - $scope.starsPromise = $scope.grafana.user.getStars(); // events $scope.onAppEvent('dashboard-deleted', $scope.dashboardDeleted); @@ -78,13 +77,10 @@ function (angular, _, config, $) { .then(function(results) { if (localSearchId < $scope.currentSearchId) { return; } - $scope.starsPromise.then(function(stars) { - $scope.starredIds = stars.dashboardIds; - $scope.tagsOnly = results.tagsOnly; - $scope.results.dashboards = results.dashboards; - $scope.results.tags = results.tags; - $scope.resultCount = results.tagsOnly ? results.tags.length : results.dashboards.length; - }); + $scope.tagsOnly = results.tagsOnly; + $scope.results.dashboards = results.dashboards; + $scope.results.tags = results.tags; + $scope.resultCount = results.tagsOnly ? results.tags.length : results.dashboards.length; }); }; diff --git a/src/app/panels/dashlist/editor.html b/src/app/panels/dashlist/editor.html new file mode 100644 index 00000000000..87a00132827 --- /dev/null +++ b/src/app/panels/dashlist/editor.html @@ -0,0 +1,41 @@ + +
+
+
+
    +
  • + Mode +
  • +
  • + +
  • +
+
+
+
+
+
+
    +
  • + Search options +
  • +
  • + Query +
  • +
  • + +
  • +
  • + Tag +
  • +
  • + +
  • +
+
+
+
+
+ diff --git a/src/app/panels/dashlist/module.html b/src/app/panels/dashlist/module.html index 3ecf6372fca..c02e993984a 100644 --- a/src/app/panels/dashlist/module.html +++ b/src/app/panels/dashlist/module.html @@ -6,7 +6,7 @@ {{dash.title}} - + diff --git a/src/app/panels/dashlist/module.js b/src/app/panels/dashlist/module.js index 05a07481298..7dd3aebcc4e 100644 --- a/src/app/panels/dashlist/module.js +++ b/src/app/panels/dashlist/module.js @@ -26,9 +26,16 @@ function (angular, app, _, config, PanelMeta) { fullscreen: true, }); + $scope.panelMeta.addEditorTab('Options', 'app/panels/dashlist/editor.html'); + var defaults = { + mode: 'starred', + query: '', + tag: '', }; + $scope.modes = ['starred', 'search']; + _.defaults($scope.panel, defaults); $scope.dashList = []; @@ -44,7 +51,14 @@ function (angular, app, _, config, PanelMeta) { }; $scope.get_data = function() { - backendSrv.get('/api/search', { starred: 1 }).then(function(result) { + var params = {}; + if ($scope.panel.mode === 'starred') { + params.starred = 1; + } else { + params.q = "tags:" + $scope.panel.tag + " AND title:" + $scope.panel.query; + } + + backendSrv.get('/api/search', params).then(function(result) { $scope.dashList = result.dashboards; $scope.panelMeta.loading = false; }); diff --git a/src/app/partials/search.html b/src/app/partials/search.html index 8e7b7abe6fe..351426d2d48 100644 --- a/src/app/partials/search.html +++ b/src/app/partials/search.html @@ -61,7 +61,7 @@ {{tag}} - + diff --git a/src/app/services/userSrv.js b/src/app/services/userSrv.js index bc8ff7681b4..14f373f7b1b 100644 --- a/src/app/services/userSrv.js +++ b/src/app/services/userSrv.js @@ -7,7 +7,7 @@ function (angular, _) { var module = angular.module('grafana.services'); - module.service('userSrv', function(backendSrv, $q) { + module.service('userSrv', function() { function User() { if (window.grafanaBootData.user) { @@ -15,16 +15,6 @@ function (angular, _) { } } - User.prototype.getStars = function() { - if (!this.isSignedIn) { - return $q.when([]); - } - - return backendSrv.get('/api/user/stars').then(function(stars) { - return stars; - }); - }; - this.getSignedInUser = function() { return new User(); }; diff --git a/src/css/less/dashlist.less b/src/css/less/dashlist.less index 87264a0d963..03fddf83de1 100644 --- a/src/css/less/dashlist.less +++ b/src/css/less/dashlist.less @@ -10,7 +10,13 @@ border: 1px solid @grafanaTargetBorder; .fa { float: right; - color: @orange; padding-top: 3px; } + .fa-star { + color: @orange; + } + + &:hover { + background-color: @grafanaTargetFuncBackground; + } } diff --git a/src/dashboards/home.json b/src/dashboards/home.json index ec63a9842ce..1cc28db24ae 100644 --- a/src/dashboards/home.json +++ b/src/dashboards/home.json @@ -25,19 +25,21 @@ ] }, { - "height": "410px", + "height": "610px", "panels": [ { "id": 2, "span": 6, "type": "dashlist", + "mode": "starred", "title": "Starred dashboards" }, { "id": 3, "span": 6, "type": "dashlist", - "title": "Previously visited dashboards" + "mode": "search", + "title": "Dashboards" } ] }