feat(playlist): reload all dashboards every cycle

closes #3706
This commit is contained in:
bergquist 2016-01-18 13:54:32 +01:00
parent dca503bcbd
commit 62ae02bdd1
2 changed files with 14 additions and 15 deletions

View File

@ -9,6 +9,7 @@ class PlaylistSrv {
private dashboards: any
private index: number
private interval: any
private playlistId: number
/** @ngInject */
constructor(
@ -22,12 +23,17 @@ class PlaylistSrv {
this.$timeout.cancel(this.cancelPromise);
angular.element(window).unbind('resize');
var dash = this.dashboards[this.index % this.dashboards.length];
this.$location.url('dashboard/' + dash.uri);
if (this.index > this.dashboards.length -1) {
this.start(this.playlistId);
} else {
var dash = this.dashboards[this.index];
this.index++;
this.cancelPromise = this.$timeout(() => { this.next(); }, this.interval);
this.$location.url('dashboard/' + dash.uri);
this.index++;
this.cancelPromise = this.$timeout(() => { this.next(); }, this.interval);
}
}
prevfunction() {
@ -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);

View File

@ -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);
}
}
});