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
6f34b154
Unverified
Commit
6f34b154
authored
Mar 12, 2019
by
Torkel Ödegaard
Committed by
GitHub
Mar 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15914 from grafana/multi-valued-datasource-variable
Multi valued datasource variable
parents
3e4153a9
aeb35534
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
5 deletions
+26
-5
public/app/features/dashboard/dashgrid/DataPanel.tsx
+1
-1
public/app/features/panel/metrics_panel_ctrl.ts
+1
-1
public/app/features/plugins/datasource_srv.ts
+9
-3
public/app/features/templating/datasource_variable.ts
+15
-0
No files found.
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
6f34b154
...
...
@@ -116,7 +116,7 @@ export class DataPanel extends Component<Props, State> {
this
.
setState
({
loading
:
LoadingState
.
Loading
});
try
{
const
ds
=
await
this
.
dataSourceSrv
.
get
(
datasource
);
const
ds
=
await
this
.
dataSourceSrv
.
get
(
datasource
,
scopedVars
);
// TODO interpolate variables
const
minInterval
=
this
.
props
.
minInterval
||
ds
.
interval
;
...
...
public/app/features/panel/metrics_panel_ctrl.ts
View file @
6f34b154
...
...
@@ -81,7 +81,7 @@ class MetricsPanelCtrl extends PanelCtrl {
// load datasource service
this
.
datasourceSrv
.
get
(
this
.
panel
.
datasource
)
.
get
(
this
.
panel
.
datasource
,
this
.
panel
.
scopedVars
)
.
then
(
this
.
updateTimeRange
.
bind
(
this
))
.
then
(
this
.
issueQueries
.
bind
(
this
))
.
then
(
this
.
handleQueryResult
.
bind
(
this
))
...
...
public/app/features/plugins/datasource_srv.ts
View file @
6f34b154
...
...
@@ -7,7 +7,7 @@ import config from 'app/core/config';
import
{
importPluginModule
}
from
'./plugin_loader'
;
// Types
import
{
DataSourceApi
,
DataSourceSelectItem
}
from
'@grafana/ui/src/types'
;
import
{
DataSourceApi
,
DataSourceSelectItem
,
ScopedVars
}
from
'@grafana/ui/src/types'
;
export
class
DatasourceSrv
{
datasources
:
{
[
name
:
string
]:
DataSourceApi
};
...
...
@@ -21,12 +21,18 @@ export class DatasourceSrv {
this
.
datasources
=
{};
}
get
(
name
?:
string
):
Promise
<
DataSourceApi
>
{
get
(
name
?:
string
,
scopedVars
?:
ScopedVars
):
Promise
<
DataSourceApi
>
{
if
(
!
name
)
{
return
this
.
get
(
config
.
defaultDatasource
);
}
name
=
this
.
templateSrv
.
replace
(
name
);
// Interpolation here is to support template variable in data source selection
name
=
this
.
templateSrv
.
replace
(
name
,
scopedVars
,
(
value
,
variable
)
=>
{
if
(
Array
.
isArray
(
value
))
{
return
value
[
0
];
}
return
value
;
});
if
(
name
===
'default'
)
{
return
this
.
get
(
config
.
defaultDatasource
);
...
...
public/app/features/templating/datasource_variable.ts
View file @
6f34b154
...
...
@@ -6,6 +6,8 @@ export class DatasourceVariable implements Variable {
query
:
string
;
options
:
any
;
current
:
any
;
multi
:
boolean
;
includeAll
:
boolean
;
refresh
:
any
;
skipUrlSync
:
boolean
;
...
...
@@ -18,6 +20,8 @@ export class DatasourceVariable implements Variable {
regex
:
''
,
options
:
[],
query
:
''
,
multi
:
false
,
includeAll
:
false
,
refresh
:
1
,
skipUrlSync
:
false
,
};
...
...
@@ -69,9 +73,16 @@ export class DatasourceVariable implements Variable {
}
this
.
options
=
options
;
if
(
this
.
includeAll
)
{
this
.
addAllOption
();
}
return
this
.
variableSrv
.
validateVariableSelectionState
(
this
);
}
addAllOption
()
{
this
.
options
.
unshift
({
text
:
'All'
,
value
:
'$__all'
});
}
dependsOn
(
variable
)
{
if
(
this
.
regex
)
{
return
containsVariable
(
this
.
regex
,
variable
.
name
);
...
...
@@ -84,6 +95,9 @@ export class DatasourceVariable implements Variable {
}
getValueForUrl
()
{
if
(
this
.
current
.
text
===
'All'
)
{
return
'All'
;
}
return
this
.
current
.
value
;
}
}
...
...
@@ -91,5 +105,6 @@ export class DatasourceVariable implements Variable {
variableTypes
[
'datasource'
]
=
{
name
:
'Datasource'
,
ctor
:
DatasourceVariable
,
supportsMulti
:
true
,
description
:
'Enabled you to dynamically switch the datasource for multiple panels'
,
};
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