Commit dcfad7d6 by Torkel Ödegaard

Fixed playlist functionallity, broken after recent changes

parent 9e892bdd
...@@ -60,7 +60,7 @@ function (angular, _, config) { ...@@ -60,7 +60,7 @@ function (angular, _, config) {
$scope.currentSearchId = $scope.currentSearchId + 1; $scope.currentSearchId = $scope.currentSearchId + 1;
var localSearchId = $scope.currentSearchId; 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; } if (localSearchId < $scope.currentSearchId) { return; }
$scope.resultCount = results.tagsOnly ? results.tags.length : results.dashboards.length; $scope.resultCount = results.tagsOnly ? results.tags.length : results.dashboards.length;
......
...@@ -8,12 +8,11 @@ function (angular, _, config) { ...@@ -8,12 +8,11 @@ function (angular, _, config) {
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('PlaylistCtrl', function($scope, playlistSrv, datasourceSrv) { module.controller('PlaylistCtrl', function($scope, playlistSrv, backendSrv) {
$scope.init = function() { $scope.init = function() {
$scope.playlist = []; $scope.playlist = [];
$scope.timespan = config.playlist_timespan; $scope.timespan = config.playlist_timespan;
$scope.db = datasourceSrv.getGrafanaDB();
$scope.search(); $scope.search();
}; };
...@@ -25,7 +24,7 @@ function (angular, _, config) { ...@@ -25,7 +24,7 @@ function (angular, _, config) {
query.starred = false; query.starred = false;
} }
$scope.db.searchDashboards(query).then(function(results) { backendSrv.search(query).then(function(results) {
$scope.searchHits = results.dashboards; $scope.searchHits = results.dashboards;
$scope.filterHits(); $scope.filterHits();
}); });
......
...@@ -17,11 +17,10 @@ function (angular, _, kbn) { ...@@ -17,11 +17,10 @@ function (angular, _, kbn) {
angular.element(window).unbind('resize'); angular.element(window).unbind('resize');
var dash = self.dashboards[self.index % self.dashboards.length]; var dash = self.dashboards[self.index % self.dashboards.length];
var relativeUrl = dash.url.substring($location.absUrl().length - $location.url().length);
$location.url(relativeUrl); $location.url('dashboard/db/' + dash.slug);
self.index++;
self.index++;
self.cancelPromise = $timeout(self.next, self.interval); self.cancelPromise = $timeout(self.next, self.interval);
}; };
...@@ -31,13 +30,16 @@ function (angular, _, kbn) { ...@@ -31,13 +30,16 @@ function (angular, _, kbn) {
}; };
this.start = function(dashboards, timespan) { this.start = function(dashboards, timespan) {
this.stop(); self.stop();
self.index = 0;
self.interval = kbn.interval_to_ms(timespan); self.interval = kbn.interval_to_ms(timespan);
self.dashboards = dashboards; self.dashboards = dashboards;
$rootScope.playlistSrv = this; $rootScope.playlistSrv = this;
self.cancelPromise = $timeout(self.next, self.interval); self.cancelPromise = $timeout(self.next, self.interval);
self.next();
}; };
this.stop = function() { this.stop = function() {
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<i class="fa fa-download"></i> <i class="fa fa-download"></i>
Import Import
</a> </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> <i class="fa fa-play"></i>
Playlist Playlist
</button> </button>
......
...@@ -18,15 +18,10 @@ function (angular, _, config, kbn, moment) { ...@@ -18,15 +18,10 @@ function (angular, _, config, kbn, moment) {
this.url = datasource.url; this.url = datasource.url;
this.name = datasource.name; this.name = datasource.name;
this.index = datasource.index; this.index = datasource.index;
this.grafanaDB = datasource.grafanaDB;
this.searchMaxResults = config.search.max_results || 20; this.searchMaxResults = config.search.max_results || 20;
this.saveTemp = _.isUndefined(datasource.save_temp) ? true : datasource.save_temp; this.saveTemp = _.isUndefined(datasource.save_temp) ? true : datasource.save_temp;
this.saveTempTTL = _.isUndefined(datasource.save_temp_ttl) ? '30d' : datasource.save_temp_ttl; 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) { ElasticDatasource.prototype._request = function(method, url, index, data) {
......
...@@ -11,11 +11,6 @@ function (angular, _, kbn) { ...@@ -11,11 +11,6 @@ function (angular, _, kbn) {
module.factory('GrafanaDatasource', function($q, backendSrv) { module.factory('GrafanaDatasource', function($q, backendSrv) {
function GrafanaDatasource() { 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) { GrafanaDatasource.prototype.getDashboard = function(slug, isTemp) {
......
...@@ -77,6 +77,10 @@ function (angular, _, config) { ...@@ -77,6 +77,10 @@ function (angular, _, config) {
}); });
}; };
this.search = function(query) {
return this.get('/api/search', query);
};
this.saveDashboard = function(dash) { this.saveDashboard = function(dash) {
return this.post('/api/dashboards/db/', {dashboard: dash}); return this.post('/api/dashboards/db/', {dashboard: dash});
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment