From a387d48b48a6f2749ec16bec2634d785fe64c147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 7 Mar 2014 19:24:45 +0100 Subject: [PATCH] began work on dashboard playlist feature, #36 --- src/app/controllers/all.js | 1 + src/app/controllers/dashLoader.js | 6 ++- src/app/controllers/playlistCtrl.js | 27 ++++++++++++ src/app/controllers/search.js | 2 +- src/app/directives/bodyClass.js | 6 ++- src/app/directives/configModal.js | 2 + src/app/panels/timepicker/module.html | 2 +- src/app/partials/dashLoader.html | 60 +++++++++++++-------------- src/app/partials/dashboard.html | 2 +- src/app/partials/playlist.html | 38 +++++++++++++++++ src/app/partials/search.html | 4 ++ src/app/services/all.js | 1 + src/app/services/playlistSrv.js | 55 ++++++++++++++++++++++++ src/css/bootstrap.dark.min.css | 2 +- src/css/bootstrap.light.min.css | 2 +- src/css/less/grafana.less | 14 +++++++ src/css/less/overrides.less | 12 ++++++ 17 files changed, 198 insertions(+), 38 deletions(-) create mode 100644 src/app/controllers/playlistCtrl.js create mode 100644 src/app/partials/playlist.html create mode 100644 src/app/services/playlistSrv.js diff --git a/src/app/controllers/all.js b/src/app/controllers/all.js index ebc9cdd9079..2626137657c 100644 --- a/src/app/controllers/all.js +++ b/src/app/controllers/all.js @@ -9,4 +9,5 @@ define([ './graphiteTarget', './graphiteImport', './influxTargetCtrl', + './playlistCtrl', ], function () {}); \ No newline at end of file diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index caa6a6e69a6..f3417abb21d 100644 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -8,7 +8,7 @@ function (angular, _, moment) { var module = angular.module('kibana.controllers'); - module.controller('dashLoader', function($scope, $rootScope, $http, dashboard, alertSrv, $location, filterSrv) { + module.controller('dashLoader', function($scope, $rootScope, $http, dashboard, alertSrv, $location, filterSrv, playlistSrv) { $scope.loader = dashboard.current.loader; $scope.init = function() { @@ -154,6 +154,10 @@ function (angular, _, moment) { }); }; + $scope.markAsFavorite = function() { + playlistSrv.markAsFavorite(); + }; + }); }); diff --git a/src/app/controllers/playlistCtrl.js b/src/app/controllers/playlistCtrl.js new file mode 100644 index 00000000000..44e112554ee --- /dev/null +++ b/src/app/controllers/playlistCtrl.js @@ -0,0 +1,27 @@ +define([ + 'angular' +], +function (angular) { + 'use strict'; + + var module = angular.module('kibana.controllers'); + + module.controller('PlaylistCtrl', function($scope, playlistSrv) { + + $scope.init = function() { + $scope.timespan = "15s"; + $scope.loadFavorites(); + $scope.$on('modal-opened', $scope.loadFavorites); + }; + + $scope.loadFavorites = function() { + $scope.favDashboards = playlistSrv.getFavorites().dashboards; + }; + + $scope.start = function() { + playlistSrv.start($scope.favDashboards, $scope.timespan); + }; + + }); + +}); \ No newline at end of file diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index eebc9d74e46..ace80b3b755 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -69,7 +69,7 @@ function (angular, _, config, $) { .query($scope.ejs.QueryStringQuery(query)) .sort('_uid') .facet($scope.ejs.TermsFacet("tags").field("tags").order('term').size(50)) - .size(50).doSearch() + .size(20).doSearch() .then(function(results) { if(_.isUndefined(results.hits)) { diff --git a/src/app/directives/bodyClass.js b/src/app/directives/bodyClass.js index ffb84c8c099..6cd9bab1346 100644 --- a/src/app/directives/bodyClass.js +++ b/src/app/directives/bodyClass.js @@ -25,13 +25,17 @@ function (angular, app, _) { }, true); $scope.$watch('dashboard.current.hideControls', function() { - var hideControls = $scope.dashboard.current.hideControls; + var hideControls = $scope.dashboard.current.hideControls || $scope.playlist_active; if (lastHideControlsVal !== hideControls) { elem.toggleClass('hide-controls', hideControls); lastHideControlsVal = hideControls; } + }); + $scope.$watch('playlist_active', function() { + elem.toggleClass('hide-controls', $scope.playlist_active === true); + elem.toggleClass('playlist-active', $scope.playlist_active === true); }); } }; diff --git a/src/app/directives/configModal.js b/src/app/directives/configModal.js index 452b326d242..bacd4442162 100644 --- a/src/app/directives/configModal.js +++ b/src/app/directives/configModal.js @@ -32,6 +32,8 @@ function (angular, _, $) { $q.when(panelModal).then(function(modalEl) { elem.attr('data-target', id).attr('data-toggle', 'modal'); + scope.$emit('modal-opened'); + $timeout(function () { if (!modalEl.data('modal').isShown) { modalEl.modal('show'); diff --git a/src/app/panels/timepicker/module.html b/src/app/panels/timepicker/module.html index 3b3019facd6..f0975d371ae 100644 --- a/src/app/panels/timepicker/module.html +++ b/src/app/panels/timepicker/module.html @@ -47,7 +47,7 @@ -
  • +
  • diff --git a/src/app/partials/dashLoader.html b/src/app/partials/dashLoader.html index 5bff28860c9..12308c445c9 100644 --- a/src/app/partials/dashLoader.html +++ b/src/app/partials/dashLoader.html @@ -10,7 +10,7 @@ -
  • +
  • Zoom Out @@ -18,54 +18,52 @@
  • -