mirror of
https://github.com/grafana/grafana.git
synced 2025-01-18 04:23:33 -06:00
fixed small issue with share modal
This commit is contained in:
parent
422324723a
commit
bb5eeee82e
@ -57,14 +57,15 @@ function (angular, kbn) {
|
||||
|
||||
angular
|
||||
.module('grafana.directives')
|
||||
.directive('editorCheckbox', function($compile) {
|
||||
.directive('editorCheckbox', function($compile, $interpolate) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
link: function(scope, elem, attrs) {
|
||||
var text = $interpolate(attrs.text)(scope);
|
||||
var ngchange = attrs.change ? (' ng-change="' + attrs.change + '"') : '';
|
||||
var tip = attrs.tip ? (' <tip>' + attrs.tip + '</tip>') : '';
|
||||
var label = '<label for="' + scope.$id + attrs.model + '" class="checkbox-label">' +
|
||||
attrs.text + tip + '</label>';
|
||||
text + tip + '</label>';
|
||||
|
||||
var template = '<input class="cr1" id="' + scope.$id + attrs.model + '" type="checkbox" ' +
|
||||
' ng-model="' + attrs.model + '"' + ngchange +
|
||||
|
@ -20,17 +20,17 @@
|
||||
<br>
|
||||
<div class="gf-form">
|
||||
<div class="gf-form-row">
|
||||
<editor-checkbox text="Current time range" model="forCurrent" change="buildUrl()"></editor-checkbox>
|
||||
<editor-checkbox text="Current time range" model="options.forCurrent" change="buildUrl()"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form" ng-if="panel">
|
||||
<div class="gf-form-row">
|
||||
<editor-checkbox text="This panel only" model="toPanel" change="buildUrl()"></editor-checkbox>
|
||||
<editor-checkbox text="This panel only" model="options.toPanel" change="buildUrl()"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<div class="gf-form-row">
|
||||
<editor-checkbox text="Include template variables" model="includeTemplateVars" change="buildUrl()"></editor-checkbox>
|
||||
<editor-checkbox text="Include template variables" model="options.includeTemplateVars" change="buildUrl()"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -13,15 +13,13 @@ function (angular, _, require, config) {
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.editor = { index: 0 };
|
||||
$scope.forCurrent = true;
|
||||
$scope.options = {
|
||||
forCurrent: true,
|
||||
toPanel: $scope.panel ? true : false,
|
||||
includeTemplateVars: true
|
||||
};
|
||||
|
||||
if ($scope.panel) {
|
||||
$scope.toPanel = true;
|
||||
}
|
||||
|
||||
$scope.includeTemplateVars = true;
|
||||
$scope.buildUrl();
|
||||
|
||||
};
|
||||
|
||||
$scope.buildUrl = function() {
|
||||
@ -38,7 +36,7 @@ function (angular, _, require, config) {
|
||||
params.from = range.from;
|
||||
params.to = range.to;
|
||||
|
||||
if ($scope.includeTemplateVars) {
|
||||
if ($scope.options.includeTemplateVars) {
|
||||
_.each(templateSrv.variables, function(variable) {
|
||||
params['var-' + variable.name] = variable.current.text;
|
||||
});
|
||||
@ -49,12 +47,12 @@ function (angular, _, require, config) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!$scope.forCurrent) {
|
||||
if (!$scope.options.forCurrent) {
|
||||
delete params.from;
|
||||
delete params.to;
|
||||
}
|
||||
|
||||
if ($scope.toPanel) {
|
||||
if ($scope.options.toPanel) {
|
||||
params.panelId = $scope.panel.id;
|
||||
params.fullscreen = true;
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@ define([
|
||||
it('should remove panel id when toPanel is false', function() {
|
||||
ctx.$location.path('/test');
|
||||
ctx.scope.panel = { id: 22 };
|
||||
ctx.scope.toPanel = false;
|
||||
ctx.scope.options = { toPanel: false, forCurrent: true };
|
||||
setTime({ from: 'now-1h', to: 'now' });
|
||||
|
||||
ctx.scope.buildUrl();
|
||||
@ -52,8 +52,8 @@ define([
|
||||
it('should include template variables in url', function() {
|
||||
ctx.$location.path('/test');
|
||||
ctx.scope.panel = { id: 22 };
|
||||
ctx.scope.includeTemplateVars = true;
|
||||
ctx.scope.toPanel = false;
|
||||
ctx.scope.options = { includeTemplateVars: true, toPanel: false, forCurrent: true };
|
||||
|
||||
ctx.templateSrv.variables = [{ name: 'app', current: {text: 'mupp' }}, {name: 'server', current: {text: 'srv-01'}}];
|
||||
setTime({ from: 'now-1h', to: 'now' });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user