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
4a169319
Commit
4a169319
authored
Sep 21, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mixed datasource): fixed issue when exporting dashboard using mixed data source, fixes #6032
parent
46ab09ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
10 deletions
+45
-10
public/app/features/dashboard/export/exporter.ts
+14
-2
public/app/features/dashboard/specs/exporter_specs.ts
+31
-8
No files found.
public/app/features/dashboard/export/exporter.ts
View file @
4a169319
...
...
@@ -24,6 +24,10 @@ export class DashboardExporter {
var
templateizeDatasourceUsage
=
obj
=>
{
promises
.
push
(
this
.
datasourceSrv
.
get
(
obj
.
datasource
).
then
(
ds
=>
{
if
(
ds
.
meta
.
builtIn
)
{
return
;
}
var
refName
=
'DS_'
+
ds
.
name
.
replace
(
' '
,
'_'
).
toUpperCase
();
datasources
[
refName
]
=
{
name
:
refName
,
...
...
@@ -46,11 +50,19 @@ export class DashboardExporter {
// check up panel data sources
for
(
let
row
of
dash
.
rows
)
{
_
.
each
(
row
.
panels
,
(
panel
)
=>
{
for
(
let
panel
of
row
.
panels
)
{
if
(
panel
.
datasource
!==
undefined
)
{
templateizeDatasourceUsage
(
panel
);
}
if
(
panel
.
targets
)
{
for
(
let
target
of
panel
.
targets
)
{
if
(
target
.
datasource
!==
undefined
)
{
templateizeDatasourceUsage
(
target
);
}
}
}
var
panelDef
=
config
.
panels
[
panel
.
type
];
if
(
panelDef
)
{
requires
[
'panel'
+
panelDef
.
id
]
=
{
...
...
@@ -60,7 +72,7 @@ export class DashboardExporter {
version
:
panelDef
.
info
.
version
,
};
}
}
);
}
}
// templatize template vars
...
...
public/app/features/dashboard/specs/exporter_specs.ts
View file @
4a169319
...
...
@@ -42,21 +42,34 @@ describe('given dashboard with repeated panels', function() {
repeat
:
'test'
,
panels
:
[
{
id
:
2
,
repeat
:
'apps'
,
datasource
:
'gfdb'
,
type
:
'graph'
},
{
id
:
2
,
repeat
:
null
,
repeatPanelId
:
2
},
{
id
:
3
,
repeat
:
null
,
repeatPanelId
:
2
},
{
id
:
4
,
datasource
:
'-- Mixed --'
,
targets
:
[{
datasource
:
'other'
}],
},
]
});
dash
.
rows
.
push
({
repeat
:
null
,
repeatRowId
:
1
,
panels
:
[],
});
var
datasourceSrvStub
=
{
get
:
sinon
.
stub
().
returns
(
Promise
.
resolve
({
name
:
'gfdb'
,
meta
:
{
id
:
"testdb"
,
info
:
{
version
:
"1.2.1"
},
name
:
"TestDB"
}
}))
};
var
datasourceSrvStub
=
{
get
:
sinon
.
stub
()};
datasourceSrvStub
.
get
.
withArgs
(
'gfdb'
).
returns
(
Promise
.
resolve
({
name
:
'gfdb'
,
meta
:
{
id
:
"testdb"
,
info
:
{
version
:
"1.2.1"
},
name
:
"TestDB"
}
}));
datasourceSrvStub
.
get
.
withArgs
(
'other'
).
returns
(
Promise
.
resolve
({
name
:
'other'
,
meta
:
{
id
:
"other"
,
info
:
{
version
:
"1.2.1"
},
name
:
"OtherDB"
}
}));
datasourceSrvStub
.
get
.
withArgs
(
'-- Mixed --'
).
returns
(
Promise
.
resolve
({
name
:
'mixed'
,
meta
:
{
id
:
"mixed"
,
info
:
{
version
:
"1.2.1"
},
name
:
"Mixed"
,
builtIn
:
true
}
}));
config
.
panels
[
'graph'
]
=
{
id
:
"graph"
,
...
...
@@ -72,7 +85,7 @@ describe('given dashboard with repeated panels', function() {
});
it
(
'exported dashboard should not contain repeated panels'
,
function
()
{
expect
(
exported
.
rows
[
0
].
panels
.
length
).
to
.
be
(
1
);
expect
(
exported
.
rows
[
0
].
panels
.
length
).
to
.
be
(
2
);
});
it
(
'exported dashboard should not contain repeated rows'
,
function
()
{
...
...
@@ -109,6 +122,16 @@ describe('given dashboard with repeated panels', function() {
expect
(
require
.
version
).
to
.
be
(
"1.2.1"
);
});
it
(
'should not add built in datasources to required'
,
function
()
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'Mixed'
});
expect
(
require
).
to
.
be
(
undefined
);
});
it
(
'should add datasources used in mixed mode'
,
function
()
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'OtherDB'
});
expect
(
require
).
to
.
not
.
be
(
undefined
);
});
it
(
'should add panel to required'
,
function
()
{
var
require
=
_
.
find
(
exported
.
__requires
,
{
name
:
'Graph'
});
expect
(
require
.
name
).
to
.
be
(
"Graph"
);
...
...
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