mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 10:50:37 -06:00
parent
dca503bcbd
commit
62ae02bdd1
@ -9,6 +9,7 @@ class PlaylistSrv {
|
||||
private dashboards: any
|
||||
private index: number
|
||||
private interval: any
|
||||
private playlistId: number
|
||||
|
||||
/** @ngInject */
|
||||
constructor(
|
||||
@ -22,13 +23,18 @@ class PlaylistSrv {
|
||||
this.$timeout.cancel(this.cancelPromise);
|
||||
|
||||
angular.element(window).unbind('resize');
|
||||
var dash = this.dashboards[this.index % this.dashboards.length];
|
||||
|
||||
if (this.index > this.dashboards.length -1) {
|
||||
this.start(this.playlistId);
|
||||
} else {
|
||||
var dash = this.dashboards[this.index];
|
||||
|
||||
this.$location.url('dashboard/' + dash.uri);
|
||||
|
||||
this.index++;
|
||||
this.cancelPromise = this.$timeout(() => { this.next(); }, this.interval);
|
||||
}
|
||||
}
|
||||
|
||||
prevfunction() {
|
||||
this.index = Math.max(this.index - 2, 0);
|
||||
@ -39,6 +45,7 @@ class PlaylistSrv {
|
||||
this.stop();
|
||||
|
||||
this.index = 0;
|
||||
this.playlistId = playlistId;
|
||||
|
||||
this.$rootScope.playlistSrv = this;
|
||||
|
||||
@ -57,6 +64,7 @@ class PlaylistSrv {
|
||||
|
||||
stop() {
|
||||
this.index = 0;
|
||||
this.playlistId = 0;
|
||||
|
||||
if (this.cancelPromise) {
|
||||
this.$timeout.cancel(this.cancelPromise);
|
||||
|
@ -26,19 +26,10 @@ function (angular) {
|
||||
templateUrl: 'app/partials/dashboard.html',
|
||||
controller : 'LoadDashboardCtrl',
|
||||
resolve: {
|
||||
init: function(backendSrv, playlistSrv, $route) {
|
||||
init: function(playlistSrv, $route) {
|
||||
var playlistId = $route.current.params.id;
|
||||
|
||||
playlistSrv.start(playlistId)
|
||||
/*
|
||||
return backendSrv.get('/api/playlists/' + playlistId)
|
||||
.then(function(playlist) {
|
||||
return backendSrv.get('/api/playlists/' + playlistId + '/dashboards')
|
||||
.then(function(dashboards) {
|
||||
playlistSrv.start(dashboards, playlist.interval);
|
||||
});
|
||||
});
|
||||
*/
|
||||
playlistSrv.start(playlistId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user