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
3f27d3ea
Commit
3f27d3ea
authored
Mar 05, 2019
by
Jeremy Doupe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make datasource variables multiselect and dashboard repeatable
closes #7492 (and #7030)
parent
b5826110
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
1 deletions
+39
-1
public/app/features/panel/metrics_panel_ctrl.ts
+20
-1
public/app/features/plugins/datasource_srv.ts
+4
-0
public/app/features/templating/datasource_variable.ts
+15
-0
No files found.
public/app/features/panel/metrics_panel_ctrl.ts
View file @
3f27d3ea
...
...
@@ -79,9 +79,28 @@ class MetricsPanelCtrl extends PanelCtrl {
delete
this
.
error
;
this
.
loading
=
true
;
// set "mydatasource" to whatever the panel has defined
let
mydatasource
=
this
.
panel
.
datasource
;
let
datasourceVarName
=
''
;
// look for data source variables
for
(
let
i
=
0
;
i
<
this
.
templateSrv
.
variables
.
length
;
i
++
)
{
const
variable
=
this
.
templateSrv
.
variables
[
i
];
if
(
variable
.
type
!==
'datasource'
)
{
continue
;
}
datasourceVarName
=
variable
.
name
;
}
// if a data source variable was found, use its value
if
(
datasourceVarName
!==
''
&&
this
.
panel
.
scopedVars
&&
this
.
panel
.
scopedVars
[
datasourceVarName
])
{
mydatasource
=
this
.
panel
.
scopedVars
[
datasourceVarName
].
value
;
}
// load datasource service
this
.
datasourceSrv
.
get
(
this
.
panel
.
datasource
)
.
get
(
my
datasource
)
.
then
(
this
.
updateTimeRange
.
bind
(
this
))
.
then
(
this
.
issueQueries
.
bind
(
this
))
.
then
(
this
.
handleQueryResult
.
bind
(
this
))
...
...
public/app/features/plugins/datasource_srv.ts
View file @
3f27d3ea
...
...
@@ -40,6 +40,10 @@ export class DatasourceSrv {
}
loadDatasource
(
name
:
string
):
Promise
<
DataSourceApi
>
{
// if there are multiple datasources provided, just use the first one
const
re
=
/{
([^
,}
]
+
)
.*/
;
name
=
name
.
replace
(
re
,
'$1'
);
const
dsConfig
=
config
.
datasources
[
name
];
if
(
!
dsConfig
)
{
return
this
.
$q
.
reject
({
message
:
'Datasource named '
+
name
+
' was not found'
});
...
...
public/app/features/templating/datasource_variable.ts
View file @
3f27d3ea
...
...
@@ -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