Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
2cc53f32
Commit
2cc53f32
authored
Jul 30, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(templating): fixed scoped vars issue when generating urls for panel links, fixes #2410
parent
aaae23e9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
18 deletions
+43
-18
public/app/features/panellinks/linkSrv.js
+7
-7
public/app/features/templating/templateSrv.js
+11
-8
public/app/panels/singlestat/singleStatPanel.js
+1
-1
public/test/specs/templateSrv-specs.js
+24
-2
No files found.
public/app/features/panellinks/linkSrv.js
View file @
2cc53f32
...
...
@@ -59,21 +59,21 @@ function (angular, kbn, _) {
return
info
;
};
this
.
getPanelLinkAnchorInfo
=
function
(
link
)
{
this
.
getPanelLinkAnchorInfo
=
function
(
link
,
scopedVars
)
{
var
info
=
{};
if
(
link
.
type
===
'absolute'
)
{
info
.
target
=
link
.
targetBlank
?
'_blank'
:
'_self'
;
info
.
href
=
templateSrv
.
replace
(
link
.
url
||
''
);
info
.
title
=
templateSrv
.
replace
(
link
.
title
||
''
);
info
.
href
=
templateSrv
.
replace
(
link
.
url
||
''
,
scopedVars
);
info
.
title
=
templateSrv
.
replace
(
link
.
title
||
''
,
scopedVars
);
info
.
href
+=
'?'
;
}
else
if
(
link
.
dashUri
)
{
info
.
href
=
'dashboard/'
+
link
.
dashUri
+
'?'
;
info
.
title
=
templateSrv
.
replace
(
link
.
title
||
''
);
info
.
title
=
templateSrv
.
replace
(
link
.
title
||
''
,
scopedVars
);
info
.
target
=
link
.
targetBlank
?
'_blank'
:
''
;
}
else
{
info
.
title
=
templateSrv
.
replace
(
link
.
title
||
''
);
info
.
title
=
templateSrv
.
replace
(
link
.
title
||
''
,
scopedVars
);
var
slug
=
kbn
.
slugifyForUrl
(
link
.
dashboard
||
''
);
info
.
href
=
'dashboard/db/'
+
slug
+
'?'
;
}
...
...
@@ -87,12 +87,12 @@ function (angular, kbn, _) {
}
if
(
link
.
includeVars
)
{
templateSrv
.
fillVariableValuesForUrl
(
params
);
templateSrv
.
fillVariableValuesForUrl
(
params
,
scopedVars
);
}
info
.
href
=
this
.
addParamsToUrl
(
info
.
href
,
params
);
if
(
link
.
params
)
{
info
.
href
+=
"&"
+
templateSrv
.
replace
(
link
.
params
);
info
.
href
+=
"&"
+
templateSrv
.
replace
(
link
.
params
,
scopedVars
);
}
return
info
;
...
...
public/app/features/templating/templateSrv.js
View file @
2cc53f32
...
...
@@ -115,17 +115,20 @@ function (angular, _) {
});
};
this
.
fillVariableValuesForUrl
=
function
(
params
)
{
var
toUrlVal
=
function
(
current
)
{
this
.
fillVariableValuesForUrl
=
function
(
params
,
scopedVars
)
{
_
.
each
(
this
.
variables
,
function
(
variable
)
{
var
current
=
variable
.
current
;
var
value
=
current
.
value
;
if
(
current
.
text
===
'All'
)
{
return
'All'
;
}
else
{
return
current
.
value
;
value
=
'All'
;
}
};
_
.
each
(
this
.
variables
,
function
(
variable
)
{
params
[
'var-'
+
variable
.
name
]
=
toUrlVal
(
variable
.
current
);
if
(
scopedVars
&&
scopedVars
[
variable
.
name
]
!==
void
0
)
{
value
=
scopedVars
[
variable
.
name
].
value
;
}
params
[
'var-'
+
variable
.
name
]
=
value
;
});
};
...
...
public/app/panels/singlestat/singleStatPanel.js
View file @
2cc53f32
...
...
@@ -183,7 +183,7 @@ function (angular, app, _, $) {
elem
.
click
(
function
()
{
if
(
panel
.
links
.
length
===
0
)
{
return
;
}
var
link
=
panel
.
links
[
0
];
var
linkInfo
=
linkSrv
.
getPanelLinkAnchorInfo
(
link
);
var
linkInfo
=
linkSrv
.
getPanelLinkAnchorInfo
(
link
,
scope
.
panel
.
scopedVars
);
if
(
panel
.
links
[
0
].
targetBlank
)
{
var
redirectWindow
=
window
.
open
(
linkInfo
.
href
,
'_blank'
);
redirectWindow
.
location
;
...
...
public/test/specs/templateSrv-specs.js
View file @
2cc53f32
...
...
@@ -109,7 +109,6 @@ define([
describe
(
'when checking if a string contains a variable'
,
function
()
{
beforeEach
(
function
()
{
_templateSrv
.
init
([{
name
:
'test'
,
current
:
{
value
:
'muuuu'
}
}]);
_templateSrv
.
updateTemplateData
();
});
it
(
'should find it with $var syntax'
,
function
()
{
...
...
@@ -127,7 +126,6 @@ define([
describe
(
'updateTemplateData with simple value'
,
function
()
{
beforeEach
(
function
()
{
_templateSrv
.
init
([{
name
:
'test'
,
current
:
{
value
:
'muuuu'
}
}]);
_templateSrv
.
updateTemplateData
();
});
it
(
'should set current value and update template data'
,
function
()
{
...
...
@@ -136,6 +134,30 @@ define([
});
});
describe
(
'fillVariableValuesForUrl with multi value'
,
function
()
{
beforeEach
(
function
()
{
_templateSrv
.
init
([{
name
:
'test'
,
current
:
{
value
:
[
'val1'
,
'val2'
]
}}]);
});
it
(
'should set multiple url params'
,
function
()
{
var
params
=
{};
_templateSrv
.
fillVariableValuesForUrl
(
params
);
expect
(
params
[
'var-test'
]).
to
.
eql
([
'val1'
,
'val2'
]);
});
});
describe
(
'fillVariableValuesForUrl with multi value and scopedVars'
,
function
()
{
beforeEach
(
function
()
{
_templateSrv
.
init
([{
name
:
'test'
,
current
:
{
value
:
[
'val1'
,
'val2'
]
}}]);
});
it
(
'should set multiple url params'
,
function
()
{
var
params
=
{};
_templateSrv
.
fillVariableValuesForUrl
(
params
,
{
'test'
:
{
value
:
'val1'
}});
expect
(
params
[
'var-test'
]).
to
.
eql
(
'val1'
);
});
});
describe
(
'replaceWithText'
,
function
()
{
beforeEach
(
function
()
{
_templateSrv
.
init
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment