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
4e49c453
Unverified
Commit
4e49c453
authored
Nov 07, 2018
by
Torkel Ödegaard
Committed by
GitHub
Nov 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13990 from grafana/exporter-fix-13891
Exporter bug fix
parents
0712c52c
99610e04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
13 deletions
+34
-13
public/app/features/dashboard/export/exporter.ts
+22
-11
public/app/features/dashboard/specs/exporter.test.ts
+12
-2
No files found.
public/app/features/dashboard/export/exporter.ts
View file @
4e49c453
...
...
@@ -29,19 +29,36 @@ export class DashboardExporter {
}
const
templateizeDatasourceUsage
=
obj
=>
{
let
datasource
=
obj
.
datasource
;
let
datasourceVariable
=
null
;
// ignore data source properties that contain a variable
if
(
obj
.
datasource
&&
obj
.
datasource
.
indexOf
(
'$'
)
===
0
)
{
if
(
variableLookup
[
obj
.
datasource
.
substring
(
1
)])
{
return
;
if
(
datasource
&&
datasource
.
indexOf
(
'$'
)
===
0
)
{
datasourceVariable
=
variableLookup
[
datasource
.
substring
(
1
)];
if
(
datasourceVariable
&&
datasourceVariable
.
current
)
{
datasource
=
datasourceVariable
.
current
.
value
;
}
}
promises
.
push
(
this
.
datasourceSrv
.
get
(
obj
.
datasource
).
then
(
ds
=>
{
this
.
datasourceSrv
.
get
(
datasource
).
then
(
ds
=>
{
if
(
ds
.
meta
.
builtIn
)
{
return
;
}
// add data source type to require list
requires
[
'datasource'
+
ds
.
meta
.
id
]
=
{
type
:
'datasource'
,
id
:
ds
.
meta
.
id
,
name
:
ds
.
meta
.
name
,
version
:
ds
.
meta
.
info
.
version
||
'1.0.0'
,
};
// if used via variable we can skip templatizing usage
if
(
datasourceVariable
)
{
return
;
}
const
refName
=
'DS_'
+
ds
.
name
.
replace
(
' '
,
'_'
).
toUpperCase
();
datasources
[
refName
]
=
{
name
:
refName
,
...
...
@@ -51,14 +68,8 @@ export class DashboardExporter {
pluginId
:
ds
.
meta
.
id
,
pluginName
:
ds
.
meta
.
name
,
};
obj
.
datasource
=
'${'
+
refName
+
'}'
;
requires
[
'datasource'
+
ds
.
meta
.
id
]
=
{
type
:
'datasource'
,
id
:
ds
.
meta
.
id
,
name
:
ds
.
meta
.
name
,
version
:
ds
.
meta
.
info
.
version
||
'1.0.0'
,
};
obj
.
datasource
=
'${'
+
refName
+
'}'
;
})
);
};
...
...
public/app/features/dashboard/specs/exporter.test.ts
View file @
4e49c453
...
...
@@ -32,8 +32,8 @@ describe('given dashboard with repeated panels', () => {
{
name
:
'ds'
,
type
:
'datasource'
,
query
:
'
testdb
'
,
current
:
{
value
:
'
prod'
,
text
:
'prod
'
},
query
:
'
other2
'
,
current
:
{
value
:
'
other2'
,
text
:
'other2
'
},
options
:
[],
},
],
...
...
@@ -205,6 +205,11 @@ describe('given dashboard with repeated panels', () => {
expect
(
variable
.
options
[
0
].
text
).
toBe
(
'${VAR_PREFIX}'
);
expect
(
variable
.
options
[
0
].
value
).
toBe
(
'${VAR_PREFIX}'
);
});
it
(
'should add datasources only use via datasource variable to requires'
,
()
=>
{
const
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'OtherDB_2'
});
expect
(
require
.
id
).
toBe
(
'other2'
);
});
});
// Stub responses
...
...
@@ -219,6 +224,11 @@ stubs['other'] = {
meta
:
{
id
:
'other'
,
info
:
{
version
:
'1.2.1'
},
name
:
'OtherDB'
},
};
stubs
[
'other2'
]
=
{
name
:
'other2'
,
meta
:
{
id
:
'other2'
,
info
:
{
version
:
'1.2.1'
},
name
:
'OtherDB_2'
},
};
stubs
[
'-- Mixed --'
]
=
{
name
:
'mixed'
,
meta
:
{
...
...
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