| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- define([
- 'angular',
- 'lodash',
- 'kbn',
- 'store'
- ],
- function (angular, _, kbn) {
- 'use strict';
- var module = angular.module('grafana.services');
- module.service('playlistSrv', function($location, $rootScope, $timeout) {
- var self = this;
- this.next = function() {
- $timeout.cancel(self.cancelPromise);
- angular.element(window).unbind('resize');
- var dash = self.dashboards[self.index % self.dashboards.length];
- $location.url('dashboard/db/' + dash.slug);
- self.index++;
- self.cancelPromise = $timeout(self.next, self.interval);
- };
- this.prev = function() {
- self.index = Math.max(self.index - 2, 0);
- self.next();
- };
- this.start = function(dashboards, timespan) {
- self.stop();
- self.index = 0;
- self.interval = kbn.interval_to_ms(timespan);
- self.dashboards = dashboards;
- $rootScope.playlistSrv = this;
- self.cancelPromise = $timeout(self.next, self.interval);
- self.next();
- };
- this.stop = function() {
- self.index = 0;
- if (self.cancelPromise) {
- $timeout.cancel(self.cancelPromise);
- }
- $rootScope.playlistSrv = null;
- };
- });
- });
|