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
1b6ed581
Unverified
Commit
1b6ed581
authored
Dec 10, 2018
by
Carl Bergquist
Committed by
GitHub
Dec 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14405 from IntegersOfK/master
Allow backslash escaping in custom variables
parents
e61d8770
6c95acc8
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 @
1b6ed581
...
@@ -38,8 +38,9 @@ export class CustomVariable implements Variable {
...
@@ -38,8 +38,9 @@ export class CustomVariable implements Variable {
}
}
updateOptions
()
{
updateOptions
()
{
// extract options in comma separated string
// extract options in comma separated string (use backslash to escape wanted commas)
this
.
options
=
_
.
map
(
this
.
query
.
split
(
/
[
,
]
+/
),
text
=>
{
this
.
options
=
_
.
map
(
this
.
query
.
match
(
/
(?:\\
,|
[^
,
])
+/g
),
text
=>
{
text
=
text
.
replace
(
'
\\
,'
,
','
);
return
{
text
:
text
.
trim
(),
value
:
text
.
trim
()
};
return
{
text
:
text
.
trim
(),
value
:
text
.
trim
()
};
});
});
...
...
public/app/features/templating/partials/editor.html
View file @
1b6ed581
...
@@ -151,7 +151,7 @@
...
@@ -151,7 +151,7 @@
<h5
class=
"section-heading"
>
Custom Options
</h5>
<h5
class=
"section-heading"
>
Custom Options
</h5>
<div
class=
"gf-form"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-14"
>
Values separated by comma
</span>
<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>
required
></input>
</div>
</div>
</div>
</div>
...
...
public/app/features/templating/specs/variable_srv.test.ts
View file @
1b6ed581
...
@@ -493,15 +493,17 @@ describe('VariableSrv', function(this: any) {
...
@@ -493,15 +493,17 @@ describe('VariableSrv', function(this: any) {
scenario
.
setup
(()
=>
{
scenario
.
setup
(()
=>
{
scenario
.
variableModel
=
{
scenario
.
variableModel
=
{
type
:
'custom'
,
type
:
'custom'
,
query
:
'hej, hop, asd'
,
query
:
'hej, hop, asd
, escaped
\\
,var
'
,
name
:
'test'
,
name
:
'test'
,
};
};
});
});
it
(
'should update options array'
,
()
=>
{
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
[
0
].
text
).
toBe
(
'hej'
);
expect
(
scenario
.
variable
.
options
[
1
].
value
).
toBe
(
'hop'
);
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