From dca503bcbd61a468a2c6ee80bc7af58bc1f051b4 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 18 Jan 2016 13:40:51 +0100 Subject: [PATCH] feat(playlist): playlistsrv is now started by id --- public/app/features/playlist/playlistSrv.ts | 23 ++++++++++++++----- .../app/features/playlist/playlist_routes.js | 3 +++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/public/app/features/playlist/playlistSrv.ts b/public/app/features/playlist/playlistSrv.ts index 2377aae8db2..efb45d81182 100644 --- a/public/app/features/playlist/playlistSrv.ts +++ b/public/app/features/playlist/playlistSrv.ts @@ -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() { diff --git a/public/app/features/playlist/playlist_routes.js b/public/app/features/playlist/playlist_routes.js index b9358148f8a..a7737dd4e10 100644 --- a/public/app/features/playlist/playlist_routes.js +++ b/public/app/features/playlist/playlist_routes.js @@ -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); }); }); + */ } } });