Просмотр исходного кода

Fixed playlist functionallity, broken after recent changes

Torkel Ödegaard 10 лет назад
Родитель
Сommit
dcfad7d61b

+ 1 - 1
src/app/controllers/search.js

@@ -60,7 +60,7 @@ function (angular, _, config) {
       $scope.currentSearchId = $scope.currentSearchId + 1;
       var localSearchId = $scope.currentSearchId;
 
-      return backendSrv.get('/api/search', $scope.query).then(function(results) {
+      return backendSrv.search($scope.query).then(function(results) {
         if (localSearchId < $scope.currentSearchId) { return; }
 
         $scope.resultCount = results.tagsOnly ? results.tags.length : results.dashboards.length;

+ 2 - 3
src/app/features/dashboard/playlistCtrl.js

@@ -8,12 +8,11 @@ function (angular, _, config) {
 
   var module = angular.module('grafana.controllers');
 
-  module.controller('PlaylistCtrl', function($scope, playlistSrv, datasourceSrv) {
+  module.controller('PlaylistCtrl', function($scope, playlistSrv, backendSrv) {
 
     $scope.init = function() {
       $scope.playlist = [];
       $scope.timespan = config.playlist_timespan;
-      $scope.db = datasourceSrv.getGrafanaDB();
       $scope.search();
     };
 
@@ -25,7 +24,7 @@ function (angular, _, config) {
         query.starred = false;
       }
 
-      $scope.db.searchDashboards(query).then(function(results) {
+      backendSrv.search(query).then(function(results) {
         $scope.searchHits = results.dashboards;
         $scope.filterHits();
       });

+ 6 - 4
src/app/features/dashboard/playlistSrv.js

@@ -17,11 +17,10 @@ function (angular, _, kbn) {
 
       angular.element(window).unbind('resize');
       var dash = self.dashboards[self.index % self.dashboards.length];
-      var relativeUrl = dash.url.substring($location.absUrl().length - $location.url().length);
 
-      $location.url(relativeUrl);
-      self.index++;
+      $location.url('dashboard/db/' + dash.slug);
 
+      self.index++;
       self.cancelPromise = $timeout(self.next, self.interval);
     };
 
@@ -31,13 +30,16 @@ function (angular, _, kbn) {
     };
 
     this.start = function(dashboards, timespan) {
-      this.stop();
+      self.stop();
 
+      self.index = 0;
       self.interval = kbn.interval_to_ms(timespan);
+
       self.dashboards = dashboards;
       $rootScope.playlistSrv = this;
 
       self.cancelPromise = $timeout(self.next, self.interval);
+      self.next();
     };
 
     this.stop = function() {

+ 1 - 1
src/app/partials/search.html

@@ -71,7 +71,7 @@
 			<i class="fa fa-download"></i>
 			Import
 		</a>
-		<button class="btn btn-inverse pull-left" dash-editor-link="app/partials/playlist.html" editor-scope="isolated">
+		<button class="btn btn-inverse pull-left" dash-editor-link="app/partials/playlist.html" editor-scope="isolated" ng-click="dismiss();">
 			<i class="fa fa-play"></i>
 			Playlist
 		</button>

+ 0 - 5
src/app/plugins/datasource/elasticsearch/datasource.js

@@ -18,15 +18,10 @@ function (angular, _, config, kbn, moment) {
       this.url = datasource.url;
       this.name = datasource.name;
       this.index = datasource.index;
-      this.grafanaDB = datasource.grafanaDB;
       this.searchMaxResults = config.search.max_results || 20;
 
       this.saveTemp = _.isUndefined(datasource.save_temp) ? true : datasource.save_temp;
       this.saveTempTTL = _.isUndefined(datasource.save_temp_ttl) ? '30d' : datasource.save_temp_ttl;
-
-      this.annotationEditorSrc = 'app/features/elasticsearch/partials/annotations.editor.html';
-      this.supportAnnotations = true;
-      this.supportMetrics = false;
     }
 
     ElasticDatasource.prototype._request = function(method, url, index, data) {

+ 0 - 5
src/app/plugins/datasource/grafana/datasource.js

@@ -11,11 +11,6 @@ function (angular, _, kbn) {
   module.factory('GrafanaDatasource', function($q, backendSrv) {
 
     function GrafanaDatasource() {
-      this.type = 'grafana';
-      this.grafanaDB = true;
-      this.name = "grafana";
-      this.supportMetrics = true;
-      this.editorSrc = 'app/features/grafanaDatasource/partials/query.editor.html';
     }
 
     GrafanaDatasource.prototype.getDashboard = function(slug, isTemp) {

+ 4 - 0
src/app/services/backendSrv.js

@@ -77,6 +77,10 @@ function (angular, _, config) {
       });
     };
 
+    this.search = function(query) {
+      return this.get('/api/search', query);
+    };
+
     this.saveDashboard = function(dash) {
       return this.post('/api/dashboards/db/', {dashboard: dash});
     };