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
c91e5a2d
Commit
c91e5a2d
authored
Mar 20, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaner version
parent
80d64752
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
36 deletions
+15
-36
public/app/plugins/datasource/testdata/datasource.ts
+15
-36
No files found.
public/app/plugins/datasource/testdata/datasource.ts
View file @
c91e5a2d
...
...
@@ -49,49 +49,28 @@ export class TestDataDatasource implements DataSourceApi<TestDataQuery> {
.
then
(
res
=>
{
const
data
:
TestData
[]
=
[];
// The results are not in the order we asked for them
if
(
res
.
data
.
results
)
{
const
byRefID
:
TestDataRegistry
=
{};
_
.
forEach
(
res
.
data
.
results
,
queryRes
=>
{
const
refId
=
queryRes
.
refId
||
'Result'
+
data
.
length
+
1
;
const
qdata
:
TestData
[]
=
[];
byRefID
[
refId
]
=
qdata
;
if
(
queryRes
.
tables
)
{
for
(
const
table
of
queryRes
.
tables
)
{
qdata
.
push
(
table
as
TableData
);
// Returns data in the order it was asked for.
// if the response has data with different refId, it is ignored
for
(
let
i
=
0
;
i
<
queries
.
length
;
i
++
)
{
const
query
=
queries
[
i
];
const
results
=
res
.
data
.
results
[
query
.
refId
];
if
(
results
)
{
if
(
results
.
tables
)
{
for
(
const
table
of
results
.
tables
)
{
data
.
push
(
table
as
TableData
);
}
}
if
(
queryRe
s
.
series
)
{
for
(
const
series
of
queryRe
s
.
series
)
{
q
data
.
push
({
if
(
result
s
.
series
)
{
for
(
const
series
of
result
s
.
series
)
{
data
.
push
({
target
:
series
.
name
,
datapoints
:
series
.
points
,
});
}
}
});
// Return them in the order they were asked for
queries
.
forEach
(
q
=>
{
const
found
=
byRefID
[
q
.
refId
];
if
(
found
)
{
for
(
const
d
of
found
)
{
data
.
push
(
d
);
byRefID
[
q
.
refId
]
=
null
;
}
}
});
// In case there are items left over
_
.
forEach
(
byRefID
,
v
=>
{
if
(
v
)
{
for
(
const
d
of
v
)
{
data
.
push
(
d
);
}
}
});
}
else
{
console
.
warn
(
'No Results for:'
,
query
);
}
}
return
{
data
:
data
};
...
...
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