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
d891cc59
Unverified
Commit
d891cc59
authored
May 06, 2020
by
Ryan McKinley
Committed by
GitHub
May 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TemplateSrv: expose the replace function (#24353)
parent
fa260fec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
packages/grafana-runtime/src/services/templateSrv.ts
+9
-1
public/app/features/templating/template_srv.ts
+1
-1
public/app/plugins/datasource/cloudwatch/datasource.ts
+1
-1
No files found.
packages/grafana-runtime/src/services/templateSrv.ts
View file @
d891cc59
import
{
VariableModel
}
from
'@grafana/data'
;
import
{
VariableModel
,
ScopedVars
}
from
'@grafana/data'
;
/**
/**
* Via the TemplateSrv consumers get access to all the available template variables
* Via the TemplateSrv consumers get access to all the available template variables
...
@@ -8,7 +8,15 @@ import { VariableModel } from '@grafana/data';
...
@@ -8,7 +8,15 @@ import { VariableModel } from '@grafana/data';
* @public
* @public
*/
*/
export
interface
TemplateSrv
{
export
interface
TemplateSrv
{
/**
* List the dashboard variables
*/
getVariables
():
VariableModel
[];
getVariables
():
VariableModel
[];
/**
* Replace the values within the target string. See also {@link InterpolateFunction}
*/
replace
(
target
:
string
,
scopedVars
?:
ScopedVars
,
format
?:
string
|
Function
):
string
;
}
}
let
singletonInstance
:
TemplateSrv
;
let
singletonInstance
:
TemplateSrv
;
...
...
public/app/features/templating/template_srv.ts
View file @
d891cc59
...
@@ -317,7 +317,7 @@ export class TemplateSrv implements BaseTemplateSrv {
...
@@ -317,7 +317,7 @@ export class TemplateSrv implements BaseTemplateSrv {
return
scopedVar
.
value
;
return
scopedVar
.
value
;
}
}
replace
(
target
:
string
,
scopedVars
?:
ScopedVars
,
format
?:
string
|
Function
):
any
{
replace
(
target
:
string
,
scopedVars
?:
ScopedVars
,
format
?:
string
|
Function
):
string
{
if
(
!
target
)
{
if
(
!
target
)
{
return
target
;
return
target
;
}
}
...
...
public/app/plugins/datasource/cloudwatch/datasource.ts
View file @
d891cc59
...
@@ -300,7 +300,7 @@ export class CloudWatchDatasource extends DataSourceApi<CloudWatchQuery, CloudWa
...
@@ -300,7 +300,7 @@ export class CloudWatchDatasource extends DataSourceApi<CloudWatchQuery, CloudWa
}
}
getPeriod
(
target
:
CloudWatchMetricsQuery
,
options
:
any
)
{
getPeriod
(
target
:
CloudWatchMetricsQuery
,
options
:
any
)
{
let
period
=
this
.
templateSrv
.
replace
(
target
.
period
,
options
.
scopedVars
);
let
period
=
this
.
templateSrv
.
replace
(
target
.
period
,
options
.
scopedVars
)
as
any
;
if
(
period
&&
period
.
toLowerCase
()
!==
'auto'
)
{
if
(
period
&&
period
.
toLowerCase
()
!==
'auto'
)
{
if
(
/^
\d
+$/
.
test
(
period
))
{
if
(
/^
\d
+$/
.
test
(
period
))
{
period
=
parseInt
(
period
,
10
);
period
=
parseInt
(
period
,
10
);
...
...
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