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
dc6f9773
Unverified
Commit
dc6f9773
authored
Feb 22, 2018
by
Dan Cech
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support [[variable:type]] syntax
parent
fa193fa8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
public/app/features/templating/template_srv.ts
+10
-10
No files found.
public/app/features/templating/template_srv.ts
View file @
dc6f9773
...
...
@@ -8,7 +8,7 @@ function luceneEscape(value) {
export
class
TemplateSrv
{
variables
:
any
[];
private
regex
=
/
\$(\w
+
)
|
\[\[([\s\S]
+
?)
\]\]
|
\$
{
(\w
+
)
:
?(\w
+
)?
}/g
;
private
regex
=
/
\$(\w
+
)
|
\[\[([\s\S]
+
?)
(?:
:
(\w
+
))?\]\]
|
\$
{
(\w
+
)(?:
:
(\w
+
)
)?
}/g
;
private
index
=
{};
private
grafanaVariables
=
{};
private
builtIns
=
{};
...
...
@@ -143,8 +143,8 @@ export class TemplateSrv {
str
=
_
.
escape
(
str
);
this
.
regex
.
lastIndex
=
0
;
return
str
.
replace
(
this
.
regex
,
(
match
,
g1
,
g2
,
g3
)
=>
{
if
(
this
.
index
[
g1
||
g2
||
g
3
]
||
this
.
builtIns
[
g1
||
g2
||
g3
])
{
return
str
.
replace
(
this
.
regex
,
(
match
,
g1
,
g2
,
g3
,
g4
)
=>
{
if
(
this
.
index
[
g1
||
g2
||
g
4
]
||
this
.
builtIns
[
g1
||
g2
||
g4
])
{
return
'<span class="template-variable">'
+
match
+
'</span>'
;
}
return
match
;
...
...
@@ -170,11 +170,11 @@ export class TemplateSrv {
var
variable
,
systemValue
,
value
;
this
.
regex
.
lastIndex
=
0
;
return
target
.
replace
(
this
.
regex
,
(
match
,
g1
,
g2
,
g3
,
g4
)
=>
{
variable
=
this
.
index
[
g1
||
g2
||
g
3
];
format
=
g
4
||
format
;
return
target
.
replace
(
this
.
regex
,
(
match
,
g1
,
g2
,
g3
,
g4
,
g5
)
=>
{
variable
=
this
.
index
[
g1
||
g2
||
g
4
];
format
=
g
3
||
g5
||
format
;
if
(
scopedVars
)
{
value
=
scopedVars
[
g1
||
g2
||
g
3
];
value
=
scopedVars
[
g1
||
g2
||
g
4
];
if
(
value
)
{
return
this
.
formatValue
(
value
.
value
,
format
,
variable
);
}
...
...
@@ -215,15 +215,15 @@ export class TemplateSrv {
var
variable
;
this
.
regex
.
lastIndex
=
0
;
return
target
.
replace
(
this
.
regex
,
(
match
,
g1
,
g2
,
g3
)
=>
{
return
target
.
replace
(
this
.
regex
,
(
match
,
g1
,
g2
,
g3
,
g4
)
=>
{
if
(
scopedVars
)
{
var
option
=
scopedVars
[
g1
||
g2
||
g
3
];
var
option
=
scopedVars
[
g1
||
g2
||
g
4
];
if
(
option
)
{
return
option
.
text
;
}
}
variable
=
this
.
index
[
g1
||
g2
||
g
3
];
variable
=
this
.
index
[
g1
||
g2
||
g
4
];
if
(
!
variable
)
{
return
match
;
}
...
...
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