feat(playlist): playlistsrv is now started by id

This commit is contained in:
bergquist
2016-01-18 13:40:51 +01:00
parent bc21862661
commit dca503bcbd
2 changed files with 20 additions and 6 deletions
+17 -6
View File
@@ -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);
});
});
*/
}
}
});