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
2b3d366f
Commit
2b3d366f
authored
Dec 08, 2018
by
AJ West
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow backslash escaping in custom variables
parent
683b718e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
public/app/features/templating/custom_variable.ts
+3
-2
public/app/features/templating/partials/editor.html
+1
-1
public/app/features/templating/specs/variable_srv.test.ts
+4
-2
No files found.
public/app/features/templating/custom_variable.ts
View file @
2b3d366f
...
...
@@ -38,8 +38,9 @@ export class CustomVariable implements Variable {
}
updateOptions
()
{
// extract options in comma separated string
this
.
options
=
_
.
map
(
this
.
query
.
split
(
/
[
,
]
+/
),
text
=>
{
// extract options in comma separated string (use backslash to escape wanted commas)
this
.
options
=
_
.
map
(
this
.
query
.
split
(
/
(?<
!
\\)
,+/
),
text
=>
{
text
=
text
.
replace
(
'
\\
,'
,
','
);
return
{
text
:
text
.
trim
(),
value
:
text
.
trim
()
};
});
...
...
public/app/features/templating/partials/editor.html
View file @
2b3d366f
...
...
@@ -151,7 +151,7 @@
<h5
class=
"section-heading"
>
Custom Options
</h5>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-14"
>
Values separated by comma
</span>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'current.query'
ng-blur=
"runQuery()"
placeholder=
"1, 10, 20, myvalue"
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'current.query'
ng-blur=
"runQuery()"
placeholder=
"1, 10, 20, myvalue
, escaped\,value
"
required
></input>
</div>
</div>
...
...
public/app/features/templating/specs/variable_srv.test.ts
View file @
2b3d366f
...
...
@@ -493,15 +493,17 @@ describe('VariableSrv', function(this: any) {
scenario
.
setup
(()
=>
{
scenario
.
variableModel
=
{
type
:
'custom'
,
query
:
'hej, hop, asd'
,
query
:
'hej, hop, asd
, escaped
\\
,var
'
,
name
:
'test'
,
};
});
it
(
'should update options array'
,
()
=>
{
expect
(
scenario
.
variable
.
options
.
length
).
toBe
(
3
);
expect
(
scenario
.
variable
.
options
.
length
).
toBe
(
4
);
expect
(
scenario
.
variable
.
options
[
0
].
text
).
toBe
(
'hej'
);
expect
(
scenario
.
variable
.
options
[
1
].
value
).
toBe
(
'hop'
);
expect
(
scenario
.
variable
.
options
[
2
].
value
).
toBe
(
'asd'
);
expect
(
scenario
.
variable
.
options
[
3
].
value
).
toBe
(
'escaped,var'
);
});
});
...
...
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