mirror of https://github.com/grafana/grafana
commit
3b5a583903
@ -0,0 +1,30 @@ |
|||||||
|
<div class="submenu-controls"> |
||||||
|
<div class="tight-form borderless"> |
||||||
|
|
||||||
|
<ul class="tight-form-list" ng-if="ctrl.dashboard.templating.list.length > 0"> |
||||||
|
<li ng-repeat="variable in ctrl.variables" class="submenu-item"> |
||||||
|
<span class="template-variable tight-form-item" ng-show="!variable.hideLabel" style="padding-right: 5px"> |
||||||
|
{{variable.label || variable.name}}: |
||||||
|
</span> |
||||||
|
<value-select-dropdown variable="variable" on-updated="ctrl.variableUpdated(variable)" get-values-for-tag="ctrl.getValuesForTag(variable, tagKey)"></value-select-dropdown> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<ul class="tight-form-list" ng-if="ctrl.dashboard.annotations.list.length > 0"> |
||||||
|
<li ng-repeat="annotation in ctrl.dashboard.annotations.list" class="submenu-item annotation-segment" ng-class="{'annotation-disabled': !annotation.enable}"> |
||||||
|
<a ng-click="ctrl.disableAnnotation(annotation)"> |
||||||
|
<i class="fa fa-bolt" style="color:{{annotation.iconColor}}"></i> |
||||||
|
{{annotation.name}} |
||||||
|
<input class="cr1" id="hideYAxis" type="checkbox" ng-model="annotation.enable" ng-checked="annotation.enable"> |
||||||
|
<label for="hideYAxis" class="cr1"></label> |
||||||
|
</a> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<ul class="tight-form-list pull-right" ng-if="ctrl.dashboard.links.length > 0"> |
||||||
|
<dash-links-container links="ctrl.dashboard.links"></dash-links-container> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<div class="clearfix"></div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
///<reference path="../../../headers/common.d.ts" />
|
||||||
|
|
||||||
|
import angular from 'angular'; |
||||||
|
|
||||||
|
export class SubmenuCtrl { |
||||||
|
annotations: any; |
||||||
|
variables: any; |
||||||
|
dashboard: any; |
||||||
|
|
||||||
|
constructor(private $rootScope, private templateValuesSrv, private dynamicDashboardSrv) { |
||||||
|
this.annotations = this.dashboard.templating.list; |
||||||
|
this.variables = this.dashboard.templating.list; |
||||||
|
} |
||||||
|
|
||||||
|
disableAnnotation(annotation) { |
||||||
|
annotation.enable = !annotation.enable; |
||||||
|
this.$rootScope.$broadcast('refresh'); |
||||||
|
} |
||||||
|
|
||||||
|
getValuesForTag(variable, tagKey) { |
||||||
|
return this.templateValuesSrv.getValuesForTag(variable, tagKey); |
||||||
|
} |
||||||
|
|
||||||
|
variableUpdated(variable) { |
||||||
|
this.templateValuesSrv.variableUpdated(variable).then(() => { |
||||||
|
this.dynamicDashboardSrv.update(this.dashboard); |
||||||
|
this.$rootScope.$emit('template-variable-value-updated'); |
||||||
|
this.$rootScope.$broadcast('refresh'); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export function submenuDirective() { |
||||||
|
return { |
||||||
|
restrict: 'E', |
||||||
|
templateUrl: 'app/features/dashboard/submenu/submenu.html', |
||||||
|
controller: SubmenuCtrl, |
||||||
|
bindToController: true, |
||||||
|
controllerAs: 'ctrl', |
||||||
|
scope: { |
||||||
|
dashboard: "=", |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
angular.module('grafana.directives').directive('dashboardSubmenu', submenuDirective); |
||||||
@ -1,39 +0,0 @@ |
|||||||
define([ |
|
||||||
'angular', |
|
||||||
], |
|
||||||
function (angular) { |
|
||||||
'use strict'; |
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers'); |
|
||||||
|
|
||||||
module.controller('SubmenuCtrl', function($scope, $q, $rootScope, templateValuesSrv, dynamicDashboardSrv) { |
|
||||||
|
|
||||||
$scope.init = function() { |
|
||||||
$scope.panel = $scope.pulldown; |
|
||||||
$scope.row = $scope.pulldown; |
|
||||||
$scope.annotations = $scope.dashboard.templating.list; |
|
||||||
$scope.variables = $scope.dashboard.templating.list; |
|
||||||
}; |
|
||||||
|
|
||||||
$scope.disableAnnotation = function (annotation) { |
|
||||||
annotation.enable = !annotation.enable; |
|
||||||
$rootScope.$broadcast('refresh'); |
|
||||||
}; |
|
||||||
|
|
||||||
$scope.getValuesForTag = function(variable, tagKey) { |
|
||||||
return templateValuesSrv.getValuesForTag(variable, tagKey); |
|
||||||
}; |
|
||||||
|
|
||||||
$scope.variableUpdated = function(variable) { |
|
||||||
templateValuesSrv.variableUpdated(variable).then(function() { |
|
||||||
dynamicDashboardSrv.update($scope.dashboard); |
|
||||||
$rootScope.$emit('template-variable-value-updated'); |
|
||||||
$rootScope.$broadcast('refresh'); |
|
||||||
}); |
|
||||||
}; |
|
||||||
|
|
||||||
$scope.init(); |
|
||||||
|
|
||||||
}); |
|
||||||
|
|
||||||
}); |
|
||||||
@ -1,6 +1,6 @@ |
|||||||
define([ |
define([ |
||||||
'./playlists_ctrl', |
'./playlists_ctrl', |
||||||
'./playlistSrv', |
'./playlist_srv', |
||||||
'./playlist_edit_ctrl', |
'./playlist_edit_ctrl', |
||||||
'./playlist_routes' |
'./playlist_routes' |
||||||
], function () {}); |
], function () {}); |
||||||
|
|||||||
@ -1,56 +0,0 @@ |
|||||||
define([ |
|
||||||
'angular', |
|
||||||
'lodash', |
|
||||||
'app/core/utils/kbn', |
|
||||||
], |
|
||||||
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/' + dash.uri); |
|
||||||
|
|
||||||
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, interval) { |
|
||||||
self.stop(); |
|
||||||
|
|
||||||
self.index = 0; |
|
||||||
self.interval = kbn.interval_to_ms(interval); |
|
||||||
|
|
||||||
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; |
|
||||||
}; |
|
||||||
|
|
||||||
}); |
|
||||||
|
|
||||||
}); |
|
||||||
@ -0,0 +1,67 @@ |
|||||||
|
///<reference path="../../headers/common.d.ts" />
|
||||||
|
|
||||||
|
import angular from 'angular'; |
||||||
|
import coreModule from '../../core/core_module'; |
||||||
|
import kbn from 'app/core/utils/kbn'; |
||||||
|
|
||||||
|
class PlaylistSrv { |
||||||
|
private cancelPromise: any; |
||||||
|
private dashboards: any; |
||||||
|
private index: number; |
||||||
|
private interval: any; |
||||||
|
private playlistId: number; |
||||||
|
|
||||||
|
/** @ngInject */ |
||||||
|
constructor(private $rootScope: any, private $location: any, private $timeout: any, private backendSrv: any) { } |
||||||
|
|
||||||
|
next() { |
||||||
|
this.$timeout.cancel(this.cancelPromise); |
||||||
|
|
||||||
|
var playedAllDashboards = this.index > this.dashboards.length - 1; |
||||||
|
|
||||||
|
if (playedAllDashboards) { |
||||||
|
this.start(this.playlistId); |
||||||
|
} else { |
||||||
|
var dash = this.dashboards[this.index]; |
||||||
|
|
||||||
|
this.$location.url('dashboard/' + dash.uri); |
||||||
|
|
||||||
|
this.index++; |
||||||
|
this.cancelPromise = this.$timeout(() => this.next(), this.interval); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
prev() { |
||||||
|
this.index = Math.max(this.index - 2, 0); |
||||||
|
this.next(); |
||||||
|
} |
||||||
|
|
||||||
|
start(playlistId) { |
||||||
|
this.stop(); |
||||||
|
|
||||||
|
this.index = 0; |
||||||
|
this.playlistId = playlistId; |
||||||
|
this.$rootScope.playlistSrv = this; |
||||||
|
|
||||||
|
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.next(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
stop() { |
||||||
|
this.index = 0; |
||||||
|
this.playlistId = 0; |
||||||
|
|
||||||
|
if (this.cancelPromise) { |
||||||
|
this.$timeout.cancel(this.cancelPromise); |
||||||
|
} |
||||||
|
|
||||||
|
this.$rootScope.playlistSrv = null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
coreModule.service('playlistSrv', PlaylistSrv); |
||||||
@ -1,30 +0,0 @@ |
|||||||
<div class="submenu-controls" ng-controller="SubmenuCtrl"> |
|
||||||
<div class="tight-form borderless"> |
|
||||||
|
|
||||||
<ul class="tight-form-list" ng-if="dashboard.templating.list.length > 0"> |
|
||||||
<li ng-repeat="variable in variables" class="submenu-item"> |
|
||||||
<span class="template-variable tight-form-item" ng-show="!variable.hideLabel" style="padding-right: 5px"> |
|
||||||
{{variable.label || variable.name}}: |
|
||||||
</span> |
|
||||||
<value-select-dropdown variable="variable" on-updated="variableUpdated(variable)" get-values-for-tag="getValuesForTag(variable, tagKey)"></value-select-dropdown> |
|
||||||
</li> |
|
||||||
</ul> |
|
||||||
|
|
||||||
<ul class="tight-form-list" ng-if="dashboard.annotations.list.length > 0"> |
|
||||||
<li ng-repeat="annotation in dashboard.annotations.list" class="submenu-item annotation-segment" ng-class="{'annotation-disabled': !annotation.enable}"> |
|
||||||
<a ng-click="disableAnnotation(annotation)"> |
|
||||||
<i class="fa fa-bolt" style="color:{{annotation.iconColor}}"></i> |
|
||||||
{{annotation.name}} |
|
||||||
<input class="cr1" id="hideYAxis" type="checkbox" ng-model="annotation.enable" ng-checked="annotation.enable"> |
|
||||||
<label for="hideYAxis" class="cr1"></label> |
|
||||||
</a> |
|
||||||
</li> |
|
||||||
</ul> |
|
||||||
|
|
||||||
<ul class="tight-form-list pull-right" ng-if="dashboard.links.length > 0"> |
|
||||||
<dash-links-container links="dashboard.links"></dash-links-container> |
|
||||||
</ul> |
|
||||||
|
|
||||||
<div class="clearfix"></div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#/bin/bash |
||||||
|
|
||||||
|
ln -s .hooks/* .git/hooks/ |
||||||
Loading…
Reference in new issue