mirror of
https://github.com/grafana/grafana.git
synced 2026-08-25 21:07:38 -05:00
feat(playlist): playlistsrv is now started by id
This commit is contained in:
@@ -11,7 +11,11 @@ class PlaylistSrv {
|
||||
private interval: any
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private $rootScope:any, private $location:any, private $timeout:any) {
|
||||
constructor(
|
||||
private $rootScope:any,
|
||||
private $location:any,
|
||||
private $timeout:any,
|
||||
private backendSrv:any) {
|
||||
}
|
||||
|
||||
next() {
|
||||
@@ -31,17 +35,24 @@ class PlaylistSrv {
|
||||
this.next();
|
||||
}
|
||||
|
||||
start(dashboards, interval) {
|
||||
start(playlistId) {
|
||||
this.stop();
|
||||
|
||||
this.index = 0;
|
||||
this.interval = kbn.interval_to_ms(interval);
|
||||
|
||||
this.dashboards = dashboards;
|
||||
this.$rootScope.playlistSrv = this;
|
||||
|
||||
this.cancelPromise = this.$timeout(() => { this.next(); }, this.interval);
|
||||
this.next();
|
||||
this.backendSrv.get('/api/playlists/' + playlistId)
|
||||
.then((playlist) => {
|
||||
this.backendSrv.get('/api/playlists/' + playlistId + '/dashboards')
|
||||
.then((dashboards) => {
|
||||
this.dashboards = dashboards;
|
||||
this.interval = kbn.interval_to_ms(playlist.interval);
|
||||
this.cancelPromise = this.$timeout(() => { this.next(); }, this.interval);
|
||||
|
||||
this.next();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
||||
@@ -29,6 +29,8 @@ function (angular) {
|
||||
init: function(backendSrv, 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')
|
||||
@@ -36,6 +38,7 @@ function (angular) {
|
||||
playlistSrv.start(dashboards, playlist.interval);
|
||||
});
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user