Browse Source

feat(playlist): reload all dashboards every cycle

closes #3706
bergquist 10 years ago
parent
commit
62ae02bdd1

+ 12 - 4
public/app/features/playlist/playlistSrv.ts

@@ -9,6 +9,7 @@ class PlaylistSrv {
   private dashboards: any
   private dashboards: any
   private index: number
   private index: number
   private interval: any
   private interval: any
+  private playlistId: number
 
 
   /** @ngInject */
   /** @ngInject */
   constructor(
   constructor(
@@ -22,12 +23,17 @@ class PlaylistSrv {
     this.$timeout.cancel(this.cancelPromise);
     this.$timeout.cancel(this.cancelPromise);
 
 
     angular.element(window).unbind('resize');
     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() {
   prevfunction() {
@@ -39,6 +45,7 @@ class PlaylistSrv {
     this.stop();
     this.stop();
 
 
     this.index = 0;
     this.index = 0;
+    this.playlistId = playlistId;
 
 
     this.$rootScope.playlistSrv = this;
     this.$rootScope.playlistSrv = this;
 
 
@@ -57,6 +64,7 @@ class PlaylistSrv {
 
 
   stop() {
   stop() {
     this.index = 0;
     this.index = 0;
+    this.playlistId = 0;
 
 
     if (this.cancelPromise) {
     if (this.cancelPromise) {
         this.$timeout.cancel(this.cancelPromise);
         this.$timeout.cancel(this.cancelPromise);

+ 2 - 11
public/app/features/playlist/playlist_routes.js

@@ -26,19 +26,10 @@ function (angular) {
         templateUrl: 'app/partials/dashboard.html',
         templateUrl: 'app/partials/dashboard.html',
         controller : 'LoadDashboardCtrl',
         controller : 'LoadDashboardCtrl',
         resolve: {
         resolve: {
-          init: function(backendSrv, playlistSrv, $route) {
+          init: function(playlistSrv, $route) {
             var playlistId = $route.current.params.id;
             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);
           }
           }
         }
         }
       });
       });